12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078 |
- #include <qdf_types.h>
- #include <qdf_lock.h>
- #include <qdf_net_types.h>
- #include <qdf_lro.h>
- #include <qdf_module.h>
- #include <hal_hw_headers.h>
- #include <hal_api.h>
- #include <hif.h>
- #include <htt.h>
- #include <wdi_event.h>
- #include <queue.h>
- #include "dp_types.h"
- #include "dp_internal.h"
- #include "dp_tx.h"
- #include "dp_tx_desc.h"
- #include "dp_rx.h"
- #include "dp_rx_mon.h"
- #ifdef DP_RATETABLE_SUPPORT
- #include "dp_ratetable.h"
- #endif
- #include <cdp_txrx_handle.h>
- #include <wlan_cfg.h>
- #include "cdp_txrx_cmn_struct.h"
- #include "cdp_txrx_stats_struct.h"
- #include "cdp_txrx_cmn_reg.h"
- #include <qdf_util.h>
- #include "dp_peer.h"
- #include "dp_rx_mon.h"
- #include "htt_stats.h"
- #include "dp_htt.h"
- #include "htt_ppdu_stats.h"
- #include "qdf_mem.h"
- #include "cfg_ucfg_api.h"
- #ifdef QCA_LL_TX_FLOW_CONTROL_V2
- #include "cdp_txrx_flow_ctrl_v2.h"
- #else
- static inline void
- cdp_dump_flow_pool_info(struct cdp_soc_t *soc)
- {
- return;
- }
- #endif
- #include "dp_ipa.h"
- #include "dp_cal_client_api.h"
- #ifdef FEATURE_WDS
- #include "dp_txrx_wds.h"
- #endif
- #ifdef ATH_SUPPORT_IQUE
- #include "dp_txrx_me.h"
- #endif
- #if defined(DP_CON_MON)
- extern int con_mode_monitor;
- #ifndef REMOVE_PKT_LOG
- #include <pktlog_ac_api.h>
- #include <pktlog_ac.h>
- #endif
- #endif
- #ifdef WLAN_FEATURE_DP_EVENT_HISTORY
- QDF_COMPILE_TIME_ASSERT(num_intr_grps,
- HIF_NUM_INT_CONTEXTS == WLAN_CFG_INT_NUM_CONTEXTS);
- QDF_COMPILE_TIME_ASSERT(hif_event_history_size,
- (HIF_EVENT_HIST_MAX & (HIF_EVENT_HIST_MAX - 1)) == 0);
- #endif
- QDF_COMPILE_TIME_ASSERT(wlan_cfg_num_int_ctxs,
- WLAN_CFG_INT_NUM_CONTEXTS_MAX >=
- WLAN_CFG_INT_NUM_CONTEXTS);
- #ifdef WLAN_RX_PKT_CAPTURE_ENH
- #include "dp_rx_mon_feature.h"
- #else
- static QDF_STATUS
- dp_config_enh_rx_capture(struct cdp_pdev *pdev_handle, uint8_t val)
- {
- return QDF_STATUS_E_INVAL;
- }
- #endif
- #ifdef WLAN_TX_PKT_CAPTURE_ENH
- #include "dp_tx_capture.h"
- #else
- static QDF_STATUS
- dp_config_enh_tx_capture(struct cdp_pdev *pdev_handle, int val)
- {
- return QDF_STATUS_E_INVAL;
- }
- #endif
- void *dp_soc_init(void *dpsoc, HTC_HANDLE htc_handle, void *hif_handle);
- static void dp_pdev_detach(struct cdp_pdev *txrx_pdev, int force);
- static struct dp_soc *
- dp_soc_attach(struct cdp_ctrl_objmgr_psoc *ctrl_psoc, HTC_HANDLE htc_handle,
- qdf_device_t qdf_osdev,
- struct ol_if_ops *ol_ops, uint16_t device_id);
- static void dp_pktlogmod_exit(struct dp_pdev *handle);
- static void *dp_peer_create_wifi3(struct cdp_vdev *vdev_handle,
- uint8_t *peer_mac_addr,
- struct cdp_ctrl_objmgr_peer *ctrl_peer);
- static void dp_peer_delete_wifi3(void *peer_handle, uint32_t bitmap);
- static void dp_ppdu_ring_reset(struct dp_pdev *pdev);
- static void dp_ppdu_ring_cfg(struct dp_pdev *pdev);
- #ifdef ENABLE_VERBOSE_DEBUG
- bool is_dp_verbose_debug_enabled;
- #endif
- static uint8_t dp_soc_ring_if_nss_offloaded(struct dp_soc *soc,
- enum hal_ring_type ring_type,
- int ring_num);
- #define DP_INTR_POLL_TIMER_MS 10
- #define DP_AST_AGING_TIMER_DEFAULT_MS 1000
- #define DP_MCS_LENGTH (6*MAX_MCS)
- #define DP_CURR_FW_STATS_AVAIL 19
- #define DP_HTT_DBG_EXT_STATS_MAX 256
- #define DP_MAX_SLEEP_TIME 100
- #ifndef QCA_WIFI_3_0_EMU
- #define SUSPEND_DRAIN_WAIT 500
- #else
- #define SUSPEND_DRAIN_WAIT 3000
- #endif
- #ifdef IPA_OFFLOAD
- #define TX_RING_MASK_VAL 0xb
- #define RX_RING_MASK_VAL 0x7
- #else
- #define TX_RING_MASK_VAL 0xF
- #define RX_RING_MASK_VAL 0xF
- #endif
- #define STR_MAXLEN 64
- #define RNG_ERR "SRNG setup failed for"
- #define DP_RX_CACHED_BUFQ_THRESH 64
- static uint8_t default_dscp_tid_map[DSCP_TID_MAP_MAX] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 1, 1, 1, 1, 1, 1, 1, 1,
- 2, 2, 2, 2, 2, 2, 2, 2,
- 3, 3, 3, 3, 3, 3, 3, 3,
- 4, 4, 4, 4, 4, 4, 4, 4,
- 5, 5, 5, 5, 5, 5, 5, 5,
- 6, 6, 6, 6, 6, 6, 6, 6,
- 7, 7, 7, 7, 7, 7, 7, 7,
- };
- static uint8_t default_pcp_tid_map[PCP_TID_MAP_MAX] = {
- 0, 1, 2, 3, 4, 5, 6, 7,
- };
- uint8_t
- dp_cpu_ring_map[DP_NSS_CPU_RING_MAP_MAX][WLAN_CFG_INT_NUM_CONTEXTS_MAX] = {
- {0x0, 0x1, 0x2, 0x0, 0x0, 0x1, 0x2, 0x0, 0x0, 0x1, 0x2},
- {0x1, 0x2, 0x1, 0x2, 0x1, 0x2, 0x1, 0x2, 0x1, 0x2, 0x1},
- {0x0, 0x2, 0x0, 0x2, 0x0, 0x2, 0x0, 0x2, 0x0, 0x2, 0x0},
- {0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2},
- {0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3},
- #ifdef WLAN_TX_PKT_CAPTURE_ENH
- {0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1}
- #endif
- };
- enum dp_stats_type {
- STATS_FW = 0,
- STATS_HOST = 1,
- STATS_TYPE_MAX = 2,
- };
- enum dp_fw_stats {
- TXRX_FW_STATS_INVALID = -1,
- };
- const int dp_stats_mapping_table[][STATS_TYPE_MAX] = {
- {HTT_DBG_EXT_STATS_RESET, TXRX_HOST_STATS_INVALID},
- {HTT_DBG_EXT_STATS_PDEV_TX, TXRX_HOST_STATS_INVALID},
- {HTT_DBG_EXT_STATS_PDEV_RX, TXRX_HOST_STATS_INVALID},
- {HTT_DBG_EXT_STATS_PDEV_TX_HWQ, TXRX_HOST_STATS_INVALID},
- {HTT_DBG_EXT_STATS_PDEV_TX_SCHED, TXRX_HOST_STATS_INVALID},
- {HTT_DBG_EXT_STATS_PDEV_ERROR, TXRX_HOST_STATS_INVALID},
- {HTT_DBG_EXT_STATS_PDEV_TQM, TXRX_HOST_STATS_INVALID},
- {HTT_DBG_EXT_STATS_TQM_CMDQ, TXRX_HOST_STATS_INVALID},
- {HTT_DBG_EXT_STATS_TX_DE_INFO, TXRX_HOST_STATS_INVALID},
- {HTT_DBG_EXT_STATS_PDEV_TX_RATE, TXRX_HOST_STATS_INVALID},
- {HTT_DBG_EXT_STATS_PDEV_RX_RATE, TXRX_HOST_STATS_INVALID},
- {TXRX_FW_STATS_INVALID, TXRX_HOST_STATS_INVALID},
- {HTT_DBG_EXT_STATS_TX_SELFGEN_INFO, TXRX_HOST_STATS_INVALID},
- {HTT_DBG_EXT_STATS_TX_MU_HWQ, TXRX_HOST_STATS_INVALID},
- {HTT_DBG_EXT_STATS_RING_IF_INFO, TXRX_HOST_STATS_INVALID},
- {HTT_DBG_EXT_STATS_SRNG_INFO, TXRX_HOST_STATS_INVALID},
- {HTT_DBG_EXT_STATS_SFM_INFO, TXRX_HOST_STATS_INVALID},
- {HTT_DBG_EXT_STATS_PDEV_TX_MU, TXRX_HOST_STATS_INVALID},
- {HTT_DBG_EXT_STATS_ACTIVE_PEERS_LIST, TXRX_HOST_STATS_INVALID},
-
- {DP_HTT_DBG_EXT_STATS_MAX, TXRX_HOST_STATS_INVALID},
- {TXRX_FW_STATS_INVALID, TXRX_CLEAR_STATS},
- {TXRX_FW_STATS_INVALID, TXRX_RX_RATE_STATS},
- {TXRX_FW_STATS_INVALID, TXRX_TX_RATE_STATS},
- {TXRX_FW_STATS_INVALID, TXRX_TX_HOST_STATS},
- {TXRX_FW_STATS_INVALID, TXRX_RX_HOST_STATS},
- {TXRX_FW_STATS_INVALID, TXRX_AST_STATS},
- {TXRX_FW_STATS_INVALID, TXRX_SRNG_PTR_STATS},
- {TXRX_FW_STATS_INVALID, TXRX_RX_MON_STATS},
- {TXRX_FW_STATS_INVALID, TXRX_REO_QUEUE_STATS},
- {TXRX_FW_STATS_INVALID, TXRX_SOC_CFG_PARAMS},
- {TXRX_FW_STATS_INVALID, TXRX_PDEV_CFG_PARAMS},
- {TXRX_FW_STATS_INVALID, TXRX_SOC_INTERRUPT_STATS},
- };
- #if defined(DP_CON_MON)
- static inline
- uint32_t dp_soc_get_mon_mask_for_interrupt_mode(struct dp_soc *soc, int intr_ctx_num)
- {
- return 0;
- }
- static void dp_service_mon_rings(void *arg)
- {
- struct dp_soc *soc = (struct dp_soc *)arg;
- int ring = 0, work_done, mac_id;
- struct dp_pdev *pdev = NULL;
- for (ring = 0 ; ring < MAX_PDEV_CNT; ring++) {
- pdev = soc->pdev_list[ring];
- if (!pdev)
- continue;
- for (mac_id = 0; mac_id < NUM_RXDMA_RINGS_PER_PDEV; mac_id++) {
- int mac_for_pdev = dp_get_mac_id_for_pdev(mac_id,
- pdev->pdev_id);
- work_done = dp_mon_process(soc, mac_for_pdev,
- QCA_NAPI_BUDGET);
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
- FL("Reaped %d descs from Monitor rings"),
- work_done);
- }
- }
- qdf_timer_mod(&soc->mon_reap_timer, DP_INTR_POLL_TIMER_MS);
- }
- #ifndef REMOVE_PKT_LOG
- void dp_pkt_log_init(struct cdp_pdev *ppdev, void *scn)
- {
- struct dp_pdev *handle = (struct dp_pdev *)ppdev;
- if (handle->pkt_log_init) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- "%s: Packet log not initialized", __func__);
- return;
- }
- pktlog_sethandle(&handle->pl_dev, scn);
- pktlog_set_callback_regtype(PKTLOG_DEFAULT_CALLBACK_REGISTRATION);
- if (pktlogmod_init(scn)) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- "%s: pktlogmod_init failed", __func__);
- handle->pkt_log_init = false;
- } else {
- handle->pkt_log_init = true;
- }
- }
- static void dp_pkt_log_con_service(struct cdp_pdev *ppdev, void *scn)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)ppdev;
- dp_pkt_log_init((struct cdp_pdev *)pdev, scn);
- pktlog_htc_attach();
- }
- static int dp_get_num_rx_contexts(struct cdp_soc_t *soc_hdl)
- {
- int i;
- int num_rx_contexts = 0;
- struct dp_soc *soc = (struct dp_soc *)soc_hdl;
- for (i = 0; i < wlan_cfg_get_num_contexts(soc->wlan_cfg_ctx); i++)
- if (wlan_cfg_get_rx_ring_mask(soc->wlan_cfg_ctx, i))
- num_rx_contexts++;
- return num_rx_contexts;
- }
- static void dp_pktlogmod_exit(struct dp_pdev *handle)
- {
- void *scn = (void *)handle->soc->hif_handle;
- if (!scn) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- "%s: Invalid hif(scn) handle", __func__);
- return;
- }
- pktlogmod_exit(scn);
- handle->pkt_log_init = false;
- }
- #endif
- #else
- static void dp_pktlogmod_exit(struct dp_pdev *handle) { }
- static inline
- uint32_t dp_soc_get_mon_mask_for_interrupt_mode(struct dp_soc *soc, int intr_ctx_num)
- {
- return wlan_cfg_get_rx_mon_ring_mask(soc->wlan_cfg_ctx, intr_ctx_num);
- }
- #endif
- static
- struct dp_vdev *dp_get_dp_vdev_from_cdp_vdev(struct cdp_vdev *cdp_opaque_vdev)
- {
- return (struct dp_vdev *)cdp_opaque_vdev;
- }
- static int dp_peer_add_ast_wifi3(struct cdp_soc_t *soc_hdl,
- struct cdp_peer *peer_hdl,
- uint8_t *mac_addr,
- enum cdp_txrx_ast_entry_type type,
- uint32_t flags)
- {
- return dp_peer_add_ast((struct dp_soc *)soc_hdl,
- (struct dp_peer *)peer_hdl,
- mac_addr,
- type,
- flags);
- }
- static int dp_peer_update_ast_wifi3(struct cdp_soc_t *soc_hdl,
- struct cdp_peer *peer_hdl,
- uint8_t *wds_macaddr,
- uint32_t flags)
- {
- int status = -1;
- struct dp_soc *soc = (struct dp_soc *)soc_hdl;
- struct dp_ast_entry *ast_entry = NULL;
- struct dp_peer *peer = (struct dp_peer *)peer_hdl;
- qdf_spin_lock_bh(&soc->ast_lock);
- ast_entry = dp_peer_ast_hash_find_by_pdevid(soc, wds_macaddr,
- peer->vdev->pdev->pdev_id);
- if (ast_entry) {
- status = dp_peer_update_ast(soc,
- peer,
- ast_entry, flags);
- }
- qdf_spin_unlock_bh(&soc->ast_lock);
- return status;
- }
- static void dp_wds_reset_ast_wifi3(struct cdp_soc_t *soc_hdl,
- uint8_t *wds_macaddr,
- uint8_t *peer_mac_addr,
- void *vdev_handle)
- {
- struct dp_soc *soc = (struct dp_soc *)soc_hdl;
- struct dp_ast_entry *ast_entry = NULL;
- struct dp_ast_entry *tmp_ast_entry;
- struct dp_peer *peer;
- struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle;
- struct dp_pdev *pdev;
- if (!vdev)
- return;
- pdev = vdev->pdev;
- if (peer_mac_addr) {
- peer = dp_peer_find_hash_find(soc, peer_mac_addr,
- 0, vdev->vdev_id);
- if (!peer)
- return;
- qdf_spin_lock_bh(&soc->ast_lock);
- DP_PEER_ITERATE_ASE_LIST(peer, ast_entry, tmp_ast_entry) {
- if ((ast_entry->type == CDP_TXRX_AST_TYPE_WDS_HM) ||
- (ast_entry->type == CDP_TXRX_AST_TYPE_WDS_HM_SEC))
- dp_peer_del_ast(soc, ast_entry);
- }
- qdf_spin_unlock_bh(&soc->ast_lock);
- dp_peer_unref_delete(peer);
- } else if (wds_macaddr) {
- qdf_spin_lock_bh(&soc->ast_lock);
- ast_entry = dp_peer_ast_hash_find_by_pdevid(soc, wds_macaddr,
- pdev->pdev_id);
- if (ast_entry) {
- if ((ast_entry->type == CDP_TXRX_AST_TYPE_WDS_HM) ||
- (ast_entry->type == CDP_TXRX_AST_TYPE_WDS_HM_SEC))
- dp_peer_del_ast(soc, ast_entry);
- }
- qdf_spin_unlock_bh(&soc->ast_lock);
- }
- }
- static void dp_wds_reset_ast_table_wifi3(struct cdp_soc_t *soc_hdl,
- void *vdev_hdl)
- {
- struct dp_soc *soc = (struct dp_soc *) soc_hdl;
- struct dp_pdev *pdev;
- struct dp_vdev *vdev;
- struct dp_peer *peer;
- struct dp_ast_entry *ase, *temp_ase;
- int i;
- qdf_spin_lock_bh(&soc->ast_lock);
- for (i = 0; i < MAX_PDEV_CNT && soc->pdev_list[i]; i++) {
- pdev = soc->pdev_list[i];
- qdf_spin_lock_bh(&pdev->vdev_list_lock);
- DP_PDEV_ITERATE_VDEV_LIST(pdev, vdev) {
- DP_VDEV_ITERATE_PEER_LIST(vdev, peer) {
- DP_PEER_ITERATE_ASE_LIST(peer, ase, temp_ase) {
- if ((ase->type ==
- CDP_TXRX_AST_TYPE_WDS_HM) ||
- (ase->type ==
- CDP_TXRX_AST_TYPE_WDS_HM_SEC))
- dp_peer_del_ast(soc, ase);
- }
- }
- }
- qdf_spin_unlock_bh(&pdev->vdev_list_lock);
- }
- qdf_spin_unlock_bh(&soc->ast_lock);
- }
- static void dp_wds_flush_ast_table_wifi3(struct cdp_soc_t *soc_hdl)
- {
- struct dp_soc *soc = (struct dp_soc *) soc_hdl;
- struct dp_pdev *pdev;
- struct dp_vdev *vdev;
- struct dp_peer *peer;
- struct dp_ast_entry *ase, *temp_ase;
- int i;
- qdf_spin_lock_bh(&soc->ast_lock);
- for (i = 0; i < MAX_PDEV_CNT && soc->pdev_list[i]; i++) {
- pdev = soc->pdev_list[i];
- qdf_spin_lock_bh(&pdev->vdev_list_lock);
- DP_PDEV_ITERATE_VDEV_LIST(pdev, vdev) {
- DP_VDEV_ITERATE_PEER_LIST(vdev, peer) {
- DP_PEER_ITERATE_ASE_LIST(peer, ase, temp_ase) {
- if ((ase->type ==
- CDP_TXRX_AST_TYPE_STATIC) ||
- (ase->type ==
- CDP_TXRX_AST_TYPE_SELF) ||
- (ase->type ==
- CDP_TXRX_AST_TYPE_STA_BSS))
- continue;
- dp_peer_del_ast(soc, ase);
- }
- }
- }
- qdf_spin_unlock_bh(&pdev->vdev_list_lock);
- }
- qdf_spin_unlock_bh(&soc->ast_lock);
- }
- static bool dp_peer_get_ast_info_by_soc_wifi3
- (struct cdp_soc_t *soc_hdl,
- uint8_t *ast_mac_addr,
- struct cdp_ast_entry_info *ast_entry_info)
- {
- struct dp_ast_entry *ast_entry = NULL;
- struct dp_soc *soc = (struct dp_soc *)soc_hdl;
- qdf_spin_lock_bh(&soc->ast_lock);
- ast_entry = dp_peer_ast_hash_find_soc(soc, ast_mac_addr);
- if (!ast_entry || !ast_entry->peer) {
- qdf_spin_unlock_bh(&soc->ast_lock);
- return false;
- }
- if (ast_entry->delete_in_progress && !ast_entry->callback) {
- qdf_spin_unlock_bh(&soc->ast_lock);
- return false;
- }
- ast_entry_info->type = ast_entry->type;
- ast_entry_info->pdev_id = ast_entry->pdev_id;
- ast_entry_info->vdev_id = ast_entry->vdev_id;
- ast_entry_info->peer_id = ast_entry->peer->peer_ids[0];
- qdf_mem_copy(&ast_entry_info->peer_mac_addr[0],
- &ast_entry->peer->mac_addr.raw[0],
- QDF_MAC_ADDR_SIZE);
- qdf_spin_unlock_bh(&soc->ast_lock);
- return true;
- }
- static bool dp_peer_get_ast_info_by_pdevid_wifi3
- (struct cdp_soc_t *soc_hdl,
- uint8_t *ast_mac_addr,
- uint8_t pdev_id,
- struct cdp_ast_entry_info *ast_entry_info)
- {
- struct dp_ast_entry *ast_entry;
- struct dp_soc *soc = (struct dp_soc *)soc_hdl;
- qdf_spin_lock_bh(&soc->ast_lock);
- ast_entry = dp_peer_ast_hash_find_by_pdevid(soc, ast_mac_addr, pdev_id);
- if (!ast_entry || !ast_entry->peer) {
- qdf_spin_unlock_bh(&soc->ast_lock);
- return false;
- }
- if (ast_entry->delete_in_progress && !ast_entry->callback) {
- qdf_spin_unlock_bh(&soc->ast_lock);
- return false;
- }
- ast_entry_info->type = ast_entry->type;
- ast_entry_info->pdev_id = ast_entry->pdev_id;
- ast_entry_info->vdev_id = ast_entry->vdev_id;
- ast_entry_info->peer_id = ast_entry->peer->peer_ids[0];
- qdf_mem_copy(&ast_entry_info->peer_mac_addr[0],
- &ast_entry->peer->mac_addr.raw[0],
- QDF_MAC_ADDR_SIZE);
- qdf_spin_unlock_bh(&soc->ast_lock);
- return true;
- }
- static QDF_STATUS dp_peer_ast_entry_del_by_soc(struct cdp_soc_t *soc_handle,
- uint8_t *mac_addr,
- txrx_ast_free_cb callback,
- void *cookie)
- {
- struct dp_soc *soc = (struct dp_soc *)soc_handle;
- struct dp_ast_entry *ast_entry = NULL;
- txrx_ast_free_cb cb = NULL;
- void *arg = NULL;
- qdf_spin_lock_bh(&soc->ast_lock);
- ast_entry = dp_peer_ast_hash_find_soc(soc, mac_addr);
- if (!ast_entry) {
- qdf_spin_unlock_bh(&soc->ast_lock);
- return -QDF_STATUS_E_INVAL;
- }
- if (ast_entry->callback) {
- cb = ast_entry->callback;
- arg = ast_entry->cookie;
- }
- ast_entry->callback = callback;
- ast_entry->cookie = cookie;
-
- if (!ast_entry->delete_in_progress)
- dp_peer_del_ast(soc, ast_entry);
- qdf_spin_unlock_bh(&soc->ast_lock);
- if (cb) {
- cb(soc->ctrl_psoc,
- soc,
- arg,
- CDP_TXRX_AST_DELETE_IN_PROGRESS);
- }
- return QDF_STATUS_SUCCESS;
- }
- static QDF_STATUS dp_peer_ast_entry_del_by_pdev(struct cdp_soc_t *soc_handle,
- uint8_t *mac_addr,
- uint8_t pdev_id,
- txrx_ast_free_cb callback,
- void *cookie)
- {
- struct dp_soc *soc = (struct dp_soc *)soc_handle;
- struct dp_ast_entry *ast_entry;
- txrx_ast_free_cb cb = NULL;
- void *arg = NULL;
- qdf_spin_lock_bh(&soc->ast_lock);
- ast_entry = dp_peer_ast_hash_find_by_pdevid(soc, mac_addr, pdev_id);
- if (!ast_entry) {
- qdf_spin_unlock_bh(&soc->ast_lock);
- return -QDF_STATUS_E_INVAL;
- }
- if (ast_entry->callback) {
- cb = ast_entry->callback;
- arg = ast_entry->cookie;
- }
- ast_entry->callback = callback;
- ast_entry->cookie = cookie;
-
- if (!ast_entry->delete_in_progress)
- dp_peer_del_ast(soc, ast_entry);
- qdf_spin_unlock_bh(&soc->ast_lock);
- if (cb) {
- cb(soc->ctrl_psoc,
- soc,
- arg,
- CDP_TXRX_AST_DELETE_IN_PROGRESS);
- }
- return QDF_STATUS_SUCCESS;
- }
- static int dp_srng_find_ring_in_mask(int ring_num, int *grp_mask)
- {
- int ext_group_num;
- int mask = 1 << ring_num;
- for (ext_group_num = 0; ext_group_num < WLAN_CFG_INT_NUM_CONTEXTS;
- ext_group_num++) {
- if (mask & grp_mask[ext_group_num])
- return ext_group_num;
- }
- return -QDF_STATUS_E_NOENT;
- }
- static int dp_srng_calculate_msi_group(struct dp_soc *soc,
- enum hal_ring_type ring_type,
- int ring_num)
- {
- int *grp_mask;
- switch (ring_type) {
- case WBM2SW_RELEASE:
-
- if (ring_num < 3)
- grp_mask = &soc->wlan_cfg_ctx->int_tx_ring_mask[0];
-
- else if (ring_num == 3) {
-
- grp_mask = &soc->wlan_cfg_ctx->
- int_rx_wbm_rel_ring_mask[0];
- ring_num = 0;
- } else {
- qdf_assert(0);
- return -QDF_STATUS_E_NOENT;
- }
- break;
- case REO_EXCEPTION:
-
- grp_mask = &soc->wlan_cfg_ctx->int_rx_err_ring_mask[0];
- break;
- case REO_DST:
-
- grp_mask = &soc->wlan_cfg_ctx->int_rx_ring_mask[0];
- break;
- case REO_STATUS:
-
- grp_mask = &soc->wlan_cfg_ctx->int_reo_status_ring_mask[0];
- break;
-
- case RXDMA_MONITOR_STATUS:
-
- case RXDMA_MONITOR_DST:
-
- grp_mask = &soc->wlan_cfg_ctx->int_rx_mon_ring_mask[0];
- break;
- case RXDMA_DST:
-
- grp_mask = &soc->wlan_cfg_ctx->int_rxdma2host_ring_mask[0];
- break;
- case RXDMA_BUF:
- grp_mask = &soc->wlan_cfg_ctx->int_host2rxdma_ring_mask[0];
- break;
- case RXDMA_MONITOR_BUF:
-
- return -QDF_STATUS_E_NOENT;
- break;
- case TCL_DATA:
- case TCL_CMD:
- case REO_CMD:
- case SW2WBM_RELEASE:
- case WBM_IDLE_LINK:
-
- return -QDF_STATUS_E_NOENT;
- break;
- case TCL_STATUS:
- case REO_REINJECT:
-
- return -QDF_STATUS_E_NOENT;
- break;
- case CE_SRC:
- case CE_DST:
- case CE_DST_STATUS:
-
- default:
- return -QDF_STATUS_E_NOENT;
- break;
- }
- return dp_srng_find_ring_in_mask(ring_num, grp_mask);
- }
- static void dp_srng_msi_setup(struct dp_soc *soc, struct hal_srng_params
- *ring_params, int ring_type, int ring_num)
- {
- int msi_group_number;
- int msi_data_count;
- int ret;
- uint32_t msi_data_start, msi_irq_start, addr_low, addr_high;
- ret = pld_get_user_msi_assignment(soc->osdev->dev, "DP",
- &msi_data_count, &msi_data_start,
- &msi_irq_start);
- if (ret)
- return;
- msi_group_number = dp_srng_calculate_msi_group(soc, ring_type,
- ring_num);
- if (msi_group_number < 0) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_LOW,
- FL("ring not part of an ext_group; ring_type: %d,ring_num %d"),
- ring_type, ring_num);
- ring_params->msi_addr = 0;
- ring_params->msi_data = 0;
- return;
- }
- if (msi_group_number > msi_data_count) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_WARN,
- FL("2 msi_groups will share an msi; msi_group_num %d"),
- msi_group_number);
- QDF_ASSERT(0);
- }
- pld_get_msi_address(soc->osdev->dev, &addr_low, &addr_high);
- ring_params->msi_addr = addr_low;
- ring_params->msi_addr |= (qdf_dma_addr_t)(((uint64_t)addr_high) << 32);
- ring_params->msi_data = (msi_group_number % msi_data_count)
- + msi_data_start;
- ring_params->flags |= HAL_SRNG_MSI_INTR;
- }
- #ifdef FEATURE_AST
- void dp_print_ast_stats(struct dp_soc *soc)
- {
- uint8_t i;
- uint8_t num_entries = 0;
- struct dp_vdev *vdev;
- struct dp_pdev *pdev;
- struct dp_peer *peer;
- struct dp_ast_entry *ase, *tmp_ase;
- char type[CDP_TXRX_AST_TYPE_MAX][10] = {
- "NONE", "STATIC", "SELF", "WDS", "MEC", "HMWDS", "BSS",
- "DA", "HMWDS_SEC"};
- DP_PRINT_STATS("AST Stats:");
- DP_PRINT_STATS(" Entries Added = %d", soc->stats.ast.added);
- DP_PRINT_STATS(" Entries Deleted = %d", soc->stats.ast.deleted);
- DP_PRINT_STATS(" Entries Agedout = %d", soc->stats.ast.aged_out);
- DP_PRINT_STATS(" Entries MAP ERR = %d", soc->stats.ast.map_err);
- DP_PRINT_STATS("AST Table:");
- qdf_spin_lock_bh(&soc->ast_lock);
- for (i = 0; i < MAX_PDEV_CNT && soc->pdev_list[i]; i++) {
- pdev = soc->pdev_list[i];
- qdf_spin_lock_bh(&pdev->vdev_list_lock);
- DP_PDEV_ITERATE_VDEV_LIST(pdev, vdev) {
- DP_VDEV_ITERATE_PEER_LIST(vdev, peer) {
- DP_PEER_ITERATE_ASE_LIST(peer, ase, tmp_ase) {
- DP_PRINT_STATS("%6d mac_addr = %pM"
- " peer_mac_addr = %pM"
- " peer_id = %u"
- " type = %s"
- " next_hop = %d"
- " is_active = %d"
- " ast_idx = %d"
- " ast_hash = %d"
- " delete_in_progress = %d"
- " pdev_id = %d"
- " vdev_id = %d",
- ++num_entries,
- ase->mac_addr.raw,
- ase->peer->mac_addr.raw,
- ase->peer->peer_ids[0],
- type[ase->type],
- ase->next_hop,
- ase->is_active,
- ase->ast_idx,
- ase->ast_hash_value,
- ase->delete_in_progress,
- ase->pdev_id,
- ase->vdev_id);
- }
- }
- }
- qdf_spin_unlock_bh(&pdev->vdev_list_lock);
- }
- qdf_spin_unlock_bh(&soc->ast_lock);
- }
- #else
- void dp_print_ast_stats(struct dp_soc *soc)
- {
- DP_PRINT_STATS("AST Stats not available.Enable FEATURE_AST");
- return;
- }
- #endif
- static void dp_print_peer_table(struct dp_vdev *vdev)
- {
- struct dp_peer *peer = NULL;
- DP_PRINT_STATS("Dumping Peer Table Stats:");
- TAILQ_FOREACH(peer, &vdev->peer_list, peer_list_elem) {
- if (!peer) {
- DP_PRINT_STATS("Invalid Peer");
- return;
- }
- DP_PRINT_STATS(" peer_mac_addr = %pM"
- " nawds_enabled = %d"
- " bss_peer = %d"
- " wds_enabled = %d"
- " delete in progress = %d"
- " peer id = %d",
- peer->mac_addr.raw,
- peer->nawds_enabled,
- peer->bss_peer,
- peer->wds_enabled,
- peer->delete_in_progress,
- peer->peer_ids[0]);
- }
- }
- static QDF_STATUS
- dp_srng_mem_alloc(struct dp_soc *soc, struct dp_srng *srng, uint32_t align,
- bool cached)
- {
- uint32_t align_alloc_size;
- if (!cached) {
- srng->base_vaddr_unaligned =
- qdf_mem_alloc_consistent(soc->osdev,
- soc->osdev->dev,
- srng->alloc_size,
- &srng->base_paddr_unaligned);
- } else {
- srng->base_vaddr_unaligned = qdf_mem_malloc(srng->alloc_size);
- srng->base_paddr_unaligned =
- qdf_mem_virt_to_phys(srng->base_vaddr_unaligned);
- }
- if (!srng->base_vaddr_unaligned) {
- return QDF_STATUS_E_NOMEM;
- }
-
- if ((unsigned long)(srng->base_paddr_unaligned) &
- (align - 1)) {
- align_alloc_size = srng->alloc_size + align - 1;
- if (!cached) {
- qdf_mem_free_consistent(soc->osdev, soc->osdev->dev,
- srng->alloc_size,
- srng->base_vaddr_unaligned,
- srng->base_paddr_unaligned, 0);
- srng->base_vaddr_unaligned =
- qdf_mem_alloc_consistent(soc->osdev,
- soc->osdev->dev,
- align_alloc_size,
- &srng->base_paddr_unaligned);
- } else {
- qdf_mem_free(srng->base_vaddr_unaligned);
- srng->base_vaddr_unaligned =
- qdf_mem_malloc(align_alloc_size);
- srng->base_paddr_unaligned =
- qdf_mem_virt_to_phys(srng->base_vaddr_unaligned);
- }
- srng->alloc_size = align_alloc_size;
- if (!srng->base_vaddr_unaligned) {
- return QDF_STATUS_E_NOMEM;
- }
- }
- return QDF_STATUS_SUCCESS;
- }
- #ifdef WLAN_DP_PER_RING_TYPE_CONFIG
- static void
- dp_srng_configure_interrupt_thresholds(struct dp_soc *soc,
- struct hal_srng_params *ring_params,
- int ring_type, int ring_num,
- int num_entries)
- {
- if (ring_type == WBM2SW_RELEASE && (ring_num == 3)) {
- ring_params->intr_timer_thres_us =
- wlan_cfg_get_int_timer_threshold_other(soc->wlan_cfg_ctx);
- ring_params->intr_batch_cntr_thres_entries =
- wlan_cfg_get_int_batch_threshold_other(soc->wlan_cfg_ctx);
- } else {
- ring_params->intr_timer_thres_us =
- soc->wlan_srng_cfg[ring_type].timer_threshold;
- ring_params->intr_batch_cntr_thres_entries =
- soc->wlan_srng_cfg[ring_type].batch_count_threshold;
- }
- ring_params->low_threshold =
- soc->wlan_srng_cfg[ring_type].low_threshold;
- if (ring_params->low_threshold)
- ring_params->flags |= HAL_SRNG_LOW_THRES_INTR_ENABLE;
- }
- #else
- static void
- dp_srng_configure_interrupt_thresholds(struct dp_soc *soc,
- struct hal_srng_params *ring_params,
- int ring_type, int ring_num,
- int num_entries)
- {
- if (ring_type == REO_DST) {
- ring_params->intr_timer_thres_us =
- wlan_cfg_get_int_timer_threshold_rx(soc->wlan_cfg_ctx);
- ring_params->intr_batch_cntr_thres_entries =
- wlan_cfg_get_int_batch_threshold_rx(soc->wlan_cfg_ctx);
- } else if (ring_type == WBM2SW_RELEASE && (ring_num < 3)) {
- ring_params->intr_timer_thres_us =
- wlan_cfg_get_int_timer_threshold_tx(soc->wlan_cfg_ctx);
- ring_params->intr_batch_cntr_thres_entries =
- wlan_cfg_get_int_batch_threshold_tx(soc->wlan_cfg_ctx);
- } else {
- ring_params->intr_timer_thres_us =
- wlan_cfg_get_int_timer_threshold_other(soc->wlan_cfg_ctx);
- ring_params->intr_batch_cntr_thres_entries =
- wlan_cfg_get_int_batch_threshold_other(soc->wlan_cfg_ctx);
- }
-
- if ((ring_type == RXDMA_BUF) || (ring_type == RXDMA_MONITOR_BUF) ||
- (ring_type == RXDMA_MONITOR_STATUS)) {
-
- ring_params->low_threshold = num_entries >> 3;
- ring_params->intr_timer_thres_us =
- wlan_cfg_get_int_timer_threshold_rx(soc->wlan_cfg_ctx);
- ring_params->flags |= HAL_SRNG_LOW_THRES_INTR_ENABLE;
- ring_params->intr_batch_cntr_thres_entries = 0;
- }
- }
- #endif
- static int dp_srng_setup(struct dp_soc *soc, struct dp_srng *srng,
- int ring_type, int ring_num, int mac_id,
- uint32_t num_entries, bool cached)
- {
- void *hal_soc = soc->hal_soc;
- uint32_t entry_size = hal_srng_get_entrysize(hal_soc, ring_type);
-
- uint32_t ring_base_align = 8;
- struct hal_srng_params ring_params;
- uint32_t max_entries = hal_srng_max_entries(hal_soc, ring_type);
-
- ring_params.flags = 0;
- num_entries = (num_entries > max_entries) ? max_entries : num_entries;
- srng->hal_srng = NULL;
- srng->alloc_size = num_entries * entry_size;
- srng->num_entries = num_entries;
- if (!dp_is_soc_reinit(soc)) {
- if (dp_srng_mem_alloc(soc, srng, ring_base_align, cached) !=
- QDF_STATUS_SUCCESS) {
- dp_err("alloc failed - ring_type: %d, ring_num %d",
- ring_type, ring_num);
- return QDF_STATUS_E_NOMEM;
- }
- }
- ring_params.ring_base_paddr =
- (qdf_dma_addr_t)qdf_align(
- (unsigned long)(srng->base_paddr_unaligned),
- ring_base_align);
- ring_params.ring_base_vaddr =
- (void *)((unsigned long)(srng->base_vaddr_unaligned) +
- ((unsigned long)(ring_params.ring_base_paddr) -
- (unsigned long)(srng->base_paddr_unaligned)));
- ring_params.num_entries = num_entries;
- dp_verbose_debug("Ring type: %d, num:%d vaddr %pK paddr %pK entries %u",
- ring_type, ring_num,
- (void *)ring_params.ring_base_vaddr,
- (void *)ring_params.ring_base_paddr,
- ring_params.num_entries);
- if (soc->intr_mode == DP_INTR_MSI) {
- dp_srng_msi_setup(soc, &ring_params, ring_type, ring_num);
- dp_verbose_debug("Using MSI for ring_type: %d, ring_num %d",
- ring_type, ring_num);
- } else {
- ring_params.msi_data = 0;
- ring_params.msi_addr = 0;
- dp_verbose_debug("Skipping MSI for ring_type: %d, ring_num %d",
- ring_type, ring_num);
- }
- dp_srng_configure_interrupt_thresholds(soc, &ring_params,
- ring_type, ring_num,
- num_entries);
- if (cached) {
- ring_params.flags |= HAL_SRNG_CACHED_DESC;
- srng->cached = 1;
- }
- srng->hal_srng = hal_srng_setup(hal_soc, ring_type, ring_num,
- mac_id, &ring_params);
- if (!srng->hal_srng) {
- if (cached) {
- qdf_mem_free(srng->base_vaddr_unaligned);
- } else {
- qdf_mem_free_consistent(soc->osdev, soc->osdev->dev,
- srng->alloc_size,
- srng->base_vaddr_unaligned,
- srng->base_paddr_unaligned, 0);
- }
- }
- return 0;
- }
- static void dp_srng_deinit(struct dp_soc *soc, struct dp_srng *srng,
- int ring_type, int ring_num)
- {
- if (!srng->hal_srng) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- FL("Ring type: %d, num:%d not setup"),
- ring_type, ring_num);
- return;
- }
- hal_srng_cleanup(soc->hal_soc, srng->hal_srng);
- srng->hal_srng = NULL;
- }
- static void dp_srng_cleanup(struct dp_soc *soc, struct dp_srng *srng,
- int ring_type, int ring_num)
- {
- if (!dp_is_soc_reinit(soc)) {
- if (!srng->hal_srng && (srng->alloc_size == 0)) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- FL("Ring type: %d, num:%d not setup"),
- ring_type, ring_num);
- return;
- }
- if (srng->hal_srng) {
- hal_srng_cleanup(soc->hal_soc, srng->hal_srng);
- srng->hal_srng = NULL;
- }
- }
- if (srng->alloc_size && srng->base_vaddr_unaligned) {
- if (!srng->cached) {
- qdf_mem_free_consistent(soc->osdev, soc->osdev->dev,
- srng->alloc_size,
- srng->base_vaddr_unaligned,
- srng->base_paddr_unaligned, 0);
- } else {
- qdf_mem_free(srng->base_vaddr_unaligned);
- }
- srng->alloc_size = 0;
- srng->base_vaddr_unaligned = NULL;
- }
- srng->hal_srng = NULL;
- }
- void *hif_get_hal_handle(void *hif_handle);
- #ifdef WLAN_FEATURE_DP_EVENT_HISTORY
- int dp_srng_access_start(struct dp_intr *int_ctx, struct dp_soc *dp_soc,
- hal_ring_handle_t hal_ring_hdl)
- {
- void *hal_soc = dp_soc->hal_soc;
- uint32_t hp, tp;
- uint8_t ring_id;
- hal_get_sw_hptp(hal_soc, hal_ring_hdl, &tp, &hp);
- ring_id = hal_srng_ring_id_get(hal_ring_hdl);
- hif_record_event(dp_soc->hif_handle, int_ctx->dp_intr_id,
- ring_id, hp, tp, HIF_EVENT_SRNG_ACCESS_START);
- return hal_srng_access_start(hal_soc, hal_ring_hdl);
- }
- void dp_srng_access_end(struct dp_intr *int_ctx, struct dp_soc *dp_soc,
- hal_ring_handle_t hal_ring_hdl)
- {
- void *hal_soc = dp_soc->hal_soc;
- uint32_t hp, tp;
- uint8_t ring_id;
- hal_get_sw_hptp(hal_soc, hal_ring_hdl, &tp, &hp);
- ring_id = hal_srng_ring_id_get(hal_ring_hdl);
- hif_record_event(dp_soc->hif_handle, int_ctx->dp_intr_id,
- ring_id, hp, tp, HIF_EVENT_SRNG_ACCESS_END);
- return hal_srng_access_end(hal_soc, hal_ring_hdl);
- }
- #endif
- static uint32_t dp_service_srngs(void *dp_ctx, uint32_t dp_budget)
- {
- struct dp_intr *int_ctx = (struct dp_intr *)dp_ctx;
- struct dp_intr_stats *intr_stats = &int_ctx->intr_stats;
- struct dp_soc *soc = int_ctx->soc;
- int ring = 0;
- uint32_t work_done = 0;
- int budget = dp_budget;
- uint8_t tx_mask = int_ctx->tx_ring_mask;
- uint8_t rx_mask = int_ctx->rx_ring_mask;
- uint8_t rx_err_mask = int_ctx->rx_err_ring_mask;
- uint8_t rx_wbm_rel_mask = int_ctx->rx_wbm_rel_ring_mask;
- uint8_t reo_status_mask = int_ctx->reo_status_ring_mask;
- uint32_t remaining_quota = dp_budget;
- struct dp_pdev *pdev = NULL;
- int mac_id;
- dp_verbose_debug("tx %x rx %x rx_err %x rx_wbm_rel %x reo_status %x rx_mon_ring %x host2rxdma %x rxdma2host %x\n",
- tx_mask, rx_mask, rx_err_mask, rx_wbm_rel_mask,
- reo_status_mask,
- int_ctx->rx_mon_ring_mask,
- int_ctx->host2rxdma_ring_mask,
- int_ctx->rxdma2host_ring_mask);
-
- while (tx_mask) {
- if (tx_mask & 0x1) {
- work_done = dp_tx_comp_handler(int_ctx,
- soc,
- soc->tx_comp_ring[ring].hal_srng,
- ring, remaining_quota);
- if (work_done) {
- intr_stats->num_tx_ring_masks[ring]++;
- dp_verbose_debug("tx mask 0x%x ring %d, budget %d, work_done %d",
- tx_mask, ring, budget,
- work_done);
- }
- budget -= work_done;
- if (budget <= 0)
- goto budget_done;
- remaining_quota = budget;
- }
- tx_mask = tx_mask >> 1;
- ring++;
- }
-
- if (rx_err_mask) {
- work_done = dp_rx_err_process(int_ctx, soc,
- soc->reo_exception_ring.hal_srng,
- remaining_quota);
- if (work_done) {
- intr_stats->num_rx_err_ring_masks++;
- dp_verbose_debug("REO Exception Ring: work_done %d budget %d",
- work_done, budget);
- }
- budget -= work_done;
- if (budget <= 0) {
- goto budget_done;
- }
- remaining_quota = budget;
- }
-
- if (rx_wbm_rel_mask) {
- work_done = dp_rx_wbm_err_process(int_ctx, soc,
- soc->rx_rel_ring.hal_srng,
- remaining_quota);
- if (work_done) {
- intr_stats->num_rx_wbm_rel_ring_masks++;
- dp_verbose_debug("WBM Release Ring: work_done %d budget %d",
- work_done, budget);
- }
- budget -= work_done;
- if (budget <= 0) {
- goto budget_done;
- }
- remaining_quota = budget;
- }
-
- if (rx_mask) {
- for (ring = 0; ring < soc->num_reo_dest_rings; ring++) {
- if (!(rx_mask & (1 << ring)))
- continue;
- work_done = dp_rx_process(int_ctx,
- soc->reo_dest_ring[ring].hal_srng,
- ring,
- remaining_quota);
- if (work_done) {
- intr_stats->num_rx_ring_masks[ring]++;
- dp_verbose_debug("rx mask 0x%x ring %d, work_done %d budget %d",
- rx_mask, ring,
- work_done, budget);
- budget -= work_done;
- if (budget <= 0)
- goto budget_done;
- remaining_quota = budget;
- }
- }
- }
- if (reo_status_mask) {
- if (dp_reo_status_ring_handler(int_ctx, soc))
- int_ctx->intr_stats.num_reo_status_ring_masks++;
- }
-
- for (ring = 0 ; ring < MAX_PDEV_CNT; ring++) {
- pdev = soc->pdev_list[ring];
- if (!pdev)
- continue;
- for (mac_id = 0; mac_id < NUM_RXDMA_RINGS_PER_PDEV; mac_id++) {
- int mac_for_pdev = dp_get_mac_id_for_pdev(mac_id,
- pdev->pdev_id);
- if (int_ctx->rx_mon_ring_mask & (1 << mac_for_pdev)) {
- work_done = dp_mon_process(soc, mac_for_pdev,
- remaining_quota);
- if (work_done)
- intr_stats->num_rx_mon_ring_masks++;
- budget -= work_done;
- if (budget <= 0)
- goto budget_done;
- remaining_quota = budget;
- }
- if (int_ctx->rxdma2host_ring_mask &
- (1 << mac_for_pdev)) {
- work_done = dp_rxdma_err_process(int_ctx, soc,
- mac_for_pdev,
- remaining_quota);
- if (work_done)
- intr_stats->num_rxdma2host_ring_masks++;
- budget -= work_done;
- if (budget <= 0)
- goto budget_done;
- remaining_quota = budget;
- }
- if (int_ctx->host2rxdma_ring_mask &
- (1 << mac_for_pdev)) {
- union dp_rx_desc_list_elem_t *desc_list = NULL;
- union dp_rx_desc_list_elem_t *tail = NULL;
- struct dp_srng *rx_refill_buf_ring =
- &pdev->rx_refill_buf_ring;
- intr_stats->num_host2rxdma_ring_masks++;
- DP_STATS_INC(pdev, replenish.low_thresh_intrs,
- 1);
- dp_rx_buffers_replenish(soc, mac_for_pdev,
- rx_refill_buf_ring,
- &soc->rx_desc_buf[mac_for_pdev],
- 0, &desc_list, &tail);
- }
- }
- }
- qdf_lro_flush(int_ctx->lro_ctx);
- intr_stats->num_masks++;
- budget_done:
- return dp_budget - budget;
- }
- static void dp_interrupt_timer(void *arg)
- {
- struct dp_soc *soc = (struct dp_soc *) arg;
- int i;
- if (qdf_atomic_read(&soc->cmn_init_done)) {
- for (i = 0;
- i < wlan_cfg_get_num_contexts(soc->wlan_cfg_ctx); i++)
- dp_service_srngs(&soc->intr_ctx[i], 0xffff);
- qdf_timer_mod(&soc->int_timer, DP_INTR_POLL_TIMER_MS);
- }
- }
- static QDF_STATUS dp_soc_attach_poll(void *txrx_soc)
- {
- struct dp_soc *soc = (struct dp_soc *)txrx_soc;
- int i;
- soc->intr_mode = DP_INTR_POLL;
- for (i = 0; i < wlan_cfg_get_num_contexts(soc->wlan_cfg_ctx); i++) {
- soc->intr_ctx[i].dp_intr_id = i;
- soc->intr_ctx[i].tx_ring_mask =
- wlan_cfg_get_tx_ring_mask(soc->wlan_cfg_ctx, i);
- soc->intr_ctx[i].rx_ring_mask =
- wlan_cfg_get_rx_ring_mask(soc->wlan_cfg_ctx, i);
- soc->intr_ctx[i].rx_mon_ring_mask =
- wlan_cfg_get_rx_mon_ring_mask(soc->wlan_cfg_ctx, i);
- soc->intr_ctx[i].rx_err_ring_mask =
- wlan_cfg_get_rx_err_ring_mask(soc->wlan_cfg_ctx, i);
- soc->intr_ctx[i].rx_wbm_rel_ring_mask =
- wlan_cfg_get_rx_wbm_rel_ring_mask(soc->wlan_cfg_ctx, i);
- soc->intr_ctx[i].reo_status_ring_mask =
- wlan_cfg_get_reo_status_ring_mask(soc->wlan_cfg_ctx, i);
- soc->intr_ctx[i].rxdma2host_ring_mask =
- wlan_cfg_get_rxdma2host_ring_mask(soc->wlan_cfg_ctx, i);
- soc->intr_ctx[i].soc = soc;
- soc->intr_ctx[i].lro_ctx = qdf_lro_init();
- }
- qdf_timer_init(soc->osdev, &soc->int_timer,
- dp_interrupt_timer, (void *)soc,
- QDF_TIMER_TYPE_WAKE_APPS);
- return QDF_STATUS_SUCCESS;
- }
- static QDF_STATUS dp_soc_interrupt_attach(void *txrx_soc);
- #if defined(DP_INTR_POLL_BOTH)
- static QDF_STATUS dp_soc_interrupt_attach_wrapper(void *txrx_soc)
- {
- struct dp_soc *soc = (struct dp_soc *)txrx_soc;
- if (!(soc->wlan_cfg_ctx->napi_enabled) ||
- con_mode_monitor == QDF_GLOBAL_MONITOR_MODE) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
- "%s: Poll mode", __func__);
- return dp_soc_attach_poll(txrx_soc);
- } else {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
- "%s: Interrupt mode", __func__);
- return dp_soc_interrupt_attach(txrx_soc);
- }
- }
- #else
- #if defined(DP_INTR_POLL_BASED) && DP_INTR_POLL_BASED
- static QDF_STATUS dp_soc_interrupt_attach_wrapper(void *txrx_soc)
- {
- return dp_soc_attach_poll(txrx_soc);
- }
- #else
- static QDF_STATUS dp_soc_interrupt_attach_wrapper(void *txrx_soc)
- {
- struct dp_soc *soc = (struct dp_soc *)txrx_soc;
- if (hif_is_polled_mode_enabled(soc->hif_handle))
- return dp_soc_attach_poll(txrx_soc);
- else
- return dp_soc_interrupt_attach(txrx_soc);
- }
- #endif
- #endif
- static void dp_soc_interrupt_map_calculate_integrated(struct dp_soc *soc,
- int intr_ctx_num, int *irq_id_map, int *num_irq_r)
- {
- int j;
- int num_irq = 0;
- int tx_mask =
- wlan_cfg_get_tx_ring_mask(soc->wlan_cfg_ctx, intr_ctx_num);
- int rx_mask =
- wlan_cfg_get_rx_ring_mask(soc->wlan_cfg_ctx, intr_ctx_num);
- int rx_mon_mask =
- wlan_cfg_get_rx_mon_ring_mask(soc->wlan_cfg_ctx, intr_ctx_num);
- int rx_err_ring_mask = wlan_cfg_get_rx_err_ring_mask(
- soc->wlan_cfg_ctx, intr_ctx_num);
- int rx_wbm_rel_ring_mask = wlan_cfg_get_rx_wbm_rel_ring_mask(
- soc->wlan_cfg_ctx, intr_ctx_num);
- int reo_status_ring_mask = wlan_cfg_get_reo_status_ring_mask(
- soc->wlan_cfg_ctx, intr_ctx_num);
- int rxdma2host_ring_mask = wlan_cfg_get_rxdma2host_ring_mask(
- soc->wlan_cfg_ctx, intr_ctx_num);
- int host2rxdma_ring_mask = wlan_cfg_get_host2rxdma_ring_mask(
- soc->wlan_cfg_ctx, intr_ctx_num);
- int host2rxdma_mon_ring_mask = wlan_cfg_get_host2rxdma_mon_ring_mask(
- soc->wlan_cfg_ctx, intr_ctx_num);
- for (j = 0; j < HIF_MAX_GRP_IRQ; j++) {
- if (tx_mask & (1 << j)) {
- irq_id_map[num_irq++] =
- (wbm2host_tx_completions_ring1 - j);
- }
- if (rx_mask & (1 << j)) {
- irq_id_map[num_irq++] =
- (reo2host_destination_ring1 - j);
- }
- if (rxdma2host_ring_mask & (1 << j)) {
- irq_id_map[num_irq++] =
- rxdma2host_destination_ring_mac1 -
- wlan_cfg_get_hw_mac_idx(soc->wlan_cfg_ctx, j);
- }
- if (host2rxdma_ring_mask & (1 << j)) {
- irq_id_map[num_irq++] =
- host2rxdma_host_buf_ring_mac1 -
- wlan_cfg_get_hw_mac_idx(soc->wlan_cfg_ctx, j);
- }
- if (host2rxdma_mon_ring_mask & (1 << j)) {
- irq_id_map[num_irq++] =
- host2rxdma_monitor_ring1 -
- wlan_cfg_get_hw_mac_idx(soc->wlan_cfg_ctx, j);
- }
- if (rx_mon_mask & (1 << j)) {
- irq_id_map[num_irq++] =
- ppdu_end_interrupts_mac1 -
- wlan_cfg_get_hw_mac_idx(soc->wlan_cfg_ctx, j);
- irq_id_map[num_irq++] =
- rxdma2host_monitor_status_ring_mac1 -
- wlan_cfg_get_hw_mac_idx(soc->wlan_cfg_ctx, j);
- }
- if (rx_wbm_rel_ring_mask & (1 << j))
- irq_id_map[num_irq++] = wbm2host_rx_release;
- if (rx_err_ring_mask & (1 << j))
- irq_id_map[num_irq++] = reo2host_exception;
- if (reo_status_ring_mask & (1 << j))
- irq_id_map[num_irq++] = reo2host_status;
- }
- *num_irq_r = num_irq;
- }
- static void dp_soc_interrupt_map_calculate_msi(struct dp_soc *soc,
- int intr_ctx_num, int *irq_id_map, int *num_irq_r,
- int msi_vector_count, int msi_vector_start)
- {
- int tx_mask = wlan_cfg_get_tx_ring_mask(
- soc->wlan_cfg_ctx, intr_ctx_num);
- int rx_mask = wlan_cfg_get_rx_ring_mask(
- soc->wlan_cfg_ctx, intr_ctx_num);
- int rx_mon_mask = wlan_cfg_get_rx_mon_ring_mask(
- soc->wlan_cfg_ctx, intr_ctx_num);
- int rx_err_ring_mask = wlan_cfg_get_rx_err_ring_mask(
- soc->wlan_cfg_ctx, intr_ctx_num);
- int rx_wbm_rel_ring_mask = wlan_cfg_get_rx_wbm_rel_ring_mask(
- soc->wlan_cfg_ctx, intr_ctx_num);
- int reo_status_ring_mask = wlan_cfg_get_reo_status_ring_mask(
- soc->wlan_cfg_ctx, intr_ctx_num);
- int rxdma2host_ring_mask = wlan_cfg_get_rxdma2host_ring_mask(
- soc->wlan_cfg_ctx, intr_ctx_num);
- unsigned int vector =
- (intr_ctx_num % msi_vector_count) + msi_vector_start;
- int num_irq = 0;
- soc->intr_mode = DP_INTR_MSI;
- if (tx_mask | rx_mask | rx_mon_mask | rx_err_ring_mask |
- rx_wbm_rel_ring_mask | reo_status_ring_mask | rxdma2host_ring_mask)
- irq_id_map[num_irq++] =
- pld_get_msi_irq(soc->osdev->dev, vector);
- *num_irq_r = num_irq;
- }
- static void dp_soc_interrupt_map_calculate(struct dp_soc *soc, int intr_ctx_num,
- int *irq_id_map, int *num_irq)
- {
- int msi_vector_count, ret;
- uint32_t msi_base_data, msi_vector_start;
- ret = pld_get_user_msi_assignment(soc->osdev->dev, "DP",
- &msi_vector_count,
- &msi_base_data,
- &msi_vector_start);
- if (ret)
- return dp_soc_interrupt_map_calculate_integrated(soc,
- intr_ctx_num, irq_id_map, num_irq);
- else
- dp_soc_interrupt_map_calculate_msi(soc,
- intr_ctx_num, irq_id_map, num_irq,
- msi_vector_count, msi_vector_start);
- }
- static QDF_STATUS dp_soc_interrupt_attach(void *txrx_soc)
- {
- struct dp_soc *soc = (struct dp_soc *)txrx_soc;
- int i = 0;
- int num_irq = 0;
- for (i = 0; i < wlan_cfg_get_num_contexts(soc->wlan_cfg_ctx); i++) {
- int ret = 0;
-
- int irq_id_map[HIF_MAX_GRP_IRQ];
- int tx_mask =
- wlan_cfg_get_tx_ring_mask(soc->wlan_cfg_ctx, i);
- int rx_mask =
- wlan_cfg_get_rx_ring_mask(soc->wlan_cfg_ctx, i);
- int rx_mon_mask =
- dp_soc_get_mon_mask_for_interrupt_mode(soc, i);
- int rx_err_ring_mask =
- wlan_cfg_get_rx_err_ring_mask(soc->wlan_cfg_ctx, i);
- int rx_wbm_rel_ring_mask =
- wlan_cfg_get_rx_wbm_rel_ring_mask(soc->wlan_cfg_ctx, i);
- int reo_status_ring_mask =
- wlan_cfg_get_reo_status_ring_mask(soc->wlan_cfg_ctx, i);
- int rxdma2host_ring_mask =
- wlan_cfg_get_rxdma2host_ring_mask(soc->wlan_cfg_ctx, i);
- int host2rxdma_ring_mask =
- wlan_cfg_get_host2rxdma_ring_mask(soc->wlan_cfg_ctx, i);
- int host2rxdma_mon_ring_mask =
- wlan_cfg_get_host2rxdma_mon_ring_mask(
- soc->wlan_cfg_ctx, i);
- soc->intr_ctx[i].dp_intr_id = i;
- soc->intr_ctx[i].tx_ring_mask = tx_mask;
- soc->intr_ctx[i].rx_ring_mask = rx_mask;
- soc->intr_ctx[i].rx_mon_ring_mask = rx_mon_mask;
- soc->intr_ctx[i].rx_err_ring_mask = rx_err_ring_mask;
- soc->intr_ctx[i].rxdma2host_ring_mask = rxdma2host_ring_mask;
- soc->intr_ctx[i].host2rxdma_ring_mask = host2rxdma_ring_mask;
- soc->intr_ctx[i].rx_wbm_rel_ring_mask = rx_wbm_rel_ring_mask;
- soc->intr_ctx[i].reo_status_ring_mask = reo_status_ring_mask;
- soc->intr_ctx[i].host2rxdma_mon_ring_mask =
- host2rxdma_mon_ring_mask;
- soc->intr_ctx[i].soc = soc;
- num_irq = 0;
- dp_soc_interrupt_map_calculate(soc, i, &irq_id_map[0],
- &num_irq);
- ret = hif_register_ext_group(soc->hif_handle,
- num_irq, irq_id_map, dp_service_srngs,
- &soc->intr_ctx[i], "dp_intr",
- HIF_EXEC_NAPI_TYPE, QCA_NAPI_DEF_SCALE_BIN_SHIFT);
- if (ret) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- FL("failed, ret = %d"), ret);
- return QDF_STATUS_E_FAILURE;
- }
- soc->intr_ctx[i].lro_ctx = qdf_lro_init();
- }
- hif_configure_ext_group_interrupts(soc->hif_handle);
- return QDF_STATUS_SUCCESS;
- }
- static void dp_soc_interrupt_detach(void *txrx_soc)
- {
- struct dp_soc *soc = (struct dp_soc *)txrx_soc;
- int i;
- if (soc->intr_mode == DP_INTR_POLL) {
- qdf_timer_stop(&soc->int_timer);
- qdf_timer_free(&soc->int_timer);
- } else {
- hif_deregister_exec_group(soc->hif_handle, "dp_intr");
- }
- for (i = 0; i < wlan_cfg_get_num_contexts(soc->wlan_cfg_ctx); i++) {
- soc->intr_ctx[i].tx_ring_mask = 0;
- soc->intr_ctx[i].rx_ring_mask = 0;
- soc->intr_ctx[i].rx_mon_ring_mask = 0;
- soc->intr_ctx[i].rx_err_ring_mask = 0;
- soc->intr_ctx[i].rx_wbm_rel_ring_mask = 0;
- soc->intr_ctx[i].reo_status_ring_mask = 0;
- soc->intr_ctx[i].rxdma2host_ring_mask = 0;
- soc->intr_ctx[i].host2rxdma_ring_mask = 0;
- soc->intr_ctx[i].host2rxdma_mon_ring_mask = 0;
- qdf_lro_deinit(soc->intr_ctx[i].lro_ctx);
- }
- }
- #define AVG_MAX_MPDUS_PER_TID 128
- #define AVG_TIDS_PER_CLIENT 2
- #define AVG_FLOWS_PER_TID 2
- #define AVG_MSDUS_PER_FLOW 128
- #define AVG_MSDUS_PER_MPDU 4
- static int dp_hw_link_desc_pool_setup(struct dp_soc *soc)
- {
- int link_desc_size = hal_get_link_desc_size(soc->hal_soc);
- int link_desc_align = hal_get_link_desc_align(soc->hal_soc);
- uint32_t max_clients = wlan_cfg_get_max_clients(soc->wlan_cfg_ctx);
- uint32_t num_mpdus_per_link_desc =
- hal_num_mpdus_per_link_desc(soc->hal_soc);
- uint32_t num_msdus_per_link_desc =
- hal_num_msdus_per_link_desc(soc->hal_soc);
- uint32_t num_mpdu_links_per_queue_desc =
- hal_num_mpdu_links_per_queue_desc(soc->hal_soc);
- uint32_t max_alloc_size = wlan_cfg_max_alloc_size(soc->wlan_cfg_ctx);
- uint32_t total_link_descs, total_mem_size;
- uint32_t num_mpdu_link_descs, num_mpdu_queue_descs;
- uint32_t num_tx_msdu_link_descs, num_rx_msdu_link_descs;
- uint32_t num_link_desc_banks;
- uint32_t last_bank_size = 0;
- uint32_t entry_size, num_entries;
- int i;
- uint32_t desc_id = 0;
- qdf_dma_addr_t *baseaddr = NULL;
-
- num_mpdu_link_descs = (max_clients * AVG_TIDS_PER_CLIENT *
- AVG_MAX_MPDUS_PER_TID) / num_mpdus_per_link_desc;
- num_mpdu_queue_descs = num_mpdu_link_descs /
- num_mpdu_links_per_queue_desc;
- num_tx_msdu_link_descs = (max_clients * AVG_TIDS_PER_CLIENT *
- AVG_FLOWS_PER_TID * AVG_MSDUS_PER_FLOW) /
- num_msdus_per_link_desc;
- num_rx_msdu_link_descs = (max_clients * AVG_TIDS_PER_CLIENT *
- AVG_MAX_MPDUS_PER_TID * AVG_MSDUS_PER_MPDU) / 6;
- num_entries = num_mpdu_link_descs + num_mpdu_queue_descs +
- num_tx_msdu_link_descs + num_rx_msdu_link_descs;
-
- total_link_descs = 1;
- while (total_link_descs < num_entries)
- total_link_descs <<= 1;
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_HIGH,
- FL("total_link_descs: %u, link_desc_size: %d"),
- total_link_descs, link_desc_size);
- total_mem_size = total_link_descs * link_desc_size;
- total_mem_size += link_desc_align;
- if (total_mem_size <= max_alloc_size) {
- num_link_desc_banks = 0;
- last_bank_size = total_mem_size;
- } else {
- num_link_desc_banks = (total_mem_size) /
- (max_alloc_size - link_desc_align);
- last_bank_size = total_mem_size %
- (max_alloc_size - link_desc_align);
- }
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_HIGH,
- FL("total_mem_size: %d, num_link_desc_banks: %u"),
- total_mem_size, num_link_desc_banks);
- for (i = 0; i < num_link_desc_banks; i++) {
- if (!dp_is_soc_reinit(soc)) {
- baseaddr = &soc->link_desc_banks[i].
- base_paddr_unaligned;
- soc->link_desc_banks[i].base_vaddr_unaligned =
- qdf_mem_alloc_consistent(soc->osdev,
- soc->osdev->dev,
- max_alloc_size,
- baseaddr);
- }
- soc->link_desc_banks[i].size = max_alloc_size;
- soc->link_desc_banks[i].base_vaddr = (void *)((unsigned long)(
- soc->link_desc_banks[i].base_vaddr_unaligned) +
- ((unsigned long)(
- soc->link_desc_banks[i].base_vaddr_unaligned) %
- link_desc_align));
- soc->link_desc_banks[i].base_paddr = (unsigned long)(
- soc->link_desc_banks[i].base_paddr_unaligned) +
- ((unsigned long)(soc->link_desc_banks[i].base_vaddr) -
- (unsigned long)(
- soc->link_desc_banks[i].base_vaddr_unaligned));
- if (!soc->link_desc_banks[i].base_vaddr_unaligned) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- FL("Link descriptor memory alloc failed"));
- goto fail;
- }
- if (!dp_is_soc_reinit(soc)) {
- qdf_minidump_log(soc->link_desc_banks[i].base_vaddr,
- soc->link_desc_banks[i].size,
- "link_desc_bank");
- }
- }
- if (last_bank_size) {
-
- if (!dp_is_soc_reinit(soc)) {
- baseaddr = &soc->link_desc_banks[i].
- base_paddr_unaligned;
- soc->link_desc_banks[i].base_vaddr_unaligned =
- qdf_mem_alloc_consistent(soc->osdev,
- soc->osdev->dev,
- last_bank_size,
- baseaddr);
- }
- soc->link_desc_banks[i].size = last_bank_size;
- soc->link_desc_banks[i].base_vaddr = (void *)((unsigned long)
- (soc->link_desc_banks[i].base_vaddr_unaligned) +
- ((unsigned long)(
- soc->link_desc_banks[i].base_vaddr_unaligned) %
- link_desc_align));
- soc->link_desc_banks[i].base_paddr =
- (unsigned long)(
- soc->link_desc_banks[i].base_paddr_unaligned) +
- ((unsigned long)(soc->link_desc_banks[i].base_vaddr) -
- (unsigned long)(
- soc->link_desc_banks[i].base_vaddr_unaligned));
- if (!dp_is_soc_reinit(soc)) {
- qdf_minidump_log(soc->link_desc_banks[i].base_vaddr,
- soc->link_desc_banks[i].size,
- "link_desc_bank");
- }
- }
-
- entry_size = hal_srng_get_entrysize(soc->hal_soc, WBM_IDLE_LINK);
- total_mem_size = entry_size * total_link_descs;
- if (total_mem_size <= max_alloc_size) {
- void *desc;
- if (dp_srng_setup(soc, &soc->wbm_idle_link_ring,
- WBM_IDLE_LINK, 0, 0, total_link_descs, 0)) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- FL("Link desc idle ring setup failed"));
- goto fail;
- }
- qdf_minidump_log(soc->wbm_idle_link_ring.base_vaddr_unaligned,
- soc->wbm_idle_link_ring.alloc_size,
- "wbm_idle_link_ring");
- hal_srng_access_start_unlocked(soc->hal_soc,
- soc->wbm_idle_link_ring.hal_srng);
- for (i = 0; i < MAX_LINK_DESC_BANKS &&
- soc->link_desc_banks[i].base_paddr; i++) {
- uint32_t num_entries = (soc->link_desc_banks[i].size -
- ((unsigned long)(
- soc->link_desc_banks[i].base_vaddr) -
- (unsigned long)(
- soc->link_desc_banks[i].base_vaddr_unaligned)))
- / link_desc_size;
- unsigned long paddr = (unsigned long)(
- soc->link_desc_banks[i].base_paddr);
- while (num_entries && (desc = hal_srng_src_get_next(
- soc->hal_soc,
- soc->wbm_idle_link_ring.hal_srng))) {
- hal_set_link_desc_addr(desc,
- LINK_DESC_COOKIE(desc_id, i), paddr);
- num_entries--;
- desc_id++;
- paddr += link_desc_size;
- }
- }
- hal_srng_access_end_unlocked(soc->hal_soc,
- soc->wbm_idle_link_ring.hal_srng);
- } else {
- uint32_t num_scatter_bufs;
- uint32_t num_entries_per_buf;
- uint32_t rem_entries;
- uint8_t *scatter_buf_ptr;
- uint16_t scatter_buf_num;
- uint32_t buf_size = 0;
- soc->wbm_idle_scatter_buf_size =
- hal_idle_list_scatter_buf_size(soc->hal_soc);
- num_entries_per_buf = hal_idle_scatter_buf_num_entries(
- soc->hal_soc, soc->wbm_idle_scatter_buf_size);
- num_scatter_bufs = hal_idle_list_num_scatter_bufs(
- soc->hal_soc, total_mem_size,
- soc->wbm_idle_scatter_buf_size);
- if (num_scatter_bufs > MAX_IDLE_SCATTER_BUFS) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- FL("scatter bufs size out of bounds"));
- goto fail;
- }
- for (i = 0; i < num_scatter_bufs; i++) {
- baseaddr = &soc->wbm_idle_scatter_buf_base_paddr[i];
- if (!dp_is_soc_reinit(soc)) {
- buf_size = soc->wbm_idle_scatter_buf_size;
- soc->wbm_idle_scatter_buf_base_vaddr[i] =
- qdf_mem_alloc_consistent(soc->osdev,
- soc->osdev->
- dev,
- buf_size,
- baseaddr);
- }
- if (!soc->wbm_idle_scatter_buf_base_vaddr[i]) {
- QDF_TRACE(QDF_MODULE_ID_DP,
- QDF_TRACE_LEVEL_ERROR,
- FL("Scatter lst memory alloc fail"));
- goto fail;
- }
- }
-
- scatter_buf_num = 0;
- scatter_buf_ptr = (uint8_t *)(
- soc->wbm_idle_scatter_buf_base_vaddr[scatter_buf_num]);
- rem_entries = num_entries_per_buf;
- for (i = 0; i < MAX_LINK_DESC_BANKS &&
- soc->link_desc_banks[i].base_paddr; i++) {
- uint32_t num_link_descs =
- (soc->link_desc_banks[i].size -
- ((unsigned long)(
- soc->link_desc_banks[i].base_vaddr) -
- (unsigned long)(
- soc->link_desc_banks[i].base_vaddr_unaligned)))
- / link_desc_size;
- unsigned long paddr = (unsigned long)(
- soc->link_desc_banks[i].base_paddr);
- while (num_link_descs) {
- hal_set_link_desc_addr((void *)scatter_buf_ptr,
- LINK_DESC_COOKIE(desc_id, i), paddr);
- num_link_descs--;
- desc_id++;
- paddr += link_desc_size;
- rem_entries--;
- if (rem_entries) {
- scatter_buf_ptr += entry_size;
- } else {
- rem_entries = num_entries_per_buf;
- scatter_buf_num++;
- if (scatter_buf_num >= num_scatter_bufs)
- break;
- scatter_buf_ptr = (uint8_t *)(
- soc->wbm_idle_scatter_buf_base_vaddr[
- scatter_buf_num]);
- }
- }
- }
-
- hal_setup_link_idle_list(soc->hal_soc,
- soc->wbm_idle_scatter_buf_base_paddr,
- soc->wbm_idle_scatter_buf_base_vaddr,
- num_scatter_bufs, soc->wbm_idle_scatter_buf_size,
- (uint32_t)(scatter_buf_ptr -
- (uint8_t *)(soc->wbm_idle_scatter_buf_base_vaddr[
- scatter_buf_num-1])), total_link_descs);
- }
- return 0;
- fail:
- if (soc->wbm_idle_link_ring.hal_srng) {
- dp_srng_cleanup(soc, &soc->wbm_idle_link_ring,
- WBM_IDLE_LINK, 0);
- }
- for (i = 0; i < MAX_IDLE_SCATTER_BUFS; i++) {
- if (soc->wbm_idle_scatter_buf_base_vaddr[i]) {
- qdf_mem_free_consistent(soc->osdev, soc->osdev->dev,
- soc->wbm_idle_scatter_buf_size,
- soc->wbm_idle_scatter_buf_base_vaddr[i],
- soc->wbm_idle_scatter_buf_base_paddr[i], 0);
- soc->wbm_idle_scatter_buf_base_vaddr[i] = NULL;
- }
- }
- for (i = 0; i < MAX_LINK_DESC_BANKS; i++) {
- if (soc->link_desc_banks[i].base_vaddr_unaligned) {
- qdf_mem_free_consistent(soc->osdev, soc->osdev->dev,
- soc->link_desc_banks[i].size,
- soc->link_desc_banks[i].base_vaddr_unaligned,
- soc->link_desc_banks[i].base_paddr_unaligned,
- 0);
- soc->link_desc_banks[i].base_vaddr_unaligned = NULL;
- }
- }
- return QDF_STATUS_E_FAILURE;
- }
- static void dp_hw_link_desc_pool_cleanup(struct dp_soc *soc)
- {
- int i;
- if (soc->wbm_idle_link_ring.hal_srng) {
- qdf_minidump_remove(
- soc->wbm_idle_link_ring.base_vaddr_unaligned);
- dp_srng_cleanup(soc, &soc->wbm_idle_link_ring,
- WBM_IDLE_LINK, 0);
- }
- for (i = 0; i < MAX_IDLE_SCATTER_BUFS; i++) {
- if (soc->wbm_idle_scatter_buf_base_vaddr[i]) {
- qdf_mem_free_consistent(soc->osdev, soc->osdev->dev,
- soc->wbm_idle_scatter_buf_size,
- soc->wbm_idle_scatter_buf_base_vaddr[i],
- soc->wbm_idle_scatter_buf_base_paddr[i], 0);
- soc->wbm_idle_scatter_buf_base_vaddr[i] = NULL;
- }
- }
- for (i = 0; i < MAX_LINK_DESC_BANKS; i++) {
- if (soc->link_desc_banks[i].base_vaddr_unaligned) {
- qdf_minidump_remove(soc->link_desc_banks[i].base_vaddr);
- qdf_mem_free_consistent(soc->osdev, soc->osdev->dev,
- soc->link_desc_banks[i].size,
- soc->link_desc_banks[i].base_vaddr_unaligned,
- soc->link_desc_banks[i].base_paddr_unaligned,
- 0);
- soc->link_desc_banks[i].base_vaddr_unaligned = NULL;
- }
- }
- }
- #ifdef IPA_OFFLOAD
- #define REO_DST_RING_SIZE_QCA6290 1023
- #ifndef QCA_WIFI_QCA8074_VP
- #define REO_DST_RING_SIZE_QCA8074 1023
- #else
- #define REO_DST_RING_SIZE_QCA8074 8
- #endif
- #else
- #define REO_DST_RING_SIZE_QCA6290 1024
- #ifndef QCA_WIFI_QCA8074_VP
- #define REO_DST_RING_SIZE_QCA8074 2048
- #else
- #define REO_DST_RING_SIZE_QCA8074 8
- #endif
- #endif
- #ifndef FEATURE_WDS
- static void dp_soc_wds_attach(struct dp_soc *soc)
- {
- }
- static void dp_soc_wds_detach(struct dp_soc *soc)
- {
- }
- #endif
- static void dp_soc_reset_cpu_ring_map(struct dp_soc *soc)
- {
- uint8_t i;
- int nss_config = wlan_cfg_get_dp_soc_nss_cfg(soc->wlan_cfg_ctx);
- for (i = 0; i < WLAN_CFG_INT_NUM_CONTEXTS; i++) {
- switch (nss_config) {
- case dp_nss_cfg_first_radio:
-
- soc->tx_ring_map[i] = dp_cpu_ring_map[DP_NSS_FIRST_RADIO_OFFLOADED_MAP][i];
- break;
- case dp_nss_cfg_second_radio:
-
- soc->tx_ring_map[i] = dp_cpu_ring_map[DP_NSS_SECOND_RADIO_OFFLOADED_MAP][i];
- break;
- case dp_nss_cfg_dbdc:
-
- soc->tx_ring_map[i] =
- dp_cpu_ring_map[DP_NSS_DBDC_OFFLOADED_MAP][i];
- break;
- case dp_nss_cfg_dbtc:
-
- soc->tx_ring_map[i] =
- dp_cpu_ring_map[DP_NSS_DBTC_OFFLOADED_MAP][i];
- break;
- default:
- dp_err("tx_ring_map failed due to invalid nss cfg");
- break;
- }
- }
- }
- static uint8_t dp_soc_ring_if_nss_offloaded(struct dp_soc *soc, enum hal_ring_type ring_type, int ring_num)
- {
- uint8_t nss_config = wlan_cfg_get_dp_soc_nss_cfg(soc->wlan_cfg_ctx);
- uint8_t status = 0;
- switch (ring_type) {
- case WBM2SW_RELEASE:
- case REO_DST:
- case RXDMA_BUF:
- status = ((nss_config) & (1 << ring_num));
- break;
- default:
- break;
- }
- return status;
- }
- static void dp_soc_disable_mac2_intr_mask(struct dp_soc *soc)
- {
- int *grp_mask = NULL;
- int group_number;
- grp_mask = &soc->wlan_cfg_ctx->int_host2rxdma_ring_mask[0];
- group_number = dp_srng_find_ring_in_mask(0x2, grp_mask);
- wlan_cfg_set_host2rxdma_ring_mask(soc->wlan_cfg_ctx,
- group_number, 0x0);
- grp_mask = &soc->wlan_cfg_ctx->int_rx_mon_ring_mask[0];
- group_number = dp_srng_find_ring_in_mask(0x2, grp_mask);
- wlan_cfg_set_rx_mon_ring_mask(soc->wlan_cfg_ctx,
- group_number, 0x0);
- grp_mask = &soc->wlan_cfg_ctx->int_rxdma2host_ring_mask[0];
- group_number = dp_srng_find_ring_in_mask(0x2, grp_mask);
- wlan_cfg_set_rxdma2host_ring_mask(soc->wlan_cfg_ctx,
- group_number, 0x0);
- grp_mask = &soc->wlan_cfg_ctx->int_host2rxdma_mon_ring_mask[0];
- group_number = dp_srng_find_ring_in_mask(0x2, grp_mask);
- wlan_cfg_set_host2rxdma_mon_ring_mask(soc->wlan_cfg_ctx,
- group_number, 0x0);
- }
- static void dp_soc_reset_intr_mask(struct dp_soc *soc)
- {
- uint8_t j;
- int *grp_mask = NULL;
- int group_number, mask, num_ring;
-
- num_ring = wlan_cfg_num_tcl_data_rings(soc->wlan_cfg_ctx);
-
- grp_mask = &soc->wlan_cfg_ctx->int_tx_ring_mask[0];
-
- for (j = 0; j < num_ring; j++) {
- if (!dp_soc_ring_if_nss_offloaded(soc, WBM2SW_RELEASE, j)) {
- continue;
- }
-
- group_number = dp_srng_find_ring_in_mask(j, grp_mask);
- if (group_number < 0) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
- FL("ring not part of any group; ring_type: %d,ring_num %d"),
- WBM2SW_RELEASE, j);
- return;
- }
-
- mask = wlan_cfg_get_tx_ring_mask(soc->wlan_cfg_ctx, group_number);
- mask &= (~(1 << j));
-
- wlan_cfg_set_tx_ring_mask(soc->wlan_cfg_ctx, group_number, mask);
- }
-
- num_ring = wlan_cfg_num_reo_dest_rings(soc->wlan_cfg_ctx);
-
- grp_mask = &soc->wlan_cfg_ctx->int_rx_ring_mask[0];
-
- for (j = 0; j < num_ring; j++) {
- if (!dp_soc_ring_if_nss_offloaded(soc, REO_DST, j)) {
- continue;
- }
-
- group_number = dp_srng_find_ring_in_mask(j, grp_mask);
- if (group_number < 0) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
- FL("ring not part of any group; ring_type: %d,ring_num %d"),
- REO_DST, j);
- return;
- }
-
- mask = wlan_cfg_get_rx_ring_mask(soc->wlan_cfg_ctx, group_number);
- mask &= (~(1 << j));
-
- wlan_cfg_set_rx_ring_mask(soc->wlan_cfg_ctx, group_number, mask);
- }
-
- grp_mask = &soc->wlan_cfg_ctx->int_host2rxdma_ring_mask[0];
-
- for (j = 0; j < MAX_PDEV_CNT; j++) {
- if (!dp_soc_ring_if_nss_offloaded(soc, RXDMA_BUF, j)) {
- continue;
- }
-
- group_number = dp_srng_find_ring_in_mask(j, grp_mask);
- if (group_number < 0) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
- FL("ring not part of any group; ring_type: %d,ring_num %d"),
- REO_DST, j);
- return;
- }
-
- mask = wlan_cfg_get_host2rxdma_ring_mask(soc->wlan_cfg_ctx,
- group_number);
- mask &= (~(1 << j));
-
- wlan_cfg_set_host2rxdma_ring_mask(soc->wlan_cfg_ctx,
- group_number, mask);
- }
- }
- #ifdef IPA_OFFLOAD
- bool dp_reo_remap_config(struct dp_soc *soc, uint32_t *remap1, uint32_t *remap2)
- {
- *remap1 = ((0x1 << 0) | (0x2 << 3) | (0x3 << 6) | (0x1 << 9) |
- (0x2 << 12) | (0x3 << 15) | (0x1 << 18) | (0x2 << 21)) << 8;
- *remap2 = ((0x3 << 0) | (0x1 << 3) | (0x2 << 6) | (0x3 << 9) |
- (0x1 << 12) | (0x2 << 15) | (0x3 << 18) | (0x1 << 21)) << 8;
- dp_debug("remap1 %x remap2 %x", *remap1, *remap2);
- return true;
- }
- #else
- static bool dp_reo_remap_config(struct dp_soc *soc,
- uint32_t *remap1,
- uint32_t *remap2)
- {
- uint8_t offload_radio = wlan_cfg_get_dp_soc_nss_cfg(soc->wlan_cfg_ctx);
- switch (offload_radio) {
- case dp_nss_cfg_default:
- *remap1 = ((0x1 << 0) | (0x2 << 3) | (0x3 << 6) |
- (0x4 << 9) | (0x1 << 12) | (0x2 << 15) |
- (0x3 << 18) | (0x4 << 21)) << 8;
- *remap2 = ((0x1 << 0) | (0x2 << 3) | (0x3 << 6) |
- (0x4 << 9) | (0x1 << 12) | (0x2 << 15) |
- (0x3 << 18) | (0x4 << 21)) << 8;
- break;
- case dp_nss_cfg_first_radio:
- *remap1 = ((0x2 << 0) | (0x3 << 3) | (0x4 << 6) |
- (0x2 << 9) | (0x3 << 12) | (0x4 << 15) |
- (0x2 << 18) | (0x3 << 21)) << 8;
- *remap2 = ((0x4 << 0) | (0x2 << 3) | (0x3 << 6) |
- (0x4 << 9) | (0x2 << 12) | (0x3 << 15) |
- (0x4 << 18) | (0x2 << 21)) << 8;
- break;
- case dp_nss_cfg_second_radio:
- *remap1 = ((0x1 << 0) | (0x3 << 3) | (0x4 << 6) |
- (0x1 << 9) | (0x3 << 12) | (0x4 << 15) |
- (0x1 << 18) | (0x3 << 21)) << 8;
- *remap2 = ((0x4 << 0) | (0x1 << 3) | (0x3 << 6) |
- (0x4 << 9) | (0x1 << 12) | (0x3 << 15) |
- (0x4 << 18) | (0x1 << 21)) << 8;
- break;
- case dp_nss_cfg_dbdc:
- case dp_nss_cfg_dbtc:
-
- return false;
- }
- dp_debug("remap1 %x remap2 %x offload_radio %u",
- *remap1, *remap2, offload_radio);
- return true;
- }
- #endif
- static void dp_reo_frag_dst_set(struct dp_soc *soc, uint8_t *frag_dst_ring)
- {
- uint8_t offload_radio = wlan_cfg_get_dp_soc_nss_cfg(soc->wlan_cfg_ctx);
- switch (offload_radio) {
- case dp_nss_cfg_default:
- *frag_dst_ring = HAL_SRNG_REO_EXCEPTION;
- break;
- case dp_nss_cfg_dbdc:
- case dp_nss_cfg_dbtc:
- *frag_dst_ring = HAL_SRNG_REO_ALTERNATE_SELECT;
- break;
- default:
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- FL("dp_reo_frag_dst_set invalid offload radio config"));
- break;
- }
- }
- #ifdef ENABLE_VERBOSE_DEBUG
- static void dp_enable_verbose_debug(struct dp_soc *soc)
- {
- struct wlan_cfg_dp_soc_ctxt *soc_cfg_ctx;
- soc_cfg_ctx = soc->wlan_cfg_ctx;
- if (soc_cfg_ctx->per_pkt_trace & dp_verbose_debug_mask)
- is_dp_verbose_debug_enabled = true;
- if (soc_cfg_ctx->per_pkt_trace & hal_verbose_debug_mask)
- hal_set_verbose_debug(true);
- else
- hal_set_verbose_debug(false);
- }
- #else
- static void dp_enable_verbose_debug(struct dp_soc *soc)
- {
- }
- #endif
- static int dp_soc_cmn_setup(struct dp_soc *soc)
- {
- int i, cached;
- struct hal_reo_params reo_params;
- int tx_ring_size;
- int tx_comp_ring_size;
- int reo_dst_ring_size;
- uint32_t entries;
- struct wlan_cfg_dp_soc_ctxt *soc_cfg_ctx;
- if (qdf_atomic_read(&soc->cmn_init_done))
- return 0;
- if (dp_hw_link_desc_pool_setup(soc))
- goto fail1;
- soc_cfg_ctx = soc->wlan_cfg_ctx;
- dp_enable_verbose_debug(soc);
-
-
- entries = wlan_cfg_get_dp_soc_wbm_release_ring_size(soc_cfg_ctx);
- if (dp_srng_setup(soc, &soc->wbm_desc_rel_ring, SW2WBM_RELEASE, 0, 0,
- entries, 0)) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- FL("dp_srng_setup failed for wbm_desc_rel_ring"));
- goto fail1;
- }
- qdf_minidump_log(soc->wbm_desc_rel_ring.base_vaddr_unaligned,
- soc->wbm_desc_rel_ring.alloc_size,
- "wbm_desc_rel_ring");
- soc->num_tcl_data_rings = 0;
-
- if (!wlan_cfg_per_pdev_tx_ring(soc_cfg_ctx)) {
- soc->num_tcl_data_rings =
- wlan_cfg_num_tcl_data_rings(soc_cfg_ctx);
- tx_comp_ring_size =
- wlan_cfg_tx_comp_ring_size(soc_cfg_ctx);
- tx_ring_size =
- wlan_cfg_tx_ring_size(soc_cfg_ctx);
- for (i = 0; i < soc->num_tcl_data_rings; i++) {
- if (dp_srng_setup(soc, &soc->tcl_data_ring[i],
- TCL_DATA, i, 0, tx_ring_size, 0)) {
- QDF_TRACE(QDF_MODULE_ID_DP,
- QDF_TRACE_LEVEL_ERROR,
- FL("dp_srng_setup failed for tcl_data_ring[%d]"), i);
- goto fail1;
- }
-
- cached = WLAN_CFG_DST_RING_CACHED_DESC;
- if (wlan_cfg_get_dp_soc_nss_cfg(soc_cfg_ctx))
- cached = 0;
-
- if (dp_srng_setup(soc, &soc->tx_comp_ring[i],
- WBM2SW_RELEASE, i, 0,
- tx_comp_ring_size,
- cached)) {
- QDF_TRACE(QDF_MODULE_ID_DP,
- QDF_TRACE_LEVEL_ERROR,
- FL("dp_srng_setup failed for tx_comp_ring[%d]"), i);
- goto fail1;
- }
- }
- } else {
-
- soc->num_tcl_data_rings = 0;
- }
- if (dp_tx_soc_attach(soc)) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- FL("dp_tx_soc_attach failed"));
- goto fail1;
- }
- entries = wlan_cfg_get_dp_soc_tcl_cmd_ring_size(soc_cfg_ctx);
-
- if (dp_srng_setup(soc, &soc->tcl_cmd_ring, TCL_CMD, 0, 0,
- entries, 0)) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- FL("dp_srng_setup failed for tcl_cmd_ring"));
- goto fail1;
- }
- entries = wlan_cfg_get_dp_soc_tcl_status_ring_size(soc_cfg_ctx);
- if (dp_srng_setup(soc, &soc->tcl_status_ring, TCL_STATUS, 0, 0,
- entries, 0)) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- FL("dp_srng_setup failed for tcl_status_ring"));
- goto fail1;
- }
- reo_dst_ring_size = wlan_cfg_get_reo_dst_ring_size(soc->wlan_cfg_ctx);
-
-
- if (!wlan_cfg_per_pdev_rx_ring(soc_cfg_ctx)) {
- soc->num_reo_dest_rings =
- wlan_cfg_num_reo_dest_rings(soc_cfg_ctx);
- QDF_TRACE(QDF_MODULE_ID_DP,
- QDF_TRACE_LEVEL_INFO,
- FL("num_reo_dest_rings %d"), soc->num_reo_dest_rings);
-
- cached = WLAN_CFG_DST_RING_CACHED_DESC;
- if (wlan_cfg_get_dp_soc_nss_cfg(soc_cfg_ctx))
- cached = 0;
- for (i = 0; i < soc->num_reo_dest_rings; i++) {
- if (dp_srng_setup(soc, &soc->reo_dest_ring[i], REO_DST,
- i, 0, reo_dst_ring_size, cached)) {
- QDF_TRACE(QDF_MODULE_ID_DP,
- QDF_TRACE_LEVEL_ERROR,
- FL(RNG_ERR "reo_dest_ring [%d]"), i);
- goto fail1;
- }
- }
- } else {
-
- soc->num_reo_dest_rings = 0;
- }
- entries = wlan_cfg_get_dp_soc_rxdma_err_dst_ring_size(soc_cfg_ctx);
-
- if (!wlan_cfg_per_pdev_lmac_ring(soc_cfg_ctx)) {
-
- struct dp_pdev *pdev = soc->pdev_list[0];
- for (i = 0; i < MAX_RX_MAC_RINGS; i++) {
- if (dp_srng_setup(soc, &pdev->rxdma_err_dst_ring[i],
- RXDMA_DST, 0, i, entries, 0)) {
- QDF_TRACE(QDF_MODULE_ID_DP,
- QDF_TRACE_LEVEL_ERROR,
- FL(RNG_ERR "rxdma_err_dst_ring"));
- goto fail1;
- }
- }
- }
-
-
- entries = wlan_cfg_get_dp_soc_reo_reinject_ring_size(soc_cfg_ctx);
- if (dp_srng_setup(soc, &soc->reo_reinject_ring, REO_REINJECT, 0, 0,
- entries, 0)) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- FL("dp_srng_setup failed for reo_reinject_ring"));
- goto fail1;
- }
-
- if (dp_srng_setup(soc, &soc->rx_rel_ring, WBM2SW_RELEASE, 3, 0,
- wlan_cfg_get_dp_soc_rx_release_ring_size(soc_cfg_ctx),
- 0)) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- FL("dp_srng_setup failed for rx_rel_ring"));
- goto fail1;
- }
-
- entries = wlan_cfg_get_dp_soc_reo_exception_ring_size(soc_cfg_ctx);
- if (dp_srng_setup(soc, &soc->reo_exception_ring,
- REO_EXCEPTION, 0, MAX_REO_DEST_RINGS, entries, 0)) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- FL("dp_srng_setup failed for reo_exception_ring"));
- goto fail1;
- }
-
- if (dp_srng_setup(soc, &soc->reo_cmd_ring, REO_CMD, 0, 0,
- wlan_cfg_get_dp_soc_reo_cmd_ring_size(soc_cfg_ctx),
- 0)) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- FL("dp_srng_setup failed for reo_cmd_ring"));
- goto fail1;
- }
- hal_reo_init_cmd_ring(soc->hal_soc, soc->reo_cmd_ring.hal_srng);
- TAILQ_INIT(&soc->rx.reo_cmd_list);
- qdf_spinlock_create(&soc->rx.reo_cmd_lock);
- if (dp_srng_setup(soc, &soc->reo_status_ring, REO_STATUS, 0, 0,
- wlan_cfg_get_dp_soc_reo_status_ring_size(soc_cfg_ctx),
- 0)) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- FL("dp_srng_setup failed for reo_status_ring"));
- goto fail1;
- }
-
- if (hal_get_target_type(soc->hal_soc) == TARGET_TYPE_QCA6018) {
- dp_soc_disable_mac2_intr_mask(soc);
- }
-
- if (wlan_cfg_get_dp_soc_nss_cfg(soc_cfg_ctx)) {
- dp_soc_reset_cpu_ring_map(soc);
- dp_soc_reset_intr_mask(soc);
- }
-
- qdf_mem_zero(&reo_params, sizeof(reo_params));
- if (wlan_cfg_is_rx_hash_enabled(soc_cfg_ctx)) {
-
- if (!dp_reo_remap_config(soc,
- &reo_params.remap1,
- &reo_params.remap2))
- goto out;
- reo_params.rx_hash_enabled = true;
- }
-
- TAILQ_INIT(&soc->rx.defrag.waitlist);
- soc->rx.defrag.timeout_ms =
- wlan_cfg_get_rx_defrag_min_timeout(soc_cfg_ctx);
- soc->rx.defrag.next_flush_ms = 0;
- soc->rx.flags.defrag_timeout_check =
- wlan_cfg_get_defrag_timeout_check(soc_cfg_ctx);
- qdf_spinlock_create(&soc->rx.defrag.defrag_lock);
- out:
-
- dp_reo_frag_dst_set(soc, &reo_params.frag_dst_ring);
- hal_reo_setup(soc->hal_soc, &reo_params);
- qdf_atomic_set(&soc->cmn_init_done, 1);
- dp_soc_wds_attach(soc);
- qdf_nbuf_queue_init(&soc->htt_stats.msg);
- return 0;
- fail1:
-
- return QDF_STATUS_E_FAILURE;
- }
- static void dp_soc_cmn_cleanup(struct dp_soc *soc)
- {
- qdf_spinlock_destroy(&soc->rx.defrag.defrag_lock);
- dp_reo_cmdlist_destroy(soc);
- qdf_spinlock_destroy(&soc->rx.reo_cmd_lock);
- }
- static void dp_pdev_detach_wifi3(struct cdp_pdev *txrx_pdev, int force);
- static QDF_STATUS dp_lro_hash_setup(struct dp_soc *soc, struct dp_pdev *pdev)
- {
- struct cdp_lro_hash_config lro_hash;
- QDF_STATUS status;
- if (!wlan_cfg_is_lro_enabled(soc->wlan_cfg_ctx) &&
- !wlan_cfg_is_gro_enabled(soc->wlan_cfg_ctx) &&
- !wlan_cfg_is_rx_hash_enabled(soc->wlan_cfg_ctx)) {
- dp_err("LRO, GRO and RX hash disabled");
- return QDF_STATUS_E_FAILURE;
- }
- qdf_mem_zero(&lro_hash, sizeof(lro_hash));
- if (wlan_cfg_is_lro_enabled(soc->wlan_cfg_ctx) ||
- wlan_cfg_is_gro_enabled(soc->wlan_cfg_ctx)) {
- lro_hash.lro_enable = 1;
- lro_hash.tcp_flag = QDF_TCPHDR_ACK;
- lro_hash.tcp_flag_mask = QDF_TCPHDR_FIN | QDF_TCPHDR_SYN |
- QDF_TCPHDR_RST | QDF_TCPHDR_ACK | QDF_TCPHDR_URG |
- QDF_TCPHDR_ECE | QDF_TCPHDR_CWR;
- }
- qdf_get_random_bytes(lro_hash.toeplitz_hash_ipv4,
- (sizeof(lro_hash.toeplitz_hash_ipv4[0]) *
- LRO_IPV4_SEED_ARR_SZ));
- qdf_get_random_bytes(lro_hash.toeplitz_hash_ipv6,
- (sizeof(lro_hash.toeplitz_hash_ipv6[0]) *
- LRO_IPV6_SEED_ARR_SZ));
- qdf_assert(soc->cdp_soc.ol_ops->lro_hash_config);
- if (!soc->cdp_soc.ol_ops->lro_hash_config) {
- QDF_BUG(0);
- dp_err("lro_hash_config not configured");
- return QDF_STATUS_E_FAILURE;
- }
- status = soc->cdp_soc.ol_ops->lro_hash_config(pdev->ctrl_pdev,
- &lro_hash);
- if (!QDF_IS_STATUS_SUCCESS(status)) {
- dp_err("failed to send lro_hash_config to FW %u", status);
- return status;
- }
- dp_info("LRO CMD config: lro_enable: 0x%x tcp_flag 0x%x tcp_flag_mask 0x%x",
- lro_hash.lro_enable, lro_hash.tcp_flag,
- lro_hash.tcp_flag_mask);
- dp_info("toeplitz_hash_ipv4:");
- qdf_trace_hex_dump(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
- (void *)lro_hash.toeplitz_hash_ipv4,
- (sizeof(lro_hash.toeplitz_hash_ipv4[0]) *
- LRO_IPV4_SEED_ARR_SZ));
- dp_info("toeplitz_hash_ipv6:");
- qdf_trace_hex_dump(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
- (void *)lro_hash.toeplitz_hash_ipv6,
- (sizeof(lro_hash.toeplitz_hash_ipv6[0]) *
- LRO_IPV6_SEED_ARR_SZ));
- return status;
- }
- #ifdef QCA_HOST2FW_RXBUF_RING
- static int dp_rxdma_ring_setup(struct dp_soc *soc,
- struct dp_pdev *pdev)
- {
- struct wlan_cfg_dp_pdev_ctxt *pdev_cfg_ctx;
- int max_mac_rings;
- int i;
- int ring_size;
- pdev_cfg_ctx = pdev->wlan_cfg_ctx;
- max_mac_rings = wlan_cfg_get_num_mac_rings(pdev_cfg_ctx);
- ring_size = wlan_cfg_get_rx_dma_buf_ring_size(pdev_cfg_ctx);
- for (i = 0; i < max_mac_rings; i++) {
- dp_verbose_debug("pdev_id %d mac_id %d", pdev->pdev_id, i);
- if (dp_srng_setup(soc, &pdev->rx_mac_buf_ring[i],
- RXDMA_BUF, 1, i, ring_size, 0)) {
- QDF_TRACE(QDF_MODULE_ID_DP,
- QDF_TRACE_LEVEL_ERROR,
- FL("failed rx mac ring setup"));
- return QDF_STATUS_E_FAILURE;
- }
- }
- return QDF_STATUS_SUCCESS;
- }
- #else
- static int dp_rxdma_ring_setup(struct dp_soc *soc,
- struct dp_pdev *pdev)
- {
- return QDF_STATUS_SUCCESS;
- }
- #endif
- static inline void
- dp_dscp_tid_map_setup(struct dp_pdev *pdev)
- {
- uint8_t map_id;
- struct dp_soc *soc = pdev->soc;
- if (!soc)
- return;
- for (map_id = 0; map_id < DP_MAX_TID_MAPS; map_id++) {
- qdf_mem_copy(pdev->dscp_tid_map[map_id],
- default_dscp_tid_map,
- sizeof(default_dscp_tid_map));
- }
- for (map_id = 0; map_id < soc->num_hw_dscp_tid_map; map_id++) {
- hal_tx_set_dscp_tid_map(soc->hal_soc,
- default_dscp_tid_map,
- map_id);
- }
- }
- static inline void
- dp_pcp_tid_map_setup(struct dp_pdev *pdev)
- {
- struct dp_soc *soc = pdev->soc;
- if (!soc)
- return;
- qdf_mem_copy(soc->pcp_tid_map, default_pcp_tid_map,
- sizeof(default_pcp_tid_map));
- hal_tx_set_pcp_tid_map_default(soc->hal_soc, default_pcp_tid_map);
- }
- #ifdef IPA_OFFLOAD
- static int dp_setup_ipa_rx_refill_buf_ring(struct dp_soc *soc,
- struct dp_pdev *pdev)
- {
- struct wlan_cfg_dp_soc_ctxt *soc_cfg_ctx;
- int entries;
- soc_cfg_ctx = soc->wlan_cfg_ctx;
- entries = wlan_cfg_get_dp_soc_rxdma_refill_ring_size(soc_cfg_ctx);
-
- if (dp_srng_setup(soc, &pdev->rx_refill_buf_ring2, RXDMA_BUF,
- IPA_RX_REFILL_BUF_RING_IDX, pdev->pdev_id, entries, 0)
- ) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- FL("dp_srng_setup failed second rx refill ring"));
- return QDF_STATUS_E_FAILURE;
- }
- return QDF_STATUS_SUCCESS;
- }
- static void dp_cleanup_ipa_rx_refill_buf_ring(struct dp_soc *soc,
- struct dp_pdev *pdev)
- {
- dp_srng_cleanup(soc, &pdev->rx_refill_buf_ring2, RXDMA_BUF,
- IPA_RX_REFILL_BUF_RING_IDX);
- }
- #else
- static int dp_setup_ipa_rx_refill_buf_ring(struct dp_soc *soc,
- struct dp_pdev *pdev)
- {
- return QDF_STATUS_SUCCESS;
- }
- static void dp_cleanup_ipa_rx_refill_buf_ring(struct dp_soc *soc,
- struct dp_pdev *pdev)
- {
- }
- #endif
- #if !defined(DISABLE_MON_CONFIG)
- static
- QDF_STATUS dp_mon_rings_setup(struct dp_soc *soc, struct dp_pdev *pdev)
- {
- int mac_id = 0;
- int pdev_id = pdev->pdev_id;
- int entries;
- struct wlan_cfg_dp_pdev_ctxt *pdev_cfg_ctx;
- pdev_cfg_ctx = pdev->wlan_cfg_ctx;
- for (mac_id = 0; mac_id < NUM_RXDMA_RINGS_PER_PDEV; mac_id++) {
- int mac_for_pdev = dp_get_mac_id_for_pdev(mac_id, pdev_id);
- if (soc->wlan_cfg_ctx->rxdma1_enable) {
- entries =
- wlan_cfg_get_dma_mon_buf_ring_size(pdev_cfg_ctx);
- if (dp_srng_setup(soc,
- &pdev->rxdma_mon_buf_ring[mac_id],
- RXDMA_MONITOR_BUF, 0, mac_for_pdev,
- entries, 0)) {
- QDF_TRACE(QDF_MODULE_ID_DP,
- QDF_TRACE_LEVEL_ERROR,
- FL(RNG_ERR "rxdma_mon_buf_ring "));
- return QDF_STATUS_E_NOMEM;
- }
- entries =
- wlan_cfg_get_dma_mon_dest_ring_size(pdev_cfg_ctx);
- if (dp_srng_setup(soc,
- &pdev->rxdma_mon_dst_ring[mac_id],
- RXDMA_MONITOR_DST, 0, mac_for_pdev,
- entries, 0)) {
- QDF_TRACE(QDF_MODULE_ID_DP,
- QDF_TRACE_LEVEL_ERROR,
- FL(RNG_ERR "rxdma_mon_dst_ring"));
- return QDF_STATUS_E_NOMEM;
- }
- entries =
- wlan_cfg_get_dma_mon_stat_ring_size(pdev_cfg_ctx);
- if (dp_srng_setup(soc,
- &pdev->rxdma_mon_status_ring[mac_id],
- RXDMA_MONITOR_STATUS, 0, mac_for_pdev,
- entries, 0)) {
- QDF_TRACE(QDF_MODULE_ID_DP,
- QDF_TRACE_LEVEL_ERROR,
- FL(RNG_ERR "rxdma_mon_status_ring"));
- return QDF_STATUS_E_NOMEM;
- }
- entries =
- wlan_cfg_get_dma_mon_desc_ring_size(pdev_cfg_ctx);
- if (dp_srng_setup(soc,
- &pdev->rxdma_mon_desc_ring[mac_id],
- RXDMA_MONITOR_DESC, 0, mac_for_pdev,
- entries, 0)) {
- QDF_TRACE(QDF_MODULE_ID_DP,
- QDF_TRACE_LEVEL_ERROR,
- FL(RNG_ERR "rxdma_mon_desc_ring"));
- return QDF_STATUS_E_NOMEM;
- }
- } else {
- entries =
- wlan_cfg_get_dma_mon_stat_ring_size(pdev_cfg_ctx);
- if (dp_srng_setup(soc,
- &pdev->rxdma_mon_status_ring[mac_id],
- RXDMA_MONITOR_STATUS, 0, mac_for_pdev,
- entries, 0)) {
- QDF_TRACE(QDF_MODULE_ID_DP,
- QDF_TRACE_LEVEL_ERROR,
- FL(RNG_ERR "rxdma_mon_status_ring"));
- return QDF_STATUS_E_NOMEM;
- }
- }
- }
- return QDF_STATUS_SUCCESS;
- }
- #else
- static
- QDF_STATUS dp_mon_rings_setup(struct dp_soc *soc, struct dp_pdev *pdev)
- {
- return QDF_STATUS_SUCCESS;
- }
- #endif
- #ifdef ATH_SUPPORT_EXT_STAT
- void dp_iterate_update_peer_list(void *pdev_hdl)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)pdev_hdl;
- struct dp_soc *soc = pdev->soc;
- struct dp_vdev *vdev = NULL;
- struct dp_peer *peer = NULL;
- qdf_spin_lock_bh(&soc->peer_ref_mutex);
- qdf_spin_lock_bh(&pdev->vdev_list_lock);
- DP_PDEV_ITERATE_VDEV_LIST(pdev, vdev) {
- DP_VDEV_ITERATE_PEER_LIST(vdev, peer) {
- dp_cal_client_update_peer_stats(&peer->stats);
- }
- }
- qdf_spin_unlock_bh(&pdev->vdev_list_lock);
- qdf_spin_unlock_bh(&soc->peer_ref_mutex);
- }
- #else
- void dp_iterate_update_peer_list(void *pdev_hdl)
- {
- }
- #endif
- static QDF_STATUS dp_htt_ppdu_stats_attach(struct dp_pdev *pdev)
- {
- pdev->ppdu_tlv_buf = qdf_mem_malloc(HTT_T2H_MAX_MSG_SIZE);
- if (!pdev->ppdu_tlv_buf) {
- QDF_TRACE_ERROR(QDF_MODULE_ID_DP, "ppdu_tlv_buf alloc fail");
- return QDF_STATUS_E_NOMEM;
- }
- return QDF_STATUS_SUCCESS;
- }
- static struct cdp_pdev *dp_pdev_attach_wifi3(struct cdp_soc_t *txrx_soc,
- struct cdp_ctrl_objmgr_pdev *ctrl_pdev,
- HTC_HANDLE htc_handle, qdf_device_t qdf_osdev, uint8_t pdev_id)
- {
- int ring_size;
- int entries;
- struct wlan_cfg_dp_soc_ctxt *soc_cfg_ctx;
- int nss_cfg;
- void *sojourn_buf;
- struct dp_soc *soc = (struct dp_soc *)txrx_soc;
- struct dp_pdev *pdev = NULL;
- if (dp_is_soc_reinit(soc)) {
- pdev = soc->pdev_list[pdev_id];
- } else {
- pdev = qdf_mem_malloc(sizeof(*pdev));
- qdf_minidump_log(pdev, sizeof(*pdev), "dp_pdev");
- }
- if (!pdev) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- FL("DP PDEV memory allocation failed"));
- goto fail0;
- }
-
- pdev->pdev_deinit = 0;
- pdev->invalid_peer = qdf_mem_malloc(sizeof(struct dp_peer));
- if (!pdev->invalid_peer) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- FL("Invalid peer memory allocation failed"));
- qdf_mem_free(pdev);
- goto fail0;
- }
- soc_cfg_ctx = soc->wlan_cfg_ctx;
- pdev->wlan_cfg_ctx = wlan_cfg_pdev_attach(soc->ctrl_psoc);
- if (!pdev->wlan_cfg_ctx) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- FL("pdev cfg_attach failed"));
- qdf_mem_free(pdev->invalid_peer);
- qdf_mem_free(pdev);
- goto fail0;
- }
-
- nss_cfg = wlan_cfg_get_dp_soc_nss_cfg(soc_cfg_ctx);
- wlan_cfg_set_dp_pdev_nss_enabled(pdev->wlan_cfg_ctx,
- (nss_cfg & (1 << pdev_id)));
- pdev->soc = soc;
- pdev->ctrl_pdev = ctrl_pdev;
- pdev->pdev_id = pdev_id;
- soc->pdev_list[pdev_id] = pdev;
- pdev->lmac_id = wlan_cfg_get_hw_mac_idx(soc->wlan_cfg_ctx, pdev_id);
- soc->pdev_count++;
- TAILQ_INIT(&pdev->vdev_list);
- qdf_spinlock_create(&pdev->vdev_list_lock);
- pdev->vdev_count = 0;
- qdf_spinlock_create(&pdev->tx_mutex);
- qdf_spinlock_create(&pdev->neighbour_peer_mutex);
- TAILQ_INIT(&pdev->neighbour_peers_list);
- pdev->neighbour_peers_added = false;
- pdev->monitor_configured = false;
- if (dp_soc_cmn_setup(soc)) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- FL("dp_soc_cmn_setup failed"));
- goto fail1;
- }
-
- if (wlan_cfg_per_pdev_tx_ring(soc->wlan_cfg_ctx)) {
- ring_size =
- wlan_cfg_tx_ring_size(soc_cfg_ctx);
- if (dp_srng_setup(soc, &soc->tcl_data_ring[pdev_id], TCL_DATA,
- pdev_id, pdev_id, ring_size, 0)) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- FL("dp_srng_setup failed for tcl_data_ring"));
- goto fail1;
- }
- ring_size =
- wlan_cfg_tx_comp_ring_size(soc_cfg_ctx);
- if (dp_srng_setup(soc, &soc->tx_comp_ring[pdev_id],
- WBM2SW_RELEASE, pdev_id, pdev_id,
- ring_size, 0)) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- FL("dp_srng_setup failed for tx_comp_ring"));
- goto fail1;
- }
- soc->num_tcl_data_rings++;
- }
-
- if (dp_tx_pdev_attach(pdev)) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- FL("dp_tx_pdev_attach failed"));
- goto fail1;
- }
- ring_size = wlan_cfg_get_reo_dst_ring_size(soc->wlan_cfg_ctx);
-
- if (wlan_cfg_per_pdev_rx_ring(soc_cfg_ctx)) {
- if (dp_srng_setup(soc, &soc->reo_dest_ring[pdev_id], REO_DST,
- pdev_id, pdev_id, ring_size, 0)) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- FL("dp_srng_setup failed for reo_dest_ringn"));
- goto fail1;
- }
- soc->num_reo_dest_rings++;
- }
- ring_size =
- wlan_cfg_get_dp_soc_rxdma_refill_ring_size(soc->wlan_cfg_ctx);
- if (dp_srng_setup(soc, &pdev->rx_refill_buf_ring, RXDMA_BUF, 0, pdev_id,
- ring_size, 0)) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- FL("dp_srng_setup failed rx refill ring"));
- goto fail1;
- }
- if (dp_rxdma_ring_setup(soc, pdev)) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- FL("RXDMA ring config failed"));
- goto fail1;
- }
- if (dp_mon_rings_setup(soc, pdev)) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- FL("MONITOR rings setup failed"));
- goto fail1;
- }
- entries = wlan_cfg_get_dp_soc_rxdma_err_dst_ring_size(soc_cfg_ctx);
- if (wlan_cfg_per_pdev_lmac_ring(soc->wlan_cfg_ctx)) {
- if (dp_srng_setup(soc, &pdev->rxdma_err_dst_ring[0], RXDMA_DST,
- 0, pdev_id, entries, 0)) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- FL(RNG_ERR "rxdma_err_dst_ring"));
- goto fail1;
- }
- }
- if (dp_setup_ipa_rx_refill_buf_ring(soc, pdev))
- goto fail1;
- if (dp_ipa_ring_resource_setup(soc, pdev))
- goto fail1;
- if (dp_ipa_uc_attach(soc, pdev) != QDF_STATUS_SUCCESS) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- FL("dp_ipa_uc_attach failed"));
- goto fail1;
- }
-
- if (dp_rx_pdev_attach(pdev)) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- FL("dp_rx_pdev_attach failed"));
- goto fail2;
- }
- DP_STATS_INIT(pdev);
-
- pdev->mon_filter_mode = MON_FILTER_ALL;
- pdev->fp_mgmt_filter = FILTER_MGMT_ALL;
- pdev->fp_ctrl_filter = FILTER_CTRL_ALL;
- pdev->fp_data_filter = FILTER_DATA_ALL;
- pdev->mo_mgmt_filter = FILTER_MGMT_ALL;
- pdev->mo_ctrl_filter = FILTER_CTRL_ALL;
- pdev->mo_data_filter = FILTER_DATA_ALL;
- dp_local_peer_id_pool_init(pdev);
- dp_dscp_tid_map_setup(pdev);
- dp_pcp_tid_map_setup(pdev);
-
- if (dp_rx_pdev_mon_attach(pdev)) {
- QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
- "dp_rx_pdev_mon_attach failed");
- goto fail2;
- }
- if (dp_wdi_event_attach(pdev)) {
- QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
- "dp_wdi_evet_attach failed");
- goto wdi_attach_fail;
- }
-
- pdev->reo_dest = pdev->pdev_id + 1;
-
- TAILQ_INIT(&pdev->ppdu_info_list);
- pdev->tlv_count = 0;
- pdev->list_depth = 0;
- qdf_mem_zero(&pdev->sojourn_stats, sizeof(struct cdp_tx_sojourn_stats));
- pdev->sojourn_buf = qdf_nbuf_alloc(pdev->soc->osdev,
- sizeof(struct cdp_tx_sojourn_stats), 0, 4,
- TRUE);
- if (pdev->sojourn_buf) {
- sojourn_buf = qdf_nbuf_data(pdev->sojourn_buf);
- qdf_mem_zero(sojourn_buf, sizeof(struct cdp_tx_sojourn_stats));
- }
-
- dp_cal_client_attach(&pdev->cal_client_ctx, pdev, pdev->soc->osdev,
- &dp_iterate_update_peer_list);
- qdf_event_create(&pdev->fw_peer_stats_event);
- pdev->num_tx_allowed = wlan_cfg_get_num_tx_desc(soc->wlan_cfg_ctx);
- if (dp_htt_ppdu_stats_attach(pdev) != QDF_STATUS_SUCCESS)
- goto fail1;
- dp_tx_ppdu_stats_attach(pdev);
- return (struct cdp_pdev *)pdev;
- wdi_attach_fail:
-
- dp_rx_pdev_mon_detach(pdev);
- fail2:
- dp_rx_pdev_detach(pdev);
- fail1:
- if (pdev->invalid_peer)
- qdf_mem_free(pdev->invalid_peer);
- dp_pdev_detach((struct cdp_pdev *)pdev, 0);
- fail0:
- return NULL;
- }
- #ifdef QCA_HOST2FW_RXBUF_RING
- static void dp_rxdma_ring_cleanup(struct dp_soc *soc,
- struct dp_pdev *pdev)
- {
- int i;
- for (i = 0; i < MAX_RX_MAC_RINGS; i++)
- dp_srng_cleanup(soc, &pdev->rx_mac_buf_ring[i],
- RXDMA_BUF, 1);
- qdf_timer_free(&soc->mon_reap_timer);
- }
- #else
- static void dp_rxdma_ring_cleanup(struct dp_soc *soc,
- struct dp_pdev *pdev)
- {
- }
- #endif
- static void dp_neighbour_peers_detach(struct dp_pdev *pdev)
- {
- struct dp_neighbour_peer *peer = NULL;
- struct dp_neighbour_peer *temp_peer = NULL;
- TAILQ_FOREACH_SAFE(peer, &pdev->neighbour_peers_list,
- neighbour_peer_list_elem, temp_peer) {
-
- TAILQ_REMOVE(&pdev->neighbour_peers_list,
- peer, neighbour_peer_list_elem);
- qdf_mem_free(peer);
- }
- qdf_spinlock_destroy(&pdev->neighbour_peer_mutex);
- }
- static void dp_htt_ppdu_stats_detach(struct dp_pdev *pdev)
- {
- struct ppdu_info *ppdu_info, *ppdu_info_next;
- TAILQ_FOREACH_SAFE(ppdu_info, &pdev->ppdu_info_list,
- ppdu_info_list_elem, ppdu_info_next) {
- if (!ppdu_info)
- break;
- qdf_assert_always(ppdu_info->nbuf);
- qdf_nbuf_free(ppdu_info->nbuf);
- qdf_mem_free(ppdu_info);
- }
- if (pdev->ppdu_tlv_buf)
- qdf_mem_free(pdev->ppdu_tlv_buf);
- }
- #if !defined(DISABLE_MON_CONFIG)
- static
- void dp_mon_ring_cleanup(struct dp_soc *soc, struct dp_pdev *pdev,
- int mac_id)
- {
- if (soc->wlan_cfg_ctx->rxdma1_enable) {
- dp_srng_cleanup(soc,
- &pdev->rxdma_mon_buf_ring[mac_id],
- RXDMA_MONITOR_BUF, 0);
- dp_srng_cleanup(soc,
- &pdev->rxdma_mon_dst_ring[mac_id],
- RXDMA_MONITOR_DST, 0);
- dp_srng_cleanup(soc,
- &pdev->rxdma_mon_status_ring[mac_id],
- RXDMA_MONITOR_STATUS, 0);
- dp_srng_cleanup(soc,
- &pdev->rxdma_mon_desc_ring[mac_id],
- RXDMA_MONITOR_DESC, 0);
- dp_srng_cleanup(soc,
- &pdev->rxdma_err_dst_ring[mac_id],
- RXDMA_DST, 0);
- } else {
- dp_srng_cleanup(soc,
- &pdev->rxdma_mon_status_ring[mac_id],
- RXDMA_MONITOR_STATUS, 0);
- dp_srng_cleanup(soc,
- &pdev->rxdma_err_dst_ring[mac_id],
- RXDMA_DST, 0);
- }
- }
- #else
- static void dp_mon_ring_cleanup(struct dp_soc *soc, struct dp_pdev *pdev,
- int mac_id)
- {
- }
- #endif
- static void dp_mon_ring_deinit(struct dp_soc *soc, struct dp_pdev *pdev,
- int mac_id)
- {
- }
- static void dp_pdev_mem_reset(struct dp_pdev *pdev)
- {
- uint16_t len = 0;
- uint8_t *dp_pdev_offset = (uint8_t *)pdev;
- len = sizeof(struct dp_pdev) -
- offsetof(struct dp_pdev, pdev_deinit) -
- sizeof(pdev->pdev_deinit);
- dp_pdev_offset = dp_pdev_offset +
- offsetof(struct dp_pdev, pdev_deinit) +
- sizeof(pdev->pdev_deinit);
- qdf_mem_zero(dp_pdev_offset, len);
- }
- static void dp_pdev_deinit(struct cdp_pdev *txrx_pdev, int force)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)txrx_pdev;
- struct dp_soc *soc = pdev->soc;
- qdf_nbuf_t curr_nbuf, next_nbuf;
- int mac_id;
-
- if (pdev->pdev_deinit)
- return;
- pdev->pdev_deinit = 1;
- dp_wdi_event_detach(pdev);
- dp_tx_pdev_detach(pdev);
- if (wlan_cfg_per_pdev_tx_ring(soc->wlan_cfg_ctx)) {
- dp_srng_deinit(soc, &soc->tcl_data_ring[pdev->pdev_id],
- TCL_DATA, pdev->pdev_id);
- dp_srng_deinit(soc, &soc->tx_comp_ring[pdev->pdev_id],
- WBM2SW_RELEASE, pdev->pdev_id);
- }
- dp_pktlogmod_exit(pdev);
- dp_rx_pdev_detach(pdev);
- dp_rx_pdev_mon_detach(pdev);
- dp_neighbour_peers_detach(pdev);
- qdf_spinlock_destroy(&pdev->tx_mutex);
- qdf_spinlock_destroy(&pdev->vdev_list_lock);
- dp_ipa_uc_detach(soc, pdev);
- dp_cleanup_ipa_rx_refill_buf_ring(soc, pdev);
-
- if (wlan_cfg_per_pdev_rx_ring(soc->wlan_cfg_ctx)) {
- dp_srng_deinit(soc, &soc->reo_dest_ring[pdev->pdev_id],
- REO_DST, pdev->pdev_id);
- }
- dp_srng_deinit(soc, &pdev->rx_refill_buf_ring, RXDMA_BUF, 0);
- dp_rxdma_ring_cleanup(soc, pdev);
- for (mac_id = 0; mac_id < NUM_RXDMA_RINGS_PER_PDEV; mac_id++) {
- dp_mon_ring_deinit(soc, pdev, mac_id);
- dp_srng_deinit(soc, &pdev->rxdma_err_dst_ring[mac_id],
- RXDMA_DST, 0);
- }
- curr_nbuf = pdev->invalid_peer_head_msdu;
- while (curr_nbuf) {
- next_nbuf = qdf_nbuf_next(curr_nbuf);
- qdf_nbuf_free(curr_nbuf);
- curr_nbuf = next_nbuf;
- }
- pdev->invalid_peer_head_msdu = NULL;
- pdev->invalid_peer_tail_msdu = NULL;
- dp_htt_ppdu_stats_detach(pdev);
- dp_tx_ppdu_stats_detach(pdev);
- qdf_nbuf_free(pdev->sojourn_buf);
- dp_cal_client_detach(&pdev->cal_client_ctx);
- soc->pdev_count--;
-
- if (!(soc->pdev_count))
- dp_soc_cmn_cleanup(soc);
- wlan_cfg_pdev_detach(pdev->wlan_cfg_ctx);
- if (pdev->invalid_peer)
- qdf_mem_free(pdev->invalid_peer);
- qdf_mem_free(pdev->dp_txrx_handle);
- dp_pdev_mem_reset(pdev);
- }
- static void dp_pdev_deinit_wifi3(struct cdp_pdev *txrx_pdev, int force)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)txrx_pdev;
- struct dp_soc *soc = pdev->soc;
- soc->dp_soc_reinit = TRUE;
- dp_pdev_deinit(txrx_pdev, force);
- }
- static void dp_pdev_detach(struct cdp_pdev *txrx_pdev, int force)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)txrx_pdev;
- struct dp_soc *soc = pdev->soc;
- struct rx_desc_pool *rx_desc_pool;
- int mac_id, mac_for_pdev;
- if (wlan_cfg_per_pdev_tx_ring(soc->wlan_cfg_ctx)) {
- dp_srng_cleanup(soc, &soc->tcl_data_ring[pdev->pdev_id],
- TCL_DATA, pdev->pdev_id);
- dp_srng_cleanup(soc, &soc->tx_comp_ring[pdev->pdev_id],
- WBM2SW_RELEASE, pdev->pdev_id);
- }
- dp_mon_link_free(pdev);
-
- if (wlan_cfg_per_pdev_rx_ring(soc->wlan_cfg_ctx)) {
- dp_srng_cleanup(soc, &soc->reo_dest_ring[pdev->pdev_id],
- REO_DST, pdev->pdev_id);
- }
- dp_rxdma_ring_cleanup(soc, pdev);
- wlan_cfg_pdev_detach(pdev->wlan_cfg_ctx);
- dp_srng_cleanup(soc, &pdev->rx_refill_buf_ring, RXDMA_BUF, 0);
- dp_cleanup_ipa_rx_refill_buf_ring(soc, pdev);
- for (mac_id = 0; mac_id < NUM_RXDMA_RINGS_PER_PDEV; mac_id++) {
- dp_mon_ring_cleanup(soc, pdev, mac_id);
- dp_srng_cleanup(soc, &pdev->rxdma_err_dst_ring[mac_id],
- RXDMA_DST, 0);
- if (dp_is_soc_reinit(soc)) {
- mac_for_pdev = dp_get_mac_id_for_pdev(mac_id,
- pdev->pdev_id);
- rx_desc_pool = &soc->rx_desc_status[mac_for_pdev];
- dp_rx_desc_pool_free(soc, rx_desc_pool);
- rx_desc_pool = &soc->rx_desc_mon[mac_for_pdev];
- dp_rx_desc_pool_free(soc, rx_desc_pool);
- }
- }
- if (dp_is_soc_reinit(soc)) {
- rx_desc_pool = &soc->rx_desc_buf[pdev->pdev_id];
- dp_rx_desc_pool_free(soc, rx_desc_pool);
- }
- soc->pdev_list[pdev->pdev_id] = NULL;
- qdf_minidump_remove(pdev);
- qdf_mem_free(pdev);
- }
- static void dp_pdev_detach_wifi3(struct cdp_pdev *txrx_pdev, int force)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)txrx_pdev;
- struct dp_soc *soc = pdev->soc;
- if (dp_is_soc_reinit(soc)) {
- dp_pdev_detach(txrx_pdev, force);
- } else {
- dp_pdev_deinit(txrx_pdev, force);
- dp_pdev_detach(txrx_pdev, force);
- }
- }
- static inline void dp_reo_desc_freelist_destroy(struct dp_soc *soc)
- {
- struct reo_desc_list_node *desc;
- struct dp_rx_tid *rx_tid;
- qdf_spin_lock_bh(&soc->reo_desc_freelist_lock);
- while (qdf_list_remove_front(&soc->reo_desc_freelist,
- (qdf_list_node_t **)&desc) == QDF_STATUS_SUCCESS) {
- rx_tid = &desc->rx_tid;
- qdf_mem_unmap_nbytes_single(soc->osdev,
- rx_tid->hw_qdesc_paddr,
- QDF_DMA_BIDIRECTIONAL,
- rx_tid->hw_qdesc_alloc_size);
- qdf_mem_free(rx_tid->hw_qdesc_vaddr_unaligned);
- qdf_mem_free(desc);
- }
- qdf_spin_unlock_bh(&soc->reo_desc_freelist_lock);
- qdf_list_destroy(&soc->reo_desc_freelist);
- qdf_spinlock_destroy(&soc->reo_desc_freelist_lock);
- }
- static void dp_soc_mem_reset(struct dp_soc *soc)
- {
- uint16_t len = 0;
- uint8_t *dp_soc_offset = (uint8_t *)soc;
- len = sizeof(struct dp_soc) -
- offsetof(struct dp_soc, dp_soc_reinit) -
- sizeof(soc->dp_soc_reinit);
- dp_soc_offset = dp_soc_offset +
- offsetof(struct dp_soc, dp_soc_reinit) +
- sizeof(soc->dp_soc_reinit);
- qdf_mem_zero(dp_soc_offset, len);
- }
- static void dp_soc_deinit(void *txrx_soc)
- {
- struct dp_soc *soc = (struct dp_soc *)txrx_soc;
- int i;
- qdf_atomic_set(&soc->cmn_init_done, 0);
- for (i = 0; i < MAX_PDEV_CNT; i++) {
- if (soc->pdev_list[i])
- dp_pdev_deinit((struct cdp_pdev *)
- soc->pdev_list[i], 1);
- }
- qdf_flush_work(&soc->htt_stats.work);
- qdf_disable_work(&soc->htt_stats.work);
-
- qdf_nbuf_queue_free(&soc->htt_stats.msg);
- dp_peer_find_detach(soc);
-
-
- dp_srng_deinit(soc, &soc->wbm_desc_rel_ring, SW2WBM_RELEASE, 0);
-
- if (!wlan_cfg_per_pdev_tx_ring(soc->wlan_cfg_ctx)) {
- for (i = 0; i < soc->num_tcl_data_rings; i++) {
- dp_srng_deinit(soc, &soc->tcl_data_ring[i],
- TCL_DATA, i);
- dp_srng_deinit(soc, &soc->tx_comp_ring[i],
- WBM2SW_RELEASE, i);
- }
- }
-
- dp_srng_deinit(soc, &soc->tcl_cmd_ring, TCL_CMD, 0);
- dp_srng_deinit(soc, &soc->tcl_status_ring, TCL_STATUS, 0);
-
- if (!wlan_cfg_per_pdev_rx_ring(soc->wlan_cfg_ctx)) {
- soc->num_reo_dest_rings =
- wlan_cfg_num_reo_dest_rings(soc->wlan_cfg_ctx);
- for (i = 0; i < soc->num_reo_dest_rings; i++) {
-
- dp_srng_deinit(soc, &soc->reo_dest_ring[i],
- REO_DST, i);
- }
- }
-
- dp_srng_deinit(soc, &soc->reo_reinject_ring, REO_REINJECT, 0);
-
- dp_srng_deinit(soc, &soc->rx_rel_ring, WBM2SW_RELEASE, 0);
-
-
- dp_srng_deinit(soc, &soc->reo_exception_ring, REO_EXCEPTION, 0);
-
- dp_srng_deinit(soc, &soc->reo_cmd_ring, REO_CMD, 0);
- dp_srng_deinit(soc, &soc->reo_status_ring, REO_STATUS, 0);
- dp_soc_wds_detach(soc);
- qdf_spinlock_destroy(&soc->peer_ref_mutex);
- qdf_spinlock_destroy(&soc->htt_stats.lock);
- htt_soc_htc_dealloc(soc->htt_handle);
- dp_reo_desc_freelist_destroy(soc);
- qdf_spinlock_destroy(&soc->ast_lock);
- dp_soc_mem_reset(soc);
- }
- static void dp_soc_deinit_wifi3(void *txrx_soc)
- {
- struct dp_soc *soc = (struct dp_soc *)txrx_soc;
- soc->dp_soc_reinit = 1;
- dp_soc_deinit(txrx_soc);
- }
- static void dp_soc_detach(void *txrx_soc)
- {
- struct dp_soc *soc = (struct dp_soc *)txrx_soc;
- int i;
- qdf_atomic_set(&soc->cmn_init_done, 0);
-
- for (i = 0; i < MAX_PDEV_CNT; i++) {
- if (soc->pdev_list[i])
- dp_pdev_detach((struct cdp_pdev *)
- soc->pdev_list[i], 1);
- }
-
-
- qdf_minidump_remove(soc->wbm_desc_rel_ring.base_vaddr_unaligned);
- dp_srng_cleanup(soc, &soc->wbm_desc_rel_ring, SW2WBM_RELEASE, 0);
- dp_tx_soc_detach(soc);
-
- if (!wlan_cfg_per_pdev_tx_ring(soc->wlan_cfg_ctx)) {
- for (i = 0; i < soc->num_tcl_data_rings; i++) {
- dp_srng_cleanup(soc, &soc->tcl_data_ring[i],
- TCL_DATA, i);
- dp_srng_cleanup(soc, &soc->tx_comp_ring[i],
- WBM2SW_RELEASE, i);
- }
- }
-
- dp_srng_cleanup(soc, &soc->tcl_cmd_ring, TCL_CMD, 0);
- dp_srng_cleanup(soc, &soc->tcl_status_ring, TCL_STATUS, 0);
-
- if (!wlan_cfg_per_pdev_rx_ring(soc->wlan_cfg_ctx)) {
- soc->num_reo_dest_rings =
- wlan_cfg_num_reo_dest_rings(soc->wlan_cfg_ctx);
- for (i = 0; i < soc->num_reo_dest_rings; i++) {
-
- dp_srng_cleanup(soc, &soc->reo_dest_ring[i],
- REO_DST, i);
- }
- }
-
- dp_srng_cleanup(soc, &soc->reo_reinject_ring, REO_REINJECT, 0);
-
- dp_srng_cleanup(soc, &soc->rx_rel_ring, WBM2SW_RELEASE, 0);
- dp_srng_cleanup(soc, &soc->rx_rel_ring, WBM2SW_RELEASE, 3);
-
-
- dp_srng_cleanup(soc, &soc->reo_exception_ring, REO_EXCEPTION, 0);
-
- dp_srng_cleanup(soc, &soc->reo_cmd_ring, REO_CMD, 0);
- dp_srng_cleanup(soc, &soc->reo_status_ring, REO_STATUS, 0);
- dp_hw_link_desc_pool_cleanup(soc);
- htt_soc_detach(soc->htt_handle);
- soc->dp_soc_reinit = 0;
- wlan_cfg_soc_detach(soc->wlan_cfg_ctx);
- qdf_minidump_remove(soc);
- qdf_mem_free(soc);
- }
- static void dp_soc_detach_wifi3(void *txrx_soc)
- {
- struct dp_soc *soc = (struct dp_soc *)txrx_soc;
- if (dp_is_soc_reinit(soc)) {
- dp_soc_detach(txrx_soc);
- } else {
- dp_soc_deinit(txrx_soc);
- dp_soc_detach(txrx_soc);
- }
- }
- #if !defined(DISABLE_MON_CONFIG)
- static QDF_STATUS dp_mon_htt_srng_setup(struct dp_soc *soc,
- struct dp_pdev *pdev,
- int mac_id,
- int mac_for_pdev)
- {
- QDF_STATUS status = QDF_STATUS_SUCCESS;
- if (soc->wlan_cfg_ctx->rxdma1_enable) {
- status = htt_srng_setup(soc->htt_handle, mac_for_pdev,
- pdev->rxdma_mon_buf_ring[mac_id]
- .hal_srng,
- RXDMA_MONITOR_BUF);
- if (status != QDF_STATUS_SUCCESS) {
- dp_err("Failed to send htt srng setup message for Rxdma mon buf ring");
- return status;
- }
- status = htt_srng_setup(soc->htt_handle, mac_for_pdev,
- pdev->rxdma_mon_dst_ring[mac_id]
- .hal_srng,
- RXDMA_MONITOR_DST);
- if (status != QDF_STATUS_SUCCESS) {
- dp_err("Failed to send htt srng setup message for Rxdma mon dst ring");
- return status;
- }
- status = htt_srng_setup(soc->htt_handle, mac_for_pdev,
- pdev->rxdma_mon_status_ring[mac_id]
- .hal_srng,
- RXDMA_MONITOR_STATUS);
- if (status != QDF_STATUS_SUCCESS) {
- dp_err("Failed to send htt srng setup message for Rxdma mon status ring");
- return status;
- }
- status = htt_srng_setup(soc->htt_handle, mac_for_pdev,
- pdev->rxdma_mon_desc_ring[mac_id]
- .hal_srng,
- RXDMA_MONITOR_DESC);
- if (status != QDF_STATUS_SUCCESS) {
- dp_err("Failed to send htt srng message for Rxdma mon desc ring");
- return status;
- }
- } else {
- status = htt_srng_setup(soc->htt_handle, mac_for_pdev,
- pdev->rxdma_mon_status_ring[mac_id]
- .hal_srng,
- RXDMA_MONITOR_STATUS);
- if (status != QDF_STATUS_SUCCESS) {
- dp_err("Failed to send htt srng setup message for Rxdma mon status ring");
- return status;
- }
- }
- return status;
- }
- #else
- static QDF_STATUS dp_mon_htt_srng_setup(struct dp_soc *soc,
- struct dp_pdev *pdev,
- int mac_id,
- int mac_for_pdev)
- {
- return QDF_STATUS_SUCCESS;
- }
- #endif
- #ifdef QCA_HOST2FW_RXBUF_RING
- static QDF_STATUS dp_rxdma_ring_config(struct dp_soc *soc)
- {
- int i;
- QDF_STATUS status = QDF_STATUS_SUCCESS;
- for (i = 0; i < MAX_PDEV_CNT; i++) {
- struct dp_pdev *pdev = soc->pdev_list[i];
- if (pdev) {
- int mac_id;
- bool dbs_enable = 0;
- int max_mac_rings =
- wlan_cfg_get_num_mac_rings
- (pdev->wlan_cfg_ctx);
- htt_srng_setup(soc->htt_handle, 0,
- pdev->rx_refill_buf_ring.hal_srng,
- RXDMA_BUF);
- if (pdev->rx_refill_buf_ring2.hal_srng)
- htt_srng_setup(soc->htt_handle, 0,
- pdev->rx_refill_buf_ring2.hal_srng,
- RXDMA_BUF);
- if (soc->cdp_soc.ol_ops->
- is_hw_dbs_2x2_capable) {
- dbs_enable = soc->cdp_soc.ol_ops->
- is_hw_dbs_2x2_capable(
- (void *)soc->ctrl_psoc);
- }
- if (dbs_enable) {
- QDF_TRACE(QDF_MODULE_ID_TXRX,
- QDF_TRACE_LEVEL_ERROR,
- FL("DBS enabled max_mac_rings %d"),
- max_mac_rings);
- } else {
- max_mac_rings = 1;
- QDF_TRACE(QDF_MODULE_ID_TXRX,
- QDF_TRACE_LEVEL_ERROR,
- FL("DBS disabled, max_mac_rings %d"),
- max_mac_rings);
- }
- QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
- FL("pdev_id %d max_mac_rings %d"),
- pdev->pdev_id, max_mac_rings);
- for (mac_id = 0; mac_id < max_mac_rings; mac_id++) {
- int mac_for_pdev = dp_get_mac_id_for_pdev(
- mac_id, pdev->pdev_id);
- QDF_TRACE(QDF_MODULE_ID_TXRX,
- QDF_TRACE_LEVEL_ERROR,
- FL("mac_id %d"), mac_for_pdev);
- htt_srng_setup(soc->htt_handle, mac_for_pdev,
- pdev->rx_mac_buf_ring[mac_id]
- .hal_srng,
- RXDMA_BUF);
- htt_srng_setup(soc->htt_handle, mac_for_pdev,
- pdev->rxdma_err_dst_ring[mac_id]
- .hal_srng,
- RXDMA_DST);
-
- status = dp_mon_htt_srng_setup(soc, pdev,
- mac_id,
- mac_for_pdev);
- if (status != QDF_STATUS_SUCCESS) {
- dp_err("Failed to send htt monitor messages to target");
- return status;
- }
- }
- }
- }
-
- qdf_timer_init(soc->osdev, &soc->mon_reap_timer,
- dp_service_mon_rings, (void *)soc,
- QDF_TIMER_TYPE_WAKE_APPS);
- soc->reap_timer_init = 1;
- return status;
- }
- #else
- static QDF_STATUS dp_rxdma_ring_config(struct dp_soc *soc)
- {
- int i;
- int mac_id;
- QDF_STATUS status = QDF_STATUS_SUCCESS;
- for (i = 0; i < MAX_PDEV_CNT; i++) {
- struct dp_pdev *pdev = soc->pdev_list[i];
- if (!pdev)
- continue;
- for (mac_id = 0; mac_id < NUM_RXDMA_RINGS_PER_PDEV; mac_id++) {
- int mac_for_pdev = dp_get_mac_id_for_pdev(mac_id, i);
- htt_srng_setup(soc->htt_handle, mac_for_pdev,
- pdev->rx_refill_buf_ring.hal_srng, RXDMA_BUF);
- #ifndef DISABLE_MON_CONFIG
- htt_srng_setup(soc->htt_handle, mac_for_pdev,
- pdev->rxdma_mon_buf_ring[mac_id].hal_srng,
- RXDMA_MONITOR_BUF);
- htt_srng_setup(soc->htt_handle, mac_for_pdev,
- pdev->rxdma_mon_dst_ring[mac_id].hal_srng,
- RXDMA_MONITOR_DST);
- htt_srng_setup(soc->htt_handle, mac_for_pdev,
- pdev->rxdma_mon_status_ring[mac_id].hal_srng,
- RXDMA_MONITOR_STATUS);
- htt_srng_setup(soc->htt_handle, mac_for_pdev,
- pdev->rxdma_mon_desc_ring[mac_id].hal_srng,
- RXDMA_MONITOR_DESC);
- #endif
- htt_srng_setup(soc->htt_handle, mac_for_pdev,
- pdev->rxdma_err_dst_ring[mac_id].hal_srng,
- RXDMA_DST);
- }
- }
- return status;
- }
- #endif
- #ifdef NO_RX_PKT_HDR_TLV
- static QDF_STATUS
- dp_rxdma_ring_sel_cfg(struct dp_soc *soc)
- {
- int i;
- int mac_id;
- struct htt_rx_ring_tlv_filter htt_tlv_filter = {0};
- QDF_STATUS status = QDF_STATUS_SUCCESS;
- htt_tlv_filter.mpdu_start = 1;
- htt_tlv_filter.msdu_start = 1;
- htt_tlv_filter.mpdu_end = 1;
- htt_tlv_filter.msdu_end = 1;
- htt_tlv_filter.attention = 1;
- htt_tlv_filter.packet = 1;
- htt_tlv_filter.packet_header = 0;
- htt_tlv_filter.ppdu_start = 0;
- htt_tlv_filter.ppdu_end = 0;
- htt_tlv_filter.ppdu_end_user_stats = 0;
- htt_tlv_filter.ppdu_end_user_stats_ext = 0;
- htt_tlv_filter.ppdu_end_status_done = 0;
- htt_tlv_filter.enable_fp = 1;
- htt_tlv_filter.enable_md = 0;
- htt_tlv_filter.enable_md = 0;
- htt_tlv_filter.enable_mo = 0;
- htt_tlv_filter.fp_mgmt_filter = 0;
- htt_tlv_filter.fp_ctrl_filter = FILTER_CTRL_BA_REQ;
- htt_tlv_filter.fp_data_filter = (FILTER_DATA_UCAST |
- FILTER_DATA_MCAST |
- FILTER_DATA_DATA);
- htt_tlv_filter.mo_mgmt_filter = 0;
- htt_tlv_filter.mo_ctrl_filter = 0;
- htt_tlv_filter.mo_data_filter = 0;
- htt_tlv_filter.md_data_filter = 0;
- htt_tlv_filter.offset_valid = true;
- htt_tlv_filter.rx_packet_offset = RX_PKT_TLVS_LEN;
-
- htt_tlv_filter.rx_header_offset = 0;
- htt_tlv_filter.rx_mpdu_start_offset =
- HAL_RX_PKT_TLV_MPDU_START_OFFSET(soc->hal_soc);
- htt_tlv_filter.rx_mpdu_end_offset =
- HAL_RX_PKT_TLV_MPDU_END_OFFSET(soc->hal_soc);
- htt_tlv_filter.rx_msdu_start_offset =
- HAL_RX_PKT_TLV_MSDU_START_OFFSET(soc->hal_soc);
- htt_tlv_filter.rx_msdu_end_offset =
- HAL_RX_PKT_TLV_MSDU_END_OFFSET(soc->hal_soc);
- htt_tlv_filter.rx_attn_offset =
- HAL_RX_PKT_TLV_ATTN_OFFSET(soc->hal_soc);
- for (i = 0; i < MAX_PDEV_CNT; i++) {
- struct dp_pdev *pdev = soc->pdev_list[i];
- if (!pdev)
- continue;
- for (mac_id = 0; mac_id < NUM_RXDMA_RINGS_PER_PDEV; mac_id++) {
- int mac_for_pdev = dp_get_mac_id_for_pdev(mac_id,
- pdev->pdev_id);
- htt_h2t_rx_ring_cfg(soc->htt_handle, mac_for_pdev,
- pdev->rx_refill_buf_ring.hal_srng,
- RXDMA_BUF, RX_BUFFER_SIZE,
- &htt_tlv_filter);
- }
- }
- return status;
- }
- #else
- static QDF_STATUS
- dp_rxdma_ring_sel_cfg(struct dp_soc *soc)
- {
- return QDF_STATUS_SUCCESS;
- }
- #endif
- static QDF_STATUS
- dp_soc_attach_target_wifi3(struct cdp_soc_t *cdp_soc)
- {
- struct dp_soc *soc = (struct dp_soc *)cdp_soc;
- QDF_STATUS status = QDF_STATUS_SUCCESS;
- htt_soc_attach_target(soc->htt_handle);
- status = dp_rxdma_ring_config(soc);
- if (status != QDF_STATUS_SUCCESS) {
- dp_err("Failed to send htt srng setup messages to target");
- return status;
- }
- status = dp_rxdma_ring_sel_cfg(soc);
- if (status != QDF_STATUS_SUCCESS) {
- dp_err("Failed to send htt ring config message to target");
- return status;
- }
- DP_STATS_INIT(soc);
-
- qdf_create_work(0, &soc->htt_stats.work, htt_t2h_stats_handler, soc);
- qdf_minidump_log(soc, sizeof(*soc), "dp_soc");
- return QDF_STATUS_SUCCESS;
- }
- static int dp_soc_get_nss_cfg_wifi3(struct cdp_soc_t *cdp_soc)
- {
- struct dp_soc *dsoc = (struct dp_soc *)cdp_soc;
- return wlan_cfg_get_dp_soc_nss_cfg(dsoc->wlan_cfg_ctx);
- }
- static void dp_soc_set_nss_cfg_wifi3(struct cdp_soc_t *cdp_soc, int config)
- {
- struct dp_soc *dsoc = (struct dp_soc *)cdp_soc;
- struct wlan_cfg_dp_soc_ctxt *wlan_cfg_ctx = dsoc->wlan_cfg_ctx;
- wlan_cfg_set_dp_soc_nss_cfg(wlan_cfg_ctx, config);
-
- switch (config) {
- case dp_nss_cfg_default:
- break;
- case dp_nss_cfg_dbdc:
- case dp_nss_cfg_dbtc:
- wlan_cfg_set_num_tx_desc_pool(wlan_cfg_ctx, 0);
- wlan_cfg_set_num_tx_ext_desc_pool(wlan_cfg_ctx, 0);
- wlan_cfg_set_num_tx_desc(wlan_cfg_ctx, 0);
- wlan_cfg_set_num_tx_ext_desc(wlan_cfg_ctx, 0);
- break;
- default:
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- "Invalid offload config %d", config);
- }
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
- FL("nss-wifi<0> nss config is enabled"));
- }
- static struct cdp_vdev *dp_vdev_attach_wifi3(struct cdp_pdev *txrx_pdev,
- uint8_t *vdev_mac_addr, uint8_t vdev_id, enum wlan_op_mode op_mode)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)txrx_pdev;
- struct dp_soc *soc = pdev->soc;
- struct dp_vdev *vdev = qdf_mem_malloc(sizeof(*vdev));
- if (!vdev) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- FL("DP VDEV memory allocation failed"));
- goto fail0;
- }
- vdev->pdev = pdev;
- vdev->vdev_id = vdev_id;
- vdev->opmode = op_mode;
- vdev->osdev = soc->osdev;
- vdev->osif_rx = NULL;
- vdev->osif_rsim_rx_decap = NULL;
- vdev->osif_get_key = NULL;
- vdev->osif_rx_mon = NULL;
- vdev->osif_tx_free_ext = NULL;
- vdev->osif_vdev = NULL;
- vdev->delete.pending = 0;
- vdev->safemode = 0;
- vdev->drop_unenc = 1;
- vdev->sec_type = cdp_sec_type_none;
- #ifdef notyet
- vdev->filters_num = 0;
- #endif
- qdf_mem_copy(
- &vdev->mac_addr.raw[0], vdev_mac_addr, QDF_MAC_ADDR_SIZE);
-
- TAILQ_INIT(&vdev->peer_list);
- if ((soc->intr_mode == DP_INTR_POLL) &&
- wlan_cfg_get_num_contexts(soc->wlan_cfg_ctx) != 0) {
- if ((pdev->vdev_count == 0) ||
- (wlan_op_mode_monitor == vdev->opmode))
- qdf_timer_mod(&soc->int_timer, DP_INTR_POLL_TIMER_MS);
- }
- if (wlan_op_mode_monitor == vdev->opmode) {
- pdev->monitor_vdev = vdev;
- return (struct cdp_vdev *)vdev;
- }
- vdev->tx_encap_type = wlan_cfg_pkt_type(soc->wlan_cfg_ctx);
- vdev->rx_decap_type = wlan_cfg_pkt_type(soc->wlan_cfg_ctx);
- vdev->dscp_tid_map_id = 0;
- vdev->mcast_enhancement_en = 0;
- vdev->raw_mode_war = wlan_cfg_get_raw_mode_war(soc->wlan_cfg_ctx);
- vdev->prev_tx_enq_tstamp = 0;
- vdev->prev_rx_deliver_tstamp = 0;
- qdf_spin_lock_bh(&pdev->vdev_list_lock);
-
- TAILQ_INSERT_TAIL(&pdev->vdev_list, vdev, vdev_list_elem);
- qdf_spin_unlock_bh(&pdev->vdev_list_lock);
- pdev->vdev_count++;
- if (wlan_op_mode_sta != vdev->opmode)
- vdev->ap_bridge_enabled = true;
- else
- vdev->ap_bridge_enabled = false;
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
- "%s: wlan_cfg_ap_bridge_enabled %d",
- __func__, vdev->ap_bridge_enabled);
- dp_tx_vdev_attach(vdev);
- if (pdev->vdev_count == 1)
- dp_lro_hash_setup(soc, pdev);
- dp_info("Created vdev %pK (%pM)", vdev, vdev->mac_addr.raw);
- DP_STATS_INIT(vdev);
- if (wlan_op_mode_sta == vdev->opmode)
- dp_peer_create_wifi3((struct cdp_vdev *)vdev,
- vdev->mac_addr.raw,
- NULL);
- return (struct cdp_vdev *)vdev;
- fail0:
- return NULL;
- }
- static void dp_vdev_register_wifi3(struct cdp_vdev *vdev_handle,
- void *osif_vdev, struct cdp_ctrl_objmgr_vdev *ctrl_vdev,
- struct ol_txrx_ops *txrx_ops)
- {
- struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle;
- vdev->osif_vdev = osif_vdev;
- vdev->ctrl_vdev = ctrl_vdev;
- vdev->osif_rx = txrx_ops->rx.rx;
- vdev->osif_rx_stack = txrx_ops->rx.rx_stack;
- vdev->osif_rsim_rx_decap = txrx_ops->rx.rsim_rx_decap;
- vdev->osif_get_key = txrx_ops->get_key;
- vdev->osif_rx_mon = txrx_ops->rx.mon;
- vdev->osif_tx_free_ext = txrx_ops->tx.tx_free_ext;
- vdev->tx_comp = txrx_ops->tx.tx_comp;
- #ifdef notyet
- #if ATH_SUPPORT_WAPI
- vdev->osif_check_wai = txrx_ops->rx.wai_check;
- #endif
- #endif
- #ifdef UMAC_SUPPORT_PROXY_ARP
- vdev->osif_proxy_arp = txrx_ops->proxy_arp;
- #endif
- vdev->me_convert = txrx_ops->me_convert;
-
- if (vdev->mesh_vdev)
- txrx_ops->tx.tx = dp_tx_send_mesh;
- else
- txrx_ops->tx.tx = dp_tx_send;
- txrx_ops->tx.tx_exception = dp_tx_send_exception;
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_LOW,
- "DP Vdev Register success");
- }
- static void dp_vdev_flush_peers(struct cdp_vdev *vdev_handle, bool unmap_only)
- {
- struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle;
- struct dp_pdev *pdev = vdev->pdev;
- struct dp_soc *soc = pdev->soc;
- struct dp_peer *peer;
- uint16_t *peer_ids;
- struct dp_ast_entry *ase, *tmp_ase;
- uint8_t i = 0, j = 0;
- peer_ids = qdf_mem_malloc(soc->max_peers * sizeof(peer_ids[0]));
- if (!peer_ids) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- "DP alloc failure - unable to flush peers");
- return;
- }
- qdf_spin_lock_bh(&soc->peer_ref_mutex);
- TAILQ_FOREACH(peer, &vdev->peer_list, peer_list_elem) {
- for (i = 0; i < MAX_NUM_PEER_ID_PER_PEER; i++)
- if (peer->peer_ids[i] != HTT_INVALID_PEER)
- if (j < soc->max_peers)
- peer_ids[j++] = peer->peer_ids[i];
- }
- qdf_spin_unlock_bh(&soc->peer_ref_mutex);
- for (i = 0; i < j ; i++) {
- if (unmap_only) {
- peer = __dp_peer_find_by_id(soc, peer_ids[i]);
- if (peer) {
- if (soc->is_peer_map_unmap_v2) {
-
- DP_PEER_ITERATE_ASE_LIST(peer, ase,
- tmp_ase) {
- dp_rx_peer_unmap_handler
- (soc, peer_ids[i],
- vdev->vdev_id,
- ase->mac_addr.raw,
- 1);
- }
- }
- dp_rx_peer_unmap_handler(soc, peer_ids[i],
- vdev->vdev_id,
- peer->mac_addr.raw,
- 0);
- }
- } else {
- peer = dp_peer_find_by_id(soc, peer_ids[i]);
- if (peer) {
- dp_info("peer: %pM is getting flush",
- peer->mac_addr.raw);
- if (soc->is_peer_map_unmap_v2) {
-
- DP_PEER_ITERATE_ASE_LIST(peer, ase,
- tmp_ase) {
- dp_rx_peer_unmap_handler
- (soc, peer_ids[i],
- vdev->vdev_id,
- ase->mac_addr.raw,
- 1);
- }
- }
- dp_peer_delete_wifi3(peer, 0);
-
- dp_peer_unref_del_find_by_id(peer);
- dp_rx_peer_unmap_handler(soc, peer_ids[i],
- vdev->vdev_id,
- peer->mac_addr.raw, 0);
- }
- }
- }
- qdf_mem_free(peer_ids);
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_HIGH,
- FL("Flushed peers for vdev object %pK "), vdev);
- }
- static void dp_vdev_detach_wifi3(struct cdp_vdev *vdev_handle,
- ol_txrx_vdev_delete_cb callback, void *cb_context)
- {
- struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle;
- struct dp_pdev *pdev;
- struct dp_soc *soc;
- struct dp_neighbour_peer *peer = NULL;
- struct dp_neighbour_peer *temp_peer = NULL;
-
- qdf_assert_always(vdev);
- pdev = vdev->pdev;
- soc = pdev->soc;
- if (wlan_op_mode_monitor == vdev->opmode)
- goto free_vdev;
- if (wlan_op_mode_sta == vdev->opmode)
- dp_peer_delete_wifi3(vdev->vap_self_peer, 0);
-
- if (!hif_is_target_ready(HIF_GET_SOFTC(soc->hif_handle)))
- dp_vdev_flush_peers((struct cdp_vdev *)vdev, false);
-
- qdf_spin_lock_bh(&soc->peer_ref_mutex);
-
- if (!TAILQ_EMPTY(&vdev->peer_list)) {
-
- dp_warn("not deleting vdev object %pK (%pM) until deletion finishes for all its peers",
- vdev, vdev->mac_addr.raw);
-
- vdev->delete.pending = 1;
- vdev->delete.callback = callback;
- vdev->delete.context = cb_context;
- qdf_spin_unlock_bh(&soc->peer_ref_mutex);
- return;
- }
- qdf_spin_unlock_bh(&soc->peer_ref_mutex);
- qdf_spin_lock_bh(&pdev->neighbour_peer_mutex);
- if (!soc->hw_nac_monitor_support) {
- TAILQ_FOREACH(peer, &pdev->neighbour_peers_list,
- neighbour_peer_list_elem) {
- QDF_ASSERT(peer->vdev != vdev);
- }
- } else {
- TAILQ_FOREACH_SAFE(peer, &pdev->neighbour_peers_list,
- neighbour_peer_list_elem, temp_peer) {
- if (peer->vdev == vdev) {
- TAILQ_REMOVE(&pdev->neighbour_peers_list, peer,
- neighbour_peer_list_elem);
- qdf_mem_free(peer);
- }
- }
- }
- qdf_spin_unlock_bh(&pdev->neighbour_peer_mutex);
- qdf_spin_lock_bh(&pdev->vdev_list_lock);
- dp_tx_vdev_detach(vdev);
-
- TAILQ_REMOVE(&pdev->vdev_list, vdev, vdev_list_elem);
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_HIGH,
- FL("deleting vdev object %pK (%pM)"), vdev, vdev->mac_addr.raw);
- qdf_spin_unlock_bh(&pdev->vdev_list_lock);
- free_vdev:
- if (wlan_op_mode_monitor == vdev->opmode)
- pdev->monitor_vdev = NULL;
- qdf_mem_free(vdev);
- if (callback)
- callback(cb_context);
- }
- #ifdef FEATURE_AST
- static inline void dp_peer_delete_ast_entries(struct dp_soc *soc,
- struct dp_peer *peer)
- {
- struct dp_ast_entry *ast_entry, *temp_ast_entry;
- DP_PEER_ITERATE_ASE_LIST(peer, ast_entry, temp_ast_entry)
- dp_peer_del_ast(soc, ast_entry);
- peer->self_ast_entry = NULL;
- }
- #else
- static inline void dp_peer_delete_ast_entries(struct dp_soc *soc,
- struct dp_peer *peer)
- {
- }
- #endif
- #if ATH_SUPPORT_WRAP
- static inline struct dp_peer *dp_peer_can_reuse(struct dp_vdev *vdev,
- uint8_t *peer_mac_addr)
- {
- struct dp_peer *peer;
- peer = dp_peer_find_hash_find(vdev->pdev->soc, peer_mac_addr,
- 0, vdev->vdev_id);
- if (!peer)
- return NULL;
- if (peer->bss_peer)
- return peer;
- dp_peer_unref_delete(peer);
- return NULL;
- }
- #else
- static inline struct dp_peer *dp_peer_can_reuse(struct dp_vdev *vdev,
- uint8_t *peer_mac_addr)
- {
- struct dp_peer *peer;
- peer = dp_peer_find_hash_find(vdev->pdev->soc, peer_mac_addr,
- 0, vdev->vdev_id);
- if (!peer)
- return NULL;
- if (peer->bss_peer && (peer->vdev->vdev_id == vdev->vdev_id))
- return peer;
- dp_peer_unref_delete(peer);
- return NULL;
- }
- #endif
- #ifdef FEATURE_AST
- static inline void dp_peer_ast_handle_roam_del(struct dp_soc *soc,
- struct dp_pdev *pdev,
- uint8_t *peer_mac_addr)
- {
- struct dp_ast_entry *ast_entry;
- qdf_spin_lock_bh(&soc->ast_lock);
- if (soc->ast_override_support)
- ast_entry = dp_peer_ast_hash_find_by_pdevid(soc, peer_mac_addr,
- pdev->pdev_id);
- else
- ast_entry = dp_peer_ast_hash_find_soc(soc, peer_mac_addr);
- if (ast_entry && ast_entry->next_hop && !ast_entry->delete_in_progress)
- dp_peer_del_ast(soc, ast_entry);
- qdf_spin_unlock_bh(&soc->ast_lock);
- }
- #endif
- #ifdef PEER_CACHE_RX_PKTS
- static inline void dp_peer_rx_bufq_resources_init(struct dp_peer *peer)
- {
- qdf_spinlock_create(&peer->bufq_info.bufq_lock);
- peer->bufq_info.thresh = DP_RX_CACHED_BUFQ_THRESH;
- qdf_list_create(&peer->bufq_info.cached_bufq, DP_RX_CACHED_BUFQ_THRESH);
- }
- #else
- static inline void dp_peer_rx_bufq_resources_init(struct dp_peer *peer)
- {
- }
- #endif
- static void *dp_peer_create_wifi3(struct cdp_vdev *vdev_handle,
- uint8_t *peer_mac_addr, struct cdp_ctrl_objmgr_peer *ctrl_peer)
- {
- struct dp_peer *peer;
- int i;
- struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle;
- struct dp_pdev *pdev;
- struct dp_soc *soc;
- struct cdp_peer_cookie peer_cookie;
- enum cdp_txrx_ast_entry_type ast_type = CDP_TXRX_AST_TYPE_STATIC;
-
- qdf_assert(vdev);
- qdf_assert(peer_mac_addr);
- pdev = vdev->pdev;
- soc = pdev->soc;
-
- peer = dp_peer_can_reuse(vdev, peer_mac_addr);
- if (peer) {
- qdf_atomic_init(&peer->is_default_route_set);
- dp_peer_cleanup(vdev, peer);
- qdf_spin_lock_bh(&soc->ast_lock);
- dp_peer_delete_ast_entries(soc, peer);
- peer->delete_in_progress = false;
- qdf_spin_unlock_bh(&soc->ast_lock);
- if ((vdev->opmode == wlan_op_mode_sta) &&
- !qdf_mem_cmp(peer_mac_addr, &vdev->mac_addr.raw[0],
- QDF_MAC_ADDR_SIZE)) {
- ast_type = CDP_TXRX_AST_TYPE_SELF;
- }
- dp_peer_add_ast(soc, peer, peer_mac_addr, ast_type, 0);
-
- if (soc->cdp_soc.ol_ops->peer_unref_delete) {
- soc->cdp_soc.ol_ops->peer_unref_delete(pdev->ctrl_pdev,
- peer->mac_addr.raw, vdev->mac_addr.raw,
- vdev->opmode, peer->ctrl_peer, ctrl_peer);
- }
- peer->ctrl_peer = ctrl_peer;
- dp_local_peer_id_alloc(pdev, peer);
- qdf_spinlock_create(&peer->peer_info_lock);
- dp_peer_rx_bufq_resources_init(peer);
- DP_STATS_INIT(peer);
- DP_STATS_UPD(peer, rx.avg_rssi, INVALID_RSSI);
- return (void *)peer;
- } else {
-
- dp_peer_ast_handle_roam_del(soc, pdev, peer_mac_addr);
- }
- #ifdef notyet
- peer = (struct dp_peer *)qdf_mempool_alloc(soc->osdev,
- soc->mempool_ol_ath_peer);
- #else
- peer = (struct dp_peer *)qdf_mem_malloc(sizeof(*peer));
- #endif
- if (!peer)
- return NULL;
- qdf_mem_zero(peer, sizeof(struct dp_peer));
- TAILQ_INIT(&peer->ast_entry_list);
-
- peer->vdev = vdev;
- peer->ctrl_peer = ctrl_peer;
- if ((vdev->opmode == wlan_op_mode_sta) &&
- !qdf_mem_cmp(peer_mac_addr, &vdev->mac_addr.raw[0],
- QDF_MAC_ADDR_SIZE)) {
- ast_type = CDP_TXRX_AST_TYPE_SELF;
- }
- dp_peer_add_ast(soc, peer, peer_mac_addr, ast_type, 0);
- qdf_spinlock_create(&peer->peer_info_lock);
- dp_peer_rx_bufq_resources_init(peer);
- qdf_mem_copy(
- &peer->mac_addr.raw[0], peer_mac_addr, QDF_MAC_ADDR_SIZE);
-
- peer->rx_opt_proc = soc->rx_opt_proc;
-
- for (i = 0; i < MAX_NUM_PEER_ID_PER_PEER; i++)
- peer->peer_ids[i] = HTT_INVALID_PEER;
- qdf_spin_lock_bh(&soc->peer_ref_mutex);
- qdf_atomic_init(&peer->ref_cnt);
-
- qdf_atomic_inc(&peer->ref_cnt);
-
- if (wlan_op_mode_sta == vdev->opmode)
- TAILQ_INSERT_HEAD(&vdev->peer_list, peer, peer_list_elem);
- else
- TAILQ_INSERT_TAIL(&vdev->peer_list, peer, peer_list_elem);
- qdf_spin_unlock_bh(&soc->peer_ref_mutex);
-
- dp_peer_find_hash_add(soc, peer);
-
- peer->state = OL_TXRX_PEER_STATE_DISC;
- dp_info("vdev %pK created peer %pK (%pM) ref_cnt: %d",
- vdev, peer, peer->mac_addr.raw,
- qdf_atomic_read(&peer->ref_cnt));
-
- if (qdf_mem_cmp(peer->mac_addr.raw, vdev->mac_addr.raw,
- QDF_MAC_ADDR_SIZE) == 0 &&
- (wlan_op_mode_sta != vdev->opmode)) {
- dp_info("vdev bss_peer!!");
- peer->bss_peer = 1;
- vdev->vap_bss_peer = peer;
- }
- if (wlan_op_mode_sta == vdev->opmode &&
- qdf_mem_cmp(peer->mac_addr.raw, vdev->mac_addr.raw,
- QDF_MAC_ADDR_SIZE) == 0) {
- vdev->vap_self_peer = peer;
- }
- for (i = 0; i < DP_MAX_TIDS; i++)
- qdf_spinlock_create(&peer->rx_tid[i].tid_lock);
- peer->valid = 1;
- dp_local_peer_id_alloc(pdev, peer);
- DP_STATS_INIT(peer);
- DP_STATS_UPD(peer, rx.avg_rssi, INVALID_RSSI);
- qdf_mem_copy(peer_cookie.mac_addr, peer->mac_addr.raw,
- QDF_MAC_ADDR_SIZE);
- peer_cookie.ctx = NULL;
- peer_cookie.cookie = pdev->next_peer_cookie++;
- #if defined(FEATURE_PERPKT_INFO) && WDI_EVENT_ENABLE
- dp_wdi_event_handler(WDI_EVENT_PEER_CREATE, pdev->soc,
- (void *)&peer_cookie,
- peer->peer_ids[0], WDI_NO_VAL, pdev->pdev_id);
- #endif
- if (soc->wlanstats_enabled) {
- if (!peer_cookie.ctx) {
- pdev->next_peer_cookie--;
- qdf_err("Failed to initialize peer rate stats");
- } else {
- peer->wlanstats_ctx = (void *)peer_cookie.ctx;
- }
- }
- return (void *)peer;
- }
- static
- void dp_vdev_get_default_reo_hash(struct dp_vdev *vdev,
- enum cdp_host_reo_dest_ring *reo_dest,
- bool *hash_based)
- {
- struct dp_soc *soc;
- struct dp_pdev *pdev;
- pdev = vdev->pdev;
- soc = pdev->soc;
-
- if (!wlan_cfg_get_dp_pdev_nss_enabled(pdev->wlan_cfg_ctx))
- *hash_based = wlan_cfg_is_rx_hash_enabled(soc->wlan_cfg_ctx);
-
- *reo_dest = pdev->reo_dest;
- }
- #ifdef IPA_OFFLOAD
- static void dp_peer_setup_get_reo_hash(struct dp_vdev *vdev,
- enum cdp_host_reo_dest_ring *reo_dest,
- bool *hash_based)
- {
- struct dp_soc *soc;
- struct dp_pdev *pdev;
- pdev = vdev->pdev;
- soc = pdev->soc;
- dp_vdev_get_default_reo_hash(vdev, reo_dest, hash_based);
-
- if (wlan_cfg_is_ipa_enabled(soc->wlan_cfg_ctx)) {
- if (vdev->opmode == wlan_op_mode_ap) {
- *reo_dest = IPA_REO_DEST_RING_IDX + 1;
- *hash_based = 0;
- } else if (vdev->opmode == wlan_op_mode_sta &&
- dp_ipa_is_mdm_platform()) {
- *reo_dest = IPA_REO_DEST_RING_IDX + 1;
- }
- }
- }
- #else
- static void dp_peer_setup_get_reo_hash(struct dp_vdev *vdev,
- enum cdp_host_reo_dest_ring *reo_dest,
- bool *hash_based)
- {
- dp_vdev_get_default_reo_hash(vdev, reo_dest, hash_based);
- }
- #endif
- static void dp_peer_setup_wifi3(struct cdp_vdev *vdev_hdl, void *peer_hdl)
- {
- struct dp_peer *peer = (struct dp_peer *)peer_hdl;
- struct dp_vdev *vdev = (struct dp_vdev *)vdev_hdl;
- struct dp_pdev *pdev;
- struct dp_soc *soc;
- bool hash_based = 0;
- enum cdp_host_reo_dest_ring reo_dest;
-
- qdf_assert(vdev);
- qdf_assert(peer);
- pdev = vdev->pdev;
- soc = pdev->soc;
- dp_peer_setup_get_reo_hash(vdev, &reo_dest, &hash_based);
- dp_info("pdev: %d vdev :%d opmode:%u hash-based-steering:%d default-reo_dest:%u",
- pdev->pdev_id, vdev->vdev_id,
- vdev->opmode, hash_based, reo_dest);
-
- if (peer->bss_peer && vdev->opmode == wlan_op_mode_ap)
- return;
- if (soc->cdp_soc.ol_ops->peer_set_default_routing) {
-
- soc->cdp_soc.ol_ops->peer_set_default_routing(
- pdev->ctrl_pdev, peer->mac_addr.raw,
- peer->vdev->vdev_id, hash_based, reo_dest);
- }
- qdf_atomic_set(&peer->is_default_route_set, 1);
- dp_peer_rx_init(pdev, peer);
- dp_peer_tx_init(pdev, peer);
- return;
- }
- static void dp_cp_peer_del_resp_handler(struct cdp_soc_t *soc_hdl,
- struct cdp_vdev *vdev_hdl,
- uint8_t *mac_addr)
- {
- struct dp_soc *soc = (struct dp_soc *)soc_hdl;
- struct dp_ast_entry *ast_entry = NULL;
- struct dp_vdev *vdev = (struct dp_vdev *)vdev_hdl;
- txrx_ast_free_cb cb = NULL;
- void *cookie;
- qdf_spin_lock_bh(&soc->ast_lock);
- if (soc->ast_override_support)
- ast_entry =
- dp_peer_ast_hash_find_by_pdevid(soc, mac_addr,
- vdev->pdev->pdev_id);
- else
- ast_entry = dp_peer_ast_hash_find_soc(soc, mac_addr);
-
- if (!ast_entry || ast_entry->peer || !ast_entry->delete_in_progress) {
- qdf_spin_unlock_bh(&soc->ast_lock);
- return;
- }
- if (ast_entry->is_mapped)
- soc->ast_table[ast_entry->ast_idx] = NULL;
- DP_STATS_INC(soc, ast.deleted, 1);
- dp_peer_ast_hash_remove(soc, ast_entry);
- cb = ast_entry->callback;
- cookie = ast_entry->cookie;
- ast_entry->callback = NULL;
- ast_entry->cookie = NULL;
- soc->num_ast_entries--;
- qdf_spin_unlock_bh(&soc->ast_lock);
- if (cb) {
- cb(soc->ctrl_psoc,
- soc,
- cookie,
- CDP_TXRX_AST_DELETED);
- }
- qdf_mem_free(ast_entry);
- }
- static void dp_set_vdev_tx_encap_type(struct cdp_vdev *vdev_handle,
- enum htt_cmn_pkt_type val)
- {
- struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle;
- vdev->tx_encap_type = val;
- }
- static void dp_set_vdev_rx_decap_type(struct cdp_vdev *vdev_handle,
- enum htt_cmn_pkt_type val)
- {
- struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle;
- vdev->rx_decap_type = val;
- }
- static void dp_set_ba_aging_timeout(struct cdp_soc_t *txrx_soc,
- uint8_t ac, uint32_t value)
- {
- struct dp_soc *soc = (struct dp_soc *)txrx_soc;
- hal_set_ba_aging_timeout(soc->hal_soc, ac, value);
- }
- static void dp_get_ba_aging_timeout(struct cdp_soc_t *txrx_soc,
- uint8_t ac, uint32_t *value)
- {
- struct dp_soc *soc = (struct dp_soc *)txrx_soc;
- hal_get_ba_aging_timeout(soc->hal_soc, ac, value);
- }
- static void dp_set_pdev_reo_dest(struct cdp_pdev *pdev_handle,
- enum cdp_host_reo_dest_ring val)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
- if (pdev)
- pdev->reo_dest = val;
- }
- static enum cdp_host_reo_dest_ring
- dp_get_pdev_reo_dest(struct cdp_pdev *pdev_handle)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
- if (pdev)
- return pdev->reo_dest;
- else
- return cdp_host_reo_dest_ring_unknown;
- }
- static int dp_set_filter_neighbour_peers(struct cdp_pdev *pdev_handle,
- uint32_t val)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
-
- pdev->filter_neighbour_peers = val;
- return 0;
- }
- static int dp_update_filter_neighbour_peers(struct cdp_vdev *vdev_handle,
- uint32_t cmd, uint8_t *macaddr)
- {
- struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle;
- struct dp_pdev *pdev = vdev->pdev;
- struct dp_neighbour_peer *peer = NULL;
- if (!macaddr)
- goto fail0;
-
- if (cmd == DP_NAC_PARAM_ADD) {
- peer = (struct dp_neighbour_peer *) qdf_mem_malloc(
- sizeof(*peer));
- if (!peer) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- FL("DP neighbour peer node memory allocation failed"));
- goto fail0;
- }
- qdf_mem_copy(&peer->neighbour_peers_macaddr.raw[0],
- macaddr, QDF_MAC_ADDR_SIZE);
- peer->vdev = vdev;
- qdf_spin_lock_bh(&pdev->neighbour_peer_mutex);
-
- TAILQ_INSERT_TAIL(&pdev->neighbour_peers_list, peer,
- neighbour_peer_list_elem);
- qdf_spin_unlock_bh(&pdev->neighbour_peer_mutex);
-
- if (!pdev->neighbour_peers_added) {
- pdev->neighbour_peers_added = true;
- dp_ppdu_ring_cfg(pdev);
- }
- return 1;
- } else if (cmd == DP_NAC_PARAM_DEL) {
- qdf_spin_lock_bh(&pdev->neighbour_peer_mutex);
- TAILQ_FOREACH(peer, &pdev->neighbour_peers_list,
- neighbour_peer_list_elem) {
- if (!qdf_mem_cmp(&peer->neighbour_peers_macaddr.raw[0],
- macaddr, QDF_MAC_ADDR_SIZE)) {
-
- TAILQ_REMOVE(&pdev->neighbour_peers_list,
- peer, neighbour_peer_list_elem);
- qdf_mem_free(peer);
- break;
- }
- }
-
- if (TAILQ_EMPTY(&pdev->neighbour_peers_list)) {
- pdev->neighbour_peers_added = false;
- dp_ppdu_ring_cfg(pdev);
- }
- qdf_spin_unlock_bh(&pdev->neighbour_peer_mutex);
- if (!pdev->mcopy_mode && !pdev->neighbour_peers_added &&
- !pdev->enhanced_stats_en)
- dp_ppdu_ring_reset(pdev);
- return 1;
- }
- fail0:
- return 0;
- }
- static int dp_get_sec_type(struct cdp_peer *peer, uint8_t sec_idx)
- {
- struct dp_peer *dpeer = (struct dp_peer *)peer;
- return dpeer->security[sec_idx].sec_type;
- }
- static void dp_peer_authorize(struct cdp_peer *peer_handle, uint32_t authorize)
- {
- struct dp_peer *peer = (struct dp_peer *)peer_handle;
- struct dp_soc *soc;
- if (peer) {
- soc = peer->vdev->pdev->soc;
- qdf_spin_lock_bh(&soc->peer_ref_mutex);
- peer->authorize = authorize ? 1 : 0;
- qdf_spin_unlock_bh(&soc->peer_ref_mutex);
- }
- }
- static void dp_reset_and_release_peer_mem(struct dp_soc *soc,
- struct dp_pdev *pdev,
- struct dp_peer *peer,
- struct dp_vdev *vdev)
- {
- struct dp_peer *bss_peer = NULL;
- uint8_t *m_addr = NULL;
- if (!vdev) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- "vdev is NULL");
- } else {
- if (vdev->vap_bss_peer == peer)
- vdev->vap_bss_peer = NULL;
- m_addr = peer->mac_addr.raw;
- if (soc->cdp_soc.ol_ops->peer_unref_delete)
- soc->cdp_soc.ol_ops->peer_unref_delete(pdev->ctrl_pdev,
- m_addr, vdev->mac_addr.raw, vdev->opmode,
- peer->ctrl_peer, NULL);
- if (vdev && vdev->vap_bss_peer) {
- bss_peer = vdev->vap_bss_peer;
- DP_UPDATE_STATS(vdev, peer);
- }
- }
-
- DP_AST_ASSERT(TAILQ_EMPTY(&peer->ast_entry_list));
- qdf_mem_free(peer);
- }
- static void dp_delete_pending_vdev(struct dp_pdev *pdev, struct dp_vdev *vdev,
- uint8_t vdev_id)
- {
- ol_txrx_vdev_delete_cb vdev_delete_cb = NULL;
- void *vdev_delete_context = NULL;
- vdev_delete_cb = vdev->delete.callback;
- vdev_delete_context = vdev->delete.context;
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_HIGH,
- FL("deleting vdev object %pK (%pM)- its last peer is done"),
- vdev, vdev->mac_addr.raw);
-
- dp_tx_flow_pool_unmap_handler(pdev, vdev_id,
- FLOW_TYPE_VDEV, vdev_id);
- dp_tx_vdev_detach(vdev);
- qdf_spin_lock_bh(&pdev->vdev_list_lock);
- TAILQ_REMOVE(&pdev->vdev_list, vdev, vdev_list_elem);
- qdf_spin_unlock_bh(&pdev->vdev_list_lock);
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_HIGH,
- FL("deleting vdev object %pK (%pM)"),
- vdev, vdev->mac_addr.raw);
- qdf_mem_free(vdev);
- vdev = NULL;
- if (vdev_delete_cb)
- vdev_delete_cb(vdev_delete_context);
- }
- void dp_peer_unref_delete(struct dp_peer *peer)
- {
- struct dp_vdev *vdev = peer->vdev;
- struct dp_pdev *pdev = vdev->pdev;
- struct dp_soc *soc = pdev->soc;
- struct dp_peer *tmppeer;
- int found = 0;
- uint16_t peer_id;
- uint16_t vdev_id;
- bool delete_vdev;
- struct cdp_peer_cookie peer_cookie;
-
- qdf_spin_lock_bh(&soc->peer_ref_mutex);
- if (qdf_atomic_dec_and_test(&peer->ref_cnt)) {
- peer_id = peer->peer_ids[0];
- vdev_id = vdev->vdev_id;
-
- if (peer_id != HTT_INVALID_PEER)
- soc->peer_id_to_obj_map[peer_id] = NULL;
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
- "Deleting peer %pK (%pM)", peer, peer->mac_addr.raw);
-
- dp_peer_find_hash_remove(soc, peer);
- qdf_spin_lock_bh(&soc->ast_lock);
- if (peer->self_ast_entry) {
- dp_peer_del_ast(soc, peer->self_ast_entry);
- peer->self_ast_entry = NULL;
- }
- qdf_spin_unlock_bh(&soc->ast_lock);
- TAILQ_FOREACH(tmppeer, &peer->vdev->peer_list, peer_list_elem) {
- if (tmppeer == peer) {
- found = 1;
- break;
- }
- }
- if (found) {
- TAILQ_REMOVE(&peer->vdev->peer_list, peer,
- peer_list_elem);
- } else {
-
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
- "peer:%pK not found in vdev:%pK peerlist:%pK",
- peer, vdev, &peer->vdev->peer_list);
- }
-
- qdf_mem_copy(peer_cookie.mac_addr, peer->mac_addr.raw,
- QDF_MAC_ADDR_SIZE);
- peer_cookie.ctx = NULL;
- peer_cookie.ctx = (void *)peer->wlanstats_ctx;
- #if defined(FEATURE_PERPKT_INFO) && WDI_EVENT_ENABLE
- dp_wdi_event_handler(WDI_EVENT_PEER_DESTROY,
- pdev->soc,
- (void *)&peer_cookie,
- peer->peer_ids[0],
- WDI_NO_VAL,
- pdev->pdev_id);
- #endif
- peer->wlanstats_ctx = NULL;
-
- dp_peer_cleanup(vdev, peer);
- qdf_spin_unlock_bh(&soc->peer_ref_mutex);
- dp_reset_and_release_peer_mem(soc, pdev, peer, vdev);
- qdf_spin_lock_bh(&soc->peer_ref_mutex);
-
- if (TAILQ_EMPTY(&vdev->peer_list)) {
-
- delete_vdev = vdev->delete.pending;
-
- qdf_spin_unlock_bh(&soc->peer_ref_mutex);
-
- if (delete_vdev)
- dp_delete_pending_vdev(pdev, vdev, vdev_id);
- } else {
- qdf_spin_unlock_bh(&soc->peer_ref_mutex);
- }
- } else {
- qdf_spin_unlock_bh(&soc->peer_ref_mutex);
- }
- }
- #ifdef PEER_CACHE_RX_PKTS
- static inline void dp_peer_rx_bufq_resources_deinit(struct dp_peer *peer)
- {
- dp_rx_flush_rx_cached(peer, true);
- qdf_list_destroy(&peer->bufq_info.cached_bufq);
- qdf_spinlock_destroy(&peer->bufq_info.bufq_lock);
- }
- #else
- static inline void dp_peer_rx_bufq_resources_deinit(struct dp_peer *peer)
- {
- }
- #endif
- static void dp_peer_delete_wifi3(void *peer_handle, uint32_t bitmap)
- {
- struct dp_peer *peer = (struct dp_peer *)peer_handle;
-
- peer->rx_opt_proc = dp_rx_discard;
-
- if (!(peer->vdev && (peer->vdev->opmode != wlan_op_mode_sta) &&
- !peer->bss_peer))
- peer->ctrl_peer = NULL;
- peer->valid = 0;
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_HIGH,
- FL("peer %pK (%pM)"), peer, peer->mac_addr.raw);
- dp_local_peer_id_free(peer->vdev->pdev, peer);
- dp_peer_rx_bufq_resources_deinit(peer);
- qdf_spinlock_destroy(&peer->peer_info_lock);
-
- dp_peer_unref_delete(peer_handle);
- }
- static uint8 *dp_get_vdev_mac_addr_wifi3(struct cdp_vdev *pvdev)
- {
- struct dp_vdev *vdev = (struct dp_vdev *)pvdev;
- return vdev->mac_addr.raw;
- }
- static int dp_vdev_set_wds(void *vdev_handle, uint32_t val)
- {
- struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle;
- vdev->wds_enabled = val;
- return 0;
- }
- static struct cdp_vdev *dp_get_vdev_from_vdev_id_wifi3(struct cdp_pdev *dev,
- uint8_t vdev_id)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)dev;
- struct dp_vdev *vdev = NULL;
- if (qdf_unlikely(!pdev))
- return NULL;
- qdf_spin_lock_bh(&pdev->vdev_list_lock);
- TAILQ_FOREACH(vdev, &pdev->vdev_list, vdev_list_elem) {
- if (vdev->delete.pending)
- continue;
- if (vdev->vdev_id == vdev_id)
- break;
- }
- qdf_spin_unlock_bh(&pdev->vdev_list_lock);
- return (struct cdp_vdev *)vdev;
- }
- static struct cdp_vdev *dp_get_mon_vdev_from_pdev_wifi3(struct cdp_pdev *dev)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)dev;
- if (qdf_unlikely(!pdev))
- return NULL;
- return (struct cdp_vdev *)pdev->monitor_vdev;
- }
- static int dp_get_opmode(struct cdp_vdev *vdev_handle)
- {
- struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle;
- return vdev->opmode;
- }
- static
- void dp_get_os_rx_handles_from_vdev_wifi3(struct cdp_vdev *pvdev,
- ol_txrx_rx_fp *stack_fn_p,
- ol_osif_vdev_handle *osif_vdev_p)
- {
- struct dp_vdev *vdev = dp_get_dp_vdev_from_cdp_vdev(pvdev);
- qdf_assert(vdev);
- *stack_fn_p = vdev->osif_rx_stack;
- *osif_vdev_p = vdev->osif_vdev;
- }
- static struct cdp_cfg *dp_get_ctrl_pdev_from_vdev_wifi3(struct cdp_vdev *pvdev)
- {
- struct dp_vdev *vdev = (struct dp_vdev *)pvdev;
- struct dp_pdev *pdev = vdev->pdev;
- return (struct cdp_cfg *)pdev->wlan_cfg_ctx;
- }
- static inline
- QDF_STATUS dp_monitor_mode_ring_config(struct dp_soc *soc, uint8_t mac_for_pdev,
- struct dp_pdev *pdev, uint8_t ring_num,
- struct htt_rx_ring_tlv_filter htt_tlv_filter)
- {
- QDF_STATUS status;
- if (soc->wlan_cfg_ctx->rxdma1_enable)
- status = htt_h2t_rx_ring_cfg(soc->htt_handle, mac_for_pdev,
- pdev->rxdma_mon_buf_ring[ring_num]
- .hal_srng,
- RXDMA_MONITOR_BUF, RX_BUFFER_SIZE,
- &htt_tlv_filter);
- else
- status = htt_h2t_rx_ring_cfg(soc->htt_handle, mac_for_pdev,
- pdev->rx_mac_buf_ring[ring_num]
- .hal_srng,
- RXDMA_BUF, RX_BUFFER_SIZE,
- &htt_tlv_filter);
- return status;
- }
- QDF_STATUS dp_reset_monitor_mode(struct cdp_pdev *pdev_handle)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
- struct htt_rx_ring_tlv_filter htt_tlv_filter;
- struct dp_soc *soc = pdev->soc;
- uint8_t pdev_id;
- int mac_id;
- QDF_STATUS status = QDF_STATUS_SUCCESS;
- pdev_id = pdev->pdev_id;
- soc = pdev->soc;
- qdf_spin_lock_bh(&pdev->mon_lock);
- qdf_mem_zero(&(htt_tlv_filter), sizeof(htt_tlv_filter));
- for (mac_id = 0; mac_id < NUM_RXDMA_RINGS_PER_PDEV; mac_id++) {
- int mac_for_pdev = dp_get_mac_id_for_pdev(mac_id, pdev_id);
- status = dp_monitor_mode_ring_config(soc, mac_for_pdev,
- pdev, mac_id,
- htt_tlv_filter);
- if (status != QDF_STATUS_SUCCESS) {
- dp_err("Failed to send tlv filter for monitor mode rings");
- qdf_spin_unlock_bh(&pdev->mon_lock);
- return status;
- }
- htt_h2t_rx_ring_cfg(soc->htt_handle, mac_for_pdev,
- pdev->rxdma_mon_status_ring[mac_id].hal_srng,
- RXDMA_MONITOR_STATUS, RX_BUFFER_SIZE,
- &htt_tlv_filter);
- }
- pdev->monitor_vdev = NULL;
- pdev->mcopy_mode = 0;
- pdev->monitor_configured = false;
- qdf_spin_unlock_bh(&pdev->mon_lock);
- return QDF_STATUS_SUCCESS;
- }
- static void dp_set_nac(struct cdp_peer *peer_handle)
- {
- struct dp_peer *peer = (struct dp_peer *)peer_handle;
- peer->nac = 1;
- }
- static int dp_get_tx_pending(struct cdp_pdev *pdev_handle)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
- return qdf_atomic_read(&pdev->num_tx_outstanding);
- }
- static void dp_get_peer_mac_from_peer_id(struct cdp_pdev *pdev_handle,
- uint32_t peer_id, uint8_t *peer_mac)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
- struct dp_peer *peer;
- if (pdev && peer_mac) {
- peer = dp_peer_find_by_id(pdev->soc, (uint16_t)peer_id);
- if (peer) {
- qdf_mem_copy(peer_mac, peer->mac_addr.raw,
- QDF_MAC_ADDR_SIZE);
- dp_peer_unref_del_find_by_id(peer);
- }
- }
- }
- QDF_STATUS dp_pdev_configure_monitor_rings(struct dp_pdev *pdev)
- {
- struct htt_rx_ring_tlv_filter htt_tlv_filter;
- struct dp_soc *soc;
- uint8_t pdev_id;
- int mac_id;
- QDF_STATUS status = QDF_STATUS_SUCCESS;
- pdev_id = pdev->pdev_id;
- soc = pdev->soc;
- QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_HIGH,
- "MODE[%x] FP[%02x|%02x|%02x] MO[%02x|%02x|%02x]",
- pdev->mon_filter_mode, pdev->fp_mgmt_filter,
- pdev->fp_ctrl_filter, pdev->fp_data_filter,
- pdev->mo_mgmt_filter, pdev->mo_ctrl_filter,
- pdev->mo_data_filter);
- qdf_mem_zero(&(htt_tlv_filter), sizeof(htt_tlv_filter));
- htt_tlv_filter.mpdu_start = 1;
- htt_tlv_filter.msdu_start = 1;
- htt_tlv_filter.packet = 1;
- htt_tlv_filter.msdu_end = 1;
- htt_tlv_filter.mpdu_end = 1;
- htt_tlv_filter.packet_header = 1;
- htt_tlv_filter.attention = 1;
- htt_tlv_filter.ppdu_start = 0;
- htt_tlv_filter.ppdu_end = 0;
- htt_tlv_filter.ppdu_end_user_stats = 0;
- htt_tlv_filter.ppdu_end_user_stats_ext = 0;
- htt_tlv_filter.ppdu_end_status_done = 0;
- htt_tlv_filter.header_per_msdu = 1;
- htt_tlv_filter.enable_fp =
- (pdev->mon_filter_mode & MON_FILTER_PASS) ? 1 : 0;
- htt_tlv_filter.enable_md = 0;
- htt_tlv_filter.enable_mo =
- (pdev->mon_filter_mode & MON_FILTER_OTHER) ? 1 : 0;
- htt_tlv_filter.fp_mgmt_filter = pdev->fp_mgmt_filter;
- htt_tlv_filter.fp_ctrl_filter = pdev->fp_ctrl_filter;
- if (pdev->mcopy_mode) {
- htt_tlv_filter.fp_data_filter = 0;
- htt_tlv_filter.mo_data_filter = 0;
- } else {
- htt_tlv_filter.fp_data_filter = pdev->fp_data_filter;
- htt_tlv_filter.mo_data_filter = pdev->mo_data_filter;
- }
- htt_tlv_filter.mo_mgmt_filter = pdev->mo_mgmt_filter;
- htt_tlv_filter.mo_ctrl_filter = pdev->mo_ctrl_filter;
- htt_tlv_filter.offset_valid = false;
- if ((pdev->rx_enh_capture_mode == CDP_RX_ENH_CAPTURE_MPDU) ||
- (pdev->rx_enh_capture_mode == CDP_RX_ENH_CAPTURE_MPDU_MSDU)) {
- htt_tlv_filter.fp_mgmt_filter = 0;
- htt_tlv_filter.fp_ctrl_filter = 0;
- htt_tlv_filter.fp_data_filter = 0;
- htt_tlv_filter.mo_mgmt_filter = 0;
- htt_tlv_filter.mo_ctrl_filter = 0;
- htt_tlv_filter.mo_data_filter = 0;
- }
- for (mac_id = 0; mac_id < NUM_RXDMA_RINGS_PER_PDEV; mac_id++) {
- int mac_for_pdev = dp_get_mac_id_for_pdev(mac_id, pdev_id);
- status = dp_monitor_mode_ring_config(soc, mac_for_pdev,
- pdev, mac_id,
- htt_tlv_filter);
- if (status != QDF_STATUS_SUCCESS) {
- dp_err("Failed to send tlv filter for monitor mode rings");
- return status;
- }
- }
- qdf_mem_zero(&(htt_tlv_filter), sizeof(htt_tlv_filter));
- htt_tlv_filter.mpdu_start = 1;
- htt_tlv_filter.msdu_start = 0;
- htt_tlv_filter.packet = 0;
- htt_tlv_filter.msdu_end = 0;
- htt_tlv_filter.mpdu_end = 0;
- if ((pdev->rx_enh_capture_mode == CDP_RX_ENH_CAPTURE_MPDU) ||
- (pdev->rx_enh_capture_mode == CDP_RX_ENH_CAPTURE_MPDU_MSDU)) {
- htt_tlv_filter.mpdu_end = 1;
- }
- htt_tlv_filter.attention = 0;
- htt_tlv_filter.ppdu_start = 1;
- htt_tlv_filter.ppdu_end = 1;
- htt_tlv_filter.ppdu_end_user_stats = 1;
- htt_tlv_filter.ppdu_end_user_stats_ext = 1;
- htt_tlv_filter.ppdu_end_status_done = 1;
- htt_tlv_filter.enable_fp = 1;
- htt_tlv_filter.enable_md = 0;
- htt_tlv_filter.enable_mo = 1;
- if (pdev->mcopy_mode ||
- (pdev->rx_enh_capture_mode != CDP_RX_ENH_CAPTURE_DISABLED)) {
- htt_tlv_filter.packet_header = 1;
- if (pdev->rx_enh_capture_mode == CDP_RX_ENH_CAPTURE_MPDU) {
- htt_tlv_filter.header_per_msdu = 0;
- htt_tlv_filter.enable_mo = 0;
- } else if (pdev->rx_enh_capture_mode ==
- CDP_RX_ENH_CAPTURE_MPDU_MSDU) {
- htt_tlv_filter.header_per_msdu = 1;
- htt_tlv_filter.enable_mo = 0;
- if (pdev->is_rx_protocol_tagging_enabled ||
- pdev->is_rx_enh_capture_trailer_enabled)
- htt_tlv_filter.msdu_end = 1;
- }
- }
- htt_tlv_filter.fp_mgmt_filter = FILTER_MGMT_ALL;
- htt_tlv_filter.fp_ctrl_filter = FILTER_CTRL_ALL;
- htt_tlv_filter.fp_data_filter = FILTER_DATA_ALL;
- htt_tlv_filter.mo_mgmt_filter = FILTER_MGMT_ALL;
- htt_tlv_filter.mo_ctrl_filter = FILTER_CTRL_ALL;
- htt_tlv_filter.mo_data_filter = FILTER_DATA_ALL;
- htt_tlv_filter.offset_valid = false;
- for (mac_id = 0; mac_id < NUM_RXDMA_RINGS_PER_PDEV; mac_id++) {
- int mac_for_pdev = dp_get_mac_id_for_pdev(mac_id,
- pdev->pdev_id);
- htt_h2t_rx_ring_cfg(soc->htt_handle, mac_for_pdev,
- pdev->rxdma_mon_status_ring[mac_id].hal_srng,
- RXDMA_MONITOR_STATUS, RX_BUFFER_SIZE, &htt_tlv_filter);
- }
- return status;
- }
- static QDF_STATUS dp_vdev_set_monitor_mode(struct cdp_vdev *vdev_handle,
- uint8_t special_monitor)
- {
- struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle;
- struct dp_pdev *pdev;
- qdf_assert(vdev);
- pdev = vdev->pdev;
- pdev->monitor_vdev = vdev;
- QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_WARN,
- "pdev=%pK, pdev_id=%d, soc=%pK vdev=%pK\n",
- pdev, pdev->pdev_id, pdev->soc, vdev);
-
- if (special_monitor)
- return QDF_STATUS_SUCCESS;
-
- if (pdev->monitor_configured) {
- QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
- "monitor vap already created vdev=%pK\n", vdev);
- qdf_assert(vdev);
- return QDF_STATUS_E_RESOURCES;
- }
- pdev->monitor_configured = true;
- dp_mon_buf_delayed_replenish(pdev);
- return dp_pdev_configure_monitor_rings(pdev);
- }
- static QDF_STATUS
- dp_pdev_set_advance_monitor_filter(struct cdp_pdev *pdev_handle,
- struct cdp_monitor_filter *filter_val)
- {
-
- struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
- struct dp_vdev *vdev = pdev->monitor_vdev;
- struct htt_rx_ring_tlv_filter htt_tlv_filter;
- struct dp_soc *soc;
- uint8_t pdev_id;
- int mac_id;
- QDF_STATUS status = QDF_STATUS_SUCCESS;
- pdev_id = pdev->pdev_id;
- soc = pdev->soc;
- QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_WARN,
- "pdev=%pK, pdev_id=%d, soc=%pK vdev=%pK",
- pdev, pdev_id, soc, vdev);
-
- if (!pdev->monitor_vdev) {
- QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
- "vdev=%pK", vdev);
- qdf_assert(vdev);
- }
-
- pdev->mon_filter_mode = filter_val->mode;
- pdev->fp_mgmt_filter = filter_val->fp_mgmt;
- pdev->fp_ctrl_filter = filter_val->fp_ctrl;
- pdev->fp_data_filter = filter_val->fp_data;
- pdev->mo_mgmt_filter = filter_val->mo_mgmt;
- pdev->mo_ctrl_filter = filter_val->mo_ctrl;
- pdev->mo_data_filter = filter_val->mo_data;
- QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_HIGH,
- "MODE[%x] FP[%02x|%02x|%02x] MO[%02x|%02x|%02x]",
- pdev->mon_filter_mode, pdev->fp_mgmt_filter,
- pdev->fp_ctrl_filter, pdev->fp_data_filter,
- pdev->mo_mgmt_filter, pdev->mo_ctrl_filter,
- pdev->mo_data_filter);
- qdf_mem_zero(&(htt_tlv_filter), sizeof(htt_tlv_filter));
- for (mac_id = 0; mac_id < NUM_RXDMA_RINGS_PER_PDEV; mac_id++) {
- int mac_for_pdev = dp_get_mac_id_for_pdev(mac_id, pdev_id);
- status = dp_monitor_mode_ring_config(soc, mac_for_pdev,
- pdev, mac_id,
- htt_tlv_filter);
- if (status != QDF_STATUS_SUCCESS) {
- dp_err("Failed to send tlv filter for monitor mode rings");
- return status;
- }
- htt_h2t_rx_ring_cfg(soc->htt_handle, mac_for_pdev,
- pdev->rxdma_mon_status_ring[mac_id].hal_srng,
- RXDMA_MONITOR_STATUS, RX_BUFFER_SIZE, &htt_tlv_filter);
- }
- htt_tlv_filter.mpdu_start = 1;
- htt_tlv_filter.msdu_start = 1;
- htt_tlv_filter.packet = 1;
- htt_tlv_filter.msdu_end = 1;
- htt_tlv_filter.mpdu_end = 1;
- htt_tlv_filter.packet_header = 1;
- htt_tlv_filter.attention = 1;
- htt_tlv_filter.ppdu_start = 0;
- htt_tlv_filter.ppdu_end = 0;
- htt_tlv_filter.ppdu_end_user_stats = 0;
- htt_tlv_filter.ppdu_end_user_stats_ext = 0;
- htt_tlv_filter.ppdu_end_status_done = 0;
- htt_tlv_filter.header_per_msdu = 1;
- htt_tlv_filter.enable_fp =
- (pdev->mon_filter_mode & MON_FILTER_PASS) ? 1 : 0;
- htt_tlv_filter.enable_md = 0;
- htt_tlv_filter.enable_mo =
- (pdev->mon_filter_mode & MON_FILTER_OTHER) ? 1 : 0;
- htt_tlv_filter.fp_mgmt_filter = pdev->fp_mgmt_filter;
- htt_tlv_filter.fp_ctrl_filter = pdev->fp_ctrl_filter;
- if (pdev->mcopy_mode)
- htt_tlv_filter.fp_data_filter = 0;
- else
- htt_tlv_filter.fp_data_filter = pdev->fp_data_filter;
- htt_tlv_filter.mo_mgmt_filter = pdev->mo_mgmt_filter;
- htt_tlv_filter.mo_ctrl_filter = pdev->mo_ctrl_filter;
- htt_tlv_filter.mo_data_filter = pdev->mo_data_filter;
- htt_tlv_filter.offset_valid = false;
- for (mac_id = 0; mac_id < NUM_RXDMA_RINGS_PER_PDEV; mac_id++) {
- int mac_for_pdev = dp_get_mac_id_for_pdev(mac_id, pdev_id);
- status = dp_monitor_mode_ring_config(soc, mac_for_pdev,
- pdev, mac_id,
- htt_tlv_filter);
- if (status != QDF_STATUS_SUCCESS) {
- dp_err("Failed to send tlv filter for monitor mode rings");
- return status;
- }
- }
- qdf_mem_zero(&(htt_tlv_filter), sizeof(htt_tlv_filter));
- htt_tlv_filter.mpdu_start = 1;
- htt_tlv_filter.msdu_start = 0;
- htt_tlv_filter.packet = 0;
- htt_tlv_filter.msdu_end = 0;
- htt_tlv_filter.mpdu_end = 0;
- htt_tlv_filter.attention = 0;
- htt_tlv_filter.ppdu_start = 1;
- htt_tlv_filter.ppdu_end = 1;
- htt_tlv_filter.ppdu_end_user_stats = 1;
- htt_tlv_filter.ppdu_end_user_stats_ext = 1;
- htt_tlv_filter.ppdu_end_status_done = 1;
- htt_tlv_filter.enable_fp = 1;
- htt_tlv_filter.enable_md = 0;
- htt_tlv_filter.enable_mo = 1;
- if (pdev->mcopy_mode) {
- htt_tlv_filter.packet_header = 1;
- }
- htt_tlv_filter.fp_mgmt_filter = FILTER_MGMT_ALL;
- htt_tlv_filter.fp_ctrl_filter = FILTER_CTRL_ALL;
- htt_tlv_filter.fp_data_filter = FILTER_DATA_ALL;
- htt_tlv_filter.mo_mgmt_filter = FILTER_MGMT_ALL;
- htt_tlv_filter.mo_ctrl_filter = FILTER_CTRL_ALL;
- htt_tlv_filter.mo_data_filter = FILTER_DATA_ALL;
- htt_tlv_filter.offset_valid = false;
- for (mac_id = 0; mac_id < NUM_RXDMA_RINGS_PER_PDEV; mac_id++) {
- int mac_for_pdev = dp_get_mac_id_for_pdev(mac_id,
- pdev->pdev_id);
- htt_h2t_rx_ring_cfg(soc->htt_handle, mac_for_pdev,
- pdev->rxdma_mon_status_ring[mac_id].hal_srng,
- RXDMA_MONITOR_STATUS, RX_BUFFER_SIZE, &htt_tlv_filter);
- }
- return QDF_STATUS_SUCCESS;
- }
- static
- void dp_pdev_set_monitor_channel(struct cdp_pdev *pdev_handle, int chan_num)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
- pdev->mon_chan_num = chan_num;
- }
- static
- uint8_t dp_get_pdev_id_frm_pdev(struct cdp_pdev *pdev_handle)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
- return pdev->pdev_id;
- }
- static
- bool dp_get_delay_stats_flag(struct cdp_pdev *pdev_handle)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
- return pdev->delay_stats_flag;
- }
- static
- void dp_pdev_set_chan_noise_floor(struct cdp_pdev *pdev_handle,
- int16_t chan_noise_floor)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
- pdev->chan_noise_floor = chan_noise_floor;
- }
- static bool dp_vdev_get_filter_ucast_data(struct cdp_vdev *vdev_handle)
- {
- struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle;
- struct dp_pdev *pdev;
- pdev = vdev->pdev;
- if ((pdev->fp_data_filter & FILTER_DATA_UCAST) ||
- (pdev->mo_data_filter & FILTER_DATA_UCAST))
- return true;
- return false;
- }
- static bool dp_vdev_get_filter_mcast_data(struct cdp_vdev *vdev_handle)
- {
- struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle;
- struct dp_pdev *pdev;
- pdev = vdev->pdev;
- if ((pdev->fp_data_filter & FILTER_DATA_MCAST) ||
- (pdev->mo_data_filter & FILTER_DATA_MCAST))
- return true;
- return false;
- }
- static bool dp_vdev_get_filter_non_data(struct cdp_vdev *vdev_handle)
- {
- struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle;
- struct dp_pdev *pdev;
- pdev = vdev->pdev;
- if ((pdev->fp_mgmt_filter & FILTER_MGMT_ALL) ||
- (pdev->mo_mgmt_filter & FILTER_MGMT_ALL)) {
- if ((pdev->fp_ctrl_filter & FILTER_CTRL_ALL) ||
- (pdev->mo_ctrl_filter & FILTER_CTRL_ALL)) {
- return true;
- }
- }
- return false;
- }
- #ifdef MESH_MODE_SUPPORT
- void dp_peer_set_mesh_mode(struct cdp_vdev *vdev_hdl, uint32_t val)
- {
- struct dp_vdev *vdev = (struct dp_vdev *)vdev_hdl;
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
- FL("val %d"), val);
- vdev->mesh_vdev = val;
- }
- void dp_peer_set_mesh_rx_filter(struct cdp_vdev *vdev_hdl, uint32_t val)
- {
- struct dp_vdev *vdev = (struct dp_vdev *)vdev_hdl;
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
- FL("val %d"), val);
- vdev->mesh_rx_filter = val;
- }
- #endif
- bool dp_check_pdev_exists(struct dp_soc *soc, struct dp_pdev *data)
- {
- uint8_t pdev_count;
- for (pdev_count = 0; pdev_count < MAX_PDEV_CNT; pdev_count++) {
- if (soc->pdev_list[pdev_count] &&
- soc->pdev_list[pdev_count] == data)
- return true;
- }
- return false;
- }
- void dp_rx_bar_stats_cb(struct dp_soc *soc, void *cb_ctxt,
- union hal_reo_status *reo_status)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)cb_ctxt;
- struct hal_reo_queue_status *queue_status = &(reo_status->queue_status);
- if (!dp_check_pdev_exists(soc, pdev)) {
- dp_err_rl("pdev doesn't exist");
- return;
- }
- if (!qdf_atomic_read(&soc->cmn_init_done))
- return;
- if (queue_status->header.status != HAL_REO_CMD_SUCCESS) {
- DP_PRINT_STATS("REO stats failure %d",
- queue_status->header.status);
- qdf_atomic_set(&(pdev->stats_cmd_complete), 1);
- return;
- }
- pdev->stats.rx.bar_recv_cnt += queue_status->bar_rcvd_cnt;
- qdf_atomic_set(&(pdev->stats_cmd_complete), 1);
- }
- void dp_aggregate_vdev_stats(struct dp_vdev *vdev,
- struct cdp_vdev_stats *vdev_stats)
- {
- struct dp_peer *peer = NULL;
- struct dp_soc *soc = NULL;
- if (!vdev || !vdev->pdev)
- return;
- soc = vdev->pdev->soc;
- qdf_mem_copy(vdev_stats, &vdev->stats, sizeof(vdev->stats));
- TAILQ_FOREACH(peer, &vdev->peer_list, peer_list_elem)
- dp_update_vdev_stats(vdev_stats, peer);
- #if defined(FEATURE_PERPKT_INFO) && WDI_EVENT_ENABLE
- dp_wdi_event_handler(WDI_EVENT_UPDATE_DP_STATS, vdev->pdev->soc,
- vdev_stats, vdev->vdev_id,
- UPDATE_VDEV_STATS, vdev->pdev->pdev_id);
- #endif
- }
- void dp_aggregate_pdev_stats(struct dp_pdev *pdev)
- {
- struct dp_vdev *vdev = NULL;
- struct dp_soc *soc;
- struct cdp_vdev_stats *vdev_stats =
- qdf_mem_malloc(sizeof(struct cdp_vdev_stats));
- if (!vdev_stats) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- "DP alloc failure - unable to get alloc vdev stats");
- return;
- }
- qdf_mem_zero(&pdev->stats.tx, sizeof(pdev->stats.tx));
- qdf_mem_zero(&pdev->stats.rx, sizeof(pdev->stats.rx));
- qdf_mem_zero(&pdev->stats.tx_i, sizeof(pdev->stats.tx_i));
- if (pdev->mcopy_mode)
- DP_UPDATE_STATS(pdev, pdev->invalid_peer);
- soc = pdev->soc;
- qdf_spin_lock_bh(&soc->peer_ref_mutex);
- qdf_spin_lock_bh(&pdev->vdev_list_lock);
- TAILQ_FOREACH(vdev, &pdev->vdev_list, vdev_list_elem) {
- dp_aggregate_vdev_stats(vdev, vdev_stats);
- dp_update_pdev_stats(pdev, vdev_stats);
- dp_update_pdev_ingress_stats(pdev, vdev);
- }
- qdf_spin_unlock_bh(&pdev->vdev_list_lock);
- qdf_spin_unlock_bh(&soc->peer_ref_mutex);
- qdf_mem_free(vdev_stats);
- #if defined(FEATURE_PERPKT_INFO) && WDI_EVENT_ENABLE
- dp_wdi_event_handler(WDI_EVENT_UPDATE_DP_STATS, pdev->soc, &pdev->stats,
- pdev->pdev_id, UPDATE_PDEV_STATS, pdev->pdev_id);
- #endif
- }
- static void dp_vdev_getstats(void *vdev_handle,
- struct cdp_dev_stats *stats)
- {
- struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle;
- struct dp_pdev *pdev;
- struct dp_soc *soc;
- struct cdp_vdev_stats *vdev_stats;
- if (!vdev)
- return;
- pdev = vdev->pdev;
- if (!pdev)
- return;
- soc = pdev->soc;
- vdev_stats = qdf_mem_malloc(sizeof(struct cdp_vdev_stats));
- if (!vdev_stats) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- "DP alloc failure - unable to get alloc vdev stats");
- return;
- }
- qdf_spin_lock_bh(&soc->peer_ref_mutex);
- dp_aggregate_vdev_stats(vdev, vdev_stats);
- qdf_spin_unlock_bh(&soc->peer_ref_mutex);
- stats->tx_packets = vdev_stats->tx_i.rcvd.num;
- stats->tx_bytes = vdev_stats->tx_i.rcvd.bytes;
- stats->tx_errors = vdev_stats->tx.tx_failed +
- vdev_stats->tx_i.dropped.dropped_pkt.num;
- stats->tx_dropped = stats->tx_errors;
- stats->rx_packets = vdev_stats->rx.unicast.num +
- vdev_stats->rx.multicast.num +
- vdev_stats->rx.bcast.num;
- stats->rx_bytes = vdev_stats->rx.unicast.bytes +
- vdev_stats->rx.multicast.bytes +
- vdev_stats->rx.bcast.bytes;
- qdf_mem_free(vdev_stats);
- }
- static void dp_pdev_getstats(void *pdev_handle,
- struct cdp_dev_stats *stats)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
- dp_aggregate_pdev_stats(pdev);
- stats->tx_packets = pdev->stats.tx_i.rcvd.num;
- stats->tx_bytes = pdev->stats.tx_i.rcvd.bytes;
- stats->tx_errors = pdev->stats.tx.tx_failed +
- pdev->stats.tx_i.dropped.dropped_pkt.num;
- stats->tx_dropped = stats->tx_errors;
- stats->rx_packets = pdev->stats.rx.unicast.num +
- pdev->stats.rx.multicast.num +
- pdev->stats.rx.bcast.num;
- stats->rx_bytes = pdev->stats.rx.unicast.bytes +
- pdev->stats.rx.multicast.bytes +
- pdev->stats.rx.bcast.bytes;
- }
- static void dp_get_device_stats(void *handle,
- struct cdp_dev_stats *stats, uint8_t type)
- {
- switch (type) {
- case UPDATE_VDEV_STATS:
- dp_vdev_getstats(handle, stats);
- break;
- case UPDATE_PDEV_STATS:
- dp_pdev_getstats(handle, stats);
- break;
- default:
- QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
- "apstats cannot be updated for this input "
- "type %d", type);
- break;
- }
- }
- const
- char *dp_srng_get_str_from_hal_ring_type(enum hal_ring_type ring_type)
- {
- switch (ring_type) {
- case REO_DST:
- return "Reo_dst";
- case REO_EXCEPTION:
- return "Reo_exception";
- case REO_CMD:
- return "Reo_cmd";
- case REO_REINJECT:
- return "Reo_reinject";
- case REO_STATUS:
- return "Reo_status";
- case WBM2SW_RELEASE:
- return "wbm2sw_release";
- case TCL_DATA:
- return "tcl_data";
- case TCL_CMD:
- return "tcl_cmd";
- case TCL_STATUS:
- return "tcl_status";
- case SW2WBM_RELEASE:
- return "sw2wbm_release";
- case RXDMA_BUF:
- return "Rxdma_buf";
- case RXDMA_DST:
- return "Rxdma_dst";
- case RXDMA_MONITOR_BUF:
- return "Rxdma_monitor_buf";
- case RXDMA_MONITOR_DESC:
- return "Rxdma_monitor_desc";
- case RXDMA_MONITOR_STATUS:
- return "Rxdma_monitor_status";
- default:
- dp_err("Invalid ring type");
- break;
- }
- return "Invalid";
- }
- static void dp_print_napi_stats(struct dp_soc *soc)
- {
- hif_print_napi_stats(soc->hif_handle);
- }
- static inline void
- dp_txrx_host_stats_clr(struct dp_vdev *vdev)
- {
- struct dp_peer *peer = NULL;
- if (!vdev || !vdev->pdev)
- return;
- DP_STATS_CLR(vdev->pdev);
- DP_STATS_CLR(vdev->pdev->soc);
- DP_STATS_CLR(vdev);
- hif_clear_napi_stats(vdev->pdev->soc->hif_handle);
- TAILQ_FOREACH(peer, &vdev->peer_list, peer_list_elem) {
- if (!peer)
- return;
- DP_STATS_CLR(peer);
- #if defined(FEATURE_PERPKT_INFO) && WDI_EVENT_ENABLE
- dp_wdi_event_handler(WDI_EVENT_UPDATE_DP_STATS, vdev->pdev->soc,
- &peer->stats, peer->peer_ids[0],
- UPDATE_PEER_STATS, vdev->pdev->pdev_id);
- #endif
- }
- #if defined(FEATURE_PERPKT_INFO) && WDI_EVENT_ENABLE
- dp_wdi_event_handler(WDI_EVENT_UPDATE_DP_STATS, vdev->pdev->soc,
- &vdev->stats, vdev->vdev_id,
- UPDATE_VDEV_STATS, vdev->pdev->pdev_id);
- #endif
- }
- static void
- dp_get_host_peer_stats(struct cdp_pdev *pdev_handle, char *mac_addr)
- {
- struct dp_peer *peer;
- uint8_t local_id;
- if (!mac_addr) {
- QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
- "Invalid MAC address\n");
- return;
- }
- peer = (struct dp_peer *)dp_find_peer_by_addr(pdev_handle, mac_addr,
- &local_id);
- if (!peer) {
- QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
- "%s: Invalid peer\n", __func__);
- return;
- }
-
- if ((struct dp_pdev *)pdev_handle != peer->vdev->pdev) {
- QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
- "%s: Peer is not for this pdev\n", __func__);
- return;
- }
- dp_print_peer_stats(peer);
- dp_peer_rxtid_stats(peer, dp_rx_tid_stats_cb, NULL);
- }
- static void dp_txrx_stats_help(void)
- {
- dp_info("Command: iwpriv wlan0 txrx_stats <stats_option> <mac_id>");
- dp_info("stats_option:");
- dp_info(" 1 -- HTT Tx Statistics");
- dp_info(" 2 -- HTT Rx Statistics");
- dp_info(" 3 -- HTT Tx HW Queue Statistics");
- dp_info(" 4 -- HTT Tx HW Sched Statistics");
- dp_info(" 5 -- HTT Error Statistics");
- dp_info(" 6 -- HTT TQM Statistics");
- dp_info(" 7 -- HTT TQM CMDQ Statistics");
- dp_info(" 8 -- HTT TX_DE_CMN Statistics");
- dp_info(" 9 -- HTT Tx Rate Statistics");
- dp_info(" 10 -- HTT Rx Rate Statistics");
- dp_info(" 11 -- HTT Peer Statistics");
- dp_info(" 12 -- HTT Tx SelfGen Statistics");
- dp_info(" 13 -- HTT Tx MU HWQ Statistics");
- dp_info(" 14 -- HTT RING_IF_INFO Statistics");
- dp_info(" 15 -- HTT SRNG Statistics");
- dp_info(" 16 -- HTT SFM Info Statistics");
- dp_info(" 17 -- HTT PDEV_TX_MU_MIMO_SCHED INFO Statistics");
- dp_info(" 18 -- HTT Peer List Details");
- dp_info(" 20 -- Clear Host Statistics");
- dp_info(" 21 -- Host Rx Rate Statistics");
- dp_info(" 22 -- Host Tx Rate Statistics");
- dp_info(" 23 -- Host Tx Statistics");
- dp_info(" 24 -- Host Rx Statistics");
- dp_info(" 25 -- Host AST Statistics");
- dp_info(" 26 -- Host SRNG PTR Statistics");
- dp_info(" 27 -- Host Mon Statistics");
- dp_info(" 28 -- Host REO Queue Statistics");
- dp_info(" 29 -- Host Soc cfg param Statistics");
- dp_info(" 30 -- Host pdev cfg param Statistics");
- }
- static int
- dp_print_host_stats(struct cdp_vdev *vdev_handle,
- struct cdp_txrx_stats_req *req)
- {
- struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle;
- struct dp_pdev *pdev = (struct dp_pdev *)vdev->pdev;
- enum cdp_host_txrx_stats type =
- dp_stats_mapping_table[req->stats][STATS_HOST];
- dp_aggregate_pdev_stats(pdev);
- switch (type) {
- case TXRX_CLEAR_STATS:
- dp_txrx_host_stats_clr(vdev);
- break;
- case TXRX_RX_RATE_STATS:
- dp_print_rx_rates(vdev);
- break;
- case TXRX_TX_RATE_STATS:
- dp_print_tx_rates(vdev);
- break;
- case TXRX_TX_HOST_STATS:
- dp_print_pdev_tx_stats(pdev);
- dp_print_soc_tx_stats(pdev->soc);
- break;
- case TXRX_RX_HOST_STATS:
- dp_print_pdev_rx_stats(pdev);
- dp_print_soc_rx_stats(pdev->soc);
- break;
- case TXRX_AST_STATS:
- dp_print_ast_stats(pdev->soc);
- dp_print_peer_table(vdev);
- break;
- case TXRX_SRNG_PTR_STATS:
- dp_print_ring_stats(pdev);
- break;
- case TXRX_RX_MON_STATS:
- dp_print_pdev_rx_mon_stats(pdev);
- break;
- case TXRX_REO_QUEUE_STATS:
- dp_get_host_peer_stats((struct cdp_pdev *)pdev, req->peer_addr);
- break;
- case TXRX_SOC_CFG_PARAMS:
- dp_print_soc_cfg_params(pdev->soc);
- break;
- case TXRX_PDEV_CFG_PARAMS:
- dp_print_pdev_cfg_params(pdev);
- break;
- case TXRX_NAPI_STATS:
- dp_print_napi_stats(pdev->soc);
- case TXRX_SOC_INTERRUPT_STATS:
- dp_print_soc_interrupt_stats(pdev->soc);
- break;
- default:
- dp_info("Wrong Input For TxRx Host Stats");
- dp_txrx_stats_help();
- break;
- }
- return 0;
- }
- static void
- dp_ppdu_ring_reset(struct dp_pdev *pdev)
- {
- struct htt_rx_ring_tlv_filter htt_tlv_filter;
- int mac_id;
- qdf_mem_zero(&(htt_tlv_filter), sizeof(htt_tlv_filter));
- for (mac_id = 0; mac_id < NUM_RXDMA_RINGS_PER_PDEV; mac_id++) {
- int mac_for_pdev = dp_get_mac_id_for_pdev(mac_id,
- pdev->pdev_id);
- htt_h2t_rx_ring_cfg(pdev->soc->htt_handle, mac_for_pdev,
- pdev->rxdma_mon_status_ring[mac_id].hal_srng,
- RXDMA_MONITOR_STATUS, RX_BUFFER_SIZE, &htt_tlv_filter);
- }
- }
- static void
- dp_ppdu_ring_cfg(struct dp_pdev *pdev)
- {
- struct htt_rx_ring_tlv_filter htt_tlv_filter = {0};
- int mac_id;
- htt_tlv_filter.mpdu_start = 1;
- htt_tlv_filter.msdu_start = 0;
- htt_tlv_filter.packet = 0;
- htt_tlv_filter.msdu_end = 0;
- htt_tlv_filter.mpdu_end = 0;
- htt_tlv_filter.attention = 0;
- htt_tlv_filter.ppdu_start = 1;
- htt_tlv_filter.ppdu_end = 1;
- htt_tlv_filter.ppdu_end_user_stats = 1;
- htt_tlv_filter.ppdu_end_user_stats_ext = 1;
- htt_tlv_filter.ppdu_end_status_done = 1;
- htt_tlv_filter.enable_fp = 1;
- htt_tlv_filter.enable_md = 0;
- if (pdev->neighbour_peers_added &&
- pdev->soc->hw_nac_monitor_support) {
- htt_tlv_filter.enable_md = 1;
- htt_tlv_filter.packet_header = 1;
- }
- if (pdev->mcopy_mode) {
- htt_tlv_filter.packet_header = 1;
- htt_tlv_filter.enable_mo = 1;
- }
- htt_tlv_filter.fp_mgmt_filter = FILTER_MGMT_ALL;
- htt_tlv_filter.fp_ctrl_filter = FILTER_CTRL_ALL;
- htt_tlv_filter.fp_data_filter = FILTER_DATA_ALL;
- htt_tlv_filter.mo_mgmt_filter = FILTER_MGMT_ALL;
- htt_tlv_filter.mo_ctrl_filter = FILTER_CTRL_ALL;
- htt_tlv_filter.mo_data_filter = FILTER_DATA_ALL;
- if (pdev->neighbour_peers_added &&
- pdev->soc->hw_nac_monitor_support)
- htt_tlv_filter.md_data_filter = FILTER_DATA_ALL;
- htt_tlv_filter.offset_valid = false;
- for (mac_id = 0; mac_id < NUM_RXDMA_RINGS_PER_PDEV; mac_id++) {
- int mac_for_pdev = dp_get_mac_id_for_pdev(mac_id,
- pdev->pdev_id);
- htt_h2t_rx_ring_cfg(pdev->soc->htt_handle, mac_for_pdev,
- pdev->rxdma_mon_status_ring[mac_id].hal_srng,
- RXDMA_MONITOR_STATUS, RX_BUFFER_SIZE, &htt_tlv_filter);
- }
- }
- static inline bool is_ppdu_txrx_capture_enabled(struct dp_pdev *pdev)
- {
- if (!pdev->pktlog_ppdu_stats && !pdev->tx_sniffer_enable &&
- !pdev->mcopy_mode)
- return true;
- else
- return false;
- }
- static QDF_STATUS
- dp_set_bpr_enable(struct cdp_pdev *pdev_handle, int val)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
- switch (val) {
- case CDP_BPR_DISABLE:
- pdev->bpr_enable = CDP_BPR_DISABLE;
- if (!pdev->pktlog_ppdu_stats && !pdev->enhanced_stats_en &&
- !pdev->tx_sniffer_enable && !pdev->mcopy_mode) {
- dp_h2t_cfg_stats_msg_send(pdev, 0, pdev->pdev_id);
- } else if (pdev->enhanced_stats_en &&
- !pdev->tx_sniffer_enable && !pdev->mcopy_mode &&
- !pdev->pktlog_ppdu_stats) {
- dp_h2t_cfg_stats_msg_send(pdev,
- DP_PPDU_STATS_CFG_ENH_STATS,
- pdev->pdev_id);
- }
- break;
- case CDP_BPR_ENABLE:
- pdev->bpr_enable = CDP_BPR_ENABLE;
- if (!pdev->enhanced_stats_en && !pdev->tx_sniffer_enable &&
- !pdev->mcopy_mode && !pdev->pktlog_ppdu_stats) {
- dp_h2t_cfg_stats_msg_send(pdev,
- DP_PPDU_STATS_CFG_BPR,
- pdev->pdev_id);
- } else if (pdev->enhanced_stats_en &&
- !pdev->tx_sniffer_enable && !pdev->mcopy_mode &&
- !pdev->pktlog_ppdu_stats) {
- dp_h2t_cfg_stats_msg_send(pdev,
- DP_PPDU_STATS_CFG_BPR_ENH,
- pdev->pdev_id);
- } else if (pdev->pktlog_ppdu_stats) {
- dp_h2t_cfg_stats_msg_send(pdev,
- DP_PPDU_STATS_CFG_BPR_PKTLOG,
- pdev->pdev_id);
- }
- break;
- default:
- break;
- }
- return QDF_STATUS_SUCCESS;
- }
- static void
- dp_pdev_tid_stats_ingress_inc(struct cdp_pdev *pdev, uint32_t val)
- {
- struct dp_pdev *dp_pdev = (struct dp_pdev *)pdev;
- dp_pdev->stats.tid_stats.ingress_stack += val;
- }
- static void
- dp_pdev_tid_stats_osif_drop(struct cdp_pdev *pdev, uint32_t val)
- {
- struct dp_pdev *dp_pdev = (struct dp_pdev *)pdev;
- dp_pdev->stats.tid_stats.osif_drop += val;
- }
- static QDF_STATUS
- dp_config_debug_sniffer(struct cdp_pdev *pdev_handle, int val)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
- QDF_STATUS status = QDF_STATUS_SUCCESS;
- if (pdev->mcopy_mode)
- dp_reset_monitor_mode(pdev_handle);
- switch (val) {
- case 0:
- pdev->tx_sniffer_enable = 0;
- pdev->mcopy_mode = 0;
- pdev->monitor_configured = false;
- if (!pdev->pktlog_ppdu_stats && !pdev->enhanced_stats_en &&
- !pdev->bpr_enable) {
- dp_h2t_cfg_stats_msg_send(pdev, 0, pdev->pdev_id);
- dp_ppdu_ring_reset(pdev);
- } else if (pdev->enhanced_stats_en && !pdev->bpr_enable) {
- dp_h2t_cfg_stats_msg_send(pdev,
- DP_PPDU_STATS_CFG_ENH_STATS, pdev->pdev_id);
- } else if (!pdev->enhanced_stats_en && pdev->bpr_enable) {
- dp_h2t_cfg_stats_msg_send(pdev,
- DP_PPDU_STATS_CFG_BPR_ENH,
- pdev->pdev_id);
- } else {
- dp_h2t_cfg_stats_msg_send(pdev,
- DP_PPDU_STATS_CFG_BPR,
- pdev->pdev_id);
- }
- break;
- case 1:
- pdev->tx_sniffer_enable = 1;
- pdev->mcopy_mode = 0;
- pdev->monitor_configured = false;
- if (!pdev->pktlog_ppdu_stats)
- dp_h2t_cfg_stats_msg_send(pdev,
- DP_PPDU_STATS_CFG_SNIFFER, pdev->pdev_id);
- break;
- case 2:
- if (pdev->monitor_vdev) {
- status = QDF_STATUS_E_RESOURCES;
- break;
- }
- pdev->mcopy_mode = 1;
- dp_pdev_configure_monitor_rings(pdev);
- pdev->monitor_configured = true;
- pdev->tx_sniffer_enable = 0;
- if (!pdev->pktlog_ppdu_stats)
- dp_h2t_cfg_stats_msg_send(pdev,
- DP_PPDU_STATS_CFG_SNIFFER, pdev->pdev_id);
- break;
- default:
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- "Invalid value");
- break;
- }
- return status;
- }
- static void
- dp_enable_enhanced_stats(struct cdp_pdev *pdev_handle)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
- if (pdev->enhanced_stats_en == 0)
- dp_cal_client_timer_start(pdev->cal_client_ctx);
- pdev->enhanced_stats_en = 1;
- if (!pdev->mcopy_mode && !pdev->neighbour_peers_added &&
- !pdev->monitor_vdev)
- dp_ppdu_ring_cfg(pdev);
- if (is_ppdu_txrx_capture_enabled(pdev) && !pdev->bpr_enable) {
- dp_h2t_cfg_stats_msg_send(pdev, DP_PPDU_STATS_CFG_ENH_STATS, pdev->pdev_id);
- } else if (is_ppdu_txrx_capture_enabled(pdev) && pdev->bpr_enable) {
- dp_h2t_cfg_stats_msg_send(pdev,
- DP_PPDU_STATS_CFG_BPR_ENH,
- pdev->pdev_id);
- }
- }
- static void
- dp_disable_enhanced_stats(struct cdp_pdev *pdev_handle)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
- if (pdev->enhanced_stats_en == 1)
- dp_cal_client_timer_stop(pdev->cal_client_ctx);
- pdev->enhanced_stats_en = 0;
- if (is_ppdu_txrx_capture_enabled(pdev) && !pdev->bpr_enable) {
- dp_h2t_cfg_stats_msg_send(pdev, 0, pdev->pdev_id);
- } else if (is_ppdu_txrx_capture_enabled(pdev) && pdev->bpr_enable) {
- dp_h2t_cfg_stats_msg_send(pdev,
- DP_PPDU_STATS_CFG_BPR,
- pdev->pdev_id);
- }
- if (!pdev->mcopy_mode && !pdev->neighbour_peers_added &&
- !pdev->monitor_vdev)
- dp_ppdu_ring_reset(pdev);
- }
- static void
- dp_get_fw_peer_stats(struct cdp_pdev *pdev_handle, uint8_t *mac_addr,
- uint32_t cap, uint32_t is_wait)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
- int i;
- uint32_t config_param0 = 0;
- uint32_t config_param1 = 0;
- uint32_t config_param2 = 0;
- uint32_t config_param3 = 0;
- HTT_DBG_EXT_STATS_PEER_INFO_IS_MAC_ADDR_SET(config_param0, 1);
- config_param0 |= (1 << (cap + 1));
- for (i = 0; i < HTT_PEER_STATS_MAX_TLV; i++) {
- config_param1 |= (1 << i);
- }
- config_param2 |= (mac_addr[0] & 0x000000ff);
- config_param2 |= ((mac_addr[1] << 8) & 0x0000ff00);
- config_param2 |= ((mac_addr[2] << 16) & 0x00ff0000);
- config_param2 |= ((mac_addr[3] << 24) & 0xff000000);
- config_param3 |= (mac_addr[4] & 0x000000ff);
- config_param3 |= ((mac_addr[5] << 8) & 0x0000ff00);
- if (is_wait) {
- qdf_event_reset(&pdev->fw_peer_stats_event);
- dp_h2t_ext_stats_msg_send(pdev, HTT_DBG_EXT_STATS_PEER_INFO,
- config_param0, config_param1,
- config_param2, config_param3,
- 0, 1, 0);
- qdf_wait_single_event(&pdev->fw_peer_stats_event,
- DP_FW_PEER_STATS_CMP_TIMEOUT_MSEC);
- } else {
- dp_h2t_ext_stats_msg_send(pdev, HTT_DBG_EXT_STATS_PEER_INFO,
- config_param0, config_param1,
- config_param2, config_param3,
- 0, 0, 0);
- }
- }
- struct httstats_cmd_req {
- uint32_t config_param0;
- uint32_t config_param1;
- uint32_t config_param2;
- uint32_t config_param3;
- int cookie;
- u_int8_t stats_id;
- };
- static void
- dp_get_htt_stats(struct cdp_pdev *pdev_handle, void *data, uint32_t data_len)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
- struct httstats_cmd_req *req = (struct httstats_cmd_req *)data;
- QDF_ASSERT(data_len == sizeof(struct httstats_cmd_req));
- dp_h2t_ext_stats_msg_send(pdev, req->stats_id,
- req->config_param0, req->config_param1,
- req->config_param2, req->config_param3,
- req->cookie, 0, 0);
- }
- static QDF_STATUS dp_set_pdev_param(struct cdp_pdev *pdev_handle,
- enum cdp_pdev_param_type param,
- uint8_t val)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
- switch (param) {
- case CDP_CONFIG_DEBUG_SNIFFER:
- return dp_config_debug_sniffer(pdev_handle, val);
- case CDP_CONFIG_BPR_ENABLE:
- return dp_set_bpr_enable(pdev_handle, val);
- case CDP_CONFIG_PRIMARY_RADIO:
- pdev->is_primary = val;
- break;
- case CDP_CONFIG_CAPTURE_LATENCY:
- if (val == 1)
- pdev->latency_capture_enable = true;
- else
- pdev->latency_capture_enable = false;
- break;
- case CDP_INGRESS_STATS:
- dp_pdev_tid_stats_ingress_inc(pdev_handle, val);
- break;
- case CDP_OSIF_DROP:
- dp_pdev_tid_stats_osif_drop(pdev_handle, val);
- break;
- case CDP_CONFIG_ENH_RX_CAPTURE:
- return dp_config_enh_rx_capture(pdev_handle, val);
- case CDP_CONFIG_TX_CAPTURE:
- return dp_config_enh_tx_capture(pdev_handle, val);
- default:
- return QDF_STATUS_E_INVAL;
- }
- return QDF_STATUS_SUCCESS;
- }
- static void dp_calculate_delay_stats(struct cdp_vdev *vdev_handle,
- qdf_nbuf_t nbuf)
- {
- struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle;
- dp_rx_compute_delay(vdev, nbuf);
- }
- static uint32_t dp_get_vdev_param(struct cdp_vdev *vdev_handle,
- enum cdp_vdev_param_type param)
- {
- struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle;
- uint32_t val;
- switch (param) {
- case CDP_ENABLE_WDS:
- val = vdev->wds_enabled;
- break;
- case CDP_ENABLE_MEC:
- val = vdev->mec_enabled;
- break;
- case CDP_ENABLE_DA_WAR:
- val = vdev->pdev->soc->da_war_enabled;
- break;
- default:
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- "param value %d is wrong\n",
- param);
- val = -1;
- break;
- }
- return val;
- }
- static void dp_set_vdev_param(struct cdp_vdev *vdev_handle,
- enum cdp_vdev_param_type param, uint32_t val)
- {
- struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle;
- switch (param) {
- case CDP_ENABLE_WDS:
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- "wds_enable %d for vdev(%p) id(%d)\n",
- val, vdev, vdev->vdev_id);
- vdev->wds_enabled = val;
- break;
- case CDP_ENABLE_MEC:
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- "mec_enable %d for vdev(%p) id(%d)\n",
- val, vdev, vdev->vdev_id);
- vdev->mec_enabled = val;
- break;
- case CDP_ENABLE_DA_WAR:
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- "da_war_enable %d for vdev(%p) id(%d)\n",
- val, vdev, vdev->vdev_id);
- vdev->pdev->soc->da_war_enabled = val;
- dp_wds_flush_ast_table_wifi3(((struct cdp_soc_t *)
- vdev->pdev->soc));
- break;
- case CDP_ENABLE_NAWDS:
- vdev->nawds_enabled = val;
- break;
- case CDP_ENABLE_MCAST_EN:
- vdev->mcast_enhancement_en = val;
- break;
- case CDP_ENABLE_PROXYSTA:
- vdev->proxysta_vdev = val;
- break;
- case CDP_UPDATE_TDLS_FLAGS:
- vdev->tdls_link_connected = val;
- break;
- case CDP_CFG_WDS_AGING_TIMER:
- if (val == 0)
- qdf_timer_stop(&vdev->pdev->soc->ast_aging_timer);
- else if (val != vdev->wds_aging_timer_val)
- qdf_timer_mod(&vdev->pdev->soc->ast_aging_timer, val);
- vdev->wds_aging_timer_val = val;
- break;
- case CDP_ENABLE_AP_BRIDGE:
- if (wlan_op_mode_sta != vdev->opmode)
- vdev->ap_bridge_enabled = val;
- else
- vdev->ap_bridge_enabled = false;
- break;
- case CDP_ENABLE_CIPHER:
- vdev->sec_type = val;
- break;
- case CDP_ENABLE_QWRAP_ISOLATION:
- vdev->isolation_vdev = val;
- break;
- default:
- break;
- }
- dp_tx_vdev_update_search_flags(vdev);
- }
- static void dp_peer_set_nawds(struct cdp_peer *peer_handle, uint8_t value)
- {
- struct dp_peer *peer = (struct dp_peer *)peer_handle;
- peer->nawds_enabled = value;
- }
- static void dp_set_vdev_dscp_tid_map_wifi3(struct cdp_vdev *vdev_handle,
- uint8_t map_id)
- {
- struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle;
- vdev->dscp_tid_map_id = map_id;
- return;
- }
- #ifdef DP_RATETABLE_SUPPORT
- static int dp_txrx_get_ratekbps(int preamb, int mcs,
- int htflag, int gintval)
- {
- uint32_t rix;
- return dp_getrateindex((uint32_t)gintval, (uint16_t)mcs, 1,
- (uint8_t)preamb, 1, &rix);
- }
- #else
- static int dp_txrx_get_ratekbps(int preamb, int mcs,
- int htflag, int gintval)
- {
- return 0;
- }
- #endif
- static struct cdp_pdev_stats*
- dp_txrx_get_pdev_stats(struct cdp_pdev *pdev_handle)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
- dp_aggregate_pdev_stats(pdev);
- return &pdev->stats;
- }
- static void dp_txrx_update_vdev_me_stats(struct cdp_vdev *vdev_handle,
- void *buf)
- {
- struct dp_vdev *vdev = NULL;
- struct cdp_tx_ingress_stats *host_stats = NULL;
- if (!vdev_handle) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- "Invalid vdev handle");
- return;
- }
- vdev = (struct dp_vdev *)vdev_handle;
- if (!buf) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- "Invalid host stats buf");
- return;
- }
- host_stats = (struct cdp_tx_ingress_stats *)buf;
- DP_STATS_INC_PKT(vdev, tx_i.mcast_en.mcast_pkt,
- host_stats->mcast_en.mcast_pkt.num,
- host_stats->mcast_en.mcast_pkt.bytes);
- DP_STATS_INC(vdev, tx_i.mcast_en.dropped_map_error,
- host_stats->mcast_en.dropped_map_error);
- DP_STATS_INC(vdev, tx_i.mcast_en.dropped_self_mac,
- host_stats->mcast_en.dropped_self_mac);
- DP_STATS_INC(vdev, tx_i.mcast_en.dropped_send_fail,
- host_stats->mcast_en.dropped_send_fail);
- DP_STATS_INC(vdev, tx_i.mcast_en.ucast,
- host_stats->mcast_en.ucast);
- DP_STATS_INC(vdev, tx_i.mcast_en.fail_seg_alloc,
- host_stats->mcast_en.fail_seg_alloc);
- DP_STATS_INC(vdev, tx_i.mcast_en.clone_fail,
- host_stats->mcast_en.clone_fail);
- }
- static void dp_txrx_update_vdev_host_stats(struct cdp_vdev *vdev_handle,
- void *buf,
- uint16_t stats_id)
- {
- switch (stats_id) {
- case DP_VDEV_STATS_PKT_CNT_ONLY:
- break;
- case DP_VDEV_STATS_TX_ME:
- dp_txrx_update_vdev_me_stats(vdev_handle, buf);
- break;
- default:
- qdf_info("Invalid stats_id %d", stats_id);
- break;
- }
- }
- static struct cdp_peer_stats*
- dp_txrx_get_peer_stats(struct cdp_peer *peer_handle)
- {
- struct dp_peer *peer = (struct dp_peer *)peer_handle;
- qdf_assert(peer);
- return &peer->stats;
- }
- static void dp_txrx_reset_peer_stats(struct cdp_peer *peer_handle)
- {
- struct dp_peer *peer = (struct dp_peer *)peer_handle;
- qdf_assert(peer);
- qdf_mem_zero(&peer->stats, sizeof(peer->stats));
- }
- static int dp_txrx_get_vdev_stats(struct cdp_vdev *vdev_handle, void *buf,
- bool is_aggregate)
- {
- struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle;
- struct cdp_vdev_stats *vdev_stats;
- struct dp_pdev *pdev;
- struct dp_soc *soc;
- if (!vdev)
- return 1;
- pdev = vdev->pdev;
- if (!pdev)
- return 1;
- soc = pdev->soc;
- vdev_stats = (struct cdp_vdev_stats *)buf;
- if (is_aggregate) {
- qdf_spin_lock_bh(&soc->peer_ref_mutex);
- dp_aggregate_vdev_stats(vdev, buf);
- qdf_spin_unlock_bh(&soc->peer_ref_mutex);
- } else {
- qdf_mem_copy(vdev_stats, &vdev->stats, sizeof(vdev->stats));
- }
- return 0;
- }
- static int dp_get_total_per(struct cdp_pdev *pdev_handle)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
- dp_aggregate_pdev_stats(pdev);
- if ((pdev->stats.tx.tx_success.num + pdev->stats.tx.retries) == 0)
- return 0;
- return ((pdev->stats.tx.retries * 100) /
- ((pdev->stats.tx.tx_success.num) + (pdev->stats.tx.retries)));
- }
- static int
- dp_txrx_stats_publish(struct cdp_pdev *pdev_handle, struct cdp_stats_extd *buf)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
- struct cdp_pdev_stats *buffer = (struct cdp_pdev_stats *) buf;
- struct cdp_txrx_stats_req req = {0,};
- dp_aggregate_pdev_stats(pdev);
- req.stats = (enum cdp_stats)HTT_DBG_EXT_STATS_PDEV_TX;
- req.cookie_val = 1;
- dp_h2t_ext_stats_msg_send(pdev, req.stats, req.param0,
- req.param1, req.param2, req.param3, 0,
- req.cookie_val, 0);
- msleep(DP_MAX_SLEEP_TIME);
- req.stats = (enum cdp_stats)HTT_DBG_EXT_STATS_PDEV_RX;
- req.cookie_val = 1;
- dp_h2t_ext_stats_msg_send(pdev, req.stats, req.param0,
- req.param1, req.param2, req.param3, 0,
- req.cookie_val, 0);
- msleep(DP_MAX_SLEEP_TIME);
- qdf_mem_copy(buffer, &pdev->stats, sizeof(pdev->stats));
- return TXRX_STATS_LEVEL;
- }
- static void dp_set_pdev_dscp_tid_map_wifi3(struct cdp_pdev *pdev_handle,
- uint8_t map_id, uint8_t tos, uint8_t tid)
- {
- uint8_t dscp;
- struct dp_pdev *pdev = (struct dp_pdev *) pdev_handle;
- struct dp_soc *soc = pdev->soc;
- if (!soc)
- return;
- dscp = (tos >> DP_IP_DSCP_SHIFT) & DP_IP_DSCP_MASK;
- pdev->dscp_tid_map[map_id][dscp] = tid;
- if (map_id < soc->num_hw_dscp_tid_map)
- hal_tx_update_dscp_tid(soc->hal_soc, tid,
- map_id, dscp);
- return;
- }
- static void dp_hmmc_tid_override_en_wifi3(struct cdp_pdev *pdev_handle,
- bool val)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
- pdev->hmmc_tid_override_en = val;
- }
- static void dp_set_hmmc_tid_val_wifi3(struct cdp_pdev *pdev_handle,
- uint8_t tid)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
- pdev->hmmc_tid = tid;
- }
- static int dp_fw_stats_process(struct cdp_vdev *vdev_handle,
- struct cdp_txrx_stats_req *req)
- {
- struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle;
- struct dp_pdev *pdev = NULL;
- uint32_t stats = req->stats;
- uint8_t mac_id = req->mac_id;
- if (!vdev) {
- DP_TRACE(NONE, "VDEV not found");
- return 1;
- }
- pdev = vdev->pdev;
-
- if (req->stats == CDP_TXRX_STATS_0) {
- req->param0 = HTT_DBG_EXT_STATS_PDEV_TX;
- req->param1 = 0xFFFFFFFF;
- req->param2 = 0xFFFFFFFF;
- req->param3 = 0xFFFFFFFF;
- } else if (req->stats == (uint8_t)HTT_DBG_EXT_STATS_PDEV_TX_MU) {
- req->param0 = HTT_DBG_EXT_STATS_SET_VDEV_MASK(vdev->vdev_id);
- }
- return dp_h2t_ext_stats_msg_send(pdev, stats, req->param0,
- req->param1, req->param2, req->param3,
- 0, 0, mac_id);
- }
- static
- QDF_STATUS dp_txrx_stats_request(struct cdp_vdev *vdev,
- struct cdp_txrx_stats_req *req)
- {
- int host_stats;
- int fw_stats;
- enum cdp_stats stats;
- int num_stats;
- if (!vdev || !req) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- "Invalid vdev/req instance");
- return QDF_STATUS_E_INVAL;
- }
- if (req->mac_id >= WLAN_CFG_MAC_PER_TARGET) {
- dp_err("Invalid mac id request");
- return QDF_STATUS_E_INVAL;
- }
- stats = req->stats;
- if (stats >= CDP_TXRX_MAX_STATS)
- return QDF_STATUS_E_INVAL;
-
- if (stats > CDP_TXRX_STATS_HTT_MAX)
- stats = stats + DP_CURR_FW_STATS_AVAIL - DP_HTT_DBG_EXT_STATS_MAX;
- num_stats = QDF_ARRAY_SIZE(dp_stats_mapping_table);
- if (stats >= num_stats) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- "%s: Invalid stats option: %d", __func__, stats);
- return QDF_STATUS_E_INVAL;
- }
- req->stats = stats;
- fw_stats = dp_stats_mapping_table[stats][STATS_FW];
- host_stats = dp_stats_mapping_table[stats][STATS_HOST];
- dp_info("stats: %u fw_stats_type: %d host_stats: %d",
- stats, fw_stats, host_stats);
- if (fw_stats != TXRX_FW_STATS_INVALID) {
-
- req->stats = fw_stats;
- return dp_fw_stats_process(vdev, req);
- }
- if ((host_stats != TXRX_HOST_STATS_INVALID) &&
- (host_stats <= TXRX_HOST_STATS_MAX))
- return dp_print_host_stats(vdev, req);
- else
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
- "Wrong Input for TxRx Stats");
- return QDF_STATUS_SUCCESS;
- }
- static QDF_STATUS dp_txrx_dump_stats(void *psoc, uint16_t value,
- enum qdf_stats_verbosity_level level)
- {
- struct dp_soc *soc =
- (struct dp_soc *)psoc;
- QDF_STATUS status = QDF_STATUS_SUCCESS;
- if (!soc) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- "%s: soc is NULL", __func__);
- return QDF_STATUS_E_INVAL;
- }
- switch (value) {
- case CDP_TXRX_PATH_STATS:
- dp_txrx_path_stats(soc);
- dp_print_soc_interrupt_stats(soc);
- break;
- case CDP_RX_RING_STATS:
- dp_print_per_ring_stats(soc);
- break;
- case CDP_TXRX_TSO_STATS:
-
- break;
- case CDP_DUMP_TX_FLOW_POOL_INFO:
- cdp_dump_flow_pool_info((struct cdp_soc_t *)soc);
- break;
- case CDP_DP_NAPI_STATS:
- dp_print_napi_stats(soc);
- break;
- case CDP_TXRX_DESC_STATS:
-
- break;
- default:
- status = QDF_STATUS_E_INVAL;
- break;
- }
- return status;
- }
- #ifdef QCA_LL_TX_FLOW_CONTROL_V2
- static inline
- void dp_update_flow_control_parameters(struct dp_soc *soc,
- struct cdp_config_params *params)
- {
- soc->wlan_cfg_ctx->tx_flow_stop_queue_threshold =
- params->tx_flow_stop_queue_threshold;
- soc->wlan_cfg_ctx->tx_flow_start_queue_offset =
- params->tx_flow_start_queue_offset;
- }
- #else
- static inline
- void dp_update_flow_control_parameters(struct dp_soc *soc,
- struct cdp_config_params *params)
- {
- }
- #endif
- #ifdef WLAN_FEATURE_RX_SOFTIRQ_TIME_LIMIT
- #define DP_TX_COMP_LOOP_PKT_LIMIT_MAX 1024
- #define DP_RX_REAP_LOOP_PKT_LIMIT_MAX 1024
- static
- void dp_update_rx_soft_irq_limit_params(struct dp_soc *soc,
- struct cdp_config_params *params)
- {
- soc->wlan_cfg_ctx->tx_comp_loop_pkt_limit =
- params->tx_comp_loop_pkt_limit;
- if (params->tx_comp_loop_pkt_limit < DP_TX_COMP_LOOP_PKT_LIMIT_MAX)
- soc->wlan_cfg_ctx->tx_comp_enable_eol_data_check = true;
- else
- soc->wlan_cfg_ctx->tx_comp_enable_eol_data_check = false;
- soc->wlan_cfg_ctx->rx_reap_loop_pkt_limit =
- params->rx_reap_loop_pkt_limit;
- if (params->rx_reap_loop_pkt_limit < DP_RX_REAP_LOOP_PKT_LIMIT_MAX)
- soc->wlan_cfg_ctx->rx_enable_eol_data_check = true;
- else
- soc->wlan_cfg_ctx->rx_enable_eol_data_check = false;
- soc->wlan_cfg_ctx->rx_hp_oos_update_limit =
- params->rx_hp_oos_update_limit;
- dp_info("tx_comp_loop_pkt_limit %u tx_comp_enable_eol_data_check %u rx_reap_loop_pkt_limit %u rx_enable_eol_data_check %u rx_hp_oos_update_limit %u",
- soc->wlan_cfg_ctx->tx_comp_loop_pkt_limit,
- soc->wlan_cfg_ctx->tx_comp_enable_eol_data_check,
- soc->wlan_cfg_ctx->rx_reap_loop_pkt_limit,
- soc->wlan_cfg_ctx->rx_enable_eol_data_check,
- soc->wlan_cfg_ctx->rx_hp_oos_update_limit);
- }
- #else
- static inline
- void dp_update_rx_soft_irq_limit_params(struct dp_soc *soc,
- struct cdp_config_params *params)
- { }
- #endif
- static
- QDF_STATUS dp_update_config_parameters(struct cdp_soc *psoc,
- struct cdp_config_params *params)
- {
- struct dp_soc *soc = (struct dp_soc *)psoc;
- if (!(soc)) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- "%s: Invalid handle", __func__);
- return QDF_STATUS_E_INVAL;
- }
- soc->wlan_cfg_ctx->tso_enabled = params->tso_enable;
- soc->wlan_cfg_ctx->lro_enabled = params->lro_enable;
- soc->wlan_cfg_ctx->rx_hash = params->flow_steering_enable;
- soc->wlan_cfg_ctx->tcp_udp_checksumoffload =
- params->tcp_udp_checksumoffload;
- soc->wlan_cfg_ctx->napi_enabled = params->napi_enable;
- soc->wlan_cfg_ctx->ipa_enabled = params->ipa_enable;
- soc->wlan_cfg_ctx->gro_enabled = params->gro_enable;
- dp_update_rx_soft_irq_limit_params(soc, params);
- dp_update_flow_control_parameters(soc, params);
- return QDF_STATUS_SUCCESS;
- }
- static struct cdp_wds_ops dp_ops_wds = {
- .vdev_set_wds = dp_vdev_set_wds,
- #ifdef WDS_VENDOR_EXTENSION
- .txrx_set_wds_rx_policy = dp_txrx_set_wds_rx_policy,
- .txrx_wds_peer_tx_policy_update = dp_txrx_peer_wds_tx_policy_update,
- #endif
- };
- static void
- dp_txrx_data_tx_cb_set(struct cdp_vdev *vdev_handle,
- ol_txrx_data_tx_cb callback, void *ctxt)
- {
- struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle;
- vdev->tx_non_std_data_callback.func = callback;
- vdev->tx_non_std_data_callback.ctxt = ctxt;
- }
- static void *dp_pdev_get_dp_txrx_handle(struct cdp_pdev *pdev_hdl)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)pdev_hdl;
- return pdev->dp_txrx_handle;
- }
- static void
- dp_pdev_set_dp_txrx_handle(struct cdp_pdev *pdev_hdl, void *dp_txrx_hdl)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)pdev_hdl;
- pdev->dp_txrx_handle = dp_txrx_hdl;
- }
- static void *dp_soc_get_dp_txrx_handle(struct cdp_soc *soc_handle)
- {
- struct dp_soc *soc = (struct dp_soc *)soc_handle;
- return soc->external_txrx_handle;
- }
- static void
- dp_soc_set_dp_txrx_handle(struct cdp_soc *soc_handle, void *txrx_handle)
- {
- struct dp_soc *soc = (struct dp_soc *)soc_handle;
- soc->external_txrx_handle = txrx_handle;
- }
- static void
- dp_soc_map_pdev_to_lmac(struct cdp_pdev *pdev_hdl, uint32_t lmac_id)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)pdev_hdl;
- struct dp_soc *soc = pdev->soc;
- pdev->lmac_id = lmac_id;
- wlan_cfg_set_hw_macid(soc->wlan_cfg_ctx,
- pdev->pdev_id,
- (lmac_id + 1));
- }
- static bool
- dp_get_cfg_capabilities(struct cdp_soc_t *soc_handle,
- enum cdp_capabilities dp_caps)
- {
- struct dp_soc *soc = (struct dp_soc *)soc_handle;
- return wlan_cfg_get_dp_caps(soc->wlan_cfg_ctx, dp_caps);
- }
- #ifdef FEATURE_AST
- static void dp_peer_teardown_wifi3(struct cdp_vdev *vdev_hdl, void *peer_hdl)
- {
- struct dp_vdev *vdev = (struct dp_vdev *)vdev_hdl;
- struct dp_peer *peer = (struct dp_peer *)peer_hdl;
- struct dp_soc *soc = (struct dp_soc *)vdev->pdev->soc;
-
- if (peer->bss_peer && (qdf_atomic_read(&peer->ref_cnt) > 2))
- return;
- qdf_spin_lock_bh(&soc->ast_lock);
- peer->delete_in_progress = true;
- dp_peer_delete_ast_entries(soc, peer);
- qdf_spin_unlock_bh(&soc->ast_lock);
- }
- #endif
- #ifdef ATH_SUPPORT_NAC_RSSI
- static QDF_STATUS dp_vdev_get_neighbour_rssi(struct cdp_vdev *vdev_hdl,
- char *mac_addr,
- uint8_t *rssi)
- {
- struct dp_vdev *vdev = (struct dp_vdev *)vdev_hdl;
- struct dp_pdev *pdev = vdev->pdev;
- struct dp_neighbour_peer *peer = NULL;
- QDF_STATUS status = QDF_STATUS_E_FAILURE;
- *rssi = 0;
- qdf_spin_lock_bh(&pdev->neighbour_peer_mutex);
- TAILQ_FOREACH(peer, &pdev->neighbour_peers_list,
- neighbour_peer_list_elem) {
- if (qdf_mem_cmp(&peer->neighbour_peers_macaddr.raw[0],
- mac_addr, QDF_MAC_ADDR_SIZE) == 0) {
- *rssi = peer->rssi;
- status = QDF_STATUS_SUCCESS;
- break;
- }
- }
- qdf_spin_unlock_bh(&pdev->neighbour_peer_mutex);
- return status;
- }
- static QDF_STATUS dp_config_for_nac_rssi(struct cdp_vdev *vdev_handle,
- enum cdp_nac_param_cmd cmd, char *bssid, char *client_macaddr,
- uint8_t chan_num)
- {
- struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle;
- struct dp_pdev *pdev = (struct dp_pdev *)vdev->pdev;
- struct dp_soc *soc = (struct dp_soc *) vdev->pdev->soc;
- pdev->nac_rssi_filtering = 1;
-
- if (cmd == CDP_NAC_PARAM_ADD) {
- dp_update_filter_neighbour_peers(vdev_handle, DP_NAC_PARAM_ADD,
- client_macaddr);
- } else if (cmd == CDP_NAC_PARAM_DEL) {
- dp_update_filter_neighbour_peers(vdev_handle,
- DP_NAC_PARAM_DEL,
- client_macaddr);
- }
- if (soc->cdp_soc.ol_ops->config_bssid_in_fw_for_nac_rssi)
- soc->cdp_soc.ol_ops->config_bssid_in_fw_for_nac_rssi
- ((void *)vdev->pdev->ctrl_pdev,
- vdev->vdev_id, cmd, bssid);
- return QDF_STATUS_SUCCESS;
- }
- #endif
- static int
- dp_enable_peer_based_pktlog(
- struct cdp_pdev *txrx_pdev_handle,
- char *mac_addr, uint8_t enb_dsb)
- {
- struct dp_peer *peer;
- uint8_t local_id;
- struct dp_pdev *pdev = (struct dp_pdev *)txrx_pdev_handle;
- peer = (struct dp_peer *)dp_find_peer_by_addr(txrx_pdev_handle,
- mac_addr, &local_id);
- if (!peer) {
- dp_err("Invalid Peer");
- return QDF_STATUS_E_FAILURE;
- }
- peer->peer_based_pktlog_filter = enb_dsb;
- pdev->dp_peer_based_pktlog = enb_dsb;
- return QDF_STATUS_SUCCESS;
- }
- #ifdef WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG
- #ifdef WLAN_SUPPORT_RX_TAG_STATISTICS
- static uint64_t dp_summarize_tag_stats(struct cdp_pdev *pdev_handle,
- uint16_t protocol_type)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
- uint8_t ring_idx;
- uint64_t total_tag_cnt = 0;
- for (ring_idx = 0; ring_idx < MAX_REO_DEST_RINGS; ring_idx++) {
- total_tag_cnt +=
- pdev->reo_proto_tag_stats[ring_idx][protocol_type].tag_ctr;
- }
- total_tag_cnt += pdev->rx_err_proto_tag_stats[protocol_type].tag_ctr;
- DP_PRINT_STATS("ProtoID: %d, Tag: %u Tagged MSDU cnt: %llu",
- protocol_type,
- pdev->rx_proto_tag_map[protocol_type].tag,
- total_tag_cnt);
- return total_tag_cnt;
- }
- static void
- dp_dump_pdev_rx_protocol_tag_stats(struct cdp_pdev *pdev_handle,
- uint16_t protocol_type)
- {
- uint16_t proto_idx;
- if (protocol_type != RX_PROTOCOL_TAG_ALL &&
- protocol_type >= RX_PROTOCOL_TAG_MAX) {
- DP_PRINT_STATS("Invalid protocol type : %u", protocol_type);
- return;
- }
-
- if (protocol_type != RX_PROTOCOL_TAG_ALL) {
- dp_summarize_tag_stats(pdev_handle, protocol_type);
- return;
- }
-
- for (proto_idx = 0; proto_idx < RX_PROTOCOL_TAG_MAX; proto_idx++)
- dp_summarize_tag_stats(pdev_handle, proto_idx);
- }
- #endif
- #ifdef WLAN_SUPPORT_RX_TAG_STATISTICS
- static void
- dp_reset_pdev_rx_protocol_tag_stats(struct cdp_pdev *pdev_handle,
- uint16_t protocol_type)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
- uint8_t ring_idx;
- for (ring_idx = 0; ring_idx < MAX_REO_DEST_RINGS; ring_idx++)
- pdev->reo_proto_tag_stats[ring_idx][protocol_type].tag_ctr = 0;
- pdev->rx_err_proto_tag_stats[protocol_type].tag_ctr = 0;
- }
- #else
- static void
- dp_reset_pdev_rx_protocol_tag_stats(struct cdp_pdev *pdev_handle,
- uint16_t protocol_type)
- {
-
- }
- #endif
- static QDF_STATUS
- dp_update_pdev_rx_protocol_tag(struct cdp_pdev *pdev_handle,
- uint32_t enable_rx_protocol_tag,
- uint16_t protocol_type,
- uint16_t tag)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
-
- if (enable_rx_protocol_tag) {
-
- pdev->is_rx_protocol_tagging_enabled = true;
- } else {
-
- pdev->is_rx_protocol_tagging_enabled = false;
- }
-
- dp_reset_pdev_rx_protocol_tag_stats(pdev_handle, protocol_type);
- pdev->rx_proto_tag_map[protocol_type].tag = tag;
- return QDF_STATUS_SUCCESS;
- }
- #endif
- static QDF_STATUS dp_peer_map_attach_wifi3(struct cdp_soc_t *soc_hdl,
- uint32_t max_peers,
- uint32_t max_ast_index,
- bool peer_map_unmap_v2)
- {
- struct dp_soc *soc = (struct dp_soc *)soc_hdl;
- soc->max_peers = max_peers;
- qdf_print ("%s max_peers %u, max_ast_index: %u\n",
- __func__, max_peers, max_ast_index);
- wlan_cfg_set_max_ast_idx(soc->wlan_cfg_ctx, max_ast_index);
- if (dp_peer_find_attach(soc))
- return QDF_STATUS_E_FAILURE;
- soc->is_peer_map_unmap_v2 = peer_map_unmap_v2;
- return QDF_STATUS_SUCCESS;
- }
- static void dp_pdev_set_ctrl_pdev(struct cdp_pdev *dp_pdev,
- struct cdp_ctrl_objmgr_pdev *ctrl_pdev)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)dp_pdev;
- pdev->ctrl_pdev = ctrl_pdev;
- }
- static void dp_set_rate_stats_cap(struct cdp_soc_t *soc_hdl,
- uint8_t val)
- {
- struct dp_soc *soc = (struct dp_soc *)soc_hdl;
- soc->wlanstats_enabled = val;
- }
- static void dp_soc_set_rate_stats_ctx(struct cdp_soc_t *soc_handle,
- void *stats_ctx)
- {
- struct dp_soc *soc = (struct dp_soc *)soc_handle;
- soc->rate_stats_ctx = stats_ctx;
- }
- #if defined(FEATURE_PERPKT_INFO) && WDI_EVENT_ENABLE
- static void dp_flush_rate_stats_req(struct cdp_soc_t *soc_hdl,
- struct cdp_pdev *pdev_hdl)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)pdev_hdl;
- struct dp_soc *soc = (struct dp_soc *)pdev->soc;
- struct dp_vdev *vdev = NULL;
- struct dp_peer *peer = NULL;
- qdf_spin_lock_bh(&soc->peer_ref_mutex);
- qdf_spin_lock_bh(&pdev->vdev_list_lock);
- TAILQ_FOREACH(vdev, &pdev->vdev_list, vdev_list_elem) {
- TAILQ_FOREACH(peer, &vdev->peer_list, peer_list_elem) {
- if (peer && !peer->bss_peer)
- dp_wdi_event_handler(
- WDI_EVENT_FLUSH_RATE_STATS_REQ,
- pdev->soc, peer->wlanstats_ctx,
- peer->peer_ids[0],
- WDI_NO_VAL, pdev->pdev_id);
- }
- }
- qdf_spin_unlock_bh(&pdev->vdev_list_lock);
- qdf_spin_unlock_bh(&soc->peer_ref_mutex);
- }
- #else
- static inline void
- dp_flush_rate_stats_req(struct cdp_soc_t *soc_hdl,
- struct cdp_pdev *pdev_hdl)
- {
- }
- #endif
- #if defined(FEATURE_PERPKT_INFO) && WDI_EVENT_ENABLE
- static void dp_peer_flush_rate_stats(struct cdp_soc_t *soc,
- struct cdp_pdev *pdev_handle,
- void *buf)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
- dp_wdi_event_handler(WDI_EVENT_PEER_FLUSH_RATE_STATS,
- pdev->soc, buf, HTT_INVALID_PEER,
- WDI_NO_VAL, pdev->pdev_id);
- }
- #else
- static inline void
- dp_peer_flush_rate_stats(struct cdp_soc_t *soc,
- struct cdp_pdev *pdev_handle,
- void *buf)
- {
- }
- #endif
- static void *dp_soc_get_rate_stats_ctx(struct cdp_soc_t *soc_handle)
- {
- struct dp_soc *soc = (struct dp_soc *)soc_handle;
- return soc->rate_stats_ctx;
- }
- static uint32_t dp_get_cfg(void *soc, enum cdp_dp_cfg cfg)
- {
- struct dp_soc *dpsoc = (struct dp_soc *)soc;
- uint32_t value = 0;
- switch (cfg) {
- case cfg_dp_enable_data_stall:
- value = dpsoc->wlan_cfg_ctx->enable_data_stall_detection;
- break;
- case cfg_dp_enable_ip_tcp_udp_checksum_offload:
- value = dpsoc->wlan_cfg_ctx->tcp_udp_checksumoffload;
- break;
- case cfg_dp_tso_enable:
- value = dpsoc->wlan_cfg_ctx->tso_enabled;
- break;
- case cfg_dp_lro_enable:
- value = dpsoc->wlan_cfg_ctx->lro_enabled;
- break;
- case cfg_dp_gro_enable:
- value = dpsoc->wlan_cfg_ctx->gro_enabled;
- break;
- case cfg_dp_tx_flow_start_queue_offset:
- value = dpsoc->wlan_cfg_ctx->tx_flow_start_queue_offset;
- break;
- case cfg_dp_tx_flow_stop_queue_threshold:
- value = dpsoc->wlan_cfg_ctx->tx_flow_stop_queue_threshold;
- break;
- case cfg_dp_disable_intra_bss_fwd:
- value = dpsoc->wlan_cfg_ctx->disable_intra_bss_fwd;
- break;
- default:
- value = 0;
- }
- return value;
- }
- #ifdef PEER_FLOW_CONTROL
- static uint32_t dp_tx_flow_ctrl_configure_pdev(void *pdev_handle,
- enum _ol_ath_param_t param,
- uint32_t value, void *buff)
- {
- struct dp_soc *soc = NULL;
- struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
- if (qdf_unlikely(!pdev))
- return 1;
- soc = pdev->soc;
- if (!soc)
- return 1;
- switch (param) {
- #ifdef QCA_ENH_V3_STATS_SUPPORT
- case OL_ATH_PARAM_VIDEO_DELAY_STATS_FC:
- if (value)
- pdev->delay_stats_flag = true;
- else
- pdev->delay_stats_flag = false;
- break;
- case OL_ATH_PARAM_VIDEO_STATS_FC:
- qdf_print("------- TID Stats ------\n");
- dp_pdev_print_tid_stats(pdev);
- qdf_print("------ Delay Stats ------\n");
- dp_pdev_print_delay_stats(pdev);
- break;
- #endif
- case OL_ATH_PARAM_TOTAL_Q_SIZE:
- {
- uint32_t tx_min, tx_max;
- tx_min = wlan_cfg_get_min_tx_desc(soc->wlan_cfg_ctx);
- tx_max = wlan_cfg_get_num_tx_desc(soc->wlan_cfg_ctx);
- if (!buff) {
- if ((value >= tx_min) && (value <= tx_max)) {
- pdev->num_tx_allowed = value;
- } else {
- QDF_TRACE(QDF_MODULE_ID_DP,
- QDF_TRACE_LEVEL_INFO,
- "Failed to update num_tx_allowed, Q_min = %d Q_max = %d",
- tx_min, tx_max);
- break;
- }
- } else {
- *(int *)buff = pdev->num_tx_allowed;
- }
- }
- break;
- default:
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
- "%s: not handled param %d ", __func__, param);
- break;
- }
- return 0;
- }
- #endif
- static QDF_STATUS dp_set_pdev_pcp_tid_map_wifi3(struct cdp_pdev *pdev_handle,
- uint8_t pcp, uint8_t tid)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
- struct dp_soc *soc = pdev->soc;
- soc->pcp_tid_map[pcp] = tid;
- hal_tx_update_pcp_tid_map(soc->hal_soc, pcp, tid);
- return QDF_STATUS_SUCCESS;
- }
- static QDF_STATUS dp_set_pdev_tidmap_prty_wifi3(struct cdp_pdev *pdev_handle,
- uint8_t prio)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
- struct dp_soc *soc = pdev->soc;
- soc->tidmap_prty = prio;
- hal_tx_set_tidmap_prty(soc->hal_soc, prio);
- return QDF_STATUS_SUCCESS;
- }
- static QDF_STATUS dp_set_vdev_pcp_tid_map_wifi3(struct cdp_vdev *vdev_handle,
- uint8_t pcp, uint8_t tid)
- {
- struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle;
- vdev->pcp_tid_map[pcp] = tid;
- return QDF_STATUS_SUCCESS;
- }
- static QDF_STATUS dp_set_vdev_tidmap_tbl_id_wifi3(struct cdp_vdev *vdev_handle,
- uint8_t mapid)
- {
- struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle;
- vdev->tidmap_tbl_id = mapid;
- return QDF_STATUS_SUCCESS;
- }
- static QDF_STATUS dp_set_vdev_tidmap_prty_wifi3(struct cdp_vdev *vdev_handle,
- uint8_t prio)
- {
- struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle;
- vdev->tidmap_prty = prio;
- return QDF_STATUS_SUCCESS;
- }
- static struct cdp_cmn_ops dp_ops_cmn = {
- .txrx_soc_attach_target = dp_soc_attach_target_wifi3,
- .txrx_vdev_attach = dp_vdev_attach_wifi3,
- .txrx_vdev_detach = dp_vdev_detach_wifi3,
- .txrx_pdev_attach = dp_pdev_attach_wifi3,
- .txrx_pdev_detach = dp_pdev_detach_wifi3,
- .txrx_pdev_deinit = dp_pdev_deinit_wifi3,
- .txrx_peer_create = dp_peer_create_wifi3,
- .txrx_peer_setup = dp_peer_setup_wifi3,
- #ifdef FEATURE_AST
- .txrx_peer_teardown = dp_peer_teardown_wifi3,
- #else
- .txrx_peer_teardown = NULL,
- #endif
- .txrx_peer_add_ast = dp_peer_add_ast_wifi3,
- .txrx_peer_update_ast = dp_peer_update_ast_wifi3,
- .txrx_peer_get_ast_info_by_soc = dp_peer_get_ast_info_by_soc_wifi3,
- .txrx_peer_get_ast_info_by_pdev =
- dp_peer_get_ast_info_by_pdevid_wifi3,
- .txrx_peer_ast_delete_by_soc =
- dp_peer_ast_entry_del_by_soc,
- .txrx_peer_ast_delete_by_pdev =
- dp_peer_ast_entry_del_by_pdev,
- .txrx_peer_delete = dp_peer_delete_wifi3,
- .txrx_vdev_register = dp_vdev_register_wifi3,
- .txrx_vdev_flush_peers = dp_vdev_flush_peers,
- .txrx_soc_detach = dp_soc_detach_wifi3,
- .txrx_soc_deinit = dp_soc_deinit_wifi3,
- .txrx_soc_init = dp_soc_init_wifi3,
- .txrx_tso_soc_attach = dp_tso_soc_attach,
- .txrx_tso_soc_detach = dp_tso_soc_detach,
- .txrx_get_vdev_mac_addr = dp_get_vdev_mac_addr_wifi3,
- .txrx_get_vdev_from_vdev_id = dp_get_vdev_from_vdev_id_wifi3,
- .txrx_get_mon_vdev_from_pdev = dp_get_mon_vdev_from_pdev_wifi3,
- .txrx_get_ctrl_pdev_from_vdev = dp_get_ctrl_pdev_from_vdev_wifi3,
- .txrx_ath_getstats = dp_get_device_stats,
- .addba_requestprocess = dp_addba_requestprocess_wifi3,
- .addba_responsesetup = dp_addba_responsesetup_wifi3,
- .addba_resp_tx_completion = dp_addba_resp_tx_completion_wifi3,
- .delba_process = dp_delba_process_wifi3,
- .set_addba_response = dp_set_addba_response,
- .get_peer_mac_addr_frm_id = dp_get_peer_mac_addr_frm_id,
- .flush_cache_rx_queue = NULL,
-
- .set_vdev_dscp_tid_map = dp_set_vdev_dscp_tid_map_wifi3,
- .set_pdev_dscp_tid_map = dp_set_pdev_dscp_tid_map_wifi3,
- .hmmc_tid_override_en = dp_hmmc_tid_override_en_wifi3,
- .set_hmmc_tid_val = dp_set_hmmc_tid_val_wifi3,
- .txrx_get_total_per = dp_get_total_per,
- .txrx_stats_request = dp_txrx_stats_request,
- .txrx_set_monitor_mode = dp_vdev_set_monitor_mode,
- .txrx_get_pdev_id_frm_pdev = dp_get_pdev_id_frm_pdev,
- .txrx_get_vow_config_frm_pdev = dp_get_delay_stats_flag,
- .txrx_pdev_set_chan_noise_floor = dp_pdev_set_chan_noise_floor,
- .txrx_set_nac = dp_set_nac,
- .txrx_get_tx_pending = dp_get_tx_pending,
- .txrx_set_pdev_tx_capture = dp_config_debug_sniffer,
- .txrx_get_peer_mac_from_peer_id = dp_get_peer_mac_from_peer_id,
- .display_stats = dp_txrx_dump_stats,
- .txrx_soc_set_nss_cfg = dp_soc_set_nss_cfg_wifi3,
- .txrx_soc_get_nss_cfg = dp_soc_get_nss_cfg_wifi3,
- .txrx_intr_attach = dp_soc_interrupt_attach_wrapper,
- .txrx_intr_detach = dp_soc_interrupt_detach,
- .set_pn_check = dp_set_pn_check_wifi3,
- .update_config_parameters = dp_update_config_parameters,
-
- .txrx_data_tx_cb_set = dp_txrx_data_tx_cb_set,
- .get_dp_txrx_handle = dp_pdev_get_dp_txrx_handle,
- .set_dp_txrx_handle = dp_pdev_set_dp_txrx_handle,
- .get_soc_dp_txrx_handle = dp_soc_get_dp_txrx_handle,
- .set_soc_dp_txrx_handle = dp_soc_set_dp_txrx_handle,
- .map_pdev_to_lmac = dp_soc_map_pdev_to_lmac,
- .txrx_set_ba_aging_timeout = dp_set_ba_aging_timeout,
- .txrx_get_ba_aging_timeout = dp_get_ba_aging_timeout,
- .tx_send = dp_tx_send,
- .txrx_peer_reset_ast = dp_wds_reset_ast_wifi3,
- .txrx_peer_reset_ast_table = dp_wds_reset_ast_table_wifi3,
- .txrx_peer_flush_ast_table = dp_wds_flush_ast_table_wifi3,
- .txrx_peer_map_attach = dp_peer_map_attach_wifi3,
- .txrx_pdev_set_ctrl_pdev = dp_pdev_set_ctrl_pdev,
- .txrx_get_os_rx_handles_from_vdev =
- dp_get_os_rx_handles_from_vdev_wifi3,
- .delba_tx_completion = dp_delba_tx_completion_wifi3,
- .get_dp_capabilities = dp_get_cfg_capabilities,
- .txrx_get_cfg = dp_get_cfg,
- .set_rate_stats_ctx = dp_soc_set_rate_stats_ctx,
- .get_rate_stats_ctx = dp_soc_get_rate_stats_ctx,
- .txrx_peer_flush_rate_stats = dp_peer_flush_rate_stats,
- .txrx_flush_rate_stats_request = dp_flush_rate_stats_req,
- .set_pdev_pcp_tid_map = dp_set_pdev_pcp_tid_map_wifi3,
- .set_pdev_tidmap_prty = dp_set_pdev_tidmap_prty_wifi3,
- .set_vdev_pcp_tid_map = dp_set_vdev_pcp_tid_map_wifi3,
- .set_vdev_tidmap_prty = dp_set_vdev_tidmap_prty_wifi3,
- .set_vdev_tidmap_tbl_id = dp_set_vdev_tidmap_tbl_id_wifi3,
- .txrx_cp_peer_del_response = dp_cp_peer_del_resp_handler,
- };
- static struct cdp_ctrl_ops dp_ops_ctrl = {
- .txrx_peer_authorize = dp_peer_authorize,
- .txrx_set_vdev_rx_decap_type = dp_set_vdev_rx_decap_type,
- .txrx_set_tx_encap_type = dp_set_vdev_tx_encap_type,
- #ifdef MESH_MODE_SUPPORT
- .txrx_set_mesh_mode = dp_peer_set_mesh_mode,
- .txrx_set_mesh_rx_filter = dp_peer_set_mesh_rx_filter,
- #endif
- .txrx_set_vdev_param = dp_set_vdev_param,
- .txrx_peer_set_nawds = dp_peer_set_nawds,
- .txrx_set_pdev_reo_dest = dp_set_pdev_reo_dest,
- .txrx_get_pdev_reo_dest = dp_get_pdev_reo_dest,
- .txrx_set_filter_neighbour_peers = dp_set_filter_neighbour_peers,
- .txrx_update_filter_neighbour_peers =
- dp_update_filter_neighbour_peers,
- .txrx_get_sec_type = dp_get_sec_type,
-
- .txrx_wdi_event_sub = dp_wdi_event_sub,
- .txrx_wdi_event_unsub = dp_wdi_event_unsub,
- #ifdef WDI_EVENT_ENABLE
- .txrx_get_pldev = dp_get_pldev,
- #endif
- .txrx_set_pdev_param = dp_set_pdev_param,
- #ifdef ATH_SUPPORT_NAC_RSSI
- .txrx_vdev_config_for_nac_rssi = dp_config_for_nac_rssi,
- .txrx_vdev_get_neighbour_rssi = dp_vdev_get_neighbour_rssi,
- #endif
- .set_key = dp_set_michael_key,
- .txrx_get_vdev_param = dp_get_vdev_param,
- .enable_peer_based_pktlog = dp_enable_peer_based_pktlog,
- .calculate_delay_stats = dp_calculate_delay_stats,
- #ifdef WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG
- .txrx_update_pdev_rx_protocol_tag = dp_update_pdev_rx_protocol_tag,
- #ifdef WLAN_SUPPORT_RX_TAG_STATISTICS
- .txrx_dump_pdev_rx_protocol_tag_stats =
- dp_dump_pdev_rx_protocol_tag_stats,
- #endif
- #endif
- };
- static struct cdp_me_ops dp_ops_me = {
- #ifdef ATH_SUPPORT_IQUE
- .tx_me_alloc_descriptor = dp_tx_me_alloc_descriptor,
- .tx_me_free_descriptor = dp_tx_me_free_descriptor,
- .tx_me_convert_ucast = dp_tx_me_send_convert_ucast,
- #endif
- };
- static struct cdp_mon_ops dp_ops_mon = {
- .txrx_monitor_set_filter_ucast_data = NULL,
- .txrx_monitor_set_filter_mcast_data = NULL,
- .txrx_monitor_set_filter_non_data = NULL,
- .txrx_monitor_get_filter_ucast_data = dp_vdev_get_filter_ucast_data,
- .txrx_monitor_get_filter_mcast_data = dp_vdev_get_filter_mcast_data,
- .txrx_monitor_get_filter_non_data = dp_vdev_get_filter_non_data,
- .txrx_reset_monitor_mode = dp_reset_monitor_mode,
-
- .txrx_set_advance_monitor_filter = dp_pdev_set_advance_monitor_filter,
- .txrx_monitor_record_channel = dp_pdev_set_monitor_channel,
- };
- static struct cdp_host_stats_ops dp_ops_host_stats = {
- .txrx_per_peer_stats = dp_get_host_peer_stats,
- .get_fw_peer_stats = dp_get_fw_peer_stats,
- .get_htt_stats = dp_get_htt_stats,
- .txrx_enable_enhanced_stats = dp_enable_enhanced_stats,
- .txrx_disable_enhanced_stats = dp_disable_enhanced_stats,
- .txrx_stats_publish = dp_txrx_stats_publish,
- .txrx_get_vdev_stats = dp_txrx_get_vdev_stats,
- .txrx_get_peer_stats = dp_txrx_get_peer_stats,
- .txrx_reset_peer_stats = dp_txrx_reset_peer_stats,
- .txrx_get_pdev_stats = dp_txrx_get_pdev_stats,
- .txrx_get_ratekbps = dp_txrx_get_ratekbps,
- .configure_rate_stats = dp_set_rate_stats_cap,
- .txrx_update_vdev_stats = dp_txrx_update_vdev_host_stats,
-
- };
- static struct cdp_raw_ops dp_ops_raw = {
-
- };
- #ifdef PEER_FLOW_CONTROL
- static struct cdp_pflow_ops dp_ops_pflow = {
- dp_tx_flow_ctrl_configure_pdev,
- };
- #endif
- #ifdef FEATURE_RUNTIME_PM
- static QDF_STATUS dp_runtime_suspend(struct cdp_pdev *opaque_pdev)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)opaque_pdev;
- struct dp_soc *soc = pdev->soc;
-
- if (dp_get_tx_pending(opaque_pdev) > 0) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
- FL("Abort suspend due to pending TX packets"));
- return QDF_STATUS_E_AGAIN;
- }
- if (soc->intr_mode == DP_INTR_POLL)
- qdf_timer_stop(&soc->int_timer);
- return QDF_STATUS_SUCCESS;
- }
- static QDF_STATUS dp_runtime_resume(struct cdp_pdev *opaque_pdev)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)opaque_pdev;
- struct dp_soc *soc = pdev->soc;
- void *hal_srng;
- int i;
- if (soc->intr_mode == DP_INTR_POLL)
- qdf_timer_mod(&soc->int_timer, DP_INTR_POLL_TIMER_MS);
- for (i = 0; i < MAX_TCL_DATA_RINGS; i++) {
- hal_srng = soc->tcl_data_ring[i].hal_srng;
- if (hal_srng) {
-
- hal_srng_access_start(soc->hal_soc, hal_srng);
-
- hal_srng_access_end(soc->hal_soc, hal_srng);
- }
- }
- return QDF_STATUS_SUCCESS;
- }
- #endif
- static uint32_t dp_tx_get_success_ack_stats(struct cdp_pdev *pdev,
- uint8_t vdev_id)
- {
- struct dp_vdev *vdev =
- (struct dp_vdev *)dp_get_vdev_from_vdev_id_wifi3(pdev,
- vdev_id);
- struct dp_soc *soc = ((struct dp_pdev *)pdev)->soc;
- struct cdp_vdev_stats *vdev_stats = NULL;
- uint32_t tx_success;
- if (!vdev) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- FL("Invalid vdev id %d"), vdev_id);
- return 0;
- }
- vdev_stats = qdf_mem_malloc_atomic(sizeof(struct cdp_vdev_stats));
- if (!vdev_stats) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- "DP alloc failure - unable to get alloc vdev stats");
- return 0;
- }
- qdf_spin_lock_bh(&soc->peer_ref_mutex);
- dp_aggregate_vdev_stats(vdev, vdev_stats);
- qdf_spin_unlock_bh(&soc->peer_ref_mutex);
- tx_success = vdev_stats->tx.tx_success.num;
- qdf_mem_free(vdev_stats);
- return tx_success;
- }
- #ifdef DP_PEER_EXTENDED_API
- static struct cdp_misc_ops dp_ops_misc = {
- #ifdef FEATURE_WLAN_TDLS
- .tx_non_std = dp_tx_non_std,
- #endif
- .get_opmode = dp_get_opmode,
- #ifdef FEATURE_RUNTIME_PM
- .runtime_suspend = dp_runtime_suspend,
- .runtime_resume = dp_runtime_resume,
- #endif
- .pkt_log_init = dp_pkt_log_init,
- .pkt_log_con_service = dp_pkt_log_con_service,
- .get_num_rx_contexts = dp_get_num_rx_contexts,
- .get_tx_ack_stats = dp_tx_get_success_ack_stats,
- };
- #endif
- #ifdef DP_FLOW_CTL
- static struct cdp_flowctl_ops dp_ops_flowctl = {
-
- #ifdef QCA_LL_TX_FLOW_CONTROL_V2
- .flow_pool_map_handler = dp_tx_flow_pool_map,
- .flow_pool_unmap_handler = dp_tx_flow_pool_unmap,
- .register_pause_cb = dp_txrx_register_pause_cb,
- .dump_flow_pool_info = dp_tx_dump_flow_pool_info,
- .tx_desc_thresh_reached = dp_tx_desc_thresh_reached,
- #endif
- };
- static struct cdp_lflowctl_ops dp_ops_l_flowctl = {
-
- };
- #endif
- #ifdef IPA_OFFLOAD
- static struct cdp_ipa_ops dp_ops_ipa = {
- .ipa_get_resource = dp_ipa_get_resource,
- .ipa_set_doorbell_paddr = dp_ipa_set_doorbell_paddr,
- .ipa_op_response = dp_ipa_op_response,
- .ipa_register_op_cb = dp_ipa_register_op_cb,
- .ipa_get_stat = dp_ipa_get_stat,
- .ipa_tx_data_frame = dp_tx_send_ipa_data_frame,
- .ipa_enable_autonomy = dp_ipa_enable_autonomy,
- .ipa_disable_autonomy = dp_ipa_disable_autonomy,
- .ipa_setup = dp_ipa_setup,
- .ipa_cleanup = dp_ipa_cleanup,
- .ipa_setup_iface = dp_ipa_setup_iface,
- .ipa_cleanup_iface = dp_ipa_cleanup_iface,
- .ipa_enable_pipes = dp_ipa_enable_pipes,
- .ipa_disable_pipes = dp_ipa_disable_pipes,
- .ipa_set_perf_level = dp_ipa_set_perf_level,
- .ipa_rx_intrabss_fwd = dp_ipa_rx_intrabss_fwd
- };
- #endif
- #ifdef DP_POWER_SAVE
- static QDF_STATUS dp_bus_suspend(struct cdp_pdev *opaque_pdev)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)opaque_pdev;
- struct dp_soc *soc = pdev->soc;
- int timeout = SUSPEND_DRAIN_WAIT;
- int drain_wait_delay = 50;
-
- while (dp_get_tx_pending(opaque_pdev) > 0) {
- qdf_sleep(drain_wait_delay);
- if (timeout <= 0) {
- dp_err("TX frames are pending, abort suspend");
- return QDF_STATUS_E_TIMEOUT;
- }
- timeout = timeout - drain_wait_delay;
- }
- if (soc->intr_mode == DP_INTR_POLL)
- qdf_timer_stop(&soc->int_timer);
- return QDF_STATUS_SUCCESS;
- }
- static QDF_STATUS dp_bus_resume(struct cdp_pdev *opaque_pdev)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)opaque_pdev;
- struct dp_soc *soc = pdev->soc;
- if (soc->intr_mode == DP_INTR_POLL)
- qdf_timer_mod(&soc->int_timer, DP_INTR_POLL_TIMER_MS);
- return QDF_STATUS_SUCCESS;
- }
- static struct cdp_bus_ops dp_ops_bus = {
- .bus_suspend = dp_bus_suspend,
- .bus_resume = dp_bus_resume
- };
- #endif
- #ifdef DP_FLOW_CTL
- static struct cdp_throttle_ops dp_ops_throttle = {
-
- };
- static struct cdp_cfg_ops dp_ops_cfg = {
-
- };
- #endif
- #ifdef DP_PEER_EXTENDED_API
- static struct cdp_ocb_ops dp_ops_ocb = {
-
- };
- static struct cdp_mob_stats_ops dp_ops_mob_stats = {
-
- };
- static inline void *
- dp_peer_get_ref_find_by_addr(struct cdp_pdev *dev, uint8_t *peer_mac_addr,
- uint8_t *local_id,
- enum peer_debug_id_type debug_id)
- {
- struct dp_pdev *pdev = (struct dp_pdev *)dev;
- struct dp_peer *peer;
- peer = dp_peer_find_hash_find(pdev->soc, peer_mac_addr, 0, DP_VDEV_ALL);
- if (!peer)
- return NULL;
- *local_id = peer->local_id;
- DP_TRACE(INFO, "%s: peer %pK id %d", __func__, peer, *local_id);
- return peer;
- }
- static inline
- void dp_peer_release_ref(void *peer, enum peer_debug_id_type debug_id)
- {
- dp_peer_unref_delete(peer);
- }
- static struct cdp_peer_ops dp_ops_peer = {
- .register_peer = dp_register_peer,
- .clear_peer = dp_clear_peer,
- .find_peer_by_addr = dp_find_peer_by_addr,
- .find_peer_by_addr_and_vdev = dp_find_peer_by_addr_and_vdev,
- .peer_get_ref_by_addr = dp_peer_get_ref_find_by_addr,
- .peer_release_ref = dp_peer_release_ref,
- .local_peer_id = dp_local_peer_id,
- .peer_find_by_local_id = dp_peer_find_by_local_id,
- .peer_state_update = dp_peer_state_update,
- .get_vdevid = dp_get_vdevid,
- .get_vdev_by_sta_id = dp_get_vdev_by_sta_id,
- .peer_get_peer_mac_addr = dp_peer_get_peer_mac_addr,
- .get_vdev_for_peer = dp_get_vdev_for_peer,
- .get_peer_state = dp_get_peer_state,
- };
- #endif
- static struct cdp_ops dp_txrx_ops = {
- .cmn_drv_ops = &dp_ops_cmn,
- .ctrl_ops = &dp_ops_ctrl,
- .me_ops = &dp_ops_me,
- .mon_ops = &dp_ops_mon,
- .host_stats_ops = &dp_ops_host_stats,
- .wds_ops = &dp_ops_wds,
- .raw_ops = &dp_ops_raw,
- #ifdef PEER_FLOW_CONTROL
- .pflow_ops = &dp_ops_pflow,
- #endif
- #ifdef DP_PEER_EXTENDED_API
- .misc_ops = &dp_ops_misc,
- .ocb_ops = &dp_ops_ocb,
- .peer_ops = &dp_ops_peer,
- .mob_stats_ops = &dp_ops_mob_stats,
- #endif
- #ifdef DP_FLOW_CTL
- .cfg_ops = &dp_ops_cfg,
- .flowctl_ops = &dp_ops_flowctl,
- .l_flowctl_ops = &dp_ops_l_flowctl,
- .throttle_ops = &dp_ops_throttle,
- #endif
- #ifdef IPA_OFFLOAD
- .ipa_ops = &dp_ops_ipa,
- #endif
- #ifdef DP_POWER_SAVE
- .bus_ops = &dp_ops_bus,
- #endif
- };
- void dp_soc_set_txrx_ring_map(struct dp_soc *soc)
- {
- uint32_t i;
- for (i = 0; i < WLAN_CFG_INT_NUM_CONTEXTS; i++) {
- soc->tx_ring_map[i] = dp_cpu_ring_map[DP_NSS_DEFAULT_MAP][i];
- }
- }
- #if defined(QCA_WIFI_QCA8074) || defined(QCA_WIFI_QCA6018)
- #ifndef QCA_MEM_ATTACH_ON_WIFI3
- void *dp_soc_attach_wifi3(struct cdp_ctrl_objmgr_psoc *ctrl_psoc,
- void *hif_handle,
- HTC_HANDLE htc_handle, qdf_device_t qdf_osdev,
- struct ol_if_ops *ol_ops, uint16_t device_id)
- {
- struct dp_soc *dp_soc = NULL;
- dp_soc = dp_soc_attach(ctrl_psoc, htc_handle, qdf_osdev,
- ol_ops, device_id);
- if (!dp_soc)
- return NULL;
- if (!dp_soc_init(dp_soc, htc_handle, hif_handle))
- return NULL;
- return (void *)dp_soc;
- }
- #else
- void *dp_soc_attach_wifi3(struct cdp_ctrl_objmgr_psoc *ctrl_psoc,
- void *hif_handle,
- HTC_HANDLE htc_handle, qdf_device_t qdf_osdev,
- struct ol_if_ops *ol_ops, uint16_t device_id)
- {
- struct dp_soc *dp_soc = NULL;
- dp_soc = dp_soc_attach(ctrl_psoc, htc_handle, qdf_osdev,
- ol_ops, device_id);
- return (void *)dp_soc;
- }
- #endif
- static struct dp_soc *
- dp_soc_attach(struct cdp_ctrl_objmgr_psoc *ctrl_psoc, HTC_HANDLE htc_handle,
- qdf_device_t qdf_osdev,
- struct ol_if_ops *ol_ops, uint16_t device_id)
- {
- int int_ctx;
- struct dp_soc *soc = NULL;
- struct htt_soc *htt_soc;
- soc = qdf_mem_malloc(sizeof(*soc));
- if (!soc) {
- dp_err("DP SOC memory allocation failed");
- goto fail0;
- }
- int_ctx = 0;
- soc->device_id = device_id;
- soc->cdp_soc.ops = &dp_txrx_ops;
- soc->cdp_soc.ol_ops = ol_ops;
- soc->ctrl_psoc = ctrl_psoc;
- soc->osdev = qdf_osdev;
- soc->num_hw_dscp_tid_map = HAL_MAX_HW_DSCP_TID_MAPS;
- wlan_set_srng_cfg(&soc->wlan_srng_cfg);
- soc->wlan_cfg_ctx = wlan_cfg_soc_attach(soc->ctrl_psoc);
- if (!soc->wlan_cfg_ctx) {
- dp_err("wlan_cfg_ctx failed\n");
- goto fail1;
- }
- htt_soc = htt_soc_attach(soc, htc_handle);
- if (!htt_soc)
- goto fail1;
- soc->htt_handle = htt_soc;
- if (htt_soc_htc_prealloc(htt_soc) != QDF_STATUS_SUCCESS)
- goto fail2;
- return (void *)soc;
- fail2:
- htt_soc_detach(htt_soc);
- fail1:
- qdf_mem_free(soc);
- fail0:
- return NULL;
- }
- void *dp_soc_init(void *dpsoc, HTC_HANDLE htc_handle, void *hif_handle)
- {
- int target_type;
- struct dp_soc *soc = (struct dp_soc *)dpsoc;
- struct htt_soc *htt_soc = soc->htt_handle;
- htt_set_htc_handle(htt_soc, htc_handle);
- soc->hif_handle = hif_handle;
- soc->hal_soc = hif_get_hal_handle(soc->hif_handle);
- if (!soc->hal_soc)
- return NULL;
- htt_soc_initialize(soc->htt_handle, soc->ctrl_psoc,
- htt_get_htc_handle(htt_soc),
- soc->hal_soc, soc->osdev);
- target_type = hal_get_target_type(soc->hal_soc);
- switch (target_type) {
- case TARGET_TYPE_QCA6290:
- wlan_cfg_set_reo_dst_ring_size(soc->wlan_cfg_ctx,
- REO_DST_RING_SIZE_QCA6290);
- soc->ast_override_support = 1;
- soc->da_war_enabled = false;
- break;
- #ifdef QCA_WIFI_QCA6390
- case TARGET_TYPE_QCA6390:
- wlan_cfg_set_reo_dst_ring_size(soc->wlan_cfg_ctx,
- REO_DST_RING_SIZE_QCA6290);
- wlan_cfg_set_raw_mode_war(soc->wlan_cfg_ctx, true);
- soc->ast_override_support = 1;
- if (con_mode_monitor == QDF_GLOBAL_MONITOR_MODE) {
- int int_ctx;
- for (int_ctx = 0; int_ctx < WLAN_CFG_INT_NUM_CONTEXTS; int_ctx++) {
- soc->wlan_cfg_ctx->int_rx_ring_mask[int_ctx] = 0;
- soc->wlan_cfg_ctx->int_rxdma2host_ring_mask[int_ctx] = 0;
- }
- }
- soc->wlan_cfg_ctx->rxdma1_enable = 0;
- break;
- #endif
- case TARGET_TYPE_QCA8074:
- wlan_cfg_set_reo_dst_ring_size(soc->wlan_cfg_ctx,
- REO_DST_RING_SIZE_QCA8074);
- wlan_cfg_set_raw_mode_war(soc->wlan_cfg_ctx, true);
- soc->da_war_enabled = true;
- break;
- case TARGET_TYPE_QCA8074V2:
- case TARGET_TYPE_QCA6018:
- wlan_cfg_set_reo_dst_ring_size(soc->wlan_cfg_ctx,
- REO_DST_RING_SIZE_QCA8074);
- wlan_cfg_set_raw_mode_war(soc->wlan_cfg_ctx, false);
- soc->hw_nac_monitor_support = 1;
- soc->ast_override_support = 1;
- soc->per_tid_basize_max_tid = 8;
- soc->num_hw_dscp_tid_map = HAL_MAX_HW_DSCP_TID_V2_MAPS;
- soc->da_war_enabled = false;
- break;
- default:
- qdf_print("%s: Unknown tgt type %d\n", __func__, target_type);
- qdf_assert_always(0);
- break;
- }
- wlan_cfg_set_rx_hash(soc->wlan_cfg_ctx,
- cfg_get(soc->ctrl_psoc, CFG_DP_RX_HASH));
- soc->cce_disable = false;
- if (soc->cdp_soc.ol_ops->get_dp_cfg_param) {
- int ret = soc->cdp_soc.ol_ops->get_dp_cfg_param(soc->ctrl_psoc,
- CDP_CFG_MAX_PEER_ID);
- if (ret != -EINVAL) {
- wlan_cfg_set_max_peer_id(soc->wlan_cfg_ctx, ret);
- }
- ret = soc->cdp_soc.ol_ops->get_dp_cfg_param(soc->ctrl_psoc,
- CDP_CFG_CCE_DISABLE);
- if (ret == 1)
- soc->cce_disable = true;
- }
- qdf_spinlock_create(&soc->peer_ref_mutex);
- qdf_spinlock_create(&soc->ast_lock);
- qdf_spinlock_create(&soc->reo_desc_freelist_lock);
- qdf_list_create(&soc->reo_desc_freelist, REO_DESC_FREELIST_SIZE);
-
- dp_soc_set_txrx_ring_map(soc);
- qdf_spinlock_create(&soc->htt_stats.lock);
-
- qdf_create_work(0, &soc->htt_stats.work, htt_t2h_stats_handler, soc);
- return soc;
- }
- void *dp_soc_init_wifi3(void *dpsoc, struct cdp_ctrl_objmgr_psoc *ctrl_psoc,
- void *hif_handle,
- HTC_HANDLE htc_handle, qdf_device_t qdf_osdev,
- struct ol_if_ops *ol_ops, uint16_t device_id)
- {
- return dp_soc_init(dpsoc, htc_handle, hif_handle);
- }
- #endif
- void *dp_get_pdev_for_mac_id(struct dp_soc *soc, uint32_t mac_id)
- {
- if (wlan_cfg_per_pdev_lmac_ring(soc->wlan_cfg_ctx))
- return soc->pdev_list[mac_id];
-
- return soc->pdev_list[0];
- }
- static
- void dp_is_hw_dbs_enable(struct dp_soc *soc,
- int *max_mac_rings)
- {
- bool dbs_enable = false;
- if (soc->cdp_soc.ol_ops->is_hw_dbs_2x2_capable)
- dbs_enable = soc->cdp_soc.ol_ops->
- is_hw_dbs_2x2_capable((void *)soc->ctrl_psoc);
- *max_mac_rings = (dbs_enable)?(*max_mac_rings):1;
- }
- bool dp_is_soc_reinit(struct dp_soc *soc)
- {
- return soc->dp_soc_reinit;
- }
- #ifdef WDI_EVENT_ENABLE
- int dp_set_pktlog_wifi3(struct dp_pdev *pdev, uint32_t event,
- bool enable)
- {
- struct dp_soc *soc = NULL;
- struct htt_rx_ring_tlv_filter htt_tlv_filter = {0};
- int max_mac_rings = wlan_cfg_get_num_mac_rings
- (pdev->wlan_cfg_ctx);
- uint8_t mac_id = 0;
- soc = pdev->soc;
- dp_is_hw_dbs_enable(soc, &max_mac_rings);
- QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_DEBUG,
- FL("Max_mac_rings %d "),
- max_mac_rings);
- if (enable) {
- switch (event) {
- case WDI_EVENT_RX_DESC:
- if (pdev->monitor_vdev) {
-
- return 0;
- }
- if (pdev->rx_pktlog_mode != DP_RX_PKTLOG_FULL) {
- pdev->rx_pktlog_mode = DP_RX_PKTLOG_FULL;
- htt_tlv_filter.mpdu_start = 1;
- htt_tlv_filter.msdu_start = 1;
- htt_tlv_filter.msdu_end = 1;
- htt_tlv_filter.mpdu_end = 1;
- htt_tlv_filter.packet_header = 1;
- htt_tlv_filter.attention = 1;
- htt_tlv_filter.ppdu_start = 1;
- htt_tlv_filter.ppdu_end = 1;
- htt_tlv_filter.ppdu_end_user_stats = 1;
- htt_tlv_filter.ppdu_end_user_stats_ext = 1;
- htt_tlv_filter.ppdu_end_status_done = 1;
- htt_tlv_filter.enable_fp = 1;
- htt_tlv_filter.fp_mgmt_filter = FILTER_MGMT_ALL;
- htt_tlv_filter.fp_ctrl_filter = FILTER_CTRL_ALL;
- htt_tlv_filter.fp_data_filter = FILTER_DATA_ALL;
- htt_tlv_filter.mo_mgmt_filter = FILTER_MGMT_ALL;
- htt_tlv_filter.mo_ctrl_filter = FILTER_CTRL_ALL;
- htt_tlv_filter.mo_data_filter = FILTER_DATA_ALL;
- htt_tlv_filter.offset_valid = false;
- for (mac_id = 0; mac_id < max_mac_rings;
- mac_id++) {
- int mac_for_pdev =
- dp_get_mac_id_for_pdev(mac_id,
- pdev->pdev_id);
- htt_h2t_rx_ring_cfg(soc->htt_handle,
- mac_for_pdev,
- pdev->rxdma_mon_status_ring[mac_id]
- .hal_srng,
- RXDMA_MONITOR_STATUS,
- RX_BUFFER_SIZE,
- &htt_tlv_filter);
- }
- if (soc->reap_timer_init)
- qdf_timer_mod(&soc->mon_reap_timer,
- DP_INTR_POLL_TIMER_MS);
- }
- break;
- case WDI_EVENT_LITE_RX:
- if (pdev->monitor_vdev) {
-
- return 0;
- }
- if (pdev->rx_pktlog_mode != DP_RX_PKTLOG_LITE) {
- pdev->rx_pktlog_mode = DP_RX_PKTLOG_LITE;
- htt_tlv_filter.ppdu_start = 1;
- htt_tlv_filter.ppdu_end = 1;
- htt_tlv_filter.ppdu_end_user_stats = 1;
- htt_tlv_filter.ppdu_end_user_stats_ext = 1;
- htt_tlv_filter.ppdu_end_status_done = 1;
- htt_tlv_filter.mpdu_start = 1;
- htt_tlv_filter.enable_fp = 1;
- htt_tlv_filter.fp_mgmt_filter = FILTER_MGMT_ALL;
- htt_tlv_filter.fp_ctrl_filter = FILTER_CTRL_ALL;
- htt_tlv_filter.fp_data_filter = FILTER_DATA_ALL;
- htt_tlv_filter.mo_mgmt_filter = FILTER_MGMT_ALL;
- htt_tlv_filter.mo_ctrl_filter = FILTER_CTRL_ALL;
- htt_tlv_filter.mo_data_filter = FILTER_DATA_ALL;
- htt_tlv_filter.offset_valid = false;
- for (mac_id = 0; mac_id < max_mac_rings;
- mac_id++) {
- int mac_for_pdev =
- dp_get_mac_id_for_pdev(mac_id,
- pdev->pdev_id);
- htt_h2t_rx_ring_cfg(soc->htt_handle,
- mac_for_pdev,
- pdev->rxdma_mon_status_ring[mac_id]
- .hal_srng,
- RXDMA_MONITOR_STATUS,
- RX_BUFFER_SIZE_PKTLOG_LITE,
- &htt_tlv_filter);
- }
- if (soc->reap_timer_init)
- qdf_timer_mod(&soc->mon_reap_timer,
- DP_INTR_POLL_TIMER_MS);
- }
- break;
- case WDI_EVENT_LITE_T2H:
- if (pdev->monitor_vdev) {
-
- return 0;
- }
- for (mac_id = 0; mac_id < max_mac_rings; mac_id++) {
- int mac_for_pdev = dp_get_mac_id_for_pdev(
- mac_id, pdev->pdev_id);
- pdev->pktlog_ppdu_stats = true;
- dp_h2t_cfg_stats_msg_send(pdev,
- DP_PPDU_TXLITE_STATS_BITMASK_CFG,
- mac_for_pdev);
- }
- break;
- default:
-
- break;
- }
- } else {
- switch (event) {
- case WDI_EVENT_RX_DESC:
- case WDI_EVENT_LITE_RX:
- if (pdev->monitor_vdev) {
-
- return 0;
- }
- if (pdev->rx_pktlog_mode != DP_RX_PKTLOG_DISABLED) {
- pdev->rx_pktlog_mode = DP_RX_PKTLOG_DISABLED;
- for (mac_id = 0; mac_id < max_mac_rings;
- mac_id++) {
- int mac_for_pdev =
- dp_get_mac_id_for_pdev(mac_id,
- pdev->pdev_id);
- htt_h2t_rx_ring_cfg(soc->htt_handle,
- mac_for_pdev,
- pdev->rxdma_mon_status_ring[mac_id]
- .hal_srng,
- RXDMA_MONITOR_STATUS,
- RX_BUFFER_SIZE,
- &htt_tlv_filter);
- }
- if (soc->reap_timer_init)
- qdf_timer_stop(&soc->mon_reap_timer);
- }
- break;
- case WDI_EVENT_LITE_T2H:
- if (pdev->monitor_vdev) {
-
- return 0;
- }
-
- for (mac_id = 0; mac_id < max_mac_rings; mac_id++) {
- int mac_for_pdev =
- dp_get_mac_id_for_pdev(mac_id,
- pdev->pdev_id);
- pdev->pktlog_ppdu_stats = false;
- if (!pdev->enhanced_stats_en && !pdev->tx_sniffer_enable && !pdev->mcopy_mode) {
- dp_h2t_cfg_stats_msg_send(pdev, 0,
- mac_for_pdev);
- } else if (pdev->tx_sniffer_enable || pdev->mcopy_mode) {
- dp_h2t_cfg_stats_msg_send(pdev, DP_PPDU_STATS_CFG_SNIFFER,
- mac_for_pdev);
- } else if (pdev->enhanced_stats_en) {
- dp_h2t_cfg_stats_msg_send(pdev, DP_PPDU_STATS_CFG_ENH_STATS,
- mac_for_pdev);
- }
- }
- break;
- default:
-
- break;
- }
- }
- return 0;
- }
- #endif
- static uint8_t dp_bucket_index(uint32_t delay, uint16_t *array)
- {
- uint8_t i = CDP_DELAY_BUCKET_0;
- for (; i < CDP_DELAY_BUCKET_MAX; i++) {
- if (delay >= array[i] && delay <= array[i + 1])
- return i;
- }
- return (CDP_DELAY_BUCKET_MAX - 1);
- }
- static struct cdp_delay_stats *
- dp_fill_delay_buckets(struct dp_pdev *pdev, uint32_t delay,
- uint8_t tid, uint8_t mode, uint8_t ring_id)
- {
- uint8_t delay_index = 0;
- struct cdp_tid_tx_stats *tstats =
- &pdev->stats.tid_stats.tid_tx_stats[ring_id][tid];
- struct cdp_tid_rx_stats *rstats =
- &pdev->stats.tid_stats.tid_rx_stats[ring_id][tid];
-
- uint16_t cdp_fw_to_hw_delay[CDP_DELAY_BUCKET_MAX] = {
- 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 250, 500};
-
- uint16_t cdp_sw_enq_delay[CDP_DELAY_BUCKET_MAX] = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
-
- uint16_t cdp_intfrm_delay[CDP_DELAY_BUCKET_MAX] = {
- 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60};
-
- switch (mode) {
-
- case CDP_DELAY_STATS_SW_ENQ:
- delay_index = dp_bucket_index(delay, cdp_sw_enq_delay);
- tstats->swq_delay.delay_bucket[delay_index]++;
- return &tstats->swq_delay;
-
- case CDP_DELAY_STATS_FW_HW_TRANSMIT:
- delay_index = dp_bucket_index(delay, cdp_fw_to_hw_delay);
- tstats->hwtx_delay.delay_bucket[delay_index]++;
- return &tstats->hwtx_delay;
-
- case CDP_DELAY_STATS_TX_INTERFRAME:
- delay_index = dp_bucket_index(delay, cdp_intfrm_delay);
- tstats->intfrm_delay.delay_bucket[delay_index]++;
- return &tstats->intfrm_delay;
-
- case CDP_DELAY_STATS_RX_INTERFRAME:
- delay_index = dp_bucket_index(delay, cdp_intfrm_delay);
- rstats->intfrm_delay.delay_bucket[delay_index]++;
- return &rstats->intfrm_delay;
-
- case CDP_DELAY_STATS_REAP_STACK:
- delay_index = dp_bucket_index(delay, cdp_intfrm_delay);
- rstats->to_stack_delay.delay_bucket[delay_index]++;
- return &rstats->to_stack_delay;
- default:
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
- "%s Incorrect delay mode: %d", __func__, mode);
- }
- return NULL;
- }
- void dp_update_delay_stats(struct dp_pdev *pdev, uint32_t delay,
- uint8_t tid, uint8_t mode, uint8_t ring_id)
- {
- struct cdp_delay_stats *dstats = NULL;
-
- dstats = dp_fill_delay_buckets(pdev, delay, tid, mode, ring_id);
- if (qdf_unlikely(!dstats))
- return;
- if (delay != 0) {
-
- if (delay < dstats->min_delay)
- dstats->min_delay = delay;
- if (delay > dstats->max_delay)
- dstats->max_delay = delay;
-
- if (!dstats->avg_delay)
- dstats->avg_delay = delay;
- else
- dstats->avg_delay = ((delay + dstats->avg_delay) / 2);
- }
- }
|