dp_main.c 217 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002
  1. /*
  2. * Copyright (c) 2016-2018 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. #include <qdf_types.h>
  19. #include <qdf_lock.h>
  20. #include <qdf_net_types.h>
  21. #include <qdf_lro.h>
  22. #include <qdf_module.h>
  23. #include <hal_hw_headers.h>
  24. #include <hal_api.h>
  25. #include <hif.h>
  26. #include <htt.h>
  27. #include <wdi_event.h>
  28. #include <queue.h>
  29. #include "dp_htt.h"
  30. #include "dp_types.h"
  31. #include "dp_internal.h"
  32. #include "dp_tx.h"
  33. #include "dp_tx_desc.h"
  34. #include "dp_rx.h"
  35. #include <cdp_txrx_handle.h>
  36. #include <wlan_cfg.h>
  37. #include "cdp_txrx_cmn_struct.h"
  38. #include "cdp_txrx_stats_struct.h"
  39. #include <qdf_util.h>
  40. #include "dp_peer.h"
  41. #include "dp_rx_mon.h"
  42. #include "htt_stats.h"
  43. #include "qdf_mem.h" /* qdf_mem_malloc,free */
  44. #include "cfg_ucfg_api.h"
  45. #ifdef QCA_LL_TX_FLOW_CONTROL_V2
  46. #include "cdp_txrx_flow_ctrl_v2.h"
  47. #else
  48. static inline void
  49. cdp_dump_flow_pool_info(struct cdp_soc_t *soc)
  50. {
  51. return;
  52. }
  53. #endif
  54. #include "dp_ipa.h"
  55. #ifdef CONFIG_MCL
  56. #ifndef REMOVE_PKT_LOG
  57. #include <pktlog_ac_api.h>
  58. #include <pktlog_ac.h>
  59. #endif
  60. #endif
  61. static void dp_pktlogmod_exit(struct dp_pdev *handle);
  62. static void *dp_peer_create_wifi3(struct cdp_vdev *vdev_handle,
  63. uint8_t *peer_mac_addr,
  64. struct cdp_ctrl_objmgr_peer *ctrl_peer);
  65. static void dp_peer_delete_wifi3(void *peer_handle, uint32_t bitmap);
  66. #define DP_INTR_POLL_TIMER_MS 10
  67. #define DP_WDS_AGING_TIMER_DEFAULT_MS 120000
  68. #define DP_MCS_LENGTH (6*MAX_MCS)
  69. #define DP_NSS_LENGTH (6*SS_COUNT)
  70. #define DP_RXDMA_ERR_LENGTH (6*HAL_RXDMA_ERR_MAX)
  71. #define DP_REO_ERR_LENGTH (6*HAL_REO_ERR_MAX)
  72. #define DP_MAX_MCS_STRING_LEN 30
  73. #define DP_CURR_FW_STATS_AVAIL 19
  74. #define DP_HTT_DBG_EXT_STATS_MAX 256
  75. #define DP_MAX_SLEEP_TIME 100
  76. #ifdef IPA_OFFLOAD
  77. /* Exclude IPA rings from the interrupt context */
  78. #define TX_RING_MASK_VAL 0xb
  79. #define RX_RING_MASK_VAL 0x7
  80. #else
  81. #define TX_RING_MASK_VAL 0xF
  82. #define RX_RING_MASK_VAL 0xF
  83. #endif
  84. #define STR_MAXLEN 64
  85. #define DP_PPDU_STATS_CFG_ALL 0xFFFF
  86. /* PPDU stats mask sent to FW to enable enhanced stats */
  87. #define DP_PPDU_STATS_CFG_ENH_STATS 0xE67
  88. /* PPDU stats mask sent to FW to support debug sniffer feature */
  89. #define DP_PPDU_STATS_CFG_SNIFFER 0x2FFF
  90. /* PPDU stats mask sent to FW to support BPR feature*/
  91. #define DP_PPDU_STATS_CFG_BPR 0x2000
  92. /* PPDU stats mask sent to FW to support BPR and enhanced stats feature */
  93. #define DP_PPDU_STATS_CFG_BPR_ENH (DP_PPDU_STATS_CFG_BPR | \
  94. DP_PPDU_STATS_CFG_ENH_STATS)
  95. /* PPDU stats mask sent to FW to support BPR and pcktlog stats feature */
  96. #define DP_PPDU_STATS_CFG_BPR_PKTLOG (DP_PPDU_STATS_CFG_BPR | \
  97. DP_PPDU_TXLITE_STATS_BITMASK_CFG)
  98. #define RNG_ERR "SRNG setup failed for"
  99. /**
  100. * default_dscp_tid_map - Default DSCP-TID mapping
  101. *
  102. * DSCP TID
  103. * 000000 0
  104. * 001000 1
  105. * 010000 2
  106. * 011000 3
  107. * 100000 4
  108. * 101000 5
  109. * 110000 6
  110. * 111000 7
  111. */
  112. static uint8_t default_dscp_tid_map[DSCP_TID_MAP_MAX] = {
  113. 0, 0, 0, 0, 0, 0, 0, 0,
  114. 1, 1, 1, 1, 1, 1, 1, 1,
  115. 2, 2, 2, 2, 2, 2, 2, 2,
  116. 3, 3, 3, 3, 3, 3, 3, 3,
  117. 4, 4, 4, 4, 4, 4, 4, 4,
  118. 5, 5, 5, 5, 5, 5, 5, 5,
  119. 6, 6, 6, 6, 6, 6, 6, 6,
  120. 7, 7, 7, 7, 7, 7, 7, 7,
  121. };
  122. /*
  123. * struct dp_rate_debug
  124. *
  125. * @mcs_type: print string for a given mcs
  126. * @valid: valid mcs rate?
  127. */
  128. struct dp_rate_debug {
  129. char mcs_type[DP_MAX_MCS_STRING_LEN];
  130. uint8_t valid;
  131. };
  132. #define MCS_VALID 1
  133. #define MCS_INVALID 0
  134. static const struct dp_rate_debug dp_rate_string[DOT11_MAX][MAX_MCS] = {
  135. {
  136. {"OFDM 48 Mbps", MCS_VALID},
  137. {"OFDM 24 Mbps", MCS_VALID},
  138. {"OFDM 12 Mbps", MCS_VALID},
  139. {"OFDM 6 Mbps ", MCS_VALID},
  140. {"OFDM 54 Mbps", MCS_VALID},
  141. {"OFDM 36 Mbps", MCS_VALID},
  142. {"OFDM 18 Mbps", MCS_VALID},
  143. {"OFDM 9 Mbps ", MCS_VALID},
  144. {"INVALID ", MCS_INVALID},
  145. {"INVALID ", MCS_INVALID},
  146. {"INVALID ", MCS_INVALID},
  147. {"INVALID ", MCS_INVALID},
  148. {"INVALID ", MCS_VALID},
  149. },
  150. {
  151. {"CCK 11 Mbps Long ", MCS_VALID},
  152. {"CCK 5.5 Mbps Long ", MCS_VALID},
  153. {"CCK 2 Mbps Long ", MCS_VALID},
  154. {"CCK 1 Mbps Long ", MCS_VALID},
  155. {"CCK 11 Mbps Short ", MCS_VALID},
  156. {"CCK 5.5 Mbps Short", MCS_VALID},
  157. {"CCK 2 Mbps Short ", MCS_VALID},
  158. {"INVALID ", MCS_INVALID},
  159. {"INVALID ", MCS_INVALID},
  160. {"INVALID ", MCS_INVALID},
  161. {"INVALID ", MCS_INVALID},
  162. {"INVALID ", MCS_INVALID},
  163. {"INVALID ", MCS_VALID},
  164. },
  165. {
  166. {"HT MCS 0 (BPSK 1/2) ", MCS_VALID},
  167. {"HT MCS 1 (QPSK 1/2) ", MCS_VALID},
  168. {"HT MCS 2 (QPSK 3/4) ", MCS_VALID},
  169. {"HT MCS 3 (16-QAM 1/2)", MCS_VALID},
  170. {"HT MCS 4 (16-QAM 3/4)", MCS_VALID},
  171. {"HT MCS 5 (64-QAM 2/3)", MCS_VALID},
  172. {"HT MCS 6 (64-QAM 3/4)", MCS_VALID},
  173. {"HT MCS 7 (64-QAM 5/6)", MCS_VALID},
  174. {"INVALID ", MCS_INVALID},
  175. {"INVALID ", MCS_INVALID},
  176. {"INVALID ", MCS_INVALID},
  177. {"INVALID ", MCS_INVALID},
  178. {"INVALID ", MCS_VALID},
  179. },
  180. {
  181. {"VHT MCS 0 (BPSK 1/2) ", MCS_VALID},
  182. {"VHT MCS 1 (QPSK 1/2) ", MCS_VALID},
  183. {"VHT MCS 2 (QPSK 3/4) ", MCS_VALID},
  184. {"VHT MCS 3 (16-QAM 1/2) ", MCS_VALID},
  185. {"VHT MCS 4 (16-QAM 3/4) ", MCS_VALID},
  186. {"VHT MCS 5 (64-QAM 2/3) ", MCS_VALID},
  187. {"VHT MCS 6 (64-QAM 3/4) ", MCS_VALID},
  188. {"VHT MCS 7 (64-QAM 5/6) ", MCS_VALID},
  189. {"VHT MCS 8 (256-QAM 3/4) ", MCS_VALID},
  190. {"VHT MCS 9 (256-QAM 5/6) ", MCS_VALID},
  191. {"VHT MCS 10 (1024-QAM 3/4)", MCS_VALID},
  192. {"VHT MCS 11 (1024-QAM 5/6)", MCS_VALID},
  193. {"INVALID ", MCS_VALID},
  194. },
  195. {
  196. {"HE MCS 0 (BPSK 1/2) ", MCS_VALID},
  197. {"HE MCS 1 (QPSK 1/2) ", MCS_VALID},
  198. {"HE MCS 2 (QPSK 3/4) ", MCS_VALID},
  199. {"HE MCS 3 (16-QAM 1/2) ", MCS_VALID},
  200. {"HE MCS 4 (16-QAM 3/4) ", MCS_VALID},
  201. {"HE MCS 5 (64-QAM 2/3) ", MCS_VALID},
  202. {"HE MCS 6 (64-QAM 3/4) ", MCS_VALID},
  203. {"HE MCS 7 (64-QAM 5/6) ", MCS_VALID},
  204. {"HE MCS 8 (256-QAM 3/4) ", MCS_VALID},
  205. {"HE MCS 9 (256-QAM 5/6) ", MCS_VALID},
  206. {"HE MCS 10 (1024-QAM 3/4)", MCS_VALID},
  207. {"HE MCS 11 (1024-QAM 5/6)", MCS_VALID},
  208. {"INVALID ", MCS_VALID},
  209. }
  210. };
  211. /**
  212. * @brief Cpu ring map types
  213. */
  214. enum dp_cpu_ring_map_types {
  215. DP_DEFAULT_MAP,
  216. DP_NSS_FIRST_RADIO_OFFLOADED_MAP,
  217. DP_NSS_SECOND_RADIO_OFFLOADED_MAP,
  218. DP_NSS_ALL_RADIO_OFFLOADED_MAP,
  219. DP_CPU_RING_MAP_MAX
  220. };
  221. /**
  222. * @brief Cpu to tx ring map
  223. */
  224. static uint8_t dp_cpu_ring_map[DP_CPU_RING_MAP_MAX][WLAN_CFG_INT_NUM_CONTEXTS] = {
  225. {0x0, 0x1, 0x2, 0x0},
  226. {0x1, 0x2, 0x1, 0x2},
  227. {0x0, 0x2, 0x0, 0x2},
  228. {0x2, 0x2, 0x2, 0x2}
  229. };
  230. /**
  231. * @brief Select the type of statistics
  232. */
  233. enum dp_stats_type {
  234. STATS_FW = 0,
  235. STATS_HOST = 1,
  236. STATS_TYPE_MAX = 2,
  237. };
  238. /**
  239. * @brief General Firmware statistics options
  240. *
  241. */
  242. enum dp_fw_stats {
  243. TXRX_FW_STATS_INVALID = -1,
  244. };
  245. /**
  246. * dp_stats_mapping_table - Firmware and Host statistics
  247. * currently supported
  248. */
  249. const int dp_stats_mapping_table[][STATS_TYPE_MAX] = {
  250. {HTT_DBG_EXT_STATS_RESET, TXRX_HOST_STATS_INVALID},
  251. {HTT_DBG_EXT_STATS_PDEV_TX, TXRX_HOST_STATS_INVALID},
  252. {HTT_DBG_EXT_STATS_PDEV_RX, TXRX_HOST_STATS_INVALID},
  253. {HTT_DBG_EXT_STATS_PDEV_TX_HWQ, TXRX_HOST_STATS_INVALID},
  254. {HTT_DBG_EXT_STATS_PDEV_TX_SCHED, TXRX_HOST_STATS_INVALID},
  255. {HTT_DBG_EXT_STATS_PDEV_ERROR, TXRX_HOST_STATS_INVALID},
  256. {HTT_DBG_EXT_STATS_PDEV_TQM, TXRX_HOST_STATS_INVALID},
  257. {HTT_DBG_EXT_STATS_TQM_CMDQ, TXRX_HOST_STATS_INVALID},
  258. {HTT_DBG_EXT_STATS_TX_DE_INFO, TXRX_HOST_STATS_INVALID},
  259. {HTT_DBG_EXT_STATS_PDEV_TX_RATE, TXRX_HOST_STATS_INVALID},
  260. {HTT_DBG_EXT_STATS_PDEV_RX_RATE, TXRX_HOST_STATS_INVALID},
  261. {TXRX_FW_STATS_INVALID, TXRX_HOST_STATS_INVALID},
  262. {HTT_DBG_EXT_STATS_TX_SELFGEN_INFO, TXRX_HOST_STATS_INVALID},
  263. {HTT_DBG_EXT_STATS_TX_MU_HWQ, TXRX_HOST_STATS_INVALID},
  264. {HTT_DBG_EXT_STATS_RING_IF_INFO, TXRX_HOST_STATS_INVALID},
  265. {HTT_DBG_EXT_STATS_SRNG_INFO, TXRX_HOST_STATS_INVALID},
  266. {HTT_DBG_EXT_STATS_SFM_INFO, TXRX_HOST_STATS_INVALID},
  267. {HTT_DBG_EXT_STATS_PDEV_TX_MU, TXRX_HOST_STATS_INVALID},
  268. {HTT_DBG_EXT_STATS_ACTIVE_PEERS_LIST, TXRX_HOST_STATS_INVALID},
  269. /* Last ENUM for HTT FW STATS */
  270. {DP_HTT_DBG_EXT_STATS_MAX, TXRX_HOST_STATS_INVALID},
  271. {TXRX_FW_STATS_INVALID, TXRX_CLEAR_STATS},
  272. {TXRX_FW_STATS_INVALID, TXRX_RX_RATE_STATS},
  273. {TXRX_FW_STATS_INVALID, TXRX_TX_RATE_STATS},
  274. {TXRX_FW_STATS_INVALID, TXRX_TX_HOST_STATS},
  275. {TXRX_FW_STATS_INVALID, TXRX_RX_HOST_STATS},
  276. {TXRX_FW_STATS_INVALID, TXRX_AST_STATS},
  277. {TXRX_FW_STATS_INVALID, TXRX_SRNG_PTR_STATS},
  278. {TXRX_FW_STATS_INVALID, TXRX_RX_MON_STATS},
  279. };
  280. /* MCL specific functions */
  281. #ifdef CONFIG_MCL
  282. /**
  283. * dp_soc_get_mon_mask_for_interrupt_mode() - get mon mode mask for intr mode
  284. * @soc: pointer to dp_soc handle
  285. * @intr_ctx_num: interrupt context number for which mon mask is needed
  286. *
  287. * For MCL, monitor mode rings are being processed in timer contexts (polled).
  288. * This function is returning 0, since in interrupt mode(softirq based RX),
  289. * we donot want to process monitor mode rings in a softirq.
  290. *
  291. * So, in case packet log is enabled for SAP/STA/P2P modes,
  292. * regular interrupt processing will not process monitor mode rings. It would be
  293. * done in a separate timer context.
  294. *
  295. * Return: 0
  296. */
  297. static inline
  298. uint32_t dp_soc_get_mon_mask_for_interrupt_mode(struct dp_soc *soc, int intr_ctx_num)
  299. {
  300. return 0;
  301. }
  302. /*
  303. * dp_service_mon_rings()- timer to reap monitor rings
  304. * reqd as we are not getting ppdu end interrupts
  305. * @arg: SoC Handle
  306. *
  307. * Return:
  308. *
  309. */
  310. static void dp_service_mon_rings(void *arg)
  311. {
  312. struct dp_soc *soc = (struct dp_soc *)arg;
  313. int ring = 0, work_done, mac_id;
  314. struct dp_pdev *pdev = NULL;
  315. for (ring = 0 ; ring < MAX_PDEV_CNT; ring++) {
  316. pdev = soc->pdev_list[ring];
  317. if (!pdev)
  318. continue;
  319. for (mac_id = 0; mac_id < NUM_RXDMA_RINGS_PER_PDEV; mac_id++) {
  320. int mac_for_pdev = dp_get_mac_id_for_pdev(mac_id,
  321. pdev->pdev_id);
  322. work_done = dp_mon_process(soc, mac_for_pdev,
  323. QCA_NAPI_BUDGET);
  324. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  325. FL("Reaped %d descs from Monitor rings"),
  326. work_done);
  327. }
  328. }
  329. qdf_timer_mod(&soc->mon_reap_timer, DP_INTR_POLL_TIMER_MS);
  330. }
  331. #ifndef REMOVE_PKT_LOG
  332. /**
  333. * dp_pkt_log_init() - API to initialize packet log
  334. * @ppdev: physical device handle
  335. * @scn: HIF context
  336. *
  337. * Return: none
  338. */
  339. void dp_pkt_log_init(struct cdp_pdev *ppdev, void *scn)
  340. {
  341. struct dp_pdev *handle = (struct dp_pdev *)ppdev;
  342. if (handle->pkt_log_init) {
  343. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  344. "%s: Packet log not initialized", __func__);
  345. return;
  346. }
  347. pktlog_sethandle(&handle->pl_dev, scn);
  348. pktlog_set_callback_regtype(PKTLOG_LITE_CALLBACK_REGISTRATION);
  349. if (pktlogmod_init(scn)) {
  350. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  351. "%s: pktlogmod_init failed", __func__);
  352. handle->pkt_log_init = false;
  353. } else {
  354. handle->pkt_log_init = true;
  355. }
  356. }
  357. /**
  358. * dp_pkt_log_con_service() - connect packet log service
  359. * @ppdev: physical device handle
  360. * @scn: device context
  361. *
  362. * Return: none
  363. */
  364. static void dp_pkt_log_con_service(struct cdp_pdev *ppdev, void *scn)
  365. {
  366. struct dp_pdev *pdev = (struct dp_pdev *)ppdev;
  367. dp_pkt_log_init((struct cdp_pdev *)pdev, scn);
  368. pktlog_htc_attach();
  369. }
  370. /**
  371. * dp_pktlogmod_exit() - API to cleanup pktlog info
  372. * @handle: Pdev handle
  373. *
  374. * Return: none
  375. */
  376. static void dp_pktlogmod_exit(struct dp_pdev *handle)
  377. {
  378. void *scn = (void *)handle->soc->hif_handle;
  379. if (!scn) {
  380. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  381. "%s: Invalid hif(scn) handle", __func__);
  382. return;
  383. }
  384. pktlogmod_exit(scn);
  385. handle->pkt_log_init = false;
  386. }
  387. #endif
  388. #else
  389. static void dp_pktlogmod_exit(struct dp_pdev *handle) { }
  390. /**
  391. * dp_soc_get_mon_mask_for_interrupt_mode() - get mon mode mask for intr mode
  392. * @soc: pointer to dp_soc handle
  393. * @intr_ctx_num: interrupt context number for which mon mask is needed
  394. *
  395. * Return: mon mask value
  396. */
  397. static inline
  398. uint32_t dp_soc_get_mon_mask_for_interrupt_mode(struct dp_soc *soc, int intr_ctx_num)
  399. {
  400. return wlan_cfg_get_rx_mon_ring_mask(soc->wlan_cfg_ctx, intr_ctx_num);
  401. }
  402. #endif
  403. static int dp_peer_add_ast_wifi3(struct cdp_soc_t *soc_hdl,
  404. struct cdp_peer *peer_hdl,
  405. uint8_t *mac_addr,
  406. enum cdp_txrx_ast_entry_type type,
  407. uint32_t flags)
  408. {
  409. return dp_peer_add_ast((struct dp_soc *)soc_hdl,
  410. (struct dp_peer *)peer_hdl,
  411. mac_addr,
  412. type,
  413. flags);
  414. }
  415. static void dp_peer_del_ast_wifi3(struct cdp_soc_t *soc_hdl,
  416. void *ast_entry_hdl)
  417. {
  418. struct dp_soc *soc = (struct dp_soc *)soc_hdl;
  419. qdf_spin_lock_bh(&soc->ast_lock);
  420. dp_peer_del_ast((struct dp_soc *)soc_hdl,
  421. (struct dp_ast_entry *)ast_entry_hdl);
  422. qdf_spin_unlock_bh(&soc->ast_lock);
  423. }
  424. static int dp_peer_update_ast_wifi3(struct cdp_soc_t *soc_hdl,
  425. struct cdp_peer *peer_hdl,
  426. uint8_t *wds_macaddr,
  427. uint32_t flags)
  428. {
  429. int status = -1;
  430. struct dp_soc *soc = (struct dp_soc *)soc_hdl;
  431. struct dp_ast_entry *ast_entry = NULL;
  432. qdf_spin_lock_bh(&soc->ast_lock);
  433. ast_entry = dp_peer_ast_hash_find(soc, wds_macaddr);
  434. if (ast_entry) {
  435. status = dp_peer_update_ast(soc,
  436. (struct dp_peer *)peer_hdl,
  437. ast_entry, flags);
  438. }
  439. qdf_spin_unlock_bh(&soc->ast_lock);
  440. return status;
  441. }
  442. /*
  443. * dp_wds_reset_ast_wifi3() - Reset the is_active param for ast entry
  444. * @soc_handle: Datapath SOC handle
  445. * @wds_macaddr: MAC address of the WDS entry to be added
  446. * @vdev_hdl: vdev handle
  447. * Return: None
  448. */
  449. static void dp_wds_reset_ast_wifi3(struct cdp_soc_t *soc_hdl,
  450. uint8_t *wds_macaddr, void *vdev_hdl)
  451. {
  452. struct dp_soc *soc = (struct dp_soc *)soc_hdl;
  453. struct dp_ast_entry *ast_entry = NULL;
  454. qdf_spin_lock_bh(&soc->ast_lock);
  455. ast_entry = dp_peer_ast_hash_find(soc, wds_macaddr);
  456. if (ast_entry) {
  457. if (ast_entry->type != CDP_TXRX_AST_TYPE_STATIC)
  458. ast_entry->is_active = TRUE;
  459. }
  460. qdf_spin_unlock_bh(&soc->ast_lock);
  461. }
  462. /*
  463. * dp_wds_reset_ast_table_wifi3() - Reset the is_active param for all ast entry
  464. * @soc: Datapath SOC handle
  465. * @vdev_hdl: vdev handle
  466. *
  467. * Return: None
  468. */
  469. static void dp_wds_reset_ast_table_wifi3(struct cdp_soc_t *soc_hdl,
  470. void *vdev_hdl)
  471. {
  472. struct dp_soc *soc = (struct dp_soc *) soc_hdl;
  473. struct dp_pdev *pdev;
  474. struct dp_vdev *vdev;
  475. struct dp_peer *peer;
  476. struct dp_ast_entry *ase, *temp_ase;
  477. int i;
  478. qdf_spin_lock_bh(&soc->ast_lock);
  479. for (i = 0; i < MAX_PDEV_CNT && soc->pdev_list[i]; i++) {
  480. pdev = soc->pdev_list[i];
  481. qdf_spin_lock_bh(&pdev->vdev_list_lock);
  482. DP_PDEV_ITERATE_VDEV_LIST(pdev, vdev) {
  483. DP_VDEV_ITERATE_PEER_LIST(vdev, peer) {
  484. DP_PEER_ITERATE_ASE_LIST(peer, ase, temp_ase) {
  485. if (ase->type ==
  486. CDP_TXRX_AST_TYPE_STATIC)
  487. continue;
  488. ase->is_active = TRUE;
  489. }
  490. }
  491. }
  492. qdf_spin_unlock_bh(&pdev->vdev_list_lock);
  493. }
  494. qdf_spin_unlock_bh(&soc->ast_lock);
  495. }
  496. /*
  497. * dp_wds_flush_ast_table_wifi3() - Delete all wds and hmwds ast entry
  498. * @soc: Datapath SOC handle
  499. *
  500. * Return: None
  501. */
  502. static void dp_wds_flush_ast_table_wifi3(struct cdp_soc_t *soc_hdl)
  503. {
  504. struct dp_soc *soc = (struct dp_soc *) soc_hdl;
  505. struct dp_pdev *pdev;
  506. struct dp_vdev *vdev;
  507. struct dp_peer *peer;
  508. struct dp_ast_entry *ase, *temp_ase;
  509. int i;
  510. qdf_spin_lock_bh(&soc->ast_lock);
  511. for (i = 0; i < MAX_PDEV_CNT && soc->pdev_list[i]; i++) {
  512. pdev = soc->pdev_list[i];
  513. qdf_spin_lock_bh(&pdev->vdev_list_lock);
  514. DP_PDEV_ITERATE_VDEV_LIST(pdev, vdev) {
  515. DP_VDEV_ITERATE_PEER_LIST(vdev, peer) {
  516. DP_PEER_ITERATE_ASE_LIST(peer, ase, temp_ase) {
  517. if (ase->type ==
  518. CDP_TXRX_AST_TYPE_STATIC)
  519. continue;
  520. dp_peer_del_ast(soc, ase);
  521. }
  522. }
  523. }
  524. qdf_spin_unlock_bh(&pdev->vdev_list_lock);
  525. }
  526. qdf_spin_unlock_bh(&soc->ast_lock);
  527. }
  528. static void *dp_peer_ast_hash_find_wifi3(struct cdp_soc_t *soc_hdl,
  529. uint8_t *ast_mac_addr)
  530. {
  531. struct dp_ast_entry *ast_entry;
  532. struct dp_soc *soc = (struct dp_soc *)soc_hdl;
  533. qdf_spin_lock_bh(&soc->ast_lock);
  534. ast_entry = dp_peer_ast_hash_find(soc, ast_mac_addr);
  535. qdf_spin_unlock_bh(&soc->ast_lock);
  536. return (void *)ast_entry;
  537. }
  538. static uint8_t dp_peer_ast_get_pdev_id_wifi3(struct cdp_soc_t *soc_hdl,
  539. void *ast_entry_hdl)
  540. {
  541. return dp_peer_ast_get_pdev_id((struct dp_soc *)soc_hdl,
  542. (struct dp_ast_entry *)ast_entry_hdl);
  543. }
  544. static uint8_t dp_peer_ast_get_next_hop_wifi3(struct cdp_soc_t *soc_hdl,
  545. void *ast_entry_hdl)
  546. {
  547. return dp_peer_ast_get_next_hop((struct dp_soc *)soc_hdl,
  548. (struct dp_ast_entry *)ast_entry_hdl);
  549. }
  550. static void dp_peer_ast_set_type_wifi3(
  551. struct cdp_soc_t *soc_hdl,
  552. void *ast_entry_hdl,
  553. enum cdp_txrx_ast_entry_type type)
  554. {
  555. dp_peer_ast_set_type((struct dp_soc *)soc_hdl,
  556. (struct dp_ast_entry *)ast_entry_hdl,
  557. type);
  558. }
  559. /**
  560. * dp_srng_find_ring_in_mask() - find which ext_group a ring belongs
  561. * @ring_num: ring num of the ring being queried
  562. * @grp_mask: the grp_mask array for the ring type in question.
  563. *
  564. * The grp_mask array is indexed by group number and the bit fields correspond
  565. * to ring numbers. We are finding which interrupt group a ring belongs to.
  566. *
  567. * Return: the index in the grp_mask array with the ring number.
  568. * -QDF_STATUS_E_NOENT if no entry is found
  569. */
  570. static int dp_srng_find_ring_in_mask(int ring_num, int *grp_mask)
  571. {
  572. int ext_group_num;
  573. int mask = 1 << ring_num;
  574. for (ext_group_num = 0; ext_group_num < WLAN_CFG_INT_NUM_CONTEXTS;
  575. ext_group_num++) {
  576. if (mask & grp_mask[ext_group_num])
  577. return ext_group_num;
  578. }
  579. return -QDF_STATUS_E_NOENT;
  580. }
  581. static int dp_srng_calculate_msi_group(struct dp_soc *soc,
  582. enum hal_ring_type ring_type,
  583. int ring_num)
  584. {
  585. int *grp_mask;
  586. switch (ring_type) {
  587. case WBM2SW_RELEASE:
  588. /* dp_tx_comp_handler - soc->tx_comp_ring */
  589. if (ring_num < 3)
  590. grp_mask = &soc->wlan_cfg_ctx->int_tx_ring_mask[0];
  591. /* dp_rx_wbm_err_process - soc->rx_rel_ring */
  592. else if (ring_num == 3) {
  593. /* sw treats this as a separate ring type */
  594. grp_mask = &soc->wlan_cfg_ctx->
  595. int_rx_wbm_rel_ring_mask[0];
  596. ring_num = 0;
  597. } else {
  598. qdf_assert(0);
  599. return -QDF_STATUS_E_NOENT;
  600. }
  601. break;
  602. case REO_EXCEPTION:
  603. /* dp_rx_err_process - &soc->reo_exception_ring */
  604. grp_mask = &soc->wlan_cfg_ctx->int_rx_err_ring_mask[0];
  605. break;
  606. case REO_DST:
  607. /* dp_rx_process - soc->reo_dest_ring */
  608. grp_mask = &soc->wlan_cfg_ctx->int_rx_ring_mask[0];
  609. break;
  610. case REO_STATUS:
  611. /* dp_reo_status_ring_handler - soc->reo_status_ring */
  612. grp_mask = &soc->wlan_cfg_ctx->int_reo_status_ring_mask[0];
  613. break;
  614. /* dp_rx_mon_status_srng_process - pdev->rxdma_mon_status_ring*/
  615. case RXDMA_MONITOR_STATUS:
  616. /* dp_rx_mon_dest_process - pdev->rxdma_mon_dst_ring */
  617. case RXDMA_MONITOR_DST:
  618. /* dp_mon_process */
  619. grp_mask = &soc->wlan_cfg_ctx->int_rx_mon_ring_mask[0];
  620. break;
  621. case RXDMA_DST:
  622. /* dp_rxdma_err_process */
  623. grp_mask = &soc->wlan_cfg_ctx->int_rxdma2host_ring_mask[0];
  624. break;
  625. case RXDMA_BUF:
  626. grp_mask = &soc->wlan_cfg_ctx->int_host2rxdma_ring_mask[0];
  627. break;
  628. case RXDMA_MONITOR_BUF:
  629. /* TODO: support low_thresh interrupt */
  630. return -QDF_STATUS_E_NOENT;
  631. break;
  632. case TCL_DATA:
  633. case TCL_CMD:
  634. case REO_CMD:
  635. case SW2WBM_RELEASE:
  636. case WBM_IDLE_LINK:
  637. /* normally empty SW_TO_HW rings */
  638. return -QDF_STATUS_E_NOENT;
  639. break;
  640. case TCL_STATUS:
  641. case REO_REINJECT:
  642. /* misc unused rings */
  643. return -QDF_STATUS_E_NOENT;
  644. break;
  645. case CE_SRC:
  646. case CE_DST:
  647. case CE_DST_STATUS:
  648. /* CE_rings - currently handled by hif */
  649. default:
  650. return -QDF_STATUS_E_NOENT;
  651. break;
  652. }
  653. return dp_srng_find_ring_in_mask(ring_num, grp_mask);
  654. }
  655. static void dp_srng_msi_setup(struct dp_soc *soc, struct hal_srng_params
  656. *ring_params, int ring_type, int ring_num)
  657. {
  658. int msi_group_number;
  659. int msi_data_count;
  660. int ret;
  661. uint32_t msi_data_start, msi_irq_start, addr_low, addr_high;
  662. ret = pld_get_user_msi_assignment(soc->osdev->dev, "DP",
  663. &msi_data_count, &msi_data_start,
  664. &msi_irq_start);
  665. if (ret)
  666. return;
  667. msi_group_number = dp_srng_calculate_msi_group(soc, ring_type,
  668. ring_num);
  669. if (msi_group_number < 0) {
  670. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_LOW,
  671. FL("ring not part of an ext_group; ring_type: %d,ring_num %d"),
  672. ring_type, ring_num);
  673. ring_params->msi_addr = 0;
  674. ring_params->msi_data = 0;
  675. return;
  676. }
  677. if (msi_group_number > msi_data_count) {
  678. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_WARN,
  679. FL("2 msi_groups will share an msi; msi_group_num %d"),
  680. msi_group_number);
  681. QDF_ASSERT(0);
  682. }
  683. pld_get_msi_address(soc->osdev->dev, &addr_low, &addr_high);
  684. ring_params->msi_addr = addr_low;
  685. ring_params->msi_addr |= (qdf_dma_addr_t)(((uint64_t)addr_high) << 32);
  686. ring_params->msi_data = (msi_group_number % msi_data_count)
  687. + msi_data_start;
  688. ring_params->flags |= HAL_SRNG_MSI_INTR;
  689. }
  690. /**
  691. * dp_print_ast_stats() - Dump AST table contents
  692. * @soc: Datapath soc handle
  693. *
  694. * return void
  695. */
  696. #ifdef FEATURE_AST
  697. static void dp_print_ast_stats(struct dp_soc *soc)
  698. {
  699. uint8_t i;
  700. uint8_t num_entries = 0;
  701. struct dp_vdev *vdev;
  702. struct dp_pdev *pdev;
  703. struct dp_peer *peer;
  704. struct dp_ast_entry *ase, *tmp_ase;
  705. char type[5][10] = {"NONE", "STATIC", "WDS", "MEC", "HMWDS"};
  706. DP_PRINT_STATS("AST Stats:");
  707. DP_PRINT_STATS(" Entries Added = %d", soc->stats.ast.added);
  708. DP_PRINT_STATS(" Entries Deleted = %d", soc->stats.ast.deleted);
  709. DP_PRINT_STATS(" Entries Agedout = %d", soc->stats.ast.aged_out);
  710. DP_PRINT_STATS("AST Table:");
  711. for (i = 0; i < MAX_PDEV_CNT && soc->pdev_list[i]; i++) {
  712. pdev = soc->pdev_list[i];
  713. qdf_spin_lock_bh(&pdev->vdev_list_lock);
  714. DP_PDEV_ITERATE_VDEV_LIST(pdev, vdev) {
  715. DP_VDEV_ITERATE_PEER_LIST(vdev, peer) {
  716. DP_PEER_ITERATE_ASE_LIST(peer, ase, tmp_ase) {
  717. DP_PRINT_STATS("%6d mac_addr = %pM"
  718. " peer_mac_addr = %pM"
  719. " type = %s"
  720. " next_hop = %d"
  721. " is_active = %d"
  722. " is_bss = %d"
  723. " ast_idx = %d"
  724. " pdev_id = %d"
  725. " vdev_id = %d",
  726. ++num_entries,
  727. ase->mac_addr.raw,
  728. ase->peer->mac_addr.raw,
  729. type[ase->type],
  730. ase->next_hop,
  731. ase->is_active,
  732. ase->is_bss,
  733. ase->ast_idx,
  734. ase->pdev_id,
  735. ase->vdev_id);
  736. }
  737. }
  738. }
  739. qdf_spin_unlock_bh(&pdev->vdev_list_lock);
  740. }
  741. }
  742. #else
  743. static void dp_print_ast_stats(struct dp_soc *soc)
  744. {
  745. DP_PRINT_STATS("AST Stats not available.Enable FEATURE_AST");
  746. return;
  747. }
  748. #endif
  749. static void dp_print_peer_table(struct dp_vdev *vdev)
  750. {
  751. struct dp_peer *peer = NULL;
  752. DP_PRINT_STATS("Dumping Peer Table Stats:");
  753. TAILQ_FOREACH(peer, &vdev->peer_list, peer_list_elem) {
  754. if (!peer) {
  755. DP_PRINT_STATS("Invalid Peer");
  756. return;
  757. }
  758. DP_PRINT_STATS(" peer_mac_addr = %pM"
  759. " nawds_enabled = %d"
  760. " bss_peer = %d"
  761. " wapi = %d"
  762. " wds_enabled = %d"
  763. " delete in progress = %d",
  764. peer->mac_addr.raw,
  765. peer->nawds_enabled,
  766. peer->bss_peer,
  767. peer->wapi,
  768. peer->wds_enabled,
  769. peer->delete_in_progress);
  770. }
  771. }
  772. /*
  773. * dp_setup_srng - Internal function to setup SRNG rings used by data path
  774. */
  775. static int dp_srng_setup(struct dp_soc *soc, struct dp_srng *srng,
  776. int ring_type, int ring_num, int mac_id, uint32_t num_entries)
  777. {
  778. void *hal_soc = soc->hal_soc;
  779. uint32_t entry_size = hal_srng_get_entrysize(hal_soc, ring_type);
  780. /* TODO: See if we should get align size from hal */
  781. uint32_t ring_base_align = 8;
  782. struct hal_srng_params ring_params;
  783. uint32_t max_entries = hal_srng_max_entries(hal_soc, ring_type);
  784. /* TODO: Currently hal layer takes care of endianness related settings.
  785. * See if these settings need to passed from DP layer
  786. */
  787. ring_params.flags = 0;
  788. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_LOW,
  789. FL("Ring type: %d, num:%d"), ring_type, ring_num);
  790. num_entries = (num_entries > max_entries) ? max_entries : num_entries;
  791. srng->hal_srng = NULL;
  792. srng->alloc_size = (num_entries * entry_size) + ring_base_align - 1;
  793. srng->num_entries = num_entries;
  794. srng->base_vaddr_unaligned = qdf_mem_alloc_consistent(
  795. soc->osdev, soc->osdev->dev, srng->alloc_size,
  796. &(srng->base_paddr_unaligned));
  797. if (!srng->base_vaddr_unaligned) {
  798. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  799. FL("alloc failed - ring_type: %d, ring_num %d"),
  800. ring_type, ring_num);
  801. return QDF_STATUS_E_NOMEM;
  802. }
  803. ring_params.ring_base_vaddr = srng->base_vaddr_unaligned +
  804. ((unsigned long)srng->base_vaddr_unaligned % ring_base_align);
  805. ring_params.ring_base_paddr = srng->base_paddr_unaligned +
  806. ((unsigned long)(ring_params.ring_base_vaddr) -
  807. (unsigned long)srng->base_vaddr_unaligned);
  808. ring_params.num_entries = num_entries;
  809. if (soc->intr_mode == DP_INTR_MSI) {
  810. dp_srng_msi_setup(soc, &ring_params, ring_type, ring_num);
  811. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  812. FL("Using MSI for ring_type: %d, ring_num %d"),
  813. ring_type, ring_num);
  814. } else {
  815. ring_params.msi_data = 0;
  816. ring_params.msi_addr = 0;
  817. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  818. FL("Skipping MSI for ring_type: %d, ring_num %d"),
  819. ring_type, ring_num);
  820. }
  821. /*
  822. * Setup interrupt timer and batch counter thresholds for
  823. * interrupt mitigation based on ring type
  824. */
  825. if (ring_type == REO_DST) {
  826. ring_params.intr_timer_thres_us =
  827. wlan_cfg_get_int_timer_threshold_rx(soc->wlan_cfg_ctx);
  828. ring_params.intr_batch_cntr_thres_entries =
  829. wlan_cfg_get_int_batch_threshold_rx(soc->wlan_cfg_ctx);
  830. } else if (ring_type == WBM2SW_RELEASE && (ring_num < 3)) {
  831. ring_params.intr_timer_thres_us =
  832. wlan_cfg_get_int_timer_threshold_tx(soc->wlan_cfg_ctx);
  833. ring_params.intr_batch_cntr_thres_entries =
  834. wlan_cfg_get_int_batch_threshold_tx(soc->wlan_cfg_ctx);
  835. } else {
  836. ring_params.intr_timer_thres_us =
  837. wlan_cfg_get_int_timer_threshold_other(soc->wlan_cfg_ctx);
  838. ring_params.intr_batch_cntr_thres_entries =
  839. wlan_cfg_get_int_batch_threshold_other(soc->wlan_cfg_ctx);
  840. }
  841. /* Enable low threshold interrupts for rx buffer rings (regular and
  842. * monitor buffer rings.
  843. * TODO: See if this is required for any other ring
  844. */
  845. if ((ring_type == RXDMA_BUF) || (ring_type == RXDMA_MONITOR_BUF) ||
  846. (ring_type == RXDMA_MONITOR_STATUS)) {
  847. /* TODO: Setting low threshold to 1/8th of ring size
  848. * see if this needs to be configurable
  849. */
  850. ring_params.low_threshold = num_entries >> 3;
  851. ring_params.flags |= HAL_SRNG_LOW_THRES_INTR_ENABLE;
  852. ring_params.intr_timer_thres_us =
  853. wlan_cfg_get_int_timer_threshold_rx(soc->wlan_cfg_ctx);
  854. ring_params.intr_batch_cntr_thres_entries = 0;
  855. }
  856. srng->hal_srng = hal_srng_setup(hal_soc, ring_type, ring_num,
  857. mac_id, &ring_params);
  858. if (!srng->hal_srng) {
  859. qdf_mem_free_consistent(soc->osdev, soc->osdev->dev,
  860. srng->alloc_size,
  861. srng->base_vaddr_unaligned,
  862. srng->base_paddr_unaligned, 0);
  863. }
  864. return 0;
  865. }
  866. /**
  867. * dp_srng_cleanup - Internal function to cleanup SRNG rings used by data path
  868. * Any buffers allocated and attached to ring entries are expected to be freed
  869. * before calling this function.
  870. */
  871. static void dp_srng_cleanup(struct dp_soc *soc, struct dp_srng *srng,
  872. int ring_type, int ring_num)
  873. {
  874. if (!srng->hal_srng) {
  875. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  876. FL("Ring type: %d, num:%d not setup"),
  877. ring_type, ring_num);
  878. return;
  879. }
  880. hal_srng_cleanup(soc->hal_soc, srng->hal_srng);
  881. qdf_mem_free_consistent(soc->osdev, soc->osdev->dev,
  882. srng->alloc_size,
  883. srng->base_vaddr_unaligned,
  884. srng->base_paddr_unaligned, 0);
  885. srng->hal_srng = NULL;
  886. }
  887. /* TODO: Need this interface from HIF */
  888. void *hif_get_hal_handle(void *hif_handle);
  889. /*
  890. * dp_service_srngs() - Top level interrupt handler for DP Ring interrupts
  891. * @dp_ctx: DP SOC handle
  892. * @budget: Number of frames/descriptors that can be processed in one shot
  893. *
  894. * Return: remaining budget/quota for the soc device
  895. */
  896. static uint32_t dp_service_srngs(void *dp_ctx, uint32_t dp_budget)
  897. {
  898. struct dp_intr *int_ctx = (struct dp_intr *)dp_ctx;
  899. struct dp_soc *soc = int_ctx->soc;
  900. int ring = 0;
  901. uint32_t work_done = 0;
  902. int budget = dp_budget;
  903. uint8_t tx_mask = int_ctx->tx_ring_mask;
  904. uint8_t rx_mask = int_ctx->rx_ring_mask;
  905. uint8_t rx_err_mask = int_ctx->rx_err_ring_mask;
  906. uint8_t rx_wbm_rel_mask = int_ctx->rx_wbm_rel_ring_mask;
  907. uint8_t reo_status_mask = int_ctx->reo_status_ring_mask;
  908. uint32_t remaining_quota = dp_budget;
  909. struct dp_pdev *pdev = NULL;
  910. int mac_id;
  911. /* Process Tx completion interrupts first to return back buffers */
  912. while (tx_mask) {
  913. if (tx_mask & 0x1) {
  914. work_done = dp_tx_comp_handler(soc,
  915. soc->tx_comp_ring[ring].hal_srng,
  916. remaining_quota);
  917. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  918. "tx mask 0x%x ring %d, budget %d, work_done %d",
  919. tx_mask, ring, budget, work_done);
  920. budget -= work_done;
  921. if (budget <= 0)
  922. goto budget_done;
  923. remaining_quota = budget;
  924. }
  925. tx_mask = tx_mask >> 1;
  926. ring++;
  927. }
  928. /* Process REO Exception ring interrupt */
  929. if (rx_err_mask) {
  930. work_done = dp_rx_err_process(soc,
  931. soc->reo_exception_ring.hal_srng,
  932. remaining_quota);
  933. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  934. "REO Exception Ring: work_done %d budget %d",
  935. work_done, budget);
  936. budget -= work_done;
  937. if (budget <= 0) {
  938. goto budget_done;
  939. }
  940. remaining_quota = budget;
  941. }
  942. /* Process Rx WBM release ring interrupt */
  943. if (rx_wbm_rel_mask) {
  944. work_done = dp_rx_wbm_err_process(soc,
  945. soc->rx_rel_ring.hal_srng, remaining_quota);
  946. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  947. "WBM Release Ring: work_done %d budget %d",
  948. work_done, budget);
  949. budget -= work_done;
  950. if (budget <= 0) {
  951. goto budget_done;
  952. }
  953. remaining_quota = budget;
  954. }
  955. /* Process Rx interrupts */
  956. if (rx_mask) {
  957. for (ring = 0; ring < soc->num_reo_dest_rings; ring++) {
  958. if (rx_mask & (1 << ring)) {
  959. work_done = dp_rx_process(int_ctx,
  960. soc->reo_dest_ring[ring].hal_srng,
  961. remaining_quota);
  962. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  963. "rx mask 0x%x ring %d, work_done %d budget %d",
  964. rx_mask, ring, work_done, budget);
  965. budget -= work_done;
  966. if (budget <= 0)
  967. goto budget_done;
  968. remaining_quota = budget;
  969. }
  970. }
  971. for (ring = 0; ring < MAX_RX_MAC_RINGS; ring++) {
  972. work_done = dp_rxdma_err_process(soc, ring,
  973. remaining_quota);
  974. budget -= work_done;
  975. }
  976. }
  977. if (reo_status_mask)
  978. dp_reo_status_ring_handler(soc);
  979. /* Process LMAC interrupts */
  980. for (ring = 0 ; ring < MAX_PDEV_CNT; ring++) {
  981. pdev = soc->pdev_list[ring];
  982. if (pdev == NULL)
  983. continue;
  984. for (mac_id = 0; mac_id < NUM_RXDMA_RINGS_PER_PDEV; mac_id++) {
  985. int mac_for_pdev = dp_get_mac_id_for_pdev(mac_id,
  986. pdev->pdev_id);
  987. if (int_ctx->rx_mon_ring_mask & (1 << mac_for_pdev)) {
  988. work_done = dp_mon_process(soc, mac_for_pdev,
  989. remaining_quota);
  990. budget -= work_done;
  991. if (budget <= 0)
  992. goto budget_done;
  993. remaining_quota = budget;
  994. }
  995. if (int_ctx->rxdma2host_ring_mask &
  996. (1 << mac_for_pdev)) {
  997. work_done = dp_rxdma_err_process(soc,
  998. mac_for_pdev,
  999. remaining_quota);
  1000. budget -= work_done;
  1001. if (budget <= 0)
  1002. goto budget_done;
  1003. remaining_quota = budget;
  1004. }
  1005. if (int_ctx->host2rxdma_ring_mask &
  1006. (1 << mac_for_pdev)) {
  1007. union dp_rx_desc_list_elem_t *desc_list = NULL;
  1008. union dp_rx_desc_list_elem_t *tail = NULL;
  1009. struct dp_srng *rx_refill_buf_ring =
  1010. &pdev->rx_refill_buf_ring;
  1011. DP_STATS_INC(pdev, replenish.low_thresh_intrs,
  1012. 1);
  1013. dp_rx_buffers_replenish(soc, mac_for_pdev,
  1014. rx_refill_buf_ring,
  1015. &soc->rx_desc_buf[mac_for_pdev], 0,
  1016. &desc_list, &tail);
  1017. }
  1018. }
  1019. }
  1020. qdf_lro_flush(int_ctx->lro_ctx);
  1021. budget_done:
  1022. return dp_budget - budget;
  1023. }
  1024. #ifdef DP_INTR_POLL_BASED
  1025. /* dp_interrupt_timer()- timer poll for interrupts
  1026. *
  1027. * @arg: SoC Handle
  1028. *
  1029. * Return:
  1030. *
  1031. */
  1032. static void dp_interrupt_timer(void *arg)
  1033. {
  1034. struct dp_soc *soc = (struct dp_soc *) arg;
  1035. int i;
  1036. if (qdf_atomic_read(&soc->cmn_init_done)) {
  1037. for (i = 0;
  1038. i < wlan_cfg_get_num_contexts(soc->wlan_cfg_ctx); i++)
  1039. dp_service_srngs(&soc->intr_ctx[i], 0xffff);
  1040. qdf_timer_mod(&soc->int_timer, DP_INTR_POLL_TIMER_MS);
  1041. }
  1042. }
  1043. /*
  1044. * dp_soc_interrupt_attach_poll() - Register handlers for DP interrupts
  1045. * @txrx_soc: DP SOC handle
  1046. *
  1047. * Host driver will register for “DP_NUM_INTERRUPT_CONTEXTS” number of NAPI
  1048. * contexts. Each NAPI context will have a tx_ring_mask , rx_ring_mask ,and
  1049. * rx_monitor_ring mask to indicate the rings that are processed by the handler.
  1050. *
  1051. * Return: 0 for success. nonzero for failure.
  1052. */
  1053. static QDF_STATUS dp_soc_attach_poll(void *txrx_soc)
  1054. {
  1055. struct dp_soc *soc = (struct dp_soc *)txrx_soc;
  1056. int i;
  1057. soc->intr_mode = DP_INTR_POLL;
  1058. for (i = 0; i < wlan_cfg_get_num_contexts(soc->wlan_cfg_ctx); i++) {
  1059. soc->intr_ctx[i].dp_intr_id = i;
  1060. soc->intr_ctx[i].tx_ring_mask =
  1061. wlan_cfg_get_tx_ring_mask(soc->wlan_cfg_ctx, i);
  1062. soc->intr_ctx[i].rx_ring_mask =
  1063. wlan_cfg_get_rx_ring_mask(soc->wlan_cfg_ctx, i);
  1064. soc->intr_ctx[i].rx_mon_ring_mask =
  1065. wlan_cfg_get_rx_mon_ring_mask(soc->wlan_cfg_ctx, i);
  1066. soc->intr_ctx[i].rx_err_ring_mask =
  1067. wlan_cfg_get_rx_err_ring_mask(soc->wlan_cfg_ctx, i);
  1068. soc->intr_ctx[i].rx_wbm_rel_ring_mask =
  1069. wlan_cfg_get_rx_wbm_rel_ring_mask(soc->wlan_cfg_ctx, i);
  1070. soc->intr_ctx[i].reo_status_ring_mask =
  1071. wlan_cfg_get_reo_status_ring_mask(soc->wlan_cfg_ctx, i);
  1072. soc->intr_ctx[i].rxdma2host_ring_mask =
  1073. wlan_cfg_get_rxdma2host_ring_mask(soc->wlan_cfg_ctx, i);
  1074. soc->intr_ctx[i].soc = soc;
  1075. soc->intr_ctx[i].lro_ctx = qdf_lro_init();
  1076. }
  1077. qdf_timer_init(soc->osdev, &soc->int_timer,
  1078. dp_interrupt_timer, (void *)soc,
  1079. QDF_TIMER_TYPE_WAKE_APPS);
  1080. return QDF_STATUS_SUCCESS;
  1081. }
  1082. #else
  1083. static QDF_STATUS dp_soc_attach_poll(void *txrx_soc)
  1084. {
  1085. return -QDF_STATUS_E_NOSUPPORT;
  1086. }
  1087. #endif
  1088. static QDF_STATUS dp_soc_interrupt_attach(void *txrx_soc);
  1089. #if defined(CONFIG_MCL)
  1090. extern int con_mode_monitor;
  1091. /*
  1092. * dp_soc_interrupt_attach_wrapper() - Register handlers for DP interrupts
  1093. * @txrx_soc: DP SOC handle
  1094. *
  1095. * Call the appropriate attach function based on the mode of operation.
  1096. * This is a WAR for enabling monitor mode.
  1097. *
  1098. * Return: 0 for success. nonzero for failure.
  1099. */
  1100. static QDF_STATUS dp_soc_interrupt_attach_wrapper(void *txrx_soc)
  1101. {
  1102. struct dp_soc *soc = (struct dp_soc *)txrx_soc;
  1103. if (!(soc->wlan_cfg_ctx->napi_enabled) ||
  1104. con_mode_monitor == QDF_GLOBAL_MONITOR_MODE) {
  1105. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  1106. "%s: Poll mode", __func__);
  1107. return dp_soc_attach_poll(txrx_soc);
  1108. } else {
  1109. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  1110. "%s: Interrupt mode", __func__);
  1111. return dp_soc_interrupt_attach(txrx_soc);
  1112. }
  1113. }
  1114. #else
  1115. static QDF_STATUS dp_soc_interrupt_attach_wrapper(void *txrx_soc)
  1116. {
  1117. struct dp_soc *soc = (struct dp_soc *)txrx_soc;
  1118. if (hif_is_polled_mode_enabled(soc->hif_handle))
  1119. return dp_soc_attach_poll(txrx_soc);
  1120. else
  1121. return dp_soc_interrupt_attach(txrx_soc);
  1122. }
  1123. #endif
  1124. static void dp_soc_interrupt_map_calculate_integrated(struct dp_soc *soc,
  1125. int intr_ctx_num, int *irq_id_map, int *num_irq_r)
  1126. {
  1127. int j;
  1128. int num_irq = 0;
  1129. int tx_mask =
  1130. wlan_cfg_get_tx_ring_mask(soc->wlan_cfg_ctx, intr_ctx_num);
  1131. int rx_mask =
  1132. wlan_cfg_get_rx_ring_mask(soc->wlan_cfg_ctx, intr_ctx_num);
  1133. int rx_mon_mask =
  1134. wlan_cfg_get_rx_mon_ring_mask(soc->wlan_cfg_ctx, intr_ctx_num);
  1135. int rx_err_ring_mask = wlan_cfg_get_rx_err_ring_mask(
  1136. soc->wlan_cfg_ctx, intr_ctx_num);
  1137. int rx_wbm_rel_ring_mask = wlan_cfg_get_rx_wbm_rel_ring_mask(
  1138. soc->wlan_cfg_ctx, intr_ctx_num);
  1139. int reo_status_ring_mask = wlan_cfg_get_reo_status_ring_mask(
  1140. soc->wlan_cfg_ctx, intr_ctx_num);
  1141. int rxdma2host_ring_mask = wlan_cfg_get_rxdma2host_ring_mask(
  1142. soc->wlan_cfg_ctx, intr_ctx_num);
  1143. int host2rxdma_ring_mask = wlan_cfg_get_host2rxdma_ring_mask(
  1144. soc->wlan_cfg_ctx, intr_ctx_num);
  1145. for (j = 0; j < HIF_MAX_GRP_IRQ; j++) {
  1146. if (tx_mask & (1 << j)) {
  1147. irq_id_map[num_irq++] =
  1148. (wbm2host_tx_completions_ring1 - j);
  1149. }
  1150. if (rx_mask & (1 << j)) {
  1151. irq_id_map[num_irq++] =
  1152. (reo2host_destination_ring1 - j);
  1153. }
  1154. if (rxdma2host_ring_mask & (1 << j)) {
  1155. irq_id_map[num_irq++] =
  1156. rxdma2host_destination_ring_mac1 -
  1157. wlan_cfg_get_hw_mac_idx(soc->wlan_cfg_ctx, j);
  1158. }
  1159. if (host2rxdma_ring_mask & (1 << j)) {
  1160. irq_id_map[num_irq++] =
  1161. host2rxdma_host_buf_ring_mac1 -
  1162. wlan_cfg_get_hw_mac_idx(soc->wlan_cfg_ctx, j);
  1163. }
  1164. if (rx_mon_mask & (1 << j)) {
  1165. irq_id_map[num_irq++] =
  1166. ppdu_end_interrupts_mac1 -
  1167. wlan_cfg_get_hw_mac_idx(soc->wlan_cfg_ctx, j);
  1168. irq_id_map[num_irq++] =
  1169. rxdma2host_monitor_status_ring_mac1 -
  1170. wlan_cfg_get_hw_mac_idx(soc->wlan_cfg_ctx, j);
  1171. }
  1172. if (rx_wbm_rel_ring_mask & (1 << j))
  1173. irq_id_map[num_irq++] = wbm2host_rx_release;
  1174. if (rx_err_ring_mask & (1 << j))
  1175. irq_id_map[num_irq++] = reo2host_exception;
  1176. if (reo_status_ring_mask & (1 << j))
  1177. irq_id_map[num_irq++] = reo2host_status;
  1178. }
  1179. *num_irq_r = num_irq;
  1180. }
  1181. static void dp_soc_interrupt_map_calculate_msi(struct dp_soc *soc,
  1182. int intr_ctx_num, int *irq_id_map, int *num_irq_r,
  1183. int msi_vector_count, int msi_vector_start)
  1184. {
  1185. int tx_mask = wlan_cfg_get_tx_ring_mask(
  1186. soc->wlan_cfg_ctx, intr_ctx_num);
  1187. int rx_mask = wlan_cfg_get_rx_ring_mask(
  1188. soc->wlan_cfg_ctx, intr_ctx_num);
  1189. int rx_mon_mask = wlan_cfg_get_rx_mon_ring_mask(
  1190. soc->wlan_cfg_ctx, intr_ctx_num);
  1191. int rx_err_ring_mask = wlan_cfg_get_rx_err_ring_mask(
  1192. soc->wlan_cfg_ctx, intr_ctx_num);
  1193. int rx_wbm_rel_ring_mask = wlan_cfg_get_rx_wbm_rel_ring_mask(
  1194. soc->wlan_cfg_ctx, intr_ctx_num);
  1195. int reo_status_ring_mask = wlan_cfg_get_reo_status_ring_mask(
  1196. soc->wlan_cfg_ctx, intr_ctx_num);
  1197. int rxdma2host_ring_mask = wlan_cfg_get_rxdma2host_ring_mask(
  1198. soc->wlan_cfg_ctx, intr_ctx_num);
  1199. unsigned int vector =
  1200. (intr_ctx_num % msi_vector_count) + msi_vector_start;
  1201. int num_irq = 0;
  1202. soc->intr_mode = DP_INTR_MSI;
  1203. if (tx_mask | rx_mask | rx_mon_mask | rx_err_ring_mask |
  1204. rx_wbm_rel_ring_mask | reo_status_ring_mask | rxdma2host_ring_mask)
  1205. irq_id_map[num_irq++] =
  1206. pld_get_msi_irq(soc->osdev->dev, vector);
  1207. *num_irq_r = num_irq;
  1208. }
  1209. static void dp_soc_interrupt_map_calculate(struct dp_soc *soc, int intr_ctx_num,
  1210. int *irq_id_map, int *num_irq)
  1211. {
  1212. int msi_vector_count, ret;
  1213. uint32_t msi_base_data, msi_vector_start;
  1214. ret = pld_get_user_msi_assignment(soc->osdev->dev, "DP",
  1215. &msi_vector_count,
  1216. &msi_base_data,
  1217. &msi_vector_start);
  1218. if (ret)
  1219. return dp_soc_interrupt_map_calculate_integrated(soc,
  1220. intr_ctx_num, irq_id_map, num_irq);
  1221. else
  1222. dp_soc_interrupt_map_calculate_msi(soc,
  1223. intr_ctx_num, irq_id_map, num_irq,
  1224. msi_vector_count, msi_vector_start);
  1225. }
  1226. /*
  1227. * dp_soc_interrupt_attach() - Register handlers for DP interrupts
  1228. * @txrx_soc: DP SOC handle
  1229. *
  1230. * Host driver will register for “DP_NUM_INTERRUPT_CONTEXTS” number of NAPI
  1231. * contexts. Each NAPI context will have a tx_ring_mask , rx_ring_mask ,and
  1232. * rx_monitor_ring mask to indicate the rings that are processed by the handler.
  1233. *
  1234. * Return: 0 for success. nonzero for failure.
  1235. */
  1236. static QDF_STATUS dp_soc_interrupt_attach(void *txrx_soc)
  1237. {
  1238. struct dp_soc *soc = (struct dp_soc *)txrx_soc;
  1239. int i = 0;
  1240. int num_irq = 0;
  1241. for (i = 0; i < wlan_cfg_get_num_contexts(soc->wlan_cfg_ctx); i++) {
  1242. int ret = 0;
  1243. /* Map of IRQ ids registered with one interrupt context */
  1244. int irq_id_map[HIF_MAX_GRP_IRQ];
  1245. int tx_mask =
  1246. wlan_cfg_get_tx_ring_mask(soc->wlan_cfg_ctx, i);
  1247. int rx_mask =
  1248. wlan_cfg_get_rx_ring_mask(soc->wlan_cfg_ctx, i);
  1249. int rx_mon_mask =
  1250. dp_soc_get_mon_mask_for_interrupt_mode(soc, i);
  1251. int rx_err_ring_mask =
  1252. wlan_cfg_get_rx_err_ring_mask(soc->wlan_cfg_ctx, i);
  1253. int rx_wbm_rel_ring_mask =
  1254. wlan_cfg_get_rx_wbm_rel_ring_mask(soc->wlan_cfg_ctx, i);
  1255. int reo_status_ring_mask =
  1256. wlan_cfg_get_reo_status_ring_mask(soc->wlan_cfg_ctx, i);
  1257. int rxdma2host_ring_mask =
  1258. wlan_cfg_get_rxdma2host_ring_mask(soc->wlan_cfg_ctx, i);
  1259. int host2rxdma_ring_mask =
  1260. wlan_cfg_get_host2rxdma_ring_mask(soc->wlan_cfg_ctx, i);
  1261. soc->intr_ctx[i].dp_intr_id = i;
  1262. soc->intr_ctx[i].tx_ring_mask = tx_mask;
  1263. soc->intr_ctx[i].rx_ring_mask = rx_mask;
  1264. soc->intr_ctx[i].rx_mon_ring_mask = rx_mon_mask;
  1265. soc->intr_ctx[i].rx_err_ring_mask = rx_err_ring_mask;
  1266. soc->intr_ctx[i].rxdma2host_ring_mask = rxdma2host_ring_mask;
  1267. soc->intr_ctx[i].host2rxdma_ring_mask = host2rxdma_ring_mask;
  1268. soc->intr_ctx[i].rx_wbm_rel_ring_mask = rx_wbm_rel_ring_mask;
  1269. soc->intr_ctx[i].reo_status_ring_mask = reo_status_ring_mask;
  1270. soc->intr_ctx[i].soc = soc;
  1271. num_irq = 0;
  1272. dp_soc_interrupt_map_calculate(soc, i, &irq_id_map[0],
  1273. &num_irq);
  1274. ret = hif_register_ext_group(soc->hif_handle,
  1275. num_irq, irq_id_map, dp_service_srngs,
  1276. &soc->intr_ctx[i], "dp_intr",
  1277. HIF_EXEC_NAPI_TYPE, QCA_NAPI_DEF_SCALE_BIN_SHIFT);
  1278. if (ret) {
  1279. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  1280. FL("failed, ret = %d"), ret);
  1281. return QDF_STATUS_E_FAILURE;
  1282. }
  1283. soc->intr_ctx[i].lro_ctx = qdf_lro_init();
  1284. }
  1285. hif_configure_ext_group_interrupts(soc->hif_handle);
  1286. return QDF_STATUS_SUCCESS;
  1287. }
  1288. /*
  1289. * dp_soc_interrupt_detach() - Deregister any allocations done for interrupts
  1290. * @txrx_soc: DP SOC handle
  1291. *
  1292. * Return: void
  1293. */
  1294. static void dp_soc_interrupt_detach(void *txrx_soc)
  1295. {
  1296. struct dp_soc *soc = (struct dp_soc *)txrx_soc;
  1297. int i;
  1298. if (soc->intr_mode == DP_INTR_POLL) {
  1299. qdf_timer_stop(&soc->int_timer);
  1300. qdf_timer_free(&soc->int_timer);
  1301. } else {
  1302. hif_deregister_exec_group(soc->hif_handle, "dp_intr");
  1303. }
  1304. for (i = 0; i < wlan_cfg_get_num_contexts(soc->wlan_cfg_ctx); i++) {
  1305. soc->intr_ctx[i].tx_ring_mask = 0;
  1306. soc->intr_ctx[i].rx_ring_mask = 0;
  1307. soc->intr_ctx[i].rx_mon_ring_mask = 0;
  1308. soc->intr_ctx[i].rx_err_ring_mask = 0;
  1309. soc->intr_ctx[i].rx_wbm_rel_ring_mask = 0;
  1310. soc->intr_ctx[i].reo_status_ring_mask = 0;
  1311. soc->intr_ctx[i].rxdma2host_ring_mask = 0;
  1312. soc->intr_ctx[i].host2rxdma_ring_mask = 0;
  1313. qdf_lro_deinit(soc->intr_ctx[i].lro_ctx);
  1314. }
  1315. }
  1316. #define AVG_MAX_MPDUS_PER_TID 128
  1317. #define AVG_TIDS_PER_CLIENT 2
  1318. #define AVG_FLOWS_PER_TID 2
  1319. #define AVG_MSDUS_PER_FLOW 128
  1320. #define AVG_MSDUS_PER_MPDU 4
  1321. /*
  1322. * Allocate and setup link descriptor pool that will be used by HW for
  1323. * various link and queue descriptors and managed by WBM
  1324. */
  1325. static int dp_hw_link_desc_pool_setup(struct dp_soc *soc)
  1326. {
  1327. int link_desc_size = hal_get_link_desc_size(soc->hal_soc);
  1328. int link_desc_align = hal_get_link_desc_align(soc->hal_soc);
  1329. uint32_t max_clients = wlan_cfg_get_max_clients(soc->wlan_cfg_ctx);
  1330. uint32_t num_mpdus_per_link_desc =
  1331. hal_num_mpdus_per_link_desc(soc->hal_soc);
  1332. uint32_t num_msdus_per_link_desc =
  1333. hal_num_msdus_per_link_desc(soc->hal_soc);
  1334. uint32_t num_mpdu_links_per_queue_desc =
  1335. hal_num_mpdu_links_per_queue_desc(soc->hal_soc);
  1336. uint32_t max_alloc_size = wlan_cfg_max_alloc_size(soc->wlan_cfg_ctx);
  1337. uint32_t total_link_descs, total_mem_size;
  1338. uint32_t num_mpdu_link_descs, num_mpdu_queue_descs;
  1339. uint32_t num_tx_msdu_link_descs, num_rx_msdu_link_descs;
  1340. uint32_t num_link_desc_banks;
  1341. uint32_t last_bank_size = 0;
  1342. uint32_t entry_size, num_entries;
  1343. int i;
  1344. uint32_t desc_id = 0;
  1345. /* Only Tx queue descriptors are allocated from common link descriptor
  1346. * pool Rx queue descriptors are not included in this because (REO queue
  1347. * extension descriptors) they are expected to be allocated contiguously
  1348. * with REO queue descriptors
  1349. */
  1350. num_mpdu_link_descs = (max_clients * AVG_TIDS_PER_CLIENT *
  1351. AVG_MAX_MPDUS_PER_TID) / num_mpdus_per_link_desc;
  1352. num_mpdu_queue_descs = num_mpdu_link_descs /
  1353. num_mpdu_links_per_queue_desc;
  1354. num_tx_msdu_link_descs = (max_clients * AVG_TIDS_PER_CLIENT *
  1355. AVG_FLOWS_PER_TID * AVG_MSDUS_PER_FLOW) /
  1356. num_msdus_per_link_desc;
  1357. num_rx_msdu_link_descs = (max_clients * AVG_TIDS_PER_CLIENT *
  1358. AVG_MAX_MPDUS_PER_TID * AVG_MSDUS_PER_MPDU) / 6;
  1359. num_entries = num_mpdu_link_descs + num_mpdu_queue_descs +
  1360. num_tx_msdu_link_descs + num_rx_msdu_link_descs;
  1361. /* Round up to power of 2 */
  1362. total_link_descs = 1;
  1363. while (total_link_descs < num_entries)
  1364. total_link_descs <<= 1;
  1365. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_HIGH,
  1366. FL("total_link_descs: %u, link_desc_size: %d"),
  1367. total_link_descs, link_desc_size);
  1368. total_mem_size = total_link_descs * link_desc_size;
  1369. total_mem_size += link_desc_align;
  1370. if (total_mem_size <= max_alloc_size) {
  1371. num_link_desc_banks = 0;
  1372. last_bank_size = total_mem_size;
  1373. } else {
  1374. num_link_desc_banks = (total_mem_size) /
  1375. (max_alloc_size - link_desc_align);
  1376. last_bank_size = total_mem_size %
  1377. (max_alloc_size - link_desc_align);
  1378. }
  1379. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_HIGH,
  1380. FL("total_mem_size: %d, num_link_desc_banks: %u"),
  1381. total_mem_size, num_link_desc_banks);
  1382. for (i = 0; i < num_link_desc_banks; i++) {
  1383. soc->link_desc_banks[i].base_vaddr_unaligned =
  1384. qdf_mem_alloc_consistent(soc->osdev, soc->osdev->dev,
  1385. max_alloc_size,
  1386. &(soc->link_desc_banks[i].base_paddr_unaligned));
  1387. soc->link_desc_banks[i].size = max_alloc_size;
  1388. soc->link_desc_banks[i].base_vaddr = (void *)((unsigned long)(
  1389. soc->link_desc_banks[i].base_vaddr_unaligned) +
  1390. ((unsigned long)(
  1391. soc->link_desc_banks[i].base_vaddr_unaligned) %
  1392. link_desc_align));
  1393. soc->link_desc_banks[i].base_paddr = (unsigned long)(
  1394. soc->link_desc_banks[i].base_paddr_unaligned) +
  1395. ((unsigned long)(soc->link_desc_banks[i].base_vaddr) -
  1396. (unsigned long)(
  1397. soc->link_desc_banks[i].base_vaddr_unaligned));
  1398. if (!soc->link_desc_banks[i].base_vaddr_unaligned) {
  1399. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  1400. FL("Link descriptor memory alloc failed"));
  1401. goto fail;
  1402. }
  1403. }
  1404. if (last_bank_size) {
  1405. /* Allocate last bank in case total memory required is not exact
  1406. * multiple of max_alloc_size
  1407. */
  1408. soc->link_desc_banks[i].base_vaddr_unaligned =
  1409. qdf_mem_alloc_consistent(soc->osdev, soc->osdev->dev,
  1410. last_bank_size,
  1411. &(soc->link_desc_banks[i].base_paddr_unaligned));
  1412. soc->link_desc_banks[i].size = last_bank_size;
  1413. soc->link_desc_banks[i].base_vaddr = (void *)((unsigned long)
  1414. (soc->link_desc_banks[i].base_vaddr_unaligned) +
  1415. ((unsigned long)(
  1416. soc->link_desc_banks[i].base_vaddr_unaligned) %
  1417. link_desc_align));
  1418. soc->link_desc_banks[i].base_paddr =
  1419. (unsigned long)(
  1420. soc->link_desc_banks[i].base_paddr_unaligned) +
  1421. ((unsigned long)(soc->link_desc_banks[i].base_vaddr) -
  1422. (unsigned long)(
  1423. soc->link_desc_banks[i].base_vaddr_unaligned));
  1424. }
  1425. /* Allocate and setup link descriptor idle list for HW internal use */
  1426. entry_size = hal_srng_get_entrysize(soc->hal_soc, WBM_IDLE_LINK);
  1427. total_mem_size = entry_size * total_link_descs;
  1428. if (total_mem_size <= max_alloc_size) {
  1429. void *desc;
  1430. if (dp_srng_setup(soc, &soc->wbm_idle_link_ring,
  1431. WBM_IDLE_LINK, 0, 0, total_link_descs)) {
  1432. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  1433. FL("Link desc idle ring setup failed"));
  1434. goto fail;
  1435. }
  1436. hal_srng_access_start_unlocked(soc->hal_soc,
  1437. soc->wbm_idle_link_ring.hal_srng);
  1438. for (i = 0; i < MAX_LINK_DESC_BANKS &&
  1439. soc->link_desc_banks[i].base_paddr; i++) {
  1440. uint32_t num_entries = (soc->link_desc_banks[i].size -
  1441. ((unsigned long)(
  1442. soc->link_desc_banks[i].base_vaddr) -
  1443. (unsigned long)(
  1444. soc->link_desc_banks[i].base_vaddr_unaligned)))
  1445. / link_desc_size;
  1446. unsigned long paddr = (unsigned long)(
  1447. soc->link_desc_banks[i].base_paddr);
  1448. while (num_entries && (desc = hal_srng_src_get_next(
  1449. soc->hal_soc,
  1450. soc->wbm_idle_link_ring.hal_srng))) {
  1451. hal_set_link_desc_addr(desc,
  1452. LINK_DESC_COOKIE(desc_id, i), paddr);
  1453. num_entries--;
  1454. desc_id++;
  1455. paddr += link_desc_size;
  1456. }
  1457. }
  1458. hal_srng_access_end_unlocked(soc->hal_soc,
  1459. soc->wbm_idle_link_ring.hal_srng);
  1460. } else {
  1461. uint32_t num_scatter_bufs;
  1462. uint32_t num_entries_per_buf;
  1463. uint32_t rem_entries;
  1464. uint8_t *scatter_buf_ptr;
  1465. uint16_t scatter_buf_num;
  1466. soc->wbm_idle_scatter_buf_size =
  1467. hal_idle_list_scatter_buf_size(soc->hal_soc);
  1468. num_entries_per_buf = hal_idle_scatter_buf_num_entries(
  1469. soc->hal_soc, soc->wbm_idle_scatter_buf_size);
  1470. num_scatter_bufs = hal_idle_list_num_scatter_bufs(
  1471. soc->hal_soc, total_mem_size,
  1472. soc->wbm_idle_scatter_buf_size);
  1473. if (num_scatter_bufs > MAX_IDLE_SCATTER_BUFS) {
  1474. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  1475. FL("scatter bufs size out of bounds"));
  1476. goto fail;
  1477. }
  1478. for (i = 0; i < num_scatter_bufs; i++) {
  1479. soc->wbm_idle_scatter_buf_base_vaddr[i] =
  1480. qdf_mem_alloc_consistent(soc->osdev,
  1481. soc->osdev->dev,
  1482. soc->wbm_idle_scatter_buf_size,
  1483. &(soc->wbm_idle_scatter_buf_base_paddr[i]));
  1484. if (soc->wbm_idle_scatter_buf_base_vaddr[i] == NULL) {
  1485. QDF_TRACE(QDF_MODULE_ID_DP,
  1486. QDF_TRACE_LEVEL_ERROR,
  1487. FL("Scatter list memory alloc failed"));
  1488. goto fail;
  1489. }
  1490. }
  1491. /* Populate idle list scatter buffers with link descriptor
  1492. * pointers
  1493. */
  1494. scatter_buf_num = 0;
  1495. scatter_buf_ptr = (uint8_t *)(
  1496. soc->wbm_idle_scatter_buf_base_vaddr[scatter_buf_num]);
  1497. rem_entries = num_entries_per_buf;
  1498. for (i = 0; i < MAX_LINK_DESC_BANKS &&
  1499. soc->link_desc_banks[i].base_paddr; i++) {
  1500. uint32_t num_link_descs =
  1501. (soc->link_desc_banks[i].size -
  1502. ((unsigned long)(
  1503. soc->link_desc_banks[i].base_vaddr) -
  1504. (unsigned long)(
  1505. soc->link_desc_banks[i].base_vaddr_unaligned)))
  1506. / link_desc_size;
  1507. unsigned long paddr = (unsigned long)(
  1508. soc->link_desc_banks[i].base_paddr);
  1509. while (num_link_descs) {
  1510. hal_set_link_desc_addr((void *)scatter_buf_ptr,
  1511. LINK_DESC_COOKIE(desc_id, i), paddr);
  1512. num_link_descs--;
  1513. desc_id++;
  1514. paddr += link_desc_size;
  1515. rem_entries--;
  1516. if (rem_entries) {
  1517. scatter_buf_ptr += entry_size;
  1518. } else {
  1519. rem_entries = num_entries_per_buf;
  1520. scatter_buf_num++;
  1521. if (scatter_buf_num >= num_scatter_bufs)
  1522. break;
  1523. scatter_buf_ptr = (uint8_t *)(
  1524. soc->wbm_idle_scatter_buf_base_vaddr[
  1525. scatter_buf_num]);
  1526. }
  1527. }
  1528. }
  1529. /* Setup link descriptor idle list in HW */
  1530. hal_setup_link_idle_list(soc->hal_soc,
  1531. soc->wbm_idle_scatter_buf_base_paddr,
  1532. soc->wbm_idle_scatter_buf_base_vaddr,
  1533. num_scatter_bufs, soc->wbm_idle_scatter_buf_size,
  1534. (uint32_t)(scatter_buf_ptr -
  1535. (uint8_t *)(soc->wbm_idle_scatter_buf_base_vaddr[
  1536. scatter_buf_num-1])), total_link_descs);
  1537. }
  1538. return 0;
  1539. fail:
  1540. if (soc->wbm_idle_link_ring.hal_srng) {
  1541. dp_srng_cleanup(soc->hal_soc, &soc->wbm_idle_link_ring,
  1542. WBM_IDLE_LINK, 0);
  1543. }
  1544. for (i = 0; i < MAX_IDLE_SCATTER_BUFS; i++) {
  1545. if (soc->wbm_idle_scatter_buf_base_vaddr[i]) {
  1546. qdf_mem_free_consistent(soc->osdev, soc->osdev->dev,
  1547. soc->wbm_idle_scatter_buf_size,
  1548. soc->wbm_idle_scatter_buf_base_vaddr[i],
  1549. soc->wbm_idle_scatter_buf_base_paddr[i], 0);
  1550. soc->wbm_idle_scatter_buf_base_vaddr[i] = NULL;
  1551. }
  1552. }
  1553. for (i = 0; i < MAX_LINK_DESC_BANKS; i++) {
  1554. if (soc->link_desc_banks[i].base_vaddr_unaligned) {
  1555. qdf_mem_free_consistent(soc->osdev, soc->osdev->dev,
  1556. soc->link_desc_banks[i].size,
  1557. soc->link_desc_banks[i].base_vaddr_unaligned,
  1558. soc->link_desc_banks[i].base_paddr_unaligned,
  1559. 0);
  1560. soc->link_desc_banks[i].base_vaddr_unaligned = NULL;
  1561. }
  1562. }
  1563. return QDF_STATUS_E_FAILURE;
  1564. }
  1565. /*
  1566. * Free link descriptor pool that was setup HW
  1567. */
  1568. static void dp_hw_link_desc_pool_cleanup(struct dp_soc *soc)
  1569. {
  1570. int i;
  1571. if (soc->wbm_idle_link_ring.hal_srng) {
  1572. dp_srng_cleanup(soc, &soc->wbm_idle_link_ring,
  1573. WBM_IDLE_LINK, 0);
  1574. }
  1575. for (i = 0; i < MAX_IDLE_SCATTER_BUFS; i++) {
  1576. if (soc->wbm_idle_scatter_buf_base_vaddr[i]) {
  1577. qdf_mem_free_consistent(soc->osdev, soc->osdev->dev,
  1578. soc->wbm_idle_scatter_buf_size,
  1579. soc->wbm_idle_scatter_buf_base_vaddr[i],
  1580. soc->wbm_idle_scatter_buf_base_paddr[i], 0);
  1581. soc->wbm_idle_scatter_buf_base_vaddr[i] = NULL;
  1582. }
  1583. }
  1584. for (i = 0; i < MAX_LINK_DESC_BANKS; i++) {
  1585. if (soc->link_desc_banks[i].base_vaddr_unaligned) {
  1586. qdf_mem_free_consistent(soc->osdev, soc->osdev->dev,
  1587. soc->link_desc_banks[i].size,
  1588. soc->link_desc_banks[i].base_vaddr_unaligned,
  1589. soc->link_desc_banks[i].base_paddr_unaligned,
  1590. 0);
  1591. soc->link_desc_banks[i].base_vaddr_unaligned = NULL;
  1592. }
  1593. }
  1594. }
  1595. #define REO_DST_RING_SIZE_QCA6290 1024
  1596. #define REO_DST_RING_SIZE_QCA8074 2048
  1597. /*
  1598. * dp_wds_aging_timer_fn() - Timer callback function for WDS aging
  1599. * @soc: Datapath SOC handle
  1600. *
  1601. * This is a timer function used to age out stale AST nodes from
  1602. * AST table
  1603. */
  1604. #ifdef FEATURE_WDS
  1605. static void dp_wds_aging_timer_fn(void *soc_hdl)
  1606. {
  1607. struct dp_soc *soc = (struct dp_soc *) soc_hdl;
  1608. struct dp_pdev *pdev;
  1609. struct dp_vdev *vdev;
  1610. struct dp_peer *peer;
  1611. struct dp_ast_entry *ase, *temp_ase;
  1612. int i;
  1613. qdf_spin_lock_bh(&soc->ast_lock);
  1614. for (i = 0; i < MAX_PDEV_CNT && soc->pdev_list[i]; i++) {
  1615. pdev = soc->pdev_list[i];
  1616. qdf_spin_lock_bh(&pdev->vdev_list_lock);
  1617. DP_PDEV_ITERATE_VDEV_LIST(pdev, vdev) {
  1618. DP_VDEV_ITERATE_PEER_LIST(vdev, peer) {
  1619. DP_PEER_ITERATE_ASE_LIST(peer, ase, temp_ase) {
  1620. /*
  1621. * Do not expire static ast entries
  1622. * and HM WDS entries
  1623. */
  1624. if (ase->type != CDP_TXRX_AST_TYPE_WDS)
  1625. continue;
  1626. if (ase->is_active) {
  1627. ase->is_active = FALSE;
  1628. continue;
  1629. }
  1630. DP_STATS_INC(soc, ast.aged_out, 1);
  1631. dp_peer_del_ast(soc, ase);
  1632. }
  1633. }
  1634. }
  1635. qdf_spin_unlock_bh(&pdev->vdev_list_lock);
  1636. }
  1637. qdf_spin_unlock_bh(&soc->ast_lock);
  1638. if (qdf_atomic_read(&soc->cmn_init_done))
  1639. qdf_timer_mod(&soc->wds_aging_timer, DP_WDS_AGING_TIMER_DEFAULT_MS);
  1640. }
  1641. /*
  1642. * dp_soc_wds_attach() - Setup WDS timer and AST table
  1643. * @soc: Datapath SOC handle
  1644. *
  1645. * Return: None
  1646. */
  1647. static void dp_soc_wds_attach(struct dp_soc *soc)
  1648. {
  1649. qdf_timer_init(soc->osdev, &soc->wds_aging_timer,
  1650. dp_wds_aging_timer_fn, (void *)soc,
  1651. QDF_TIMER_TYPE_WAKE_APPS);
  1652. qdf_timer_mod(&soc->wds_aging_timer, DP_WDS_AGING_TIMER_DEFAULT_MS);
  1653. }
  1654. /*
  1655. * dp_soc_wds_detach() - Detach WDS data structures and timers
  1656. * @txrx_soc: DP SOC handle
  1657. *
  1658. * Return: None
  1659. */
  1660. static void dp_soc_wds_detach(struct dp_soc *soc)
  1661. {
  1662. qdf_timer_stop(&soc->wds_aging_timer);
  1663. qdf_timer_free(&soc->wds_aging_timer);
  1664. }
  1665. #else
  1666. static void dp_soc_wds_attach(struct dp_soc *soc)
  1667. {
  1668. }
  1669. static void dp_soc_wds_detach(struct dp_soc *soc)
  1670. {
  1671. }
  1672. #endif
  1673. /*
  1674. * dp_soc_reset_ring_map() - Reset cpu ring map
  1675. * @soc: Datapath soc handler
  1676. *
  1677. * This api resets the default cpu ring map
  1678. */
  1679. static void dp_soc_reset_cpu_ring_map(struct dp_soc *soc)
  1680. {
  1681. uint8_t i;
  1682. int nss_config = wlan_cfg_get_dp_soc_nss_cfg(soc->wlan_cfg_ctx);
  1683. for (i = 0; i < WLAN_CFG_INT_NUM_CONTEXTS; i++) {
  1684. if (nss_config == 1) {
  1685. /*
  1686. * Setting Tx ring map for one nss offloaded radio
  1687. */
  1688. soc->tx_ring_map[i] = dp_cpu_ring_map[DP_NSS_FIRST_RADIO_OFFLOADED_MAP][i];
  1689. } else if (nss_config == 2) {
  1690. /*
  1691. * Setting Tx ring for two nss offloaded radios
  1692. */
  1693. soc->tx_ring_map[i] = dp_cpu_ring_map[DP_NSS_SECOND_RADIO_OFFLOADED_MAP][i];
  1694. } else {
  1695. /*
  1696. * Setting Tx ring map for all nss offloaded radios
  1697. */
  1698. soc->tx_ring_map[i] = dp_cpu_ring_map[DP_NSS_ALL_RADIO_OFFLOADED_MAP][i];
  1699. }
  1700. }
  1701. }
  1702. /*
  1703. * dp_soc_ring_if_nss_offloaded() - find if ring is offloaded to NSS
  1704. * @dp_soc - DP soc handle
  1705. * @ring_type - ring type
  1706. * @ring_num - ring_num
  1707. *
  1708. * return 0 or 1
  1709. */
  1710. static uint8_t dp_soc_ring_if_nss_offloaded(struct dp_soc *soc, enum hal_ring_type ring_type, int ring_num)
  1711. {
  1712. uint8_t nss_config = wlan_cfg_get_dp_soc_nss_cfg(soc->wlan_cfg_ctx);
  1713. uint8_t status = 0;
  1714. switch (ring_type) {
  1715. case WBM2SW_RELEASE:
  1716. case REO_DST:
  1717. case RXDMA_BUF:
  1718. status = ((nss_config) & (1 << ring_num));
  1719. break;
  1720. default:
  1721. break;
  1722. }
  1723. return status;
  1724. }
  1725. /*
  1726. * dp_soc_reset_intr_mask() - reset interrupt mask
  1727. * @dp_soc - DP Soc handle
  1728. *
  1729. * Return: Return void
  1730. */
  1731. static void dp_soc_reset_intr_mask(struct dp_soc *soc)
  1732. {
  1733. uint8_t j;
  1734. int *grp_mask = NULL;
  1735. int group_number, mask, num_ring;
  1736. /* number of tx ring */
  1737. num_ring = wlan_cfg_num_tcl_data_rings(soc->wlan_cfg_ctx);
  1738. /*
  1739. * group mask for tx completion ring.
  1740. */
  1741. grp_mask = &soc->wlan_cfg_ctx->int_tx_ring_mask[0];
  1742. /* loop and reset the mask for only offloaded ring */
  1743. for (j = 0; j < num_ring; j++) {
  1744. if (!dp_soc_ring_if_nss_offloaded(soc, WBM2SW_RELEASE, j)) {
  1745. continue;
  1746. }
  1747. /*
  1748. * Group number corresponding to tx offloaded ring.
  1749. */
  1750. group_number = dp_srng_find_ring_in_mask(j, grp_mask);
  1751. if (group_number < 0) {
  1752. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1753. FL("ring not part of any group; ring_type: %d,ring_num %d"),
  1754. WBM2SW_RELEASE, j);
  1755. return;
  1756. }
  1757. /* reset the tx mask for offloaded ring */
  1758. mask = wlan_cfg_get_tx_ring_mask(soc->wlan_cfg_ctx, group_number);
  1759. mask &= (~(1 << j));
  1760. /*
  1761. * reset the interrupt mask for offloaded ring.
  1762. */
  1763. wlan_cfg_set_tx_ring_mask(soc->wlan_cfg_ctx, group_number, mask);
  1764. }
  1765. /* number of rx rings */
  1766. num_ring = wlan_cfg_num_reo_dest_rings(soc->wlan_cfg_ctx);
  1767. /*
  1768. * group mask for reo destination ring.
  1769. */
  1770. grp_mask = &soc->wlan_cfg_ctx->int_rx_ring_mask[0];
  1771. /* loop and reset the mask for only offloaded ring */
  1772. for (j = 0; j < num_ring; j++) {
  1773. if (!dp_soc_ring_if_nss_offloaded(soc, REO_DST, j)) {
  1774. continue;
  1775. }
  1776. /*
  1777. * Group number corresponding to rx offloaded ring.
  1778. */
  1779. group_number = dp_srng_find_ring_in_mask(j, grp_mask);
  1780. if (group_number < 0) {
  1781. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1782. FL("ring not part of any group; ring_type: %d,ring_num %d"),
  1783. REO_DST, j);
  1784. return;
  1785. }
  1786. /* set the interrupt mask for offloaded ring */
  1787. mask = wlan_cfg_get_rx_ring_mask(soc->wlan_cfg_ctx, group_number);
  1788. mask &= (~(1 << j));
  1789. /*
  1790. * set the interrupt mask to zero for rx offloaded radio.
  1791. */
  1792. wlan_cfg_set_rx_ring_mask(soc->wlan_cfg_ctx, group_number, mask);
  1793. }
  1794. /*
  1795. * group mask for Rx buffer refill ring
  1796. */
  1797. grp_mask = &soc->wlan_cfg_ctx->int_host2rxdma_ring_mask[0];
  1798. /* loop and reset the mask for only offloaded ring */
  1799. for (j = 0; j < MAX_PDEV_CNT; j++) {
  1800. if (!dp_soc_ring_if_nss_offloaded(soc, RXDMA_BUF, j)) {
  1801. continue;
  1802. }
  1803. /*
  1804. * Group number corresponding to rx offloaded ring.
  1805. */
  1806. group_number = dp_srng_find_ring_in_mask(j, grp_mask);
  1807. if (group_number < 0) {
  1808. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1809. FL("ring not part of any group; ring_type: %d,ring_num %d"),
  1810. REO_DST, j);
  1811. return;
  1812. }
  1813. /* set the interrupt mask for offloaded ring */
  1814. mask = wlan_cfg_get_host2rxdma_ring_mask(soc->wlan_cfg_ctx,
  1815. group_number);
  1816. mask &= (~(1 << j));
  1817. /*
  1818. * set the interrupt mask to zero for rx offloaded radio.
  1819. */
  1820. wlan_cfg_set_host2rxdma_ring_mask(soc->wlan_cfg_ctx,
  1821. group_number, mask);
  1822. }
  1823. }
  1824. #ifdef IPA_OFFLOAD
  1825. /**
  1826. * dp_reo_remap_config() - configure reo remap register value based
  1827. * nss configuration.
  1828. * based on offload_radio value below remap configuration
  1829. * get applied.
  1830. * 0 - both Radios handled by host (remap rings 1, 2, 3 & 4)
  1831. * 1 - 1st Radio handled by NSS (remap rings 2, 3 & 4)
  1832. * 2 - 2nd Radio handled by NSS (remap rings 1, 2 & 4)
  1833. * 3 - both Radios handled by NSS (remap not required)
  1834. * 4 - IPA OFFLOAD enabled (remap rings 1,2 & 3)
  1835. *
  1836. * @remap1: output parameter indicates reo remap 1 register value
  1837. * @remap2: output parameter indicates reo remap 2 register value
  1838. * Return: bool type, true if remap is configured else false.
  1839. */
  1840. static bool dp_reo_remap_config(struct dp_soc *soc,
  1841. uint32_t *remap1,
  1842. uint32_t *remap2)
  1843. {
  1844. *remap1 = ((0x1 << 0) | (0x2 << 3) | (0x3 << 6) | (0x1 << 9) |
  1845. (0x2 << 12) | (0x3 << 15) | (0x1 << 18) | (0x2 << 21)) << 8;
  1846. *remap2 = ((0x3 << 0) | (0x1 << 3) | (0x2 << 6) | (0x3 << 9) |
  1847. (0x1 << 12) | (0x2 << 15) | (0x3 << 18) | (0x1 << 21)) << 8;
  1848. return true;
  1849. }
  1850. #else
  1851. static bool dp_reo_remap_config(struct dp_soc *soc,
  1852. uint32_t *remap1,
  1853. uint32_t *remap2)
  1854. {
  1855. uint8_t offload_radio = wlan_cfg_get_dp_soc_nss_cfg(soc->wlan_cfg_ctx);
  1856. switch (offload_radio) {
  1857. case 0:
  1858. *remap1 = ((0x1 << 0) | (0x2 << 3) | (0x3 << 6) |
  1859. (0x4 << 9) | (0x1 << 12) | (0x2 << 15) |
  1860. (0x3 << 18) | (0x4 << 21)) << 8;
  1861. *remap2 = ((0x1 << 0) | (0x2 << 3) | (0x3 << 6) |
  1862. (0x4 << 9) | (0x1 << 12) | (0x2 << 15) |
  1863. (0x3 << 18) | (0x4 << 21)) << 8;
  1864. break;
  1865. case 1:
  1866. *remap1 = ((0x2 << 0) | (0x3 << 3) | (0x4 << 6) |
  1867. (0x2 << 9) | (0x3 << 12) | (0x4 << 15) |
  1868. (0x2 << 18) | (0x3 << 21)) << 8;
  1869. *remap2 = ((0x4 << 0) | (0x2 << 3) | (0x3 << 6) |
  1870. (0x4 << 9) | (0x2 << 12) | (0x3 << 15) |
  1871. (0x4 << 18) | (0x2 << 21)) << 8;
  1872. break;
  1873. case 2:
  1874. *remap1 = ((0x1 << 0) | (0x3 << 3) | (0x4 << 6) |
  1875. (0x1 << 9) | (0x3 << 12) | (0x4 << 15) |
  1876. (0x1 << 18) | (0x3 << 21)) << 8;
  1877. *remap2 = ((0x4 << 0) | (0x1 << 3) | (0x3 << 6) |
  1878. (0x4 << 9) | (0x1 << 12) | (0x3 << 15) |
  1879. (0x4 << 18) | (0x1 << 21)) << 8;
  1880. break;
  1881. case 3:
  1882. /* return false if both radios are offloaded to NSS */
  1883. return false;
  1884. }
  1885. return true;
  1886. }
  1887. #endif
  1888. /*
  1889. * dp_reo_frag_dst_set() - configure reo register to set the
  1890. * fragment destination ring
  1891. * @soc : Datapath soc
  1892. * @frag_dst_ring : output parameter to set fragment destination ring
  1893. *
  1894. * Based on offload_radio below fragment destination rings is selected
  1895. * 0 - TCL
  1896. * 1 - SW1
  1897. * 2 - SW2
  1898. * 3 - SW3
  1899. * 4 - SW4
  1900. * 5 - Release
  1901. * 6 - FW
  1902. * 7 - alternate select
  1903. *
  1904. * return: void
  1905. */
  1906. static void dp_reo_frag_dst_set(struct dp_soc *soc, uint8_t *frag_dst_ring)
  1907. {
  1908. uint8_t offload_radio = wlan_cfg_get_dp_soc_nss_cfg(soc->wlan_cfg_ctx);
  1909. switch (offload_radio) {
  1910. case 0:
  1911. *frag_dst_ring = HAL_SRNG_REO_EXCEPTION;
  1912. break;
  1913. case 3:
  1914. *frag_dst_ring = HAL_SRNG_REO_ALTERNATE_SELECT;
  1915. break;
  1916. default:
  1917. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  1918. FL("dp_reo_frag_dst_set invalid offload radio config"));
  1919. break;
  1920. }
  1921. }
  1922. /*
  1923. * dp_soc_cmn_setup() - Common SoC level initializion
  1924. * @soc: Datapath SOC handle
  1925. *
  1926. * This is an internal function used to setup common SOC data structures,
  1927. * to be called from PDEV attach after receiving HW mode capabilities from FW
  1928. */
  1929. static int dp_soc_cmn_setup(struct dp_soc *soc)
  1930. {
  1931. int i;
  1932. struct hal_reo_params reo_params;
  1933. int tx_ring_size;
  1934. int tx_comp_ring_size;
  1935. int reo_dst_ring_size;
  1936. uint32_t entries;
  1937. struct wlan_cfg_dp_soc_ctxt *soc_cfg_ctx;
  1938. if (qdf_atomic_read(&soc->cmn_init_done))
  1939. return 0;
  1940. if (dp_hw_link_desc_pool_setup(soc))
  1941. goto fail1;
  1942. soc_cfg_ctx = soc->wlan_cfg_ctx;
  1943. /* Setup SRNG rings */
  1944. /* Common rings */
  1945. if (dp_srng_setup(soc, &soc->wbm_desc_rel_ring, SW2WBM_RELEASE, 0, 0,
  1946. wlan_cfg_get_dp_soc_wbm_release_ring_size(soc_cfg_ctx))) {
  1947. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  1948. FL("dp_srng_setup failed for wbm_desc_rel_ring"));
  1949. goto fail1;
  1950. }
  1951. soc->num_tcl_data_rings = 0;
  1952. /* Tx data rings */
  1953. if (!wlan_cfg_per_pdev_tx_ring(soc_cfg_ctx)) {
  1954. soc->num_tcl_data_rings =
  1955. wlan_cfg_num_tcl_data_rings(soc_cfg_ctx);
  1956. tx_comp_ring_size =
  1957. wlan_cfg_tx_comp_ring_size(soc_cfg_ctx);
  1958. tx_ring_size =
  1959. wlan_cfg_tx_ring_size(soc_cfg_ctx);
  1960. for (i = 0; i < soc->num_tcl_data_rings; i++) {
  1961. if (dp_srng_setup(soc, &soc->tcl_data_ring[i],
  1962. TCL_DATA, i, 0, tx_ring_size)) {
  1963. QDF_TRACE(QDF_MODULE_ID_DP,
  1964. QDF_TRACE_LEVEL_ERROR,
  1965. FL("dp_srng_setup failed for tcl_data_ring[%d]"), i);
  1966. goto fail1;
  1967. }
  1968. /*
  1969. * TBD: Set IPA WBM ring size with ini IPA UC tx buffer
  1970. * count
  1971. */
  1972. if (dp_srng_setup(soc, &soc->tx_comp_ring[i],
  1973. WBM2SW_RELEASE, i, 0, tx_comp_ring_size)) {
  1974. QDF_TRACE(QDF_MODULE_ID_DP,
  1975. QDF_TRACE_LEVEL_ERROR,
  1976. FL("dp_srng_setup failed for tx_comp_ring[%d]"), i);
  1977. goto fail1;
  1978. }
  1979. }
  1980. } else {
  1981. /* This will be incremented during per pdev ring setup */
  1982. soc->num_tcl_data_rings = 0;
  1983. }
  1984. if (dp_tx_soc_attach(soc)) {
  1985. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  1986. FL("dp_tx_soc_attach failed"));
  1987. goto fail1;
  1988. }
  1989. entries = wlan_cfg_get_dp_soc_tcl_cmd_ring_size(soc_cfg_ctx);
  1990. /* TCL command and status rings */
  1991. if (dp_srng_setup(soc, &soc->tcl_cmd_ring, TCL_CMD, 0, 0,
  1992. entries)) {
  1993. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  1994. FL("dp_srng_setup failed for tcl_cmd_ring"));
  1995. goto fail1;
  1996. }
  1997. entries = wlan_cfg_get_dp_soc_tcl_status_ring_size(soc_cfg_ctx);
  1998. if (dp_srng_setup(soc, &soc->tcl_status_ring, TCL_STATUS, 0, 0,
  1999. entries)) {
  2000. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  2001. FL("dp_srng_setup failed for tcl_status_ring"));
  2002. goto fail1;
  2003. }
  2004. reo_dst_ring_size = wlan_cfg_get_reo_dst_ring_size(soc->wlan_cfg_ctx);
  2005. /* TBD: call dp_tx_init to setup Tx SW descriptors and MSDU extension
  2006. * descriptors
  2007. */
  2008. /* Rx data rings */
  2009. if (!wlan_cfg_per_pdev_rx_ring(soc_cfg_ctx)) {
  2010. soc->num_reo_dest_rings =
  2011. wlan_cfg_num_reo_dest_rings(soc_cfg_ctx);
  2012. QDF_TRACE(QDF_MODULE_ID_DP,
  2013. QDF_TRACE_LEVEL_ERROR,
  2014. FL("num_reo_dest_rings %d\n"), soc->num_reo_dest_rings);
  2015. for (i = 0; i < soc->num_reo_dest_rings; i++) {
  2016. if (dp_srng_setup(soc, &soc->reo_dest_ring[i], REO_DST,
  2017. i, 0, reo_dst_ring_size)) {
  2018. QDF_TRACE(QDF_MODULE_ID_DP,
  2019. QDF_TRACE_LEVEL_ERROR,
  2020. FL(RNG_ERR "reo_dest_ring [%d]"), i);
  2021. goto fail1;
  2022. }
  2023. }
  2024. } else {
  2025. /* This will be incremented during per pdev ring setup */
  2026. soc->num_reo_dest_rings = 0;
  2027. }
  2028. entries = wlan_cfg_get_dp_soc_rxdma_err_dst_ring_size(soc_cfg_ctx);
  2029. /* LMAC RxDMA to SW Rings configuration */
  2030. if (!wlan_cfg_per_pdev_lmac_ring(soc_cfg_ctx)) {
  2031. /* Only valid for MCL */
  2032. struct dp_pdev *pdev = soc->pdev_list[0];
  2033. for (i = 0; i < MAX_RX_MAC_RINGS; i++) {
  2034. if (dp_srng_setup(soc, &pdev->rxdma_err_dst_ring[i],
  2035. RXDMA_DST, 0, i,
  2036. entries)) {
  2037. QDF_TRACE(QDF_MODULE_ID_DP,
  2038. QDF_TRACE_LEVEL_ERROR,
  2039. FL(RNG_ERR "rxdma_err_dst_ring"));
  2040. goto fail1;
  2041. }
  2042. }
  2043. }
  2044. /* TBD: call dp_rx_init to setup Rx SW descriptors */
  2045. /* REO reinjection ring */
  2046. entries = wlan_cfg_get_dp_soc_reo_reinject_ring_size(soc_cfg_ctx);
  2047. if (dp_srng_setup(soc, &soc->reo_reinject_ring, REO_REINJECT, 0, 0,
  2048. entries)) {
  2049. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  2050. FL("dp_srng_setup failed for reo_reinject_ring"));
  2051. goto fail1;
  2052. }
  2053. /* Rx release ring */
  2054. if (dp_srng_setup(soc, &soc->rx_rel_ring, WBM2SW_RELEASE, 3, 0,
  2055. wlan_cfg_get_dp_soc_rx_release_ring_size(soc_cfg_ctx))) {
  2056. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  2057. FL("dp_srng_setup failed for rx_rel_ring"));
  2058. goto fail1;
  2059. }
  2060. /* Rx exception ring */
  2061. entries = wlan_cfg_get_dp_soc_reo_exception_ring_size(soc_cfg_ctx);
  2062. if (dp_srng_setup(soc, &soc->reo_exception_ring,
  2063. REO_EXCEPTION, 0, MAX_REO_DEST_RINGS, entries)) {
  2064. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  2065. FL("dp_srng_setup failed for reo_exception_ring"));
  2066. goto fail1;
  2067. }
  2068. /* REO command and status rings */
  2069. if (dp_srng_setup(soc, &soc->reo_cmd_ring, REO_CMD, 0, 0,
  2070. wlan_cfg_get_dp_soc_reo_cmd_ring_size(soc_cfg_ctx))) {
  2071. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  2072. FL("dp_srng_setup failed for reo_cmd_ring"));
  2073. goto fail1;
  2074. }
  2075. hal_reo_init_cmd_ring(soc->hal_soc, soc->reo_cmd_ring.hal_srng);
  2076. TAILQ_INIT(&soc->rx.reo_cmd_list);
  2077. qdf_spinlock_create(&soc->rx.reo_cmd_lock);
  2078. if (dp_srng_setup(soc, &soc->reo_status_ring, REO_STATUS, 0, 0,
  2079. wlan_cfg_get_dp_soc_reo_status_ring_size(soc_cfg_ctx))) {
  2080. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  2081. FL("dp_srng_setup failed for reo_status_ring"));
  2082. goto fail1;
  2083. }
  2084. qdf_spinlock_create(&soc->ast_lock);
  2085. dp_soc_wds_attach(soc);
  2086. /* Reset the cpu ring map if radio is NSS offloaded */
  2087. if (wlan_cfg_get_dp_soc_nss_cfg(soc_cfg_ctx)) {
  2088. dp_soc_reset_cpu_ring_map(soc);
  2089. dp_soc_reset_intr_mask(soc);
  2090. }
  2091. /* Setup HW REO */
  2092. qdf_mem_zero(&reo_params, sizeof(reo_params));
  2093. if (wlan_cfg_is_rx_hash_enabled(soc_cfg_ctx)) {
  2094. /*
  2095. * Reo ring remap is not required if both radios
  2096. * are offloaded to NSS
  2097. */
  2098. if (!dp_reo_remap_config(soc,
  2099. &reo_params.remap1,
  2100. &reo_params.remap2))
  2101. goto out;
  2102. reo_params.rx_hash_enabled = true;
  2103. }
  2104. /* setup the global rx defrag waitlist */
  2105. TAILQ_INIT(&soc->rx.defrag.waitlist);
  2106. soc->rx.defrag.timeout_ms =
  2107. wlan_cfg_get_rx_defrag_min_timeout(soc_cfg_ctx);
  2108. soc->rx.flags.defrag_timeout_check =
  2109. wlan_cfg_get_defrag_timeout_check(soc_cfg_ctx);
  2110. qdf_spinlock_create(&soc->rx.defrag.defrag_lock);
  2111. out:
  2112. /*
  2113. * set the fragment destination ring
  2114. */
  2115. dp_reo_frag_dst_set(soc, &reo_params.frag_dst_ring);
  2116. hal_reo_setup(soc->hal_soc, &reo_params);
  2117. qdf_atomic_set(&soc->cmn_init_done, 1);
  2118. qdf_nbuf_queue_init(&soc->htt_stats.msg);
  2119. return 0;
  2120. fail1:
  2121. /*
  2122. * Cleanup will be done as part of soc_detach, which will
  2123. * be called on pdev attach failure
  2124. */
  2125. return QDF_STATUS_E_FAILURE;
  2126. }
  2127. static void dp_pdev_detach_wifi3(struct cdp_pdev *txrx_pdev, int force);
  2128. static void dp_lro_hash_setup(struct dp_soc *soc)
  2129. {
  2130. struct cdp_lro_hash_config lro_hash;
  2131. if (!wlan_cfg_is_lro_enabled(soc->wlan_cfg_ctx) &&
  2132. !wlan_cfg_is_rx_hash_enabled(soc->wlan_cfg_ctx)) {
  2133. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  2134. FL("LRO disabled RX hash disabled"));
  2135. return;
  2136. }
  2137. qdf_mem_zero(&lro_hash, sizeof(lro_hash));
  2138. if (wlan_cfg_is_lro_enabled(soc->wlan_cfg_ctx)) {
  2139. lro_hash.lro_enable = 1;
  2140. lro_hash.tcp_flag = QDF_TCPHDR_ACK;
  2141. lro_hash.tcp_flag_mask = QDF_TCPHDR_FIN | QDF_TCPHDR_SYN |
  2142. QDF_TCPHDR_RST | QDF_TCPHDR_ACK | QDF_TCPHDR_URG |
  2143. QDF_TCPHDR_ECE | QDF_TCPHDR_CWR;
  2144. }
  2145. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_LOW, FL("enabled"));
  2146. qdf_get_random_bytes(lro_hash.toeplitz_hash_ipv4,
  2147. (sizeof(lro_hash.toeplitz_hash_ipv4[0]) *
  2148. LRO_IPV4_SEED_ARR_SZ));
  2149. qdf_get_random_bytes(lro_hash.toeplitz_hash_ipv6,
  2150. (sizeof(lro_hash.toeplitz_hash_ipv6[0]) *
  2151. LRO_IPV6_SEED_ARR_SZ));
  2152. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_LOW,
  2153. "lro_hash: lro_enable: 0x%x tcp_flag 0x%x tcp_flag_mask 0x%x",
  2154. lro_hash.lro_enable, lro_hash.tcp_flag,
  2155. lro_hash.tcp_flag_mask);
  2156. qdf_trace_hex_dump(QDF_MODULE_ID_DP,
  2157. QDF_TRACE_LEVEL_ERROR,
  2158. (void *)lro_hash.toeplitz_hash_ipv4,
  2159. (sizeof(lro_hash.toeplitz_hash_ipv4[0]) *
  2160. LRO_IPV4_SEED_ARR_SZ));
  2161. qdf_trace_hex_dump(QDF_MODULE_ID_DP,
  2162. QDF_TRACE_LEVEL_ERROR,
  2163. (void *)lro_hash.toeplitz_hash_ipv6,
  2164. (sizeof(lro_hash.toeplitz_hash_ipv6[0]) *
  2165. LRO_IPV6_SEED_ARR_SZ));
  2166. qdf_assert(soc->cdp_soc.ol_ops->lro_hash_config);
  2167. if (soc->cdp_soc.ol_ops->lro_hash_config)
  2168. (void)soc->cdp_soc.ol_ops->lro_hash_config
  2169. (soc->ctrl_psoc, &lro_hash);
  2170. }
  2171. /*
  2172. * dp_rxdma_ring_setup() - configure the RX DMA rings
  2173. * @soc: data path SoC handle
  2174. * @pdev: Physical device handle
  2175. *
  2176. * Return: 0 - success, > 0 - failure
  2177. */
  2178. #ifdef QCA_HOST2FW_RXBUF_RING
  2179. static int dp_rxdma_ring_setup(struct dp_soc *soc,
  2180. struct dp_pdev *pdev)
  2181. {
  2182. struct wlan_cfg_dp_pdev_ctxt *pdev_cfg_ctx;
  2183. int max_mac_rings;
  2184. int i;
  2185. pdev_cfg_ctx = pdev->wlan_cfg_ctx;
  2186. max_mac_rings = wlan_cfg_get_num_mac_rings(pdev_cfg_ctx);
  2187. for (i = 0; i < max_mac_rings; i++) {
  2188. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  2189. "%s: pdev_id %d mac_id %d\n",
  2190. __func__, pdev->pdev_id, i);
  2191. if (dp_srng_setup(soc, &pdev->rx_mac_buf_ring[i],
  2192. RXDMA_BUF, 1, i,
  2193. wlan_cfg_get_rx_dma_buf_ring_size(pdev_cfg_ctx))) {
  2194. QDF_TRACE(QDF_MODULE_ID_DP,
  2195. QDF_TRACE_LEVEL_ERROR,
  2196. FL("failed rx mac ring setup"));
  2197. return QDF_STATUS_E_FAILURE;
  2198. }
  2199. }
  2200. return QDF_STATUS_SUCCESS;
  2201. }
  2202. #else
  2203. static int dp_rxdma_ring_setup(struct dp_soc *soc,
  2204. struct dp_pdev *pdev)
  2205. {
  2206. return QDF_STATUS_SUCCESS;
  2207. }
  2208. #endif
  2209. /**
  2210. * dp_dscp_tid_map_setup(): Initialize the dscp-tid maps
  2211. * @pdev - DP_PDEV handle
  2212. *
  2213. * Return: void
  2214. */
  2215. static inline void
  2216. dp_dscp_tid_map_setup(struct dp_pdev *pdev)
  2217. {
  2218. uint8_t map_id;
  2219. for (map_id = 0; map_id < DP_MAX_TID_MAPS; map_id++) {
  2220. qdf_mem_copy(pdev->dscp_tid_map[map_id], default_dscp_tid_map,
  2221. sizeof(default_dscp_tid_map));
  2222. }
  2223. for (map_id = 0; map_id < HAL_MAX_HW_DSCP_TID_MAPS; map_id++) {
  2224. hal_tx_set_dscp_tid_map(pdev->soc->hal_soc,
  2225. pdev->dscp_tid_map[map_id],
  2226. map_id);
  2227. }
  2228. }
  2229. #ifdef QCA_SUPPORT_SON
  2230. /**
  2231. * dp_mark_peer_inact(): Update peer inactivity status
  2232. * @peer_handle - datapath peer handle
  2233. *
  2234. * Return: void
  2235. */
  2236. void dp_mark_peer_inact(void *peer_handle, bool inactive)
  2237. {
  2238. struct dp_peer *peer = (struct dp_peer *)peer_handle;
  2239. struct dp_pdev *pdev;
  2240. struct dp_soc *soc;
  2241. bool inactive_old;
  2242. if (!peer)
  2243. return;
  2244. pdev = peer->vdev->pdev;
  2245. soc = pdev->soc;
  2246. inactive_old = peer->peer_bs_inact_flag == 1;
  2247. if (!inactive)
  2248. peer->peer_bs_inact = soc->pdev_bs_inact_reload;
  2249. peer->peer_bs_inact_flag = inactive ? 1 : 0;
  2250. if (inactive_old != inactive) {
  2251. /**
  2252. * Note: a node lookup can happen in RX datapath context
  2253. * when a node changes from inactive to active (at most once
  2254. * per inactivity timeout threshold)
  2255. */
  2256. if (soc->cdp_soc.ol_ops->record_act_change) {
  2257. soc->cdp_soc.ol_ops->record_act_change(
  2258. (void *)pdev->ctrl_pdev,
  2259. peer->mac_addr.raw, !inactive);
  2260. }
  2261. }
  2262. }
  2263. /**
  2264. * dp_txrx_peer_find_inact_timeout_handler(): Inactivity timeout function
  2265. *
  2266. * Periodically checks the inactivity status
  2267. */
  2268. static os_timer_func(dp_txrx_peer_find_inact_timeout_handler)
  2269. {
  2270. struct dp_pdev *pdev;
  2271. struct dp_vdev *vdev;
  2272. struct dp_peer *peer;
  2273. struct dp_soc *soc;
  2274. int i;
  2275. OS_GET_TIMER_ARG(soc, struct dp_soc *);
  2276. qdf_spin_lock(&soc->peer_ref_mutex);
  2277. for (i = 0; i < soc->pdev_count; i++) {
  2278. pdev = soc->pdev_list[i];
  2279. qdf_spin_lock_bh(&pdev->vdev_list_lock);
  2280. TAILQ_FOREACH(vdev, &pdev->vdev_list, vdev_list_elem) {
  2281. if (vdev->opmode != wlan_op_mode_ap)
  2282. continue;
  2283. TAILQ_FOREACH(peer, &vdev->peer_list, peer_list_elem) {
  2284. if (!peer->authorize) {
  2285. /**
  2286. * Inactivity check only interested in
  2287. * connected node
  2288. */
  2289. continue;
  2290. }
  2291. if (peer->peer_bs_inact > soc->pdev_bs_inact_reload) {
  2292. /**
  2293. * This check ensures we do not wait extra long
  2294. * due to the potential race condition
  2295. */
  2296. peer->peer_bs_inact = soc->pdev_bs_inact_reload;
  2297. }
  2298. if (peer->peer_bs_inact > 0) {
  2299. /* Do not let it wrap around */
  2300. peer->peer_bs_inact--;
  2301. }
  2302. if (peer->peer_bs_inact == 0)
  2303. dp_mark_peer_inact(peer, true);
  2304. }
  2305. }
  2306. qdf_spin_unlock_bh(&pdev->vdev_list_lock);
  2307. }
  2308. qdf_spin_unlock(&soc->peer_ref_mutex);
  2309. qdf_timer_mod(&soc->pdev_bs_inact_timer,
  2310. soc->pdev_bs_inact_interval * 1000);
  2311. }
  2312. /**
  2313. * dp_free_inact_timer(): free inact timer
  2314. * @timer - inact timer handle
  2315. *
  2316. * Return: bool
  2317. */
  2318. void dp_free_inact_timer(struct dp_soc *soc)
  2319. {
  2320. qdf_timer_free(&soc->pdev_bs_inact_timer);
  2321. }
  2322. #else
  2323. void dp_mark_peer_inact(void *peer, bool inactive)
  2324. {
  2325. return;
  2326. }
  2327. void dp_free_inact_timer(struct dp_soc *soc)
  2328. {
  2329. return;
  2330. }
  2331. #endif
  2332. #ifdef IPA_OFFLOAD
  2333. /**
  2334. * dp_setup_ipa_rx_refill_buf_ring - Setup second Rx refill buffer ring
  2335. * @soc: data path instance
  2336. * @pdev: core txrx pdev context
  2337. *
  2338. * Return: QDF_STATUS_SUCCESS: success
  2339. * QDF_STATUS_E_RESOURCES: Error return
  2340. */
  2341. static int dp_setup_ipa_rx_refill_buf_ring(struct dp_soc *soc,
  2342. struct dp_pdev *pdev)
  2343. {
  2344. struct wlan_cfg_dp_soc_ctxt *soc_cfg_ctx;
  2345. int entries;
  2346. soc_cfg_ctx = soc->wlan_cfg_ctx;
  2347. entries = wlan_cfg_get_dp_soc_rxdma_refill_ring_size(soc_cfg_ctx);
  2348. /* Setup second Rx refill buffer ring */
  2349. if (dp_srng_setup(soc, &pdev->rx_refill_buf_ring2, RXDMA_BUF,
  2350. IPA_RX_REFILL_BUF_RING_IDX,
  2351. pdev->pdev_id,
  2352. entries)) {
  2353. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  2354. FL("dp_srng_setup failed second rx refill ring"));
  2355. return QDF_STATUS_E_FAILURE;
  2356. }
  2357. return QDF_STATUS_SUCCESS;
  2358. }
  2359. /**
  2360. * dp_cleanup_ipa_rx_refill_buf_ring - Cleanup second Rx refill buffer ring
  2361. * @soc: data path instance
  2362. * @pdev: core txrx pdev context
  2363. *
  2364. * Return: void
  2365. */
  2366. static void dp_cleanup_ipa_rx_refill_buf_ring(struct dp_soc *soc,
  2367. struct dp_pdev *pdev)
  2368. {
  2369. dp_srng_cleanup(soc, &pdev->rx_refill_buf_ring2, RXDMA_BUF,
  2370. IPA_RX_REFILL_BUF_RING_IDX);
  2371. }
  2372. #else
  2373. static int dp_setup_ipa_rx_refill_buf_ring(struct dp_soc *soc,
  2374. struct dp_pdev *pdev)
  2375. {
  2376. return QDF_STATUS_SUCCESS;
  2377. }
  2378. static void dp_cleanup_ipa_rx_refill_buf_ring(struct dp_soc *soc,
  2379. struct dp_pdev *pdev)
  2380. {
  2381. }
  2382. #endif
  2383. #ifndef QCA_WIFI_QCA6390
  2384. static
  2385. QDF_STATUS dp_mon_rings_setup(struct dp_soc *soc, struct dp_pdev *pdev)
  2386. {
  2387. int mac_id = 0;
  2388. int pdev_id = pdev->pdev_id;
  2389. int entries;
  2390. struct wlan_cfg_dp_pdev_ctxt *pdev_cfg_ctx;
  2391. pdev_cfg_ctx = pdev->wlan_cfg_ctx;
  2392. for (mac_id = 0; mac_id < NUM_RXDMA_RINGS_PER_PDEV; mac_id++) {
  2393. int mac_for_pdev = dp_get_mac_id_for_pdev(mac_id, pdev_id);
  2394. entries = wlan_cfg_get_dma_mon_buf_ring_size(pdev_cfg_ctx);
  2395. if (dp_srng_setup(soc, &pdev->rxdma_mon_buf_ring[mac_id],
  2396. RXDMA_MONITOR_BUF, 0, mac_for_pdev,
  2397. entries)) {
  2398. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  2399. FL(RNG_ERR "rxdma_mon_buf_ring "));
  2400. return QDF_STATUS_E_NOMEM;
  2401. }
  2402. entries = wlan_cfg_get_dma_mon_dest_ring_size(pdev_cfg_ctx);
  2403. if (dp_srng_setup(soc, &pdev->rxdma_mon_dst_ring[mac_id],
  2404. RXDMA_MONITOR_DST, 0, mac_for_pdev,
  2405. entries)) {
  2406. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  2407. FL(RNG_ERR "rxdma_mon_dst_ring"));
  2408. return QDF_STATUS_E_NOMEM;
  2409. }
  2410. entries = wlan_cfg_get_dma_mon_stat_ring_size(pdev_cfg_ctx);
  2411. if (dp_srng_setup(soc, &pdev->rxdma_mon_status_ring[mac_id],
  2412. RXDMA_MONITOR_STATUS, 0, mac_for_pdev,
  2413. entries)) {
  2414. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  2415. FL(RNG_ERR "rxdma_mon_status_ring"));
  2416. return QDF_STATUS_E_NOMEM;
  2417. }
  2418. entries = wlan_cfg_get_dma_mon_desc_ring_size(pdev_cfg_ctx);
  2419. if (dp_srng_setup(soc, &pdev->rxdma_mon_desc_ring[mac_id],
  2420. RXDMA_MONITOR_DESC, 0, mac_for_pdev,
  2421. entries)) {
  2422. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  2423. FL(RNG_ERR "rxdma_mon_desc_ring"));
  2424. return QDF_STATUS_E_NOMEM;
  2425. }
  2426. }
  2427. return QDF_STATUS_SUCCESS;
  2428. }
  2429. #else
  2430. static QDF_STATUS dp_mon_rings_setup(struct dp_soc *soc, struct dp_pdev *pdev)
  2431. {
  2432. return QDF_STATUS_SUCCESS;
  2433. }
  2434. #endif
  2435. /*
  2436. * dp_pdev_attach_wifi3() - attach txrx pdev
  2437. * @ctrl_pdev: Opaque PDEV object
  2438. * @txrx_soc: Datapath SOC handle
  2439. * @htc_handle: HTC handle for host-target interface
  2440. * @qdf_osdev: QDF OS device
  2441. * @pdev_id: PDEV ID
  2442. *
  2443. * Return: DP PDEV handle on success, NULL on failure
  2444. */
  2445. static struct cdp_pdev *dp_pdev_attach_wifi3(struct cdp_soc_t *txrx_soc,
  2446. struct cdp_ctrl_objmgr_pdev *ctrl_pdev,
  2447. HTC_HANDLE htc_handle, qdf_device_t qdf_osdev, uint8_t pdev_id)
  2448. {
  2449. int tx_ring_size;
  2450. int tx_comp_ring_size;
  2451. int reo_dst_ring_size;
  2452. int entries;
  2453. struct wlan_cfg_dp_soc_ctxt *soc_cfg_ctx;
  2454. int nss_cfg;
  2455. struct dp_soc *soc = (struct dp_soc *)txrx_soc;
  2456. struct dp_pdev *pdev = qdf_mem_malloc(sizeof(*pdev));
  2457. if (!pdev) {
  2458. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  2459. FL("DP PDEV memory allocation failed"));
  2460. goto fail0;
  2461. }
  2462. soc_cfg_ctx = soc->wlan_cfg_ctx;
  2463. pdev->wlan_cfg_ctx = wlan_cfg_pdev_attach(soc->ctrl_psoc);
  2464. if (!pdev->wlan_cfg_ctx) {
  2465. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  2466. FL("pdev cfg_attach failed"));
  2467. qdf_mem_free(pdev);
  2468. goto fail0;
  2469. }
  2470. /*
  2471. * set nss pdev config based on soc config
  2472. */
  2473. nss_cfg = wlan_cfg_get_dp_soc_nss_cfg(soc_cfg_ctx);
  2474. wlan_cfg_set_dp_pdev_nss_enabled(pdev->wlan_cfg_ctx,
  2475. (nss_cfg & (1 << pdev_id)));
  2476. pdev->soc = soc;
  2477. pdev->ctrl_pdev = ctrl_pdev;
  2478. pdev->pdev_id = pdev_id;
  2479. soc->pdev_list[pdev_id] = pdev;
  2480. soc->pdev_count++;
  2481. TAILQ_INIT(&pdev->vdev_list);
  2482. qdf_spinlock_create(&pdev->vdev_list_lock);
  2483. pdev->vdev_count = 0;
  2484. qdf_spinlock_create(&pdev->tx_mutex);
  2485. qdf_spinlock_create(&pdev->neighbour_peer_mutex);
  2486. TAILQ_INIT(&pdev->neighbour_peers_list);
  2487. if (dp_soc_cmn_setup(soc)) {
  2488. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  2489. FL("dp_soc_cmn_setup failed"));
  2490. goto fail1;
  2491. }
  2492. /* Setup per PDEV TCL rings if configured */
  2493. if (wlan_cfg_per_pdev_tx_ring(soc->wlan_cfg_ctx)) {
  2494. tx_ring_size =
  2495. wlan_cfg_tx_ring_size(soc_cfg_ctx);
  2496. tx_comp_ring_size =
  2497. wlan_cfg_tx_comp_ring_size(soc_cfg_ctx);
  2498. if (dp_srng_setup(soc, &soc->tcl_data_ring[pdev_id], TCL_DATA,
  2499. pdev_id, pdev_id, tx_ring_size)) {
  2500. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  2501. FL("dp_srng_setup failed for tcl_data_ring"));
  2502. goto fail1;
  2503. }
  2504. if (dp_srng_setup(soc, &soc->tx_comp_ring[pdev_id],
  2505. WBM2SW_RELEASE, pdev_id, pdev_id, tx_comp_ring_size)) {
  2506. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  2507. FL("dp_srng_setup failed for tx_comp_ring"));
  2508. goto fail1;
  2509. }
  2510. soc->num_tcl_data_rings++;
  2511. }
  2512. /* Tx specific init */
  2513. if (dp_tx_pdev_attach(pdev)) {
  2514. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  2515. FL("dp_tx_pdev_attach failed"));
  2516. goto fail1;
  2517. }
  2518. reo_dst_ring_size = wlan_cfg_get_reo_dst_ring_size(soc->wlan_cfg_ctx);
  2519. /* Setup per PDEV REO rings if configured */
  2520. if (wlan_cfg_per_pdev_rx_ring(soc_cfg_ctx)) {
  2521. if (dp_srng_setup(soc, &soc->reo_dest_ring[pdev_id], REO_DST,
  2522. pdev_id, pdev_id, reo_dst_ring_size)) {
  2523. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  2524. FL("dp_srng_setup failed for reo_dest_ringn"));
  2525. goto fail1;
  2526. }
  2527. soc->num_reo_dest_rings++;
  2528. }
  2529. if (dp_srng_setup(soc, &pdev->rx_refill_buf_ring, RXDMA_BUF, 0, pdev_id,
  2530. wlan_cfg_get_dp_soc_rxdma_refill_ring_size(soc_cfg_ctx))) {
  2531. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  2532. FL("dp_srng_setup failed rx refill ring"));
  2533. goto fail1;
  2534. }
  2535. if (dp_rxdma_ring_setup(soc, pdev)) {
  2536. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  2537. FL("RXDMA ring config failed"));
  2538. goto fail1;
  2539. }
  2540. if (dp_mon_rings_setup(soc, pdev)) {
  2541. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  2542. FL("MONITOR rings setup failed"));
  2543. goto fail1;
  2544. }
  2545. entries = wlan_cfg_get_dp_soc_rxdma_err_dst_ring_size(soc_cfg_ctx);
  2546. if (wlan_cfg_per_pdev_lmac_ring(soc->wlan_cfg_ctx)) {
  2547. if (dp_srng_setup(soc, &pdev->rxdma_err_dst_ring[0], RXDMA_DST,
  2548. 0, pdev_id,
  2549. entries)) {
  2550. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  2551. FL(RNG_ERR "rxdma_err_dst_ring"));
  2552. goto fail1;
  2553. }
  2554. }
  2555. if (dp_setup_ipa_rx_refill_buf_ring(soc, pdev))
  2556. goto fail1;
  2557. if (dp_ipa_ring_resource_setup(soc, pdev))
  2558. goto fail1;
  2559. if (dp_ipa_uc_attach(soc, pdev) != QDF_STATUS_SUCCESS) {
  2560. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  2561. FL("dp_ipa_uc_attach failed"));
  2562. goto fail1;
  2563. }
  2564. /* Rx specific init */
  2565. if (dp_rx_pdev_attach(pdev)) {
  2566. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  2567. FL("dp_rx_pdev_attach failed"));
  2568. goto fail0;
  2569. }
  2570. DP_STATS_INIT(pdev);
  2571. /* Monitor filter init */
  2572. pdev->mon_filter_mode = MON_FILTER_ALL;
  2573. pdev->fp_mgmt_filter = FILTER_MGMT_ALL;
  2574. pdev->fp_ctrl_filter = FILTER_CTRL_ALL;
  2575. pdev->fp_data_filter = FILTER_DATA_ALL;
  2576. pdev->mo_mgmt_filter = FILTER_MGMT_ALL;
  2577. pdev->mo_ctrl_filter = FILTER_CTRL_ALL;
  2578. pdev->mo_data_filter = FILTER_DATA_ALL;
  2579. dp_local_peer_id_pool_init(pdev);
  2580. dp_dscp_tid_map_setup(pdev);
  2581. /* Rx monitor mode specific init */
  2582. if (dp_rx_pdev_mon_attach(pdev)) {
  2583. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  2584. "dp_rx_pdev_attach failed\n");
  2585. goto fail1;
  2586. }
  2587. if (dp_wdi_event_attach(pdev)) {
  2588. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  2589. "dp_wdi_evet_attach failed\n");
  2590. goto fail1;
  2591. }
  2592. /* set the reo destination during initialization */
  2593. pdev->reo_dest = pdev->pdev_id + 1;
  2594. /*
  2595. * initialize ppdu tlv list
  2596. */
  2597. TAILQ_INIT(&pdev->ppdu_info_list);
  2598. pdev->tlv_count = 0;
  2599. pdev->list_depth = 0;
  2600. return (struct cdp_pdev *)pdev;
  2601. fail1:
  2602. dp_pdev_detach_wifi3((struct cdp_pdev *)pdev, 0);
  2603. fail0:
  2604. return NULL;
  2605. }
  2606. /*
  2607. * dp_rxdma_ring_cleanup() - configure the RX DMA rings
  2608. * @soc: data path SoC handle
  2609. * @pdev: Physical device handle
  2610. *
  2611. * Return: void
  2612. */
  2613. #ifdef QCA_HOST2FW_RXBUF_RING
  2614. static void dp_rxdma_ring_cleanup(struct dp_soc *soc,
  2615. struct dp_pdev *pdev)
  2616. {
  2617. int max_mac_rings =
  2618. wlan_cfg_get_num_mac_rings(pdev->wlan_cfg_ctx);
  2619. int i;
  2620. max_mac_rings = max_mac_rings < MAX_RX_MAC_RINGS ?
  2621. max_mac_rings : MAX_RX_MAC_RINGS;
  2622. for (i = 0; i < MAX_RX_MAC_RINGS; i++)
  2623. dp_srng_cleanup(soc, &pdev->rx_mac_buf_ring[i],
  2624. RXDMA_BUF, 1);
  2625. qdf_timer_free(&soc->mon_reap_timer);
  2626. }
  2627. #else
  2628. static void dp_rxdma_ring_cleanup(struct dp_soc *soc,
  2629. struct dp_pdev *pdev)
  2630. {
  2631. }
  2632. #endif
  2633. /*
  2634. * dp_neighbour_peers_detach() - Detach neighbour peers(nac clients)
  2635. * @pdev: device object
  2636. *
  2637. * Return: void
  2638. */
  2639. static void dp_neighbour_peers_detach(struct dp_pdev *pdev)
  2640. {
  2641. struct dp_neighbour_peer *peer = NULL;
  2642. struct dp_neighbour_peer *temp_peer = NULL;
  2643. TAILQ_FOREACH_SAFE(peer, &pdev->neighbour_peers_list,
  2644. neighbour_peer_list_elem, temp_peer) {
  2645. /* delete this peer from the list */
  2646. TAILQ_REMOVE(&pdev->neighbour_peers_list,
  2647. peer, neighbour_peer_list_elem);
  2648. qdf_mem_free(peer);
  2649. }
  2650. qdf_spinlock_destroy(&pdev->neighbour_peer_mutex);
  2651. }
  2652. /**
  2653. * dp_htt_ppdu_stats_detach() - detach stats resources
  2654. * @pdev: Datapath PDEV handle
  2655. *
  2656. * Return: void
  2657. */
  2658. static void dp_htt_ppdu_stats_detach(struct dp_pdev *pdev)
  2659. {
  2660. struct ppdu_info *ppdu_info, *ppdu_info_next;
  2661. TAILQ_FOREACH_SAFE(ppdu_info, &pdev->ppdu_info_list,
  2662. ppdu_info_list_elem, ppdu_info_next) {
  2663. if (!ppdu_info)
  2664. break;
  2665. qdf_assert_always(ppdu_info->nbuf);
  2666. qdf_nbuf_free(ppdu_info->nbuf);
  2667. qdf_mem_free(ppdu_info);
  2668. }
  2669. }
  2670. #ifndef QCA_WIFI_QCA6390
  2671. static
  2672. void dp_mon_ring_deinit(struct dp_soc *soc, struct dp_pdev *pdev,
  2673. int mac_id)
  2674. {
  2675. dp_srng_cleanup(soc, &pdev->rxdma_mon_buf_ring[mac_id],
  2676. RXDMA_MONITOR_BUF, 0);
  2677. dp_srng_cleanup(soc, &pdev->rxdma_mon_dst_ring[mac_id],
  2678. RXDMA_MONITOR_DST, 0);
  2679. dp_srng_cleanup(soc, &pdev->rxdma_mon_status_ring[mac_id],
  2680. RXDMA_MONITOR_STATUS, 0);
  2681. dp_srng_cleanup(soc, &pdev->rxdma_mon_desc_ring[mac_id],
  2682. RXDMA_MONITOR_DESC, 0);
  2683. dp_srng_cleanup(soc, &pdev->rxdma_err_dst_ring[mac_id],
  2684. RXDMA_DST, 0);
  2685. }
  2686. #else
  2687. static void dp_mon_ring_deinit(struct dp_soc *soc, struct dp_pdev *pdev,
  2688. int mac_id)
  2689. {
  2690. }
  2691. #endif
  2692. /*
  2693. * dp_pdev_detach_wifi3() - detach txrx pdev
  2694. * @txrx_pdev: Datapath PDEV handle
  2695. * @force: Force detach
  2696. *
  2697. */
  2698. static void dp_pdev_detach_wifi3(struct cdp_pdev *txrx_pdev, int force)
  2699. {
  2700. struct dp_pdev *pdev = (struct dp_pdev *)txrx_pdev;
  2701. struct dp_soc *soc = pdev->soc;
  2702. qdf_nbuf_t curr_nbuf, next_nbuf;
  2703. int mac_id;
  2704. dp_wdi_event_detach(pdev);
  2705. dp_tx_pdev_detach(pdev);
  2706. if (wlan_cfg_per_pdev_tx_ring(soc->wlan_cfg_ctx)) {
  2707. dp_srng_cleanup(soc, &soc->tcl_data_ring[pdev->pdev_id],
  2708. TCL_DATA, pdev->pdev_id);
  2709. dp_srng_cleanup(soc, &soc->tx_comp_ring[pdev->pdev_id],
  2710. WBM2SW_RELEASE, pdev->pdev_id);
  2711. }
  2712. dp_pktlogmod_exit(pdev);
  2713. dp_rx_pdev_detach(pdev);
  2714. dp_rx_pdev_mon_detach(pdev);
  2715. dp_neighbour_peers_detach(pdev);
  2716. qdf_spinlock_destroy(&pdev->tx_mutex);
  2717. qdf_spinlock_destroy(&pdev->vdev_list_lock);
  2718. dp_ipa_uc_detach(soc, pdev);
  2719. dp_cleanup_ipa_rx_refill_buf_ring(soc, pdev);
  2720. /* Cleanup per PDEV REO rings if configured */
  2721. if (wlan_cfg_per_pdev_rx_ring(soc->wlan_cfg_ctx)) {
  2722. dp_srng_cleanup(soc, &soc->reo_dest_ring[pdev->pdev_id],
  2723. REO_DST, pdev->pdev_id);
  2724. }
  2725. dp_srng_cleanup(soc, &pdev->rx_refill_buf_ring, RXDMA_BUF, 0);
  2726. dp_rxdma_ring_cleanup(soc, pdev);
  2727. for (mac_id = 0; mac_id < NUM_RXDMA_RINGS_PER_PDEV; mac_id++) {
  2728. dp_mon_ring_deinit(soc, pdev, mac_id);
  2729. dp_srng_cleanup(soc, &pdev->rxdma_err_dst_ring[mac_id],
  2730. RXDMA_DST, 0);
  2731. }
  2732. curr_nbuf = pdev->invalid_peer_head_msdu;
  2733. while (curr_nbuf) {
  2734. next_nbuf = qdf_nbuf_next(curr_nbuf);
  2735. qdf_nbuf_free(curr_nbuf);
  2736. curr_nbuf = next_nbuf;
  2737. }
  2738. dp_htt_ppdu_stats_detach(pdev);
  2739. soc->pdev_list[pdev->pdev_id] = NULL;
  2740. soc->pdev_count--;
  2741. wlan_cfg_pdev_detach(pdev->wlan_cfg_ctx);
  2742. qdf_mem_free(pdev->dp_txrx_handle);
  2743. qdf_mem_free(pdev);
  2744. }
  2745. /*
  2746. * dp_reo_desc_freelist_destroy() - Flush REO descriptors from deferred freelist
  2747. * @soc: DP SOC handle
  2748. */
  2749. static inline void dp_reo_desc_freelist_destroy(struct dp_soc *soc)
  2750. {
  2751. struct reo_desc_list_node *desc;
  2752. struct dp_rx_tid *rx_tid;
  2753. qdf_spin_lock_bh(&soc->reo_desc_freelist_lock);
  2754. while (qdf_list_remove_front(&soc->reo_desc_freelist,
  2755. (qdf_list_node_t **)&desc) == QDF_STATUS_SUCCESS) {
  2756. rx_tid = &desc->rx_tid;
  2757. qdf_mem_unmap_nbytes_single(soc->osdev,
  2758. rx_tid->hw_qdesc_paddr,
  2759. QDF_DMA_BIDIRECTIONAL,
  2760. rx_tid->hw_qdesc_alloc_size);
  2761. qdf_mem_free(rx_tid->hw_qdesc_vaddr_unaligned);
  2762. qdf_mem_free(desc);
  2763. }
  2764. qdf_spin_unlock_bh(&soc->reo_desc_freelist_lock);
  2765. qdf_list_destroy(&soc->reo_desc_freelist);
  2766. qdf_spinlock_destroy(&soc->reo_desc_freelist_lock);
  2767. }
  2768. /*
  2769. * dp_soc_detach_wifi3() - Detach txrx SOC
  2770. * @txrx_soc: DP SOC handle, struct cdp_soc_t is first element of struct dp_soc.
  2771. */
  2772. static void dp_soc_detach_wifi3(void *txrx_soc)
  2773. {
  2774. struct dp_soc *soc = (struct dp_soc *)txrx_soc;
  2775. int i;
  2776. qdf_atomic_set(&soc->cmn_init_done, 0);
  2777. qdf_flush_work(&soc->htt_stats.work);
  2778. qdf_disable_work(&soc->htt_stats.work);
  2779. /* Free pending htt stats messages */
  2780. qdf_nbuf_queue_free(&soc->htt_stats.msg);
  2781. dp_free_inact_timer(soc);
  2782. for (i = 0; i < MAX_PDEV_CNT; i++) {
  2783. if (soc->pdev_list[i])
  2784. dp_pdev_detach_wifi3(
  2785. (struct cdp_pdev *)soc->pdev_list[i], 1);
  2786. }
  2787. dp_peer_find_detach(soc);
  2788. /* TBD: Call Tx and Rx cleanup functions to free buffers and
  2789. * SW descriptors
  2790. */
  2791. /* Free the ring memories */
  2792. /* Common rings */
  2793. dp_srng_cleanup(soc, &soc->wbm_desc_rel_ring, SW2WBM_RELEASE, 0);
  2794. dp_tx_soc_detach(soc);
  2795. /* Tx data rings */
  2796. if (!wlan_cfg_per_pdev_tx_ring(soc->wlan_cfg_ctx)) {
  2797. for (i = 0; i < soc->num_tcl_data_rings; i++) {
  2798. dp_srng_cleanup(soc, &soc->tcl_data_ring[i],
  2799. TCL_DATA, i);
  2800. dp_srng_cleanup(soc, &soc->tx_comp_ring[i],
  2801. WBM2SW_RELEASE, i);
  2802. }
  2803. }
  2804. /* TCL command and status rings */
  2805. dp_srng_cleanup(soc, &soc->tcl_cmd_ring, TCL_CMD, 0);
  2806. dp_srng_cleanup(soc, &soc->tcl_status_ring, TCL_STATUS, 0);
  2807. /* Rx data rings */
  2808. if (!wlan_cfg_per_pdev_rx_ring(soc->wlan_cfg_ctx)) {
  2809. soc->num_reo_dest_rings =
  2810. wlan_cfg_num_reo_dest_rings(soc->wlan_cfg_ctx);
  2811. for (i = 0; i < soc->num_reo_dest_rings; i++) {
  2812. /* TODO: Get number of rings and ring sizes
  2813. * from wlan_cfg
  2814. */
  2815. dp_srng_cleanup(soc, &soc->reo_dest_ring[i],
  2816. REO_DST, i);
  2817. }
  2818. }
  2819. /* REO reinjection ring */
  2820. dp_srng_cleanup(soc, &soc->reo_reinject_ring, REO_REINJECT, 0);
  2821. /* Rx release ring */
  2822. dp_srng_cleanup(soc, &soc->rx_rel_ring, WBM2SW_RELEASE, 0);
  2823. /* Rx exception ring */
  2824. /* TODO: Better to store ring_type and ring_num in
  2825. * dp_srng during setup
  2826. */
  2827. dp_srng_cleanup(soc, &soc->reo_exception_ring, REO_EXCEPTION, 0);
  2828. /* REO command and status rings */
  2829. dp_srng_cleanup(soc, &soc->reo_cmd_ring, REO_CMD, 0);
  2830. dp_srng_cleanup(soc, &soc->reo_status_ring, REO_STATUS, 0);
  2831. dp_hw_link_desc_pool_cleanup(soc);
  2832. qdf_spinlock_destroy(&soc->peer_ref_mutex);
  2833. qdf_spinlock_destroy(&soc->htt_stats.lock);
  2834. htt_soc_detach(soc->htt_handle);
  2835. qdf_spinlock_destroy(&soc->rx.defrag.defrag_lock);
  2836. dp_reo_cmdlist_destroy(soc);
  2837. qdf_spinlock_destroy(&soc->rx.reo_cmd_lock);
  2838. dp_reo_desc_freelist_destroy(soc);
  2839. wlan_cfg_soc_detach(soc->wlan_cfg_ctx);
  2840. dp_soc_wds_detach(soc);
  2841. qdf_spinlock_destroy(&soc->ast_lock);
  2842. qdf_mem_free(soc);
  2843. }
  2844. #ifndef QCA_WIFI_QCA6390
  2845. static void dp_mon_htt_srng_setup(struct dp_soc *soc,
  2846. struct dp_pdev *pdev,
  2847. int mac_id,
  2848. int mac_for_pdev)
  2849. {
  2850. htt_srng_setup(soc->htt_handle, mac_for_pdev,
  2851. pdev->rxdma_mon_buf_ring[mac_id].hal_srng,
  2852. RXDMA_MONITOR_BUF);
  2853. htt_srng_setup(soc->htt_handle, mac_for_pdev,
  2854. pdev->rxdma_mon_dst_ring[mac_id].hal_srng,
  2855. RXDMA_MONITOR_DST);
  2856. htt_srng_setup(soc->htt_handle, mac_for_pdev,
  2857. pdev->rxdma_mon_status_ring[mac_id].hal_srng,
  2858. RXDMA_MONITOR_STATUS);
  2859. htt_srng_setup(soc->htt_handle, mac_for_pdev,
  2860. pdev->rxdma_mon_desc_ring[mac_id].hal_srng,
  2861. RXDMA_MONITOR_DESC);
  2862. }
  2863. #else
  2864. static void dp_mon_htt_srng_setup(struct dp_soc *soc,
  2865. struct dp_pdev *pdev,
  2866. int mac_id,
  2867. int mac_for_pdev)
  2868. {
  2869. }
  2870. #endif
  2871. /*
  2872. * dp_rxdma_ring_config() - configure the RX DMA rings
  2873. *
  2874. * This function is used to configure the MAC rings.
  2875. * On MCL host provides buffers in Host2FW ring
  2876. * FW refills (copies) buffers to the ring and updates
  2877. * ring_idx in register
  2878. *
  2879. * @soc: data path SoC handle
  2880. *
  2881. * Return: void
  2882. */
  2883. #ifdef QCA_HOST2FW_RXBUF_RING
  2884. static void dp_rxdma_ring_config(struct dp_soc *soc)
  2885. {
  2886. int i;
  2887. for (i = 0; i < MAX_PDEV_CNT; i++) {
  2888. struct dp_pdev *pdev = soc->pdev_list[i];
  2889. if (pdev) {
  2890. int mac_id;
  2891. bool dbs_enable = 0;
  2892. int max_mac_rings =
  2893. wlan_cfg_get_num_mac_rings
  2894. (pdev->wlan_cfg_ctx);
  2895. htt_srng_setup(soc->htt_handle, 0,
  2896. pdev->rx_refill_buf_ring.hal_srng,
  2897. RXDMA_BUF);
  2898. if (pdev->rx_refill_buf_ring2.hal_srng)
  2899. htt_srng_setup(soc->htt_handle, 0,
  2900. pdev->rx_refill_buf_ring2.hal_srng,
  2901. RXDMA_BUF);
  2902. if (soc->cdp_soc.ol_ops->
  2903. is_hw_dbs_2x2_capable) {
  2904. dbs_enable = soc->cdp_soc.ol_ops->
  2905. is_hw_dbs_2x2_capable(soc->ctrl_psoc);
  2906. }
  2907. if (dbs_enable) {
  2908. QDF_TRACE(QDF_MODULE_ID_TXRX,
  2909. QDF_TRACE_LEVEL_ERROR,
  2910. FL("DBS enabled max_mac_rings %d\n"),
  2911. max_mac_rings);
  2912. } else {
  2913. max_mac_rings = 1;
  2914. QDF_TRACE(QDF_MODULE_ID_TXRX,
  2915. QDF_TRACE_LEVEL_ERROR,
  2916. FL("DBS disabled, max_mac_rings %d\n"),
  2917. max_mac_rings);
  2918. }
  2919. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  2920. FL("pdev_id %d max_mac_rings %d\n"),
  2921. pdev->pdev_id, max_mac_rings);
  2922. for (mac_id = 0; mac_id < max_mac_rings; mac_id++) {
  2923. int mac_for_pdev = dp_get_mac_id_for_pdev(
  2924. mac_id, pdev->pdev_id);
  2925. QDF_TRACE(QDF_MODULE_ID_TXRX,
  2926. QDF_TRACE_LEVEL_ERROR,
  2927. FL("mac_id %d\n"), mac_for_pdev);
  2928. htt_srng_setup(soc->htt_handle, mac_for_pdev,
  2929. pdev->rx_mac_buf_ring[mac_id]
  2930. .hal_srng,
  2931. RXDMA_BUF);
  2932. htt_srng_setup(soc->htt_handle, mac_for_pdev,
  2933. pdev->rxdma_err_dst_ring[mac_id]
  2934. .hal_srng,
  2935. RXDMA_DST);
  2936. /* Configure monitor mode rings */
  2937. dp_mon_htt_srng_setup(soc, pdev, mac_id,
  2938. mac_for_pdev);
  2939. }
  2940. }
  2941. }
  2942. /*
  2943. * Timer to reap rxdma status rings.
  2944. * Needed until we enable ppdu end interrupts
  2945. */
  2946. qdf_timer_init(soc->osdev, &soc->mon_reap_timer,
  2947. dp_service_mon_rings, (void *)soc,
  2948. QDF_TIMER_TYPE_WAKE_APPS);
  2949. soc->reap_timer_init = 1;
  2950. }
  2951. #else
  2952. /* This is only for WIN */
  2953. static void dp_rxdma_ring_config(struct dp_soc *soc)
  2954. {
  2955. int i;
  2956. int mac_id;
  2957. for (i = 0; i < MAX_PDEV_CNT; i++) {
  2958. struct dp_pdev *pdev = soc->pdev_list[i];
  2959. if (pdev == NULL)
  2960. continue;
  2961. for (mac_id = 0; mac_id < NUM_RXDMA_RINGS_PER_PDEV; mac_id++) {
  2962. int mac_for_pdev = dp_get_mac_id_for_pdev(mac_id, i);
  2963. htt_srng_setup(soc->htt_handle, mac_for_pdev,
  2964. pdev->rx_refill_buf_ring.hal_srng, RXDMA_BUF);
  2965. htt_srng_setup(soc->htt_handle, mac_for_pdev,
  2966. pdev->rxdma_mon_buf_ring[mac_id].hal_srng,
  2967. RXDMA_MONITOR_BUF);
  2968. htt_srng_setup(soc->htt_handle, mac_for_pdev,
  2969. pdev->rxdma_mon_dst_ring[mac_id].hal_srng,
  2970. RXDMA_MONITOR_DST);
  2971. htt_srng_setup(soc->htt_handle, mac_for_pdev,
  2972. pdev->rxdma_mon_status_ring[mac_id].hal_srng,
  2973. RXDMA_MONITOR_STATUS);
  2974. htt_srng_setup(soc->htt_handle, mac_for_pdev,
  2975. pdev->rxdma_mon_desc_ring[mac_id].hal_srng,
  2976. RXDMA_MONITOR_DESC);
  2977. htt_srng_setup(soc->htt_handle, mac_for_pdev,
  2978. pdev->rxdma_err_dst_ring[mac_id].hal_srng,
  2979. RXDMA_DST);
  2980. }
  2981. }
  2982. }
  2983. #endif
  2984. /*
  2985. * dp_soc_attach_target_wifi3() - SOC initialization in the target
  2986. * @txrx_soc: Datapath SOC handle
  2987. */
  2988. static int dp_soc_attach_target_wifi3(struct cdp_soc_t *cdp_soc)
  2989. {
  2990. struct dp_soc *soc = (struct dp_soc *)cdp_soc;
  2991. htt_soc_attach_target(soc->htt_handle);
  2992. dp_rxdma_ring_config(soc);
  2993. DP_STATS_INIT(soc);
  2994. /* initialize work queue for stats processing */
  2995. qdf_create_work(0, &soc->htt_stats.work, htt_t2h_stats_handler, soc);
  2996. return 0;
  2997. }
  2998. /*
  2999. * dp_soc_get_nss_cfg_wifi3() - SOC get nss config
  3000. * @txrx_soc: Datapath SOC handle
  3001. */
  3002. static int dp_soc_get_nss_cfg_wifi3(struct cdp_soc_t *cdp_soc)
  3003. {
  3004. struct dp_soc *dsoc = (struct dp_soc *)cdp_soc;
  3005. return wlan_cfg_get_dp_soc_nss_cfg(dsoc->wlan_cfg_ctx);
  3006. }
  3007. /*
  3008. * dp_soc_set_nss_cfg_wifi3() - SOC set nss config
  3009. * @txrx_soc: Datapath SOC handle
  3010. * @nss_cfg: nss config
  3011. */
  3012. static void dp_soc_set_nss_cfg_wifi3(struct cdp_soc_t *cdp_soc, int config)
  3013. {
  3014. struct dp_soc *dsoc = (struct dp_soc *)cdp_soc;
  3015. struct wlan_cfg_dp_soc_ctxt *wlan_cfg_ctx = dsoc->wlan_cfg_ctx;
  3016. wlan_cfg_set_dp_soc_nss_cfg(wlan_cfg_ctx, config);
  3017. /*
  3018. * TODO: masked out based on the per offloaded radio
  3019. */
  3020. if (config == dp_nss_cfg_dbdc) {
  3021. wlan_cfg_set_num_tx_desc_pool(wlan_cfg_ctx, 0);
  3022. wlan_cfg_set_num_tx_ext_desc_pool(wlan_cfg_ctx, 0);
  3023. wlan_cfg_set_num_tx_desc(wlan_cfg_ctx, 0);
  3024. wlan_cfg_set_num_tx_ext_desc(wlan_cfg_ctx, 0);
  3025. }
  3026. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  3027. FL("nss-wifi<0> nss config is enabled"));
  3028. }
  3029. /*
  3030. * dp_vdev_attach_wifi3() - attach txrx vdev
  3031. * @txrx_pdev: Datapath PDEV handle
  3032. * @vdev_mac_addr: MAC address of the virtual interface
  3033. * @vdev_id: VDEV Id
  3034. * @wlan_op_mode: VDEV operating mode
  3035. *
  3036. * Return: DP VDEV handle on success, NULL on failure
  3037. */
  3038. static struct cdp_vdev *dp_vdev_attach_wifi3(struct cdp_pdev *txrx_pdev,
  3039. uint8_t *vdev_mac_addr, uint8_t vdev_id, enum wlan_op_mode op_mode)
  3040. {
  3041. struct dp_pdev *pdev = (struct dp_pdev *)txrx_pdev;
  3042. struct dp_soc *soc = pdev->soc;
  3043. struct dp_vdev *vdev = qdf_mem_malloc(sizeof(*vdev));
  3044. if (!vdev) {
  3045. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  3046. FL("DP VDEV memory allocation failed"));
  3047. goto fail0;
  3048. }
  3049. vdev->pdev = pdev;
  3050. vdev->vdev_id = vdev_id;
  3051. vdev->opmode = op_mode;
  3052. vdev->osdev = soc->osdev;
  3053. vdev->osif_rx = NULL;
  3054. vdev->osif_rsim_rx_decap = NULL;
  3055. vdev->osif_get_key = NULL;
  3056. vdev->osif_rx_mon = NULL;
  3057. vdev->osif_tx_free_ext = NULL;
  3058. vdev->osif_vdev = NULL;
  3059. vdev->delete.pending = 0;
  3060. vdev->safemode = 0;
  3061. vdev->drop_unenc = 1;
  3062. vdev->sec_type = cdp_sec_type_none;
  3063. #ifdef notyet
  3064. vdev->filters_num = 0;
  3065. #endif
  3066. qdf_mem_copy(
  3067. &vdev->mac_addr.raw[0], vdev_mac_addr, OL_TXRX_MAC_ADDR_LEN);
  3068. vdev->tx_encap_type = wlan_cfg_pkt_type(soc->wlan_cfg_ctx);
  3069. vdev->rx_decap_type = wlan_cfg_pkt_type(soc->wlan_cfg_ctx);
  3070. vdev->dscp_tid_map_id = 0;
  3071. vdev->mcast_enhancement_en = 0;
  3072. /* TODO: Initialize default HTT meta data that will be used in
  3073. * TCL descriptors for packets transmitted from this VDEV
  3074. */
  3075. TAILQ_INIT(&vdev->peer_list);
  3076. qdf_spin_lock_bh(&pdev->vdev_list_lock);
  3077. /* add this vdev into the pdev's list */
  3078. TAILQ_INSERT_TAIL(&pdev->vdev_list, vdev, vdev_list_elem);
  3079. qdf_spin_unlock_bh(&pdev->vdev_list_lock);
  3080. pdev->vdev_count++;
  3081. dp_tx_vdev_attach(vdev);
  3082. if ((soc->intr_mode == DP_INTR_POLL) &&
  3083. wlan_cfg_get_num_contexts(soc->wlan_cfg_ctx) != 0) {
  3084. if (pdev->vdev_count == 1)
  3085. qdf_timer_mod(&soc->int_timer, DP_INTR_POLL_TIMER_MS);
  3086. }
  3087. dp_lro_hash_setup(soc);
  3088. /* LRO */
  3089. if (wlan_cfg_is_lro_enabled(soc->wlan_cfg_ctx) &&
  3090. wlan_op_mode_sta == vdev->opmode)
  3091. vdev->lro_enable = true;
  3092. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  3093. "LRO: vdev_id %d lro_enable %d", vdev_id, vdev->lro_enable);
  3094. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  3095. "Created vdev %pK (%pM)", vdev, vdev->mac_addr.raw);
  3096. DP_STATS_INIT(vdev);
  3097. if (wlan_op_mode_sta == vdev->opmode)
  3098. dp_peer_create_wifi3((struct cdp_vdev *)vdev,
  3099. vdev->mac_addr.raw,
  3100. NULL);
  3101. return (struct cdp_vdev *)vdev;
  3102. fail0:
  3103. return NULL;
  3104. }
  3105. /**
  3106. * dp_vdev_register_wifi3() - Register VDEV operations from osif layer
  3107. * @vdev: Datapath VDEV handle
  3108. * @osif_vdev: OSIF vdev handle
  3109. * @ctrl_vdev: UMAC vdev handle
  3110. * @txrx_ops: Tx and Rx operations
  3111. *
  3112. * Return: DP VDEV handle on success, NULL on failure
  3113. */
  3114. static void dp_vdev_register_wifi3(struct cdp_vdev *vdev_handle,
  3115. void *osif_vdev, struct cdp_ctrl_objmgr_vdev *ctrl_vdev,
  3116. struct ol_txrx_ops *txrx_ops)
  3117. {
  3118. struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle;
  3119. vdev->osif_vdev = osif_vdev;
  3120. vdev->ctrl_vdev = ctrl_vdev;
  3121. vdev->osif_rx = txrx_ops->rx.rx;
  3122. vdev->osif_rsim_rx_decap = txrx_ops->rx.rsim_rx_decap;
  3123. vdev->osif_get_key = txrx_ops->get_key;
  3124. vdev->osif_rx_mon = txrx_ops->rx.mon;
  3125. vdev->osif_tx_free_ext = txrx_ops->tx.tx_free_ext;
  3126. #ifdef notyet
  3127. #if ATH_SUPPORT_WAPI
  3128. vdev->osif_check_wai = txrx_ops->rx.wai_check;
  3129. #endif
  3130. #endif
  3131. #ifdef UMAC_SUPPORT_PROXY_ARP
  3132. vdev->osif_proxy_arp = txrx_ops->proxy_arp;
  3133. #endif
  3134. vdev->me_convert = txrx_ops->me_convert;
  3135. /* TODO: Enable the following once Tx code is integrated */
  3136. if (vdev->mesh_vdev)
  3137. txrx_ops->tx.tx = dp_tx_send_mesh;
  3138. else
  3139. txrx_ops->tx.tx = dp_tx_send;
  3140. txrx_ops->tx.tx_exception = dp_tx_send_exception;
  3141. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_LOW,
  3142. "DP Vdev Register success");
  3143. }
  3144. /**
  3145. * dp_vdev_flush_peers() - Forcibily Flush peers of vdev
  3146. * @vdev: Datapath VDEV handle
  3147. *
  3148. * Return: void
  3149. */
  3150. static void dp_vdev_flush_peers(struct dp_vdev *vdev)
  3151. {
  3152. struct dp_pdev *pdev = vdev->pdev;
  3153. struct dp_soc *soc = pdev->soc;
  3154. struct dp_peer *peer;
  3155. uint16_t *peer_ids;
  3156. uint8_t i = 0, j = 0;
  3157. peer_ids = qdf_mem_malloc(soc->max_peers * sizeof(peer_ids[0]));
  3158. if (!peer_ids) {
  3159. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  3160. "DP alloc failure - unable to flush peers");
  3161. return;
  3162. }
  3163. qdf_spin_lock_bh(&soc->peer_ref_mutex);
  3164. TAILQ_FOREACH(peer, &vdev->peer_list, peer_list_elem) {
  3165. for (i = 0; i < MAX_NUM_PEER_ID_PER_PEER; i++)
  3166. if (peer->peer_ids[i] != HTT_INVALID_PEER)
  3167. if (j < soc->max_peers)
  3168. peer_ids[j++] = peer->peer_ids[i];
  3169. }
  3170. qdf_spin_unlock_bh(&soc->peer_ref_mutex);
  3171. for (i = 0; i < j ; i++)
  3172. dp_rx_peer_unmap_handler(soc, peer_ids[i]);
  3173. qdf_mem_free(peer_ids);
  3174. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_HIGH,
  3175. FL("Flushed peers for vdev object %pK "), vdev);
  3176. }
  3177. /*
  3178. * dp_vdev_detach_wifi3() - Detach txrx vdev
  3179. * @txrx_vdev: Datapath VDEV handle
  3180. * @callback: Callback OL_IF on completion of detach
  3181. * @cb_context: Callback context
  3182. *
  3183. */
  3184. static void dp_vdev_detach_wifi3(struct cdp_vdev *vdev_handle,
  3185. ol_txrx_vdev_delete_cb callback, void *cb_context)
  3186. {
  3187. struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle;
  3188. struct dp_pdev *pdev = vdev->pdev;
  3189. struct dp_soc *soc = pdev->soc;
  3190. /* preconditions */
  3191. qdf_assert(vdev);
  3192. qdf_spin_lock_bh(&pdev->vdev_list_lock);
  3193. /* remove the vdev from its parent pdev's list */
  3194. TAILQ_REMOVE(&pdev->vdev_list, vdev, vdev_list_elem);
  3195. qdf_spin_unlock_bh(&pdev->vdev_list_lock);
  3196. if (wlan_op_mode_sta == vdev->opmode)
  3197. dp_peer_delete_wifi3(vdev->vap_bss_peer, 0);
  3198. /*
  3199. * If Target is hung, flush all peers before detaching vdev
  3200. * this will free all references held due to missing
  3201. * unmap commands from Target
  3202. */
  3203. if (hif_get_target_status(soc->hif_handle) == TARGET_STATUS_RESET)
  3204. dp_vdev_flush_peers(vdev);
  3205. /*
  3206. * Use peer_ref_mutex while accessing peer_list, in case
  3207. * a peer is in the process of being removed from the list.
  3208. */
  3209. qdf_spin_lock_bh(&soc->peer_ref_mutex);
  3210. /* check that the vdev has no peers allocated */
  3211. if (!TAILQ_EMPTY(&vdev->peer_list)) {
  3212. /* debug print - will be removed later */
  3213. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_WARN,
  3214. FL("not deleting vdev object %pK (%pM)"
  3215. "until deletion finishes for all its peers"),
  3216. vdev, vdev->mac_addr.raw);
  3217. /* indicate that the vdev needs to be deleted */
  3218. vdev->delete.pending = 1;
  3219. vdev->delete.callback = callback;
  3220. vdev->delete.context = cb_context;
  3221. qdf_spin_unlock_bh(&soc->peer_ref_mutex);
  3222. return;
  3223. }
  3224. qdf_spin_unlock_bh(&soc->peer_ref_mutex);
  3225. dp_tx_vdev_detach(vdev);
  3226. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_HIGH,
  3227. FL("deleting vdev object %pK (%pM)"), vdev, vdev->mac_addr.raw);
  3228. qdf_mem_free(vdev);
  3229. if (callback)
  3230. callback(cb_context);
  3231. }
  3232. /*
  3233. * dp_peer_delete_ast_entries(): Delete all AST entries for a peer
  3234. * @soc - datapath soc handle
  3235. * @peer - datapath peer handle
  3236. *
  3237. * Delete the AST entries belonging to a peer
  3238. */
  3239. #ifdef FEATURE_AST
  3240. static inline void dp_peer_delete_ast_entries(struct dp_soc *soc,
  3241. struct dp_peer *peer)
  3242. {
  3243. struct dp_ast_entry *ast_entry, *temp_ast_entry;
  3244. qdf_spin_lock_bh(&soc->ast_lock);
  3245. DP_PEER_ITERATE_ASE_LIST(peer, ast_entry, temp_ast_entry)
  3246. dp_peer_del_ast(soc, ast_entry);
  3247. peer->self_ast_entry = NULL;
  3248. TAILQ_INIT(&peer->ast_entry_list);
  3249. qdf_spin_unlock_bh(&soc->ast_lock);
  3250. }
  3251. #else
  3252. static inline void dp_peer_delete_ast_entries(struct dp_soc *soc,
  3253. struct dp_peer *peer)
  3254. {
  3255. }
  3256. #endif
  3257. /*
  3258. * dp_peer_create_wifi3() - attach txrx peer
  3259. * @txrx_vdev: Datapath VDEV handle
  3260. * @peer_mac_addr: Peer MAC address
  3261. *
  3262. * Return: DP peeer handle on success, NULL on failure
  3263. */
  3264. static void *dp_peer_create_wifi3(struct cdp_vdev *vdev_handle,
  3265. uint8_t *peer_mac_addr, struct cdp_ctrl_objmgr_peer *ctrl_peer)
  3266. {
  3267. struct dp_peer *peer;
  3268. int i;
  3269. struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle;
  3270. struct dp_pdev *pdev;
  3271. struct dp_soc *soc;
  3272. struct dp_ast_entry *ast_entry;
  3273. /* preconditions */
  3274. qdf_assert(vdev);
  3275. qdf_assert(peer_mac_addr);
  3276. pdev = vdev->pdev;
  3277. soc = pdev->soc;
  3278. peer = dp_peer_find_hash_find(pdev->soc, peer_mac_addr,
  3279. 0, vdev->vdev_id);
  3280. if (peer) {
  3281. peer->delete_in_progress = false;
  3282. dp_peer_delete_ast_entries(soc, peer);
  3283. /*
  3284. * on peer create, peer ref count decrements, sice new peer is not
  3285. * getting created earlier reference is reused, peer_unref_delete will
  3286. * take care of incrementing count
  3287. * */
  3288. if (soc->cdp_soc.ol_ops->peer_unref_delete) {
  3289. soc->cdp_soc.ol_ops->peer_unref_delete(pdev->ctrl_pdev,
  3290. vdev->vdev_id, peer->mac_addr.raw);
  3291. }
  3292. peer->ctrl_peer = ctrl_peer;
  3293. dp_local_peer_id_alloc(pdev, peer);
  3294. DP_STATS_INIT(peer);
  3295. return (void *)peer;
  3296. } else {
  3297. /*
  3298. * When a STA roams from RPTR AP to ROOT AP and vice versa, we
  3299. * need to remove the AST entry which was earlier added as a WDS
  3300. * entry.
  3301. */
  3302. ast_entry = dp_peer_ast_hash_find(soc, peer_mac_addr);
  3303. if (ast_entry)
  3304. dp_peer_del_ast(soc, ast_entry);
  3305. }
  3306. #ifdef notyet
  3307. peer = (struct dp_peer *)qdf_mempool_alloc(soc->osdev,
  3308. soc->mempool_ol_ath_peer);
  3309. #else
  3310. peer = (struct dp_peer *)qdf_mem_malloc(sizeof(*peer));
  3311. #endif
  3312. if (!peer)
  3313. return NULL; /* failure */
  3314. qdf_mem_zero(peer, sizeof(struct dp_peer));
  3315. TAILQ_INIT(&peer->ast_entry_list);
  3316. /* store provided params */
  3317. peer->vdev = vdev;
  3318. peer->ctrl_peer = ctrl_peer;
  3319. dp_peer_add_ast(soc, peer, peer_mac_addr, CDP_TXRX_AST_TYPE_STATIC, 0);
  3320. qdf_spinlock_create(&peer->peer_info_lock);
  3321. qdf_mem_copy(
  3322. &peer->mac_addr.raw[0], peer_mac_addr, OL_TXRX_MAC_ADDR_LEN);
  3323. /* TODO: See of rx_opt_proc is really required */
  3324. peer->rx_opt_proc = soc->rx_opt_proc;
  3325. /* initialize the peer_id */
  3326. for (i = 0; i < MAX_NUM_PEER_ID_PER_PEER; i++)
  3327. peer->peer_ids[i] = HTT_INVALID_PEER;
  3328. qdf_spin_lock_bh(&soc->peer_ref_mutex);
  3329. qdf_atomic_init(&peer->ref_cnt);
  3330. /* keep one reference for attach */
  3331. qdf_atomic_inc(&peer->ref_cnt);
  3332. /* add this peer into the vdev's list */
  3333. if (wlan_op_mode_sta == vdev->opmode)
  3334. TAILQ_INSERT_HEAD(&vdev->peer_list, peer, peer_list_elem);
  3335. else
  3336. TAILQ_INSERT_TAIL(&vdev->peer_list, peer, peer_list_elem);
  3337. qdf_spin_unlock_bh(&soc->peer_ref_mutex);
  3338. /* TODO: See if hash based search is required */
  3339. dp_peer_find_hash_add(soc, peer);
  3340. /* Initialize the peer state */
  3341. peer->state = OL_TXRX_PEER_STATE_DISC;
  3342. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_HIGH,
  3343. "vdev %pK created peer %pK (%pM) ref_cnt: %d",
  3344. vdev, peer, peer->mac_addr.raw,
  3345. qdf_atomic_read(&peer->ref_cnt));
  3346. /*
  3347. * For every peer MAp message search and set if bss_peer
  3348. */
  3349. if (memcmp(peer->mac_addr.raw, vdev->mac_addr.raw, 6) == 0) {
  3350. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_HIGH,
  3351. "vdev bss_peer!!!!");
  3352. peer->bss_peer = 1;
  3353. vdev->vap_bss_peer = peer;
  3354. }
  3355. dp_local_peer_id_alloc(pdev, peer);
  3356. DP_STATS_INIT(peer);
  3357. return (void *)peer;
  3358. }
  3359. /*
  3360. * dp_peer_setup_wifi3() - initialize the peer
  3361. * @vdev_hdl: virtual device object
  3362. * @peer: Peer object
  3363. *
  3364. * Return: void
  3365. */
  3366. static void dp_peer_setup_wifi3(struct cdp_vdev *vdev_hdl, void *peer_hdl)
  3367. {
  3368. struct dp_peer *peer = (struct dp_peer *)peer_hdl;
  3369. struct dp_vdev *vdev = (struct dp_vdev *)vdev_hdl;
  3370. struct dp_pdev *pdev;
  3371. struct dp_soc *soc;
  3372. bool hash_based = 0;
  3373. enum cdp_host_reo_dest_ring reo_dest;
  3374. /* preconditions */
  3375. qdf_assert(vdev);
  3376. qdf_assert(peer);
  3377. pdev = vdev->pdev;
  3378. soc = pdev->soc;
  3379. peer->last_assoc_rcvd = 0;
  3380. peer->last_disassoc_rcvd = 0;
  3381. peer->last_deauth_rcvd = 0;
  3382. /*
  3383. * hash based steering is disabled for Radios which are offloaded
  3384. * to NSS
  3385. */
  3386. if (!wlan_cfg_get_dp_pdev_nss_enabled(pdev->wlan_cfg_ctx))
  3387. hash_based = wlan_cfg_is_rx_hash_enabled(soc->wlan_cfg_ctx);
  3388. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  3389. FL("hash based steering for pdev: %d is %d\n"),
  3390. pdev->pdev_id, hash_based);
  3391. /*
  3392. * Below line of code will ensure the proper reo_dest ring is chosen
  3393. * for cases where toeplitz hash cannot be generated (ex: non TCP/UDP)
  3394. */
  3395. reo_dest = pdev->reo_dest;
  3396. if (soc->cdp_soc.ol_ops->peer_set_default_routing) {
  3397. /* TODO: Check the destination ring number to be passed to FW */
  3398. soc->cdp_soc.ol_ops->peer_set_default_routing(
  3399. pdev->ctrl_pdev, peer->mac_addr.raw,
  3400. peer->vdev->vdev_id, hash_based, reo_dest);
  3401. }
  3402. dp_peer_rx_init(pdev, peer);
  3403. return;
  3404. }
  3405. /*
  3406. * dp_set_vdev_tx_encap_type() - set the encap type of the vdev
  3407. * @vdev_handle: virtual device object
  3408. * @htt_pkt_type: type of pkt
  3409. *
  3410. * Return: void
  3411. */
  3412. static void dp_set_vdev_tx_encap_type(struct cdp_vdev *vdev_handle,
  3413. enum htt_cmn_pkt_type val)
  3414. {
  3415. struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle;
  3416. vdev->tx_encap_type = val;
  3417. }
  3418. /*
  3419. * dp_set_vdev_rx_decap_type() - set the decap type of the vdev
  3420. * @vdev_handle: virtual device object
  3421. * @htt_pkt_type: type of pkt
  3422. *
  3423. * Return: void
  3424. */
  3425. static void dp_set_vdev_rx_decap_type(struct cdp_vdev *vdev_handle,
  3426. enum htt_cmn_pkt_type val)
  3427. {
  3428. struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle;
  3429. vdev->rx_decap_type = val;
  3430. }
  3431. /*
  3432. * dp_set_pdev_reo_dest() - set the reo destination ring for this pdev
  3433. * @pdev_handle: physical device object
  3434. * @val: reo destination ring index (1 - 4)
  3435. *
  3436. * Return: void
  3437. */
  3438. static void dp_set_pdev_reo_dest(struct cdp_pdev *pdev_handle,
  3439. enum cdp_host_reo_dest_ring val)
  3440. {
  3441. struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
  3442. if (pdev)
  3443. pdev->reo_dest = val;
  3444. }
  3445. /*
  3446. * dp_get_pdev_reo_dest() - get the reo destination for this pdev
  3447. * @pdev_handle: physical device object
  3448. *
  3449. * Return: reo destination ring index
  3450. */
  3451. static enum cdp_host_reo_dest_ring
  3452. dp_get_pdev_reo_dest(struct cdp_pdev *pdev_handle)
  3453. {
  3454. struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
  3455. if (pdev)
  3456. return pdev->reo_dest;
  3457. else
  3458. return cdp_host_reo_dest_ring_unknown;
  3459. }
  3460. #ifdef QCA_SUPPORT_SON
  3461. static void dp_son_peer_authorize(struct dp_peer *peer)
  3462. {
  3463. struct dp_soc *soc;
  3464. soc = peer->vdev->pdev->soc;
  3465. peer->peer_bs_inact_flag = 0;
  3466. peer->peer_bs_inact = soc->pdev_bs_inact_reload;
  3467. return;
  3468. }
  3469. #else
  3470. static void dp_son_peer_authorize(struct dp_peer *peer)
  3471. {
  3472. return;
  3473. }
  3474. #endif
  3475. /*
  3476. * dp_set_filter_neighbour_peers() - set filter neighbour peers for smart mesh
  3477. * @pdev_handle: device object
  3478. * @val: value to be set
  3479. *
  3480. * Return: void
  3481. */
  3482. static int dp_set_filter_neighbour_peers(struct cdp_pdev *pdev_handle,
  3483. uint32_t val)
  3484. {
  3485. struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
  3486. /* Enable/Disable smart mesh filtering. This flag will be checked
  3487. * during rx processing to check if packets are from NAC clients.
  3488. */
  3489. pdev->filter_neighbour_peers = val;
  3490. return 0;
  3491. }
  3492. /*
  3493. * dp_update_filter_neighbour_peers() - set neighbour peers(nac clients)
  3494. * address for smart mesh filtering
  3495. * @pdev_handle: device object
  3496. * @cmd: Add/Del command
  3497. * @macaddr: nac client mac address
  3498. *
  3499. * Return: void
  3500. */
  3501. static int dp_update_filter_neighbour_peers(struct cdp_pdev *pdev_handle,
  3502. uint32_t cmd, uint8_t *macaddr)
  3503. {
  3504. struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
  3505. struct dp_neighbour_peer *peer = NULL;
  3506. if (!macaddr)
  3507. goto fail0;
  3508. /* Store address of NAC (neighbour peer) which will be checked
  3509. * against TA of received packets.
  3510. */
  3511. if (cmd == DP_NAC_PARAM_ADD) {
  3512. peer = (struct dp_neighbour_peer *) qdf_mem_malloc(
  3513. sizeof(*peer));
  3514. if (!peer) {
  3515. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  3516. FL("DP neighbour peer node memory allocation failed"));
  3517. goto fail0;
  3518. }
  3519. qdf_mem_copy(&peer->neighbour_peers_macaddr.raw[0],
  3520. macaddr, DP_MAC_ADDR_LEN);
  3521. qdf_spin_lock_bh(&pdev->neighbour_peer_mutex);
  3522. /* add this neighbour peer into the list */
  3523. TAILQ_INSERT_TAIL(&pdev->neighbour_peers_list, peer,
  3524. neighbour_peer_list_elem);
  3525. qdf_spin_unlock_bh(&pdev->neighbour_peer_mutex);
  3526. return 1;
  3527. } else if (cmd == DP_NAC_PARAM_DEL) {
  3528. qdf_spin_lock_bh(&pdev->neighbour_peer_mutex);
  3529. TAILQ_FOREACH(peer, &pdev->neighbour_peers_list,
  3530. neighbour_peer_list_elem) {
  3531. if (!qdf_mem_cmp(&peer->neighbour_peers_macaddr.raw[0],
  3532. macaddr, DP_MAC_ADDR_LEN)) {
  3533. /* delete this peer from the list */
  3534. TAILQ_REMOVE(&pdev->neighbour_peers_list,
  3535. peer, neighbour_peer_list_elem);
  3536. qdf_mem_free(peer);
  3537. break;
  3538. }
  3539. }
  3540. qdf_spin_unlock_bh(&pdev->neighbour_peer_mutex);
  3541. return 1;
  3542. }
  3543. fail0:
  3544. return 0;
  3545. }
  3546. /*
  3547. * dp_get_sec_type() - Get the security type
  3548. * @peer: Datapath peer handle
  3549. * @sec_idx: Security id (mcast, ucast)
  3550. *
  3551. * return sec_type: Security type
  3552. */
  3553. static int dp_get_sec_type(struct cdp_peer *peer, uint8_t sec_idx)
  3554. {
  3555. struct dp_peer *dpeer = (struct dp_peer *)peer;
  3556. return dpeer->security[sec_idx].sec_type;
  3557. }
  3558. /*
  3559. * dp_peer_authorize() - authorize txrx peer
  3560. * @peer_handle: Datapath peer handle
  3561. * @authorize
  3562. *
  3563. */
  3564. static void dp_peer_authorize(struct cdp_peer *peer_handle, uint32_t authorize)
  3565. {
  3566. struct dp_peer *peer = (struct dp_peer *)peer_handle;
  3567. struct dp_soc *soc;
  3568. if (peer != NULL) {
  3569. soc = peer->vdev->pdev->soc;
  3570. qdf_spin_lock_bh(&soc->peer_ref_mutex);
  3571. dp_son_peer_authorize(peer);
  3572. peer->authorize = authorize ? 1 : 0;
  3573. qdf_spin_unlock_bh(&soc->peer_ref_mutex);
  3574. }
  3575. }
  3576. #ifdef QCA_SUPPORT_SON
  3577. /*
  3578. * dp_txrx_update_inact_threshold() - Update inact timer threshold
  3579. * @pdev_handle: Device handle
  3580. * @new_threshold : updated threshold value
  3581. *
  3582. */
  3583. static void
  3584. dp_txrx_update_inact_threshold(struct cdp_pdev *pdev_handle,
  3585. u_int16_t new_threshold)
  3586. {
  3587. struct dp_vdev *vdev;
  3588. struct dp_peer *peer;
  3589. struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
  3590. struct dp_soc *soc = pdev->soc;
  3591. u_int16_t old_threshold = soc->pdev_bs_inact_reload;
  3592. if (old_threshold == new_threshold)
  3593. return;
  3594. soc->pdev_bs_inact_reload = new_threshold;
  3595. qdf_spin_lock_bh(&soc->peer_ref_mutex);
  3596. qdf_spin_lock_bh(&pdev->vdev_list_lock);
  3597. TAILQ_FOREACH(vdev, &pdev->vdev_list, vdev_list_elem) {
  3598. if (vdev->opmode != wlan_op_mode_ap)
  3599. continue;
  3600. TAILQ_FOREACH(peer, &vdev->peer_list, peer_list_elem) {
  3601. if (!peer->authorize)
  3602. continue;
  3603. if (old_threshold - peer->peer_bs_inact >=
  3604. new_threshold) {
  3605. dp_mark_peer_inact((void *)peer, true);
  3606. peer->peer_bs_inact = 0;
  3607. } else {
  3608. peer->peer_bs_inact = new_threshold -
  3609. (old_threshold - peer->peer_bs_inact);
  3610. }
  3611. }
  3612. }
  3613. qdf_spin_unlock_bh(&pdev->vdev_list_lock);
  3614. qdf_spin_unlock_bh(&soc->peer_ref_mutex);
  3615. }
  3616. /**
  3617. * dp_txrx_reset_inact_count(): Reset inact count
  3618. * @pdev_handle - device handle
  3619. *
  3620. * Return: void
  3621. */
  3622. static void
  3623. dp_txrx_reset_inact_count(struct cdp_pdev *pdev_handle)
  3624. {
  3625. struct dp_vdev *vdev = NULL;
  3626. struct dp_peer *peer = NULL;
  3627. struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
  3628. struct dp_soc *soc = pdev->soc;
  3629. qdf_spin_lock_bh(&soc->peer_ref_mutex);
  3630. qdf_spin_lock_bh(&pdev->vdev_list_lock);
  3631. TAILQ_FOREACH(vdev, &pdev->vdev_list, vdev_list_elem) {
  3632. if (vdev->opmode != wlan_op_mode_ap)
  3633. continue;
  3634. TAILQ_FOREACH(peer, &vdev->peer_list, peer_list_elem) {
  3635. if (!peer->authorize)
  3636. continue;
  3637. peer->peer_bs_inact = soc->pdev_bs_inact_reload;
  3638. }
  3639. }
  3640. qdf_spin_unlock_bh(&pdev->vdev_list_lock);
  3641. qdf_spin_unlock_bh(&soc->peer_ref_mutex);
  3642. }
  3643. /**
  3644. * dp_set_inact_params(): set inactivity params
  3645. * @pdev_handle - device handle
  3646. * @inact_check_interval - inactivity interval
  3647. * @inact_normal - Inactivity normal
  3648. * @inact_overload - Inactivity overload
  3649. *
  3650. * Return: bool
  3651. */
  3652. bool dp_set_inact_params(struct cdp_pdev *pdev_handle,
  3653. u_int16_t inact_check_interval,
  3654. u_int16_t inact_normal, u_int16_t inact_overload)
  3655. {
  3656. struct dp_soc *soc;
  3657. struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
  3658. if (!pdev)
  3659. return false;
  3660. soc = pdev->soc;
  3661. if (!soc)
  3662. return false;
  3663. soc->pdev_bs_inact_interval = inact_check_interval;
  3664. soc->pdev_bs_inact_normal = inact_normal;
  3665. soc->pdev_bs_inact_overload = inact_overload;
  3666. dp_txrx_update_inact_threshold((struct cdp_pdev *)pdev,
  3667. soc->pdev_bs_inact_normal);
  3668. return true;
  3669. }
  3670. /**
  3671. * dp_start_inact_timer(): Inactivity timer start
  3672. * @pdev_handle - device handle
  3673. * @enable - Inactivity timer start/stop
  3674. *
  3675. * Return: bool
  3676. */
  3677. bool dp_start_inact_timer(struct cdp_pdev *pdev_handle, bool enable)
  3678. {
  3679. struct dp_soc *soc;
  3680. struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
  3681. if (!pdev)
  3682. return false;
  3683. soc = pdev->soc;
  3684. if (!soc)
  3685. return false;
  3686. if (enable) {
  3687. dp_txrx_reset_inact_count((struct cdp_pdev *)pdev);
  3688. qdf_timer_mod(&soc->pdev_bs_inact_timer,
  3689. soc->pdev_bs_inact_interval * 1000);
  3690. } else {
  3691. qdf_timer_stop(&soc->pdev_bs_inact_timer);
  3692. }
  3693. return true;
  3694. }
  3695. /**
  3696. * dp_set_overload(): Set inactivity overload
  3697. * @pdev_handle - device handle
  3698. * @overload - overload status
  3699. *
  3700. * Return: void
  3701. */
  3702. void dp_set_overload(struct cdp_pdev *pdev_handle, bool overload)
  3703. {
  3704. struct dp_soc *soc;
  3705. struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
  3706. if (!pdev)
  3707. return;
  3708. soc = pdev->soc;
  3709. if (!soc)
  3710. return;
  3711. dp_txrx_update_inact_threshold((struct cdp_pdev *)pdev,
  3712. overload ? soc->pdev_bs_inact_overload :
  3713. soc->pdev_bs_inact_normal);
  3714. }
  3715. /**
  3716. * dp_peer_is_inact(): check whether peer is inactive
  3717. * @peer_handle - datapath peer handle
  3718. *
  3719. * Return: bool
  3720. */
  3721. bool dp_peer_is_inact(void *peer_handle)
  3722. {
  3723. struct dp_peer *peer = (struct dp_peer *)peer_handle;
  3724. if (!peer)
  3725. return false;
  3726. return peer->peer_bs_inact_flag == 1;
  3727. }
  3728. /**
  3729. * dp_init_inact_timer: initialize the inact timer
  3730. * @soc - SOC handle
  3731. *
  3732. * Return: void
  3733. */
  3734. void dp_init_inact_timer(struct dp_soc *soc)
  3735. {
  3736. qdf_timer_init(soc->osdev, &soc->pdev_bs_inact_timer,
  3737. dp_txrx_peer_find_inact_timeout_handler,
  3738. (void *)soc, QDF_TIMER_TYPE_WAKE_APPS);
  3739. }
  3740. #else
  3741. bool dp_set_inact_params(struct cdp_pdev *pdev, u_int16_t inact_check_interval,
  3742. u_int16_t inact_normal, u_int16_t inact_overload)
  3743. {
  3744. return false;
  3745. }
  3746. bool dp_start_inact_timer(struct cdp_pdev *pdev, bool enable)
  3747. {
  3748. return false;
  3749. }
  3750. void dp_set_overload(struct cdp_pdev *pdev, bool overload)
  3751. {
  3752. return;
  3753. }
  3754. void dp_init_inact_timer(struct dp_soc *soc)
  3755. {
  3756. return;
  3757. }
  3758. bool dp_peer_is_inact(void *peer)
  3759. {
  3760. return false;
  3761. }
  3762. #endif
  3763. /*
  3764. * dp_peer_unref_delete() - unref and delete peer
  3765. * @peer_handle: Datapath peer handle
  3766. *
  3767. */
  3768. void dp_peer_unref_delete(void *peer_handle)
  3769. {
  3770. struct dp_peer *peer = (struct dp_peer *)peer_handle;
  3771. struct dp_peer *bss_peer = NULL;
  3772. struct dp_vdev *vdev = peer->vdev;
  3773. struct dp_pdev *pdev = vdev->pdev;
  3774. struct dp_soc *soc = pdev->soc;
  3775. struct dp_peer *tmppeer;
  3776. int found = 0;
  3777. uint16_t peer_id;
  3778. uint16_t vdev_id;
  3779. /*
  3780. * Hold the lock all the way from checking if the peer ref count
  3781. * is zero until the peer references are removed from the hash
  3782. * table and vdev list (if the peer ref count is zero).
  3783. * This protects against a new HL tx operation starting to use the
  3784. * peer object just after this function concludes it's done being used.
  3785. * Furthermore, the lock needs to be held while checking whether the
  3786. * vdev's list of peers is empty, to make sure that list is not modified
  3787. * concurrently with the empty check.
  3788. */
  3789. qdf_spin_lock_bh(&soc->peer_ref_mutex);
  3790. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  3791. "%s: peer %pK ref_cnt(before decrement): %d\n", __func__,
  3792. peer, qdf_atomic_read(&peer->ref_cnt));
  3793. if (qdf_atomic_dec_and_test(&peer->ref_cnt)) {
  3794. peer_id = peer->peer_ids[0];
  3795. vdev_id = vdev->vdev_id;
  3796. /*
  3797. * Make sure that the reference to the peer in
  3798. * peer object map is removed
  3799. */
  3800. if (peer_id != HTT_INVALID_PEER)
  3801. soc->peer_id_to_obj_map[peer_id] = NULL;
  3802. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_HIGH,
  3803. "Deleting peer %pK (%pM)", peer, peer->mac_addr.raw);
  3804. /* remove the reference to the peer from the hash table */
  3805. dp_peer_find_hash_remove(soc, peer);
  3806. qdf_spin_lock_bh(&soc->ast_lock);
  3807. if (peer->self_ast_entry) {
  3808. dp_peer_del_ast(soc, peer->self_ast_entry);
  3809. peer->self_ast_entry = NULL;
  3810. }
  3811. qdf_spin_unlock_bh(&soc->ast_lock);
  3812. TAILQ_FOREACH(tmppeer, &peer->vdev->peer_list, peer_list_elem) {
  3813. if (tmppeer == peer) {
  3814. found = 1;
  3815. break;
  3816. }
  3817. }
  3818. if (found) {
  3819. TAILQ_REMOVE(&peer->vdev->peer_list, peer,
  3820. peer_list_elem);
  3821. } else {
  3822. /*Ignoring the remove operation as peer not found*/
  3823. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_WARN,
  3824. "peer %pK not found in vdev (%pK)->peer_list:%pK",
  3825. peer, vdev, &peer->vdev->peer_list);
  3826. }
  3827. /* cleanup the peer data */
  3828. dp_peer_cleanup(vdev, peer);
  3829. /* check whether the parent vdev has no peers left */
  3830. if (TAILQ_EMPTY(&vdev->peer_list)) {
  3831. /*
  3832. * Now that there are no references to the peer, we can
  3833. * release the peer reference lock.
  3834. */
  3835. qdf_spin_unlock_bh(&soc->peer_ref_mutex);
  3836. /*
  3837. * Check if the parent vdev was waiting for its peers
  3838. * to be deleted, in order for it to be deleted too.
  3839. */
  3840. if (vdev->delete.pending) {
  3841. ol_txrx_vdev_delete_cb vdev_delete_cb =
  3842. vdev->delete.callback;
  3843. void *vdev_delete_context =
  3844. vdev->delete.context;
  3845. QDF_TRACE(QDF_MODULE_ID_DP,
  3846. QDF_TRACE_LEVEL_INFO_HIGH,
  3847. FL("deleting vdev object %pK (%pM)"
  3848. " - its last peer is done"),
  3849. vdev, vdev->mac_addr.raw);
  3850. /* all peers are gone, go ahead and delete it */
  3851. dp_tx_flow_pool_unmap_handler(pdev, vdev_id,
  3852. FLOW_TYPE_VDEV,
  3853. vdev_id);
  3854. dp_tx_vdev_detach(vdev);
  3855. QDF_TRACE(QDF_MODULE_ID_DP,
  3856. QDF_TRACE_LEVEL_INFO_HIGH,
  3857. FL("deleting vdev object %pK (%pM)"),
  3858. vdev, vdev->mac_addr.raw);
  3859. qdf_mem_free(vdev);
  3860. vdev = NULL;
  3861. if (vdev_delete_cb)
  3862. vdev_delete_cb(vdev_delete_context);
  3863. }
  3864. } else {
  3865. qdf_spin_unlock_bh(&soc->peer_ref_mutex);
  3866. }
  3867. if (vdev) {
  3868. if (vdev->vap_bss_peer == peer) {
  3869. vdev->vap_bss_peer = NULL;
  3870. }
  3871. }
  3872. if (soc->cdp_soc.ol_ops->peer_unref_delete) {
  3873. soc->cdp_soc.ol_ops->peer_unref_delete(pdev->ctrl_pdev,
  3874. vdev_id, peer->mac_addr.raw);
  3875. }
  3876. if (!vdev || !vdev->vap_bss_peer) {
  3877. goto free_peer;
  3878. }
  3879. #ifdef notyet
  3880. qdf_mempool_free(soc->osdev, soc->mempool_ol_ath_peer, peer);
  3881. #else
  3882. bss_peer = vdev->vap_bss_peer;
  3883. DP_UPDATE_STATS(bss_peer, peer);
  3884. free_peer:
  3885. qdf_mem_free(peer);
  3886. #endif
  3887. } else {
  3888. qdf_spin_unlock_bh(&soc->peer_ref_mutex);
  3889. }
  3890. }
  3891. /*
  3892. * dp_peer_detach_wifi3() – Detach txrx peer
  3893. * @peer_handle: Datapath peer handle
  3894. * @bitmap: bitmap indicating special handling of request.
  3895. *
  3896. */
  3897. static void dp_peer_delete_wifi3(void *peer_handle, uint32_t bitmap)
  3898. {
  3899. struct dp_peer *peer = (struct dp_peer *)peer_handle;
  3900. /* redirect the peer's rx delivery function to point to a
  3901. * discard func
  3902. */
  3903. peer->rx_opt_proc = dp_rx_discard;
  3904. peer->ctrl_peer = NULL;
  3905. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_HIGH,
  3906. FL("peer %pK (%pM)"), peer, peer->mac_addr.raw);
  3907. dp_local_peer_id_free(peer->vdev->pdev, peer);
  3908. qdf_spinlock_destroy(&peer->peer_info_lock);
  3909. /*
  3910. * Remove the reference added during peer_attach.
  3911. * The peer will still be left allocated until the
  3912. * PEER_UNMAP message arrives to remove the other
  3913. * reference, added by the PEER_MAP message.
  3914. */
  3915. dp_peer_unref_delete(peer_handle);
  3916. }
  3917. /*
  3918. * dp_get_vdev_mac_addr_wifi3() – Detach txrx peer
  3919. * @peer_handle: Datapath peer handle
  3920. *
  3921. */
  3922. static uint8 *dp_get_vdev_mac_addr_wifi3(struct cdp_vdev *pvdev)
  3923. {
  3924. struct dp_vdev *vdev = (struct dp_vdev *)pvdev;
  3925. return vdev->mac_addr.raw;
  3926. }
  3927. /*
  3928. * dp_vdev_set_wds() - Enable per packet stats
  3929. * @vdev_handle: DP VDEV handle
  3930. * @val: value
  3931. *
  3932. * Return: none
  3933. */
  3934. static int dp_vdev_set_wds(void *vdev_handle, uint32_t val)
  3935. {
  3936. struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle;
  3937. vdev->wds_enabled = val;
  3938. return 0;
  3939. }
  3940. /*
  3941. * dp_get_vdev_from_vdev_id_wifi3() – Detach txrx peer
  3942. * @peer_handle: Datapath peer handle
  3943. *
  3944. */
  3945. static struct cdp_vdev *dp_get_vdev_from_vdev_id_wifi3(struct cdp_pdev *dev,
  3946. uint8_t vdev_id)
  3947. {
  3948. struct dp_pdev *pdev = (struct dp_pdev *)dev;
  3949. struct dp_vdev *vdev = NULL;
  3950. if (qdf_unlikely(!pdev))
  3951. return NULL;
  3952. qdf_spin_lock_bh(&pdev->vdev_list_lock);
  3953. TAILQ_FOREACH(vdev, &pdev->vdev_list, vdev_list_elem) {
  3954. if (vdev->vdev_id == vdev_id)
  3955. break;
  3956. }
  3957. qdf_spin_unlock_bh(&pdev->vdev_list_lock);
  3958. return (struct cdp_vdev *)vdev;
  3959. }
  3960. static int dp_get_opmode(struct cdp_vdev *vdev_handle)
  3961. {
  3962. struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle;
  3963. return vdev->opmode;
  3964. }
  3965. static struct cdp_cfg *dp_get_ctrl_pdev_from_vdev_wifi3(struct cdp_vdev *pvdev)
  3966. {
  3967. struct dp_vdev *vdev = (struct dp_vdev *)pvdev;
  3968. struct dp_pdev *pdev = vdev->pdev;
  3969. return (struct cdp_cfg *)pdev->wlan_cfg_ctx;
  3970. }
  3971. /**
  3972. * dp_reset_monitor_mode() - Disable monitor mode
  3973. * @pdev_handle: Datapath PDEV handle
  3974. *
  3975. * Return: 0 on success, not 0 on failure
  3976. */
  3977. static int dp_reset_monitor_mode(struct cdp_pdev *pdev_handle)
  3978. {
  3979. struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
  3980. struct htt_rx_ring_tlv_filter htt_tlv_filter;
  3981. struct dp_soc *soc = pdev->soc;
  3982. uint8_t pdev_id;
  3983. int mac_id;
  3984. pdev_id = pdev->pdev_id;
  3985. soc = pdev->soc;
  3986. qdf_spin_lock_bh(&pdev->mon_lock);
  3987. qdf_mem_set(&(htt_tlv_filter), sizeof(htt_tlv_filter), 0x0);
  3988. for (mac_id = 0; mac_id < NUM_RXDMA_RINGS_PER_PDEV; mac_id++) {
  3989. int mac_for_pdev = dp_get_mac_id_for_pdev(mac_id, pdev_id);
  3990. htt_h2t_rx_ring_cfg(soc->htt_handle, mac_for_pdev,
  3991. pdev->rxdma_mon_buf_ring[mac_id].hal_srng,
  3992. RXDMA_MONITOR_BUF, RX_BUFFER_SIZE, &htt_tlv_filter);
  3993. htt_h2t_rx_ring_cfg(soc->htt_handle, mac_for_pdev,
  3994. pdev->rxdma_mon_status_ring[mac_id].hal_srng,
  3995. RXDMA_MONITOR_STATUS, RX_BUFFER_SIZE, &htt_tlv_filter);
  3996. }
  3997. pdev->monitor_vdev = NULL;
  3998. qdf_spin_unlock_bh(&pdev->mon_lock);
  3999. return 0;
  4000. }
  4001. /**
  4002. * dp_set_nac() - set peer_nac
  4003. * @peer_handle: Datapath PEER handle
  4004. *
  4005. * Return: void
  4006. */
  4007. static void dp_set_nac(struct cdp_peer *peer_handle)
  4008. {
  4009. struct dp_peer *peer = (struct dp_peer *)peer_handle;
  4010. peer->nac = 1;
  4011. }
  4012. /**
  4013. * dp_get_tx_pending() - read pending tx
  4014. * @pdev_handle: Datapath PDEV handle
  4015. *
  4016. * Return: outstanding tx
  4017. */
  4018. static int dp_get_tx_pending(struct cdp_pdev *pdev_handle)
  4019. {
  4020. struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
  4021. return qdf_atomic_read(&pdev->num_tx_outstanding);
  4022. }
  4023. /**
  4024. * dp_get_peer_mac_from_peer_id() - get peer mac
  4025. * @pdev_handle: Datapath PDEV handle
  4026. * @peer_id: Peer ID
  4027. * @peer_mac: MAC addr of PEER
  4028. *
  4029. * Return: void
  4030. */
  4031. static void dp_get_peer_mac_from_peer_id(struct cdp_pdev *pdev_handle,
  4032. uint32_t peer_id, uint8_t *peer_mac)
  4033. {
  4034. struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
  4035. struct dp_peer *peer;
  4036. if (pdev && peer_mac) {
  4037. peer = dp_peer_find_by_id(pdev->soc, (uint16_t)peer_id);
  4038. if (peer && peer->mac_addr.raw) {
  4039. qdf_mem_copy(peer_mac, peer->mac_addr.raw,
  4040. DP_MAC_ADDR_LEN);
  4041. }
  4042. }
  4043. }
  4044. /**
  4045. * dp_vdev_set_monitor_mode() - Set DP VDEV to monitor mode
  4046. * @vdev_handle: Datapath VDEV handle
  4047. * @smart_monitor: Flag to denote if its smart monitor mode
  4048. *
  4049. * Return: 0 on success, not 0 on failure
  4050. */
  4051. static int dp_vdev_set_monitor_mode(struct cdp_vdev *vdev_handle,
  4052. uint8_t smart_monitor)
  4053. {
  4054. /* Many monitor VAPs can exists in a system but only one can be up at
  4055. * anytime
  4056. */
  4057. struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle;
  4058. struct dp_pdev *pdev;
  4059. struct htt_rx_ring_tlv_filter htt_tlv_filter;
  4060. struct dp_soc *soc;
  4061. uint8_t pdev_id;
  4062. int mac_id;
  4063. qdf_assert(vdev);
  4064. pdev = vdev->pdev;
  4065. pdev_id = pdev->pdev_id;
  4066. soc = pdev->soc;
  4067. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_WARN,
  4068. "pdev=%pK, pdev_id=%d, soc=%pK vdev=%pK\n",
  4069. pdev, pdev_id, soc, vdev);
  4070. /*Check if current pdev's monitor_vdev exists */
  4071. if (pdev->monitor_vdev) {
  4072. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  4073. "vdev=%pK\n", vdev);
  4074. qdf_assert(vdev);
  4075. }
  4076. pdev->monitor_vdev = vdev;
  4077. /* If smart monitor mode, do not configure monitor ring */
  4078. if (smart_monitor)
  4079. return QDF_STATUS_SUCCESS;
  4080. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_HIGH,
  4081. "MODE[%x] FP[%02x|%02x|%02x] MO[%02x|%02x|%02x]\n",
  4082. pdev->mon_filter_mode, pdev->fp_mgmt_filter,
  4083. pdev->fp_ctrl_filter, pdev->fp_data_filter,
  4084. pdev->mo_mgmt_filter, pdev->mo_ctrl_filter,
  4085. pdev->mo_data_filter);
  4086. qdf_mem_set(&(htt_tlv_filter), sizeof(htt_tlv_filter), 0x0);
  4087. htt_tlv_filter.mpdu_start = 1;
  4088. htt_tlv_filter.msdu_start = 1;
  4089. htt_tlv_filter.packet = 1;
  4090. htt_tlv_filter.msdu_end = 1;
  4091. htt_tlv_filter.mpdu_end = 1;
  4092. htt_tlv_filter.packet_header = 1;
  4093. htt_tlv_filter.attention = 1;
  4094. htt_tlv_filter.ppdu_start = 0;
  4095. htt_tlv_filter.ppdu_end = 0;
  4096. htt_tlv_filter.ppdu_end_user_stats = 0;
  4097. htt_tlv_filter.ppdu_end_user_stats_ext = 0;
  4098. htt_tlv_filter.ppdu_end_status_done = 0;
  4099. htt_tlv_filter.header_per_msdu = 1;
  4100. htt_tlv_filter.enable_fp =
  4101. (pdev->mon_filter_mode & MON_FILTER_PASS) ? 1 : 0;
  4102. htt_tlv_filter.enable_md = 0;
  4103. htt_tlv_filter.enable_mo =
  4104. (pdev->mon_filter_mode & MON_FILTER_OTHER) ? 1 : 0;
  4105. htt_tlv_filter.fp_mgmt_filter = pdev->fp_mgmt_filter;
  4106. htt_tlv_filter.fp_ctrl_filter = pdev->fp_ctrl_filter;
  4107. htt_tlv_filter.fp_data_filter = pdev->fp_data_filter;
  4108. htt_tlv_filter.mo_mgmt_filter = pdev->mo_mgmt_filter;
  4109. htt_tlv_filter.mo_ctrl_filter = pdev->mo_ctrl_filter;
  4110. htt_tlv_filter.mo_data_filter = pdev->mo_data_filter;
  4111. for (mac_id = 0; mac_id < NUM_RXDMA_RINGS_PER_PDEV; mac_id++) {
  4112. int mac_for_pdev = dp_get_mac_id_for_pdev(mac_id, pdev_id);
  4113. htt_h2t_rx_ring_cfg(soc->htt_handle, mac_for_pdev,
  4114. pdev->rxdma_mon_buf_ring[mac_id].hal_srng,
  4115. RXDMA_MONITOR_BUF, RX_BUFFER_SIZE, &htt_tlv_filter);
  4116. }
  4117. qdf_mem_set(&(htt_tlv_filter), sizeof(htt_tlv_filter), 0x0);
  4118. htt_tlv_filter.mpdu_start = 1;
  4119. htt_tlv_filter.msdu_start = 0;
  4120. htt_tlv_filter.packet = 0;
  4121. htt_tlv_filter.msdu_end = 0;
  4122. htt_tlv_filter.mpdu_end = 0;
  4123. htt_tlv_filter.attention = 0;
  4124. htt_tlv_filter.ppdu_start = 1;
  4125. htt_tlv_filter.ppdu_end = 1;
  4126. htt_tlv_filter.ppdu_end_user_stats = 1;
  4127. htt_tlv_filter.ppdu_end_user_stats_ext = 1;
  4128. htt_tlv_filter.ppdu_end_status_done = 1;
  4129. htt_tlv_filter.enable_fp = 1;
  4130. htt_tlv_filter.enable_md = 0;
  4131. htt_tlv_filter.enable_mo = 1;
  4132. if (pdev->mcopy_mode) {
  4133. htt_tlv_filter.packet_header = 1;
  4134. }
  4135. htt_tlv_filter.fp_mgmt_filter = FILTER_MGMT_ALL;
  4136. htt_tlv_filter.fp_ctrl_filter = FILTER_CTRL_ALL;
  4137. htt_tlv_filter.fp_data_filter = FILTER_DATA_ALL;
  4138. htt_tlv_filter.mo_mgmt_filter = FILTER_MGMT_ALL;
  4139. htt_tlv_filter.mo_ctrl_filter = FILTER_CTRL_ALL;
  4140. htt_tlv_filter.mo_data_filter = FILTER_DATA_ALL;
  4141. for (mac_id = 0; mac_id < NUM_RXDMA_RINGS_PER_PDEV; mac_id++) {
  4142. int mac_for_pdev = dp_get_mac_id_for_pdev(mac_id,
  4143. pdev->pdev_id);
  4144. htt_h2t_rx_ring_cfg(soc->htt_handle, mac_for_pdev,
  4145. pdev->rxdma_mon_status_ring[mac_id].hal_srng,
  4146. RXDMA_MONITOR_STATUS, RX_BUFFER_SIZE, &htt_tlv_filter);
  4147. }
  4148. return QDF_STATUS_SUCCESS;
  4149. }
  4150. /**
  4151. * dp_pdev_set_advance_monitor_filter() - Set DP PDEV monitor filter
  4152. * @pdev_handle: Datapath PDEV handle
  4153. * @filter_val: Flag to select Filter for monitor mode
  4154. * Return: 0 on success, not 0 on failure
  4155. */
  4156. static int dp_pdev_set_advance_monitor_filter(struct cdp_pdev *pdev_handle,
  4157. struct cdp_monitor_filter *filter_val)
  4158. {
  4159. /* Many monitor VAPs can exists in a system but only one can be up at
  4160. * anytime
  4161. */
  4162. struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
  4163. struct dp_vdev *vdev = pdev->monitor_vdev;
  4164. struct htt_rx_ring_tlv_filter htt_tlv_filter;
  4165. struct dp_soc *soc;
  4166. uint8_t pdev_id;
  4167. int mac_id;
  4168. pdev_id = pdev->pdev_id;
  4169. soc = pdev->soc;
  4170. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_WARN,
  4171. "pdev=%pK, pdev_id=%d, soc=%pK vdev=%pK\n",
  4172. pdev, pdev_id, soc, vdev);
  4173. /*Check if current pdev's monitor_vdev exists */
  4174. if (!pdev->monitor_vdev) {
  4175. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  4176. "vdev=%pK\n", vdev);
  4177. qdf_assert(vdev);
  4178. }
  4179. /* update filter mode, type in pdev structure */
  4180. pdev->mon_filter_mode = filter_val->mode;
  4181. pdev->fp_mgmt_filter = filter_val->fp_mgmt;
  4182. pdev->fp_ctrl_filter = filter_val->fp_ctrl;
  4183. pdev->fp_data_filter = filter_val->fp_data;
  4184. pdev->mo_mgmt_filter = filter_val->mo_mgmt;
  4185. pdev->mo_ctrl_filter = filter_val->mo_ctrl;
  4186. pdev->mo_data_filter = filter_val->mo_data;
  4187. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_HIGH,
  4188. "MODE[%x] FP[%02x|%02x|%02x] MO[%02x|%02x|%02x]\n",
  4189. pdev->mon_filter_mode, pdev->fp_mgmt_filter,
  4190. pdev->fp_ctrl_filter, pdev->fp_data_filter,
  4191. pdev->mo_mgmt_filter, pdev->mo_ctrl_filter,
  4192. pdev->mo_data_filter);
  4193. qdf_mem_set(&(htt_tlv_filter), sizeof(htt_tlv_filter), 0x0);
  4194. for (mac_id = 0; mac_id < NUM_RXDMA_RINGS_PER_PDEV; mac_id++) {
  4195. int mac_for_pdev = dp_get_mac_id_for_pdev(mac_id, pdev_id);
  4196. htt_h2t_rx_ring_cfg(soc->htt_handle, mac_for_pdev,
  4197. pdev->rxdma_mon_buf_ring[mac_id].hal_srng,
  4198. RXDMA_MONITOR_BUF, RX_BUFFER_SIZE, &htt_tlv_filter);
  4199. htt_h2t_rx_ring_cfg(soc->htt_handle, mac_for_pdev,
  4200. pdev->rxdma_mon_status_ring[mac_id].hal_srng,
  4201. RXDMA_MONITOR_STATUS, RX_BUFFER_SIZE, &htt_tlv_filter);
  4202. }
  4203. htt_tlv_filter.mpdu_start = 1;
  4204. htt_tlv_filter.msdu_start = 1;
  4205. htt_tlv_filter.packet = 1;
  4206. htt_tlv_filter.msdu_end = 1;
  4207. htt_tlv_filter.mpdu_end = 1;
  4208. htt_tlv_filter.packet_header = 1;
  4209. htt_tlv_filter.attention = 1;
  4210. htt_tlv_filter.ppdu_start = 0;
  4211. htt_tlv_filter.ppdu_end = 0;
  4212. htt_tlv_filter.ppdu_end_user_stats = 0;
  4213. htt_tlv_filter.ppdu_end_user_stats_ext = 0;
  4214. htt_tlv_filter.ppdu_end_status_done = 0;
  4215. htt_tlv_filter.header_per_msdu = 1;
  4216. htt_tlv_filter.enable_fp =
  4217. (pdev->mon_filter_mode & MON_FILTER_PASS) ? 1 : 0;
  4218. htt_tlv_filter.enable_md = 0;
  4219. htt_tlv_filter.enable_mo =
  4220. (pdev->mon_filter_mode & MON_FILTER_OTHER) ? 1 : 0;
  4221. htt_tlv_filter.fp_mgmt_filter = pdev->fp_mgmt_filter;
  4222. htt_tlv_filter.fp_ctrl_filter = pdev->fp_ctrl_filter;
  4223. htt_tlv_filter.fp_data_filter = pdev->fp_data_filter;
  4224. htt_tlv_filter.mo_mgmt_filter = pdev->mo_mgmt_filter;
  4225. htt_tlv_filter.mo_ctrl_filter = pdev->mo_ctrl_filter;
  4226. htt_tlv_filter.mo_data_filter = pdev->mo_data_filter;
  4227. for (mac_id = 0; mac_id < NUM_RXDMA_RINGS_PER_PDEV; mac_id++) {
  4228. int mac_for_pdev = dp_get_mac_id_for_pdev(mac_id, pdev_id);
  4229. htt_h2t_rx_ring_cfg(soc->htt_handle, mac_for_pdev,
  4230. pdev->rxdma_mon_buf_ring[mac_id].hal_srng,
  4231. RXDMA_MONITOR_BUF, RX_BUFFER_SIZE, &htt_tlv_filter);
  4232. }
  4233. qdf_mem_set(&(htt_tlv_filter), sizeof(htt_tlv_filter), 0x0);
  4234. htt_tlv_filter.mpdu_start = 1;
  4235. htt_tlv_filter.msdu_start = 0;
  4236. htt_tlv_filter.packet = 0;
  4237. htt_tlv_filter.msdu_end = 0;
  4238. htt_tlv_filter.mpdu_end = 0;
  4239. htt_tlv_filter.attention = 0;
  4240. htt_tlv_filter.ppdu_start = 1;
  4241. htt_tlv_filter.ppdu_end = 1;
  4242. htt_tlv_filter.ppdu_end_user_stats = 1;
  4243. htt_tlv_filter.ppdu_end_user_stats_ext = 1;
  4244. htt_tlv_filter.ppdu_end_status_done = 1;
  4245. htt_tlv_filter.enable_fp = 1;
  4246. htt_tlv_filter.enable_md = 0;
  4247. htt_tlv_filter.enable_mo = 1;
  4248. if (pdev->mcopy_mode) {
  4249. htt_tlv_filter.packet_header = 1;
  4250. }
  4251. htt_tlv_filter.fp_mgmt_filter = FILTER_MGMT_ALL;
  4252. htt_tlv_filter.fp_ctrl_filter = FILTER_CTRL_ALL;
  4253. htt_tlv_filter.fp_data_filter = FILTER_DATA_ALL;
  4254. htt_tlv_filter.mo_mgmt_filter = FILTER_MGMT_ALL;
  4255. htt_tlv_filter.mo_ctrl_filter = FILTER_CTRL_ALL;
  4256. htt_tlv_filter.mo_data_filter = FILTER_DATA_ALL;
  4257. for (mac_id = 0; mac_id < NUM_RXDMA_RINGS_PER_PDEV; mac_id++) {
  4258. int mac_for_pdev = dp_get_mac_id_for_pdev(mac_id,
  4259. pdev->pdev_id);
  4260. htt_h2t_rx_ring_cfg(soc->htt_handle, mac_for_pdev,
  4261. pdev->rxdma_mon_status_ring[mac_id].hal_srng,
  4262. RXDMA_MONITOR_STATUS, RX_BUFFER_SIZE, &htt_tlv_filter);
  4263. }
  4264. return QDF_STATUS_SUCCESS;
  4265. }
  4266. /**
  4267. * dp_get_pdev_id_frm_pdev() - get pdev_id
  4268. * @pdev_handle: Datapath PDEV handle
  4269. *
  4270. * Return: pdev_id
  4271. */
  4272. static
  4273. uint8_t dp_get_pdev_id_frm_pdev(struct cdp_pdev *pdev_handle)
  4274. {
  4275. struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
  4276. return pdev->pdev_id;
  4277. }
  4278. /**
  4279. * dp_vdev_get_filter_ucast_data() - get DP VDEV monitor ucast filter
  4280. * @vdev_handle: Datapath VDEV handle
  4281. * Return: true on ucast filter flag set
  4282. */
  4283. static bool dp_vdev_get_filter_ucast_data(struct cdp_vdev *vdev_handle)
  4284. {
  4285. struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle;
  4286. struct dp_pdev *pdev;
  4287. pdev = vdev->pdev;
  4288. if ((pdev->fp_data_filter & FILTER_DATA_UCAST) ||
  4289. (pdev->mo_data_filter & FILTER_DATA_UCAST))
  4290. return true;
  4291. return false;
  4292. }
  4293. /**
  4294. * dp_vdev_get_filter_mcast_data() - get DP VDEV monitor mcast filter
  4295. * @vdev_handle: Datapath VDEV handle
  4296. * Return: true on mcast filter flag set
  4297. */
  4298. static bool dp_vdev_get_filter_mcast_data(struct cdp_vdev *vdev_handle)
  4299. {
  4300. struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle;
  4301. struct dp_pdev *pdev;
  4302. pdev = vdev->pdev;
  4303. if ((pdev->fp_data_filter & FILTER_DATA_MCAST) ||
  4304. (pdev->mo_data_filter & FILTER_DATA_MCAST))
  4305. return true;
  4306. return false;
  4307. }
  4308. /**
  4309. * dp_vdev_get_filter_non_data() - get DP VDEV monitor non_data filter
  4310. * @vdev_handle: Datapath VDEV handle
  4311. * Return: true on non data filter flag set
  4312. */
  4313. static bool dp_vdev_get_filter_non_data(struct cdp_vdev *vdev_handle)
  4314. {
  4315. struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle;
  4316. struct dp_pdev *pdev;
  4317. pdev = vdev->pdev;
  4318. if ((pdev->fp_mgmt_filter & FILTER_MGMT_ALL) ||
  4319. (pdev->mo_mgmt_filter & FILTER_MGMT_ALL)) {
  4320. if ((pdev->fp_ctrl_filter & FILTER_CTRL_ALL) ||
  4321. (pdev->mo_ctrl_filter & FILTER_CTRL_ALL)) {
  4322. return true;
  4323. }
  4324. }
  4325. return false;
  4326. }
  4327. #ifdef MESH_MODE_SUPPORT
  4328. void dp_peer_set_mesh_mode(struct cdp_vdev *vdev_hdl, uint32_t val)
  4329. {
  4330. struct dp_vdev *vdev = (struct dp_vdev *)vdev_hdl;
  4331. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  4332. FL("val %d"), val);
  4333. vdev->mesh_vdev = val;
  4334. }
  4335. /*
  4336. * dp_peer_set_mesh_rx_filter() - to set the mesh rx filter
  4337. * @vdev_hdl: virtual device object
  4338. * @val: value to be set
  4339. *
  4340. * Return: void
  4341. */
  4342. void dp_peer_set_mesh_rx_filter(struct cdp_vdev *vdev_hdl, uint32_t val)
  4343. {
  4344. struct dp_vdev *vdev = (struct dp_vdev *)vdev_hdl;
  4345. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  4346. FL("val %d"), val);
  4347. vdev->mesh_rx_filter = val;
  4348. }
  4349. #endif
  4350. /*
  4351. * dp_aggregate_pdev_ctrl_frames_stats()- function to agreegate peer stats
  4352. * Current scope is bar received count
  4353. *
  4354. * @pdev_handle: DP_PDEV handle
  4355. *
  4356. * Return: void
  4357. */
  4358. #define STATS_PROC_TIMEOUT (HZ/1000)
  4359. static void
  4360. dp_aggregate_pdev_ctrl_frames_stats(struct dp_pdev *pdev)
  4361. {
  4362. struct dp_vdev *vdev;
  4363. struct dp_peer *peer;
  4364. uint32_t waitcnt;
  4365. TAILQ_FOREACH(vdev, &pdev->vdev_list, vdev_list_elem) {
  4366. TAILQ_FOREACH(peer, &vdev->peer_list, peer_list_elem) {
  4367. if (!peer) {
  4368. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  4369. FL("DP Invalid Peer refernce"));
  4370. return;
  4371. }
  4372. if (peer->delete_in_progress) {
  4373. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  4374. FL("DP Peer deletion in progress"));
  4375. continue;
  4376. }
  4377. qdf_atomic_inc(&peer->ref_cnt);
  4378. waitcnt = 0;
  4379. dp_peer_rxtid_stats(peer, dp_rx_bar_stats_cb, pdev);
  4380. while (!(qdf_atomic_read(&(pdev->stats_cmd_complete)))
  4381. && waitcnt < 10) {
  4382. schedule_timeout_interruptible(
  4383. STATS_PROC_TIMEOUT);
  4384. waitcnt++;
  4385. }
  4386. qdf_atomic_set(&(pdev->stats_cmd_complete), 0);
  4387. dp_peer_unref_delete(peer);
  4388. }
  4389. }
  4390. }
  4391. /**
  4392. * dp_rx_bar_stats_cb(): BAR received stats callback
  4393. * @soc: SOC handle
  4394. * @cb_ctxt: Call back context
  4395. * @reo_status: Reo status
  4396. *
  4397. * return: void
  4398. */
  4399. void dp_rx_bar_stats_cb(struct dp_soc *soc, void *cb_ctxt,
  4400. union hal_reo_status *reo_status)
  4401. {
  4402. struct dp_pdev *pdev = (struct dp_pdev *)cb_ctxt;
  4403. struct hal_reo_queue_status *queue_status = &(reo_status->queue_status);
  4404. if (queue_status->header.status != HAL_REO_CMD_SUCCESS) {
  4405. DP_TRACE_STATS(FATAL, "REO stats failure %d \n",
  4406. queue_status->header.status);
  4407. qdf_atomic_set(&(pdev->stats_cmd_complete), 1);
  4408. return;
  4409. }
  4410. pdev->stats.rx.bar_recv_cnt += queue_status->bar_rcvd_cnt;
  4411. qdf_atomic_set(&(pdev->stats_cmd_complete), 1);
  4412. }
  4413. /**
  4414. * dp_aggregate_vdev_stats(): Consolidate stats at VDEV level
  4415. * @vdev: DP VDEV handle
  4416. *
  4417. * return: void
  4418. */
  4419. void dp_aggregate_vdev_stats(struct dp_vdev *vdev)
  4420. {
  4421. struct dp_peer *peer = NULL;
  4422. struct dp_soc *soc = vdev->pdev->soc;
  4423. qdf_mem_set(&(vdev->stats.tx), sizeof(vdev->stats.tx), 0x0);
  4424. qdf_mem_set(&(vdev->stats.rx), sizeof(vdev->stats.rx), 0x0);
  4425. TAILQ_FOREACH(peer, &vdev->peer_list, peer_list_elem)
  4426. DP_UPDATE_STATS(vdev, peer);
  4427. if (soc->cdp_soc.ol_ops->update_dp_stats)
  4428. soc->cdp_soc.ol_ops->update_dp_stats(vdev->pdev->ctrl_pdev,
  4429. &vdev->stats, (uint16_t) vdev->vdev_id,
  4430. UPDATE_VDEV_STATS);
  4431. }
  4432. /**
  4433. * dp_aggregate_pdev_stats(): Consolidate stats at PDEV level
  4434. * @pdev: DP PDEV handle
  4435. *
  4436. * return: void
  4437. */
  4438. static inline void dp_aggregate_pdev_stats(struct dp_pdev *pdev)
  4439. {
  4440. struct dp_vdev *vdev = NULL;
  4441. struct dp_soc *soc = pdev->soc;
  4442. qdf_mem_set(&(pdev->stats.tx), sizeof(pdev->stats.tx), 0x0);
  4443. qdf_mem_set(&(pdev->stats.rx), sizeof(pdev->stats.rx), 0x0);
  4444. qdf_mem_set(&(pdev->stats.tx_i), sizeof(pdev->stats.tx_i), 0x0);
  4445. qdf_spin_lock_bh(&pdev->vdev_list_lock);
  4446. TAILQ_FOREACH(vdev, &pdev->vdev_list, vdev_list_elem) {
  4447. dp_aggregate_vdev_stats(vdev);
  4448. DP_UPDATE_STATS(pdev, vdev);
  4449. DP_STATS_AGGR_PKT(pdev, vdev, tx_i.nawds_mcast);
  4450. DP_STATS_AGGR_PKT(pdev, vdev, tx_i.rcvd);
  4451. DP_STATS_AGGR_PKT(pdev, vdev, tx_i.processed);
  4452. DP_STATS_AGGR_PKT(pdev, vdev, tx_i.reinject_pkts);
  4453. DP_STATS_AGGR_PKT(pdev, vdev, tx_i.inspect_pkts);
  4454. DP_STATS_AGGR_PKT(pdev, vdev, tx_i.raw.raw_pkt);
  4455. DP_STATS_AGGR(pdev, vdev, tx_i.raw.dma_map_error);
  4456. DP_STATS_AGGR_PKT(pdev, vdev, tx_i.tso.tso_pkt);
  4457. DP_STATS_AGGR(pdev, vdev, tx_i.tso.dropped_host.num);
  4458. DP_STATS_AGGR(pdev, vdev, tx_i.tso.dropped_target);
  4459. DP_STATS_AGGR(pdev, vdev, tx_i.sg.dropped_host.num);
  4460. DP_STATS_AGGR(pdev, vdev, tx_i.sg.dropped_target);
  4461. DP_STATS_AGGR_PKT(pdev, vdev, tx_i.sg.sg_pkt);
  4462. DP_STATS_AGGR_PKT(pdev, vdev, tx_i.mcast_en.mcast_pkt);
  4463. DP_STATS_AGGR(pdev, vdev,
  4464. tx_i.mcast_en.dropped_map_error);
  4465. DP_STATS_AGGR(pdev, vdev,
  4466. tx_i.mcast_en.dropped_self_mac);
  4467. DP_STATS_AGGR(pdev, vdev,
  4468. tx_i.mcast_en.dropped_send_fail);
  4469. DP_STATS_AGGR(pdev, vdev, tx_i.mcast_en.ucast);
  4470. DP_STATS_AGGR(pdev, vdev, tx_i.dropped.dma_error);
  4471. DP_STATS_AGGR(pdev, vdev, tx_i.dropped.ring_full);
  4472. DP_STATS_AGGR(pdev, vdev, tx_i.dropped.enqueue_fail);
  4473. DP_STATS_AGGR(pdev, vdev, tx_i.dropped.desc_na.num);
  4474. DP_STATS_AGGR(pdev, vdev, tx_i.dropped.res_full);
  4475. DP_STATS_AGGR(pdev, vdev, tx_i.cce_classified);
  4476. DP_STATS_AGGR(pdev, vdev, tx_i.cce_classified_raw);
  4477. DP_STATS_AGGR(pdev, vdev, tx_i.mesh.exception_fw);
  4478. DP_STATS_AGGR(pdev, vdev, tx_i.mesh.completion_fw);
  4479. pdev->stats.tx_i.dropped.dropped_pkt.num =
  4480. pdev->stats.tx_i.dropped.dma_error +
  4481. pdev->stats.tx_i.dropped.ring_full +
  4482. pdev->stats.tx_i.dropped.enqueue_fail +
  4483. pdev->stats.tx_i.dropped.desc_na.num +
  4484. pdev->stats.tx_i.dropped.res_full;
  4485. pdev->stats.tx.last_ack_rssi =
  4486. vdev->stats.tx.last_ack_rssi;
  4487. pdev->stats.tx_i.tso.num_seg =
  4488. vdev->stats.tx_i.tso.num_seg;
  4489. }
  4490. qdf_spin_unlock_bh(&pdev->vdev_list_lock);
  4491. if (soc->cdp_soc.ol_ops->update_dp_stats)
  4492. soc->cdp_soc.ol_ops->update_dp_stats(pdev->ctrl_pdev,
  4493. &pdev->stats, pdev->pdev_id, UPDATE_PDEV_STATS);
  4494. }
  4495. /**
  4496. * dp_vdev_getstats() - get vdev packet level stats
  4497. * @vdev_handle: Datapath VDEV handle
  4498. * @stats: cdp network device stats structure
  4499. *
  4500. * Return: void
  4501. */
  4502. static void dp_vdev_getstats(void *vdev_handle,
  4503. struct cdp_dev_stats *stats)
  4504. {
  4505. struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle;
  4506. dp_aggregate_vdev_stats(vdev);
  4507. }
  4508. /**
  4509. * dp_pdev_getstats() - get pdev packet level stats
  4510. * @pdev_handle: Datapath PDEV handle
  4511. * @stats: cdp network device stats structure
  4512. *
  4513. * Return: void
  4514. */
  4515. static void dp_pdev_getstats(void *pdev_handle,
  4516. struct cdp_dev_stats *stats)
  4517. {
  4518. struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
  4519. dp_aggregate_pdev_stats(pdev);
  4520. stats->tx_packets = pdev->stats.tx_i.rcvd.num;
  4521. stats->tx_bytes = pdev->stats.tx_i.rcvd.bytes;
  4522. stats->tx_errors = pdev->stats.tx.tx_failed +
  4523. pdev->stats.tx_i.dropped.dropped_pkt.num;
  4524. stats->tx_dropped = stats->tx_errors;
  4525. stats->rx_packets = pdev->stats.rx.unicast.num +
  4526. pdev->stats.rx.multicast.num +
  4527. pdev->stats.rx.bcast.num;
  4528. stats->rx_bytes = pdev->stats.rx.unicast.bytes +
  4529. pdev->stats.rx.multicast.bytes +
  4530. pdev->stats.rx.bcast.bytes;
  4531. }
  4532. /**
  4533. * dp_get_device_stats() - get interface level packet stats
  4534. * @handle: device handle
  4535. * @stats: cdp network device stats structure
  4536. * @type: device type pdev/vdev
  4537. *
  4538. * Return: void
  4539. */
  4540. static void dp_get_device_stats(void *handle,
  4541. struct cdp_dev_stats *stats, uint8_t type)
  4542. {
  4543. switch (type) {
  4544. case UPDATE_VDEV_STATS:
  4545. dp_vdev_getstats(handle, stats);
  4546. break;
  4547. case UPDATE_PDEV_STATS:
  4548. dp_pdev_getstats(handle, stats);
  4549. break;
  4550. default:
  4551. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  4552. "apstats cannot be updated for this input "
  4553. "type %d\n", type);
  4554. break;
  4555. }
  4556. }
  4557. /**
  4558. * dp_print_pdev_tx_stats(): Print Pdev level TX stats
  4559. * @pdev: DP_PDEV Handle
  4560. *
  4561. * Return:void
  4562. */
  4563. static inline void
  4564. dp_print_pdev_tx_stats(struct dp_pdev *pdev)
  4565. {
  4566. uint8_t index = 0;
  4567. DP_PRINT_STATS("PDEV Tx Stats:\n");
  4568. DP_PRINT_STATS("Received From Stack:");
  4569. DP_PRINT_STATS(" Packets = %d",
  4570. pdev->stats.tx_i.rcvd.num);
  4571. DP_PRINT_STATS(" Bytes = %llu",
  4572. pdev->stats.tx_i.rcvd.bytes);
  4573. DP_PRINT_STATS("Processed:");
  4574. DP_PRINT_STATS(" Packets = %d",
  4575. pdev->stats.tx_i.processed.num);
  4576. DP_PRINT_STATS(" Bytes = %llu",
  4577. pdev->stats.tx_i.processed.bytes);
  4578. DP_PRINT_STATS("Total Completions:");
  4579. DP_PRINT_STATS(" Packets = %u",
  4580. pdev->stats.tx.comp_pkt.num);
  4581. DP_PRINT_STATS(" Bytes = %llu",
  4582. pdev->stats.tx.comp_pkt.bytes);
  4583. DP_PRINT_STATS("Successful Completions:");
  4584. DP_PRINT_STATS(" Packets = %u",
  4585. pdev->stats.tx.tx_success.num);
  4586. DP_PRINT_STATS(" Bytes = %llu",
  4587. pdev->stats.tx.tx_success.bytes);
  4588. DP_PRINT_STATS("Dropped:");
  4589. DP_PRINT_STATS(" Total = %d",
  4590. pdev->stats.tx_i.dropped.dropped_pkt.num);
  4591. DP_PRINT_STATS(" Dma_map_error = %d",
  4592. pdev->stats.tx_i.dropped.dma_error);
  4593. DP_PRINT_STATS(" Ring Full = %d",
  4594. pdev->stats.tx_i.dropped.ring_full);
  4595. DP_PRINT_STATS(" Descriptor Not available = %d",
  4596. pdev->stats.tx_i.dropped.desc_na.num);
  4597. DP_PRINT_STATS(" HW enqueue failed= %d",
  4598. pdev->stats.tx_i.dropped.enqueue_fail);
  4599. DP_PRINT_STATS(" Resources Full = %d",
  4600. pdev->stats.tx_i.dropped.res_full);
  4601. DP_PRINT_STATS(" FW removed = %d",
  4602. pdev->stats.tx.dropped.fw_rem);
  4603. DP_PRINT_STATS(" FW removed transmitted = %d",
  4604. pdev->stats.tx.dropped.fw_rem_tx);
  4605. DP_PRINT_STATS(" FW removed untransmitted = %d",
  4606. pdev->stats.tx.dropped.fw_rem_notx);
  4607. DP_PRINT_STATS(" FW removed untransmitted fw_reason1 = %d",
  4608. pdev->stats.tx.dropped.fw_reason1);
  4609. DP_PRINT_STATS(" FW removed untransmitted fw_reason2 = %d",
  4610. pdev->stats.tx.dropped.fw_reason2);
  4611. DP_PRINT_STATS(" FW removed untransmitted fw_reason3 = %d",
  4612. pdev->stats.tx.dropped.fw_reason3);
  4613. DP_PRINT_STATS(" Aged Out from msdu/mpdu queues = %d",
  4614. pdev->stats.tx.dropped.age_out);
  4615. DP_PRINT_STATS(" Multicast:");
  4616. DP_PRINT_STATS(" Packets: %u",
  4617. pdev->stats.tx.mcast.num);
  4618. DP_PRINT_STATS(" Bytes: %llu",
  4619. pdev->stats.tx.mcast.bytes);
  4620. DP_PRINT_STATS("Scatter Gather:");
  4621. DP_PRINT_STATS(" Packets = %d",
  4622. pdev->stats.tx_i.sg.sg_pkt.num);
  4623. DP_PRINT_STATS(" Bytes = %llu",
  4624. pdev->stats.tx_i.sg.sg_pkt.bytes);
  4625. DP_PRINT_STATS(" Dropped By Host = %d",
  4626. pdev->stats.tx_i.sg.dropped_host.num);
  4627. DP_PRINT_STATS(" Dropped By Target = %d",
  4628. pdev->stats.tx_i.sg.dropped_target);
  4629. DP_PRINT_STATS("TSO:");
  4630. DP_PRINT_STATS(" Number of Segments = %d",
  4631. pdev->stats.tx_i.tso.num_seg);
  4632. DP_PRINT_STATS(" Packets = %d",
  4633. pdev->stats.tx_i.tso.tso_pkt.num);
  4634. DP_PRINT_STATS(" Bytes = %llu",
  4635. pdev->stats.tx_i.tso.tso_pkt.bytes);
  4636. DP_PRINT_STATS(" Dropped By Host = %d",
  4637. pdev->stats.tx_i.tso.dropped_host.num);
  4638. DP_PRINT_STATS("Mcast Enhancement:");
  4639. DP_PRINT_STATS(" Packets = %d",
  4640. pdev->stats.tx_i.mcast_en.mcast_pkt.num);
  4641. DP_PRINT_STATS(" Bytes = %llu",
  4642. pdev->stats.tx_i.mcast_en.mcast_pkt.bytes);
  4643. DP_PRINT_STATS(" Dropped: Map Errors = %d",
  4644. pdev->stats.tx_i.mcast_en.dropped_map_error);
  4645. DP_PRINT_STATS(" Dropped: Self Mac = %d",
  4646. pdev->stats.tx_i.mcast_en.dropped_self_mac);
  4647. DP_PRINT_STATS(" Dropped: Send Fail = %d",
  4648. pdev->stats.tx_i.mcast_en.dropped_send_fail);
  4649. DP_PRINT_STATS(" Unicast sent = %d",
  4650. pdev->stats.tx_i.mcast_en.ucast);
  4651. DP_PRINT_STATS("Raw:");
  4652. DP_PRINT_STATS(" Packets = %d",
  4653. pdev->stats.tx_i.raw.raw_pkt.num);
  4654. DP_PRINT_STATS(" Bytes = %llu",
  4655. pdev->stats.tx_i.raw.raw_pkt.bytes);
  4656. DP_PRINT_STATS(" DMA map error = %d",
  4657. pdev->stats.tx_i.raw.dma_map_error);
  4658. DP_PRINT_STATS("Reinjected:");
  4659. DP_PRINT_STATS(" Packets = %d",
  4660. pdev->stats.tx_i.reinject_pkts.num);
  4661. DP_PRINT_STATS(" Bytes = %llu\n",
  4662. pdev->stats.tx_i.reinject_pkts.bytes);
  4663. DP_PRINT_STATS("Inspected:");
  4664. DP_PRINT_STATS(" Packets = %d",
  4665. pdev->stats.tx_i.inspect_pkts.num);
  4666. DP_PRINT_STATS(" Bytes = %llu",
  4667. pdev->stats.tx_i.inspect_pkts.bytes);
  4668. DP_PRINT_STATS("Nawds Multicast:");
  4669. DP_PRINT_STATS(" Packets = %d",
  4670. pdev->stats.tx_i.nawds_mcast.num);
  4671. DP_PRINT_STATS(" Bytes = %llu",
  4672. pdev->stats.tx_i.nawds_mcast.bytes);
  4673. DP_PRINT_STATS("CCE Classified:");
  4674. DP_PRINT_STATS(" CCE Classified Packets: %u",
  4675. pdev->stats.tx_i.cce_classified);
  4676. DP_PRINT_STATS(" RAW CCE Classified Packets: %u",
  4677. pdev->stats.tx_i.cce_classified_raw);
  4678. DP_PRINT_STATS("Mesh stats:");
  4679. DP_PRINT_STATS(" frames to firmware: %u",
  4680. pdev->stats.tx_i.mesh.exception_fw);
  4681. DP_PRINT_STATS(" completions from fw: %u",
  4682. pdev->stats.tx_i.mesh.completion_fw);
  4683. DP_PRINT_STATS("PPDU stats counter");
  4684. for (index = 0; index < CDP_PPDU_STATS_MAX_TAG; index++) {
  4685. DP_PRINT_STATS(" Tag[%d] = %llu", index,
  4686. pdev->stats.ppdu_stats_counter[index]);
  4687. }
  4688. }
  4689. /**
  4690. * dp_print_pdev_rx_stats(): Print Pdev level RX stats
  4691. * @pdev: DP_PDEV Handle
  4692. *
  4693. * Return: void
  4694. */
  4695. static inline void
  4696. dp_print_pdev_rx_stats(struct dp_pdev *pdev)
  4697. {
  4698. DP_PRINT_STATS("PDEV Rx Stats:\n");
  4699. DP_PRINT_STATS("Received From HW (Per Rx Ring):");
  4700. DP_PRINT_STATS(" Packets = %d %d %d %d",
  4701. pdev->stats.rx.rcvd_reo[0].num,
  4702. pdev->stats.rx.rcvd_reo[1].num,
  4703. pdev->stats.rx.rcvd_reo[2].num,
  4704. pdev->stats.rx.rcvd_reo[3].num);
  4705. DP_PRINT_STATS(" Bytes = %llu %llu %llu %llu",
  4706. pdev->stats.rx.rcvd_reo[0].bytes,
  4707. pdev->stats.rx.rcvd_reo[1].bytes,
  4708. pdev->stats.rx.rcvd_reo[2].bytes,
  4709. pdev->stats.rx.rcvd_reo[3].bytes);
  4710. DP_PRINT_STATS("Replenished:");
  4711. DP_PRINT_STATS(" Packets = %d",
  4712. pdev->stats.replenish.pkts.num);
  4713. DP_PRINT_STATS(" Bytes = %llu",
  4714. pdev->stats.replenish.pkts.bytes);
  4715. DP_PRINT_STATS(" Buffers Added To Freelist = %d",
  4716. pdev->stats.buf_freelist);
  4717. DP_PRINT_STATS(" Low threshold intr = %d",
  4718. pdev->stats.replenish.low_thresh_intrs);
  4719. DP_PRINT_STATS("Dropped:");
  4720. DP_PRINT_STATS(" msdu_not_done = %d",
  4721. pdev->stats.dropped.msdu_not_done);
  4722. DP_PRINT_STATS(" mon_rx_drop = %d",
  4723. pdev->stats.dropped.mon_rx_drop);
  4724. DP_PRINT_STATS("Sent To Stack:");
  4725. DP_PRINT_STATS(" Packets = %d",
  4726. pdev->stats.rx.to_stack.num);
  4727. DP_PRINT_STATS(" Bytes = %llu",
  4728. pdev->stats.rx.to_stack.bytes);
  4729. DP_PRINT_STATS("Multicast/Broadcast:");
  4730. DP_PRINT_STATS(" Packets = %d",
  4731. (pdev->stats.rx.multicast.num +
  4732. pdev->stats.rx.bcast.num));
  4733. DP_PRINT_STATS(" Bytes = %llu",
  4734. (pdev->stats.rx.multicast.bytes +
  4735. pdev->stats.rx.bcast.bytes));
  4736. DP_PRINT_STATS("Errors:");
  4737. DP_PRINT_STATS(" Rxdma Ring Un-inititalized = %d",
  4738. pdev->stats.replenish.rxdma_err);
  4739. DP_PRINT_STATS(" Desc Alloc Failed: = %d",
  4740. pdev->stats.err.desc_alloc_fail);
  4741. DP_PRINT_STATS(" IP checksum error = %d",
  4742. pdev->stats.err.ip_csum_err);
  4743. DP_PRINT_STATS(" TCP/UDP checksum error = %d",
  4744. pdev->stats.err.tcp_udp_csum_err);
  4745. /* Get bar_recv_cnt */
  4746. dp_aggregate_pdev_ctrl_frames_stats(pdev);
  4747. DP_PRINT_STATS("BAR Received Count: = %d",
  4748. pdev->stats.rx.bar_recv_cnt);
  4749. }
  4750. /**
  4751. * dp_print_pdev_rx_mon_stats(): Print Pdev level RX monitor stats
  4752. * @pdev: DP_PDEV Handle
  4753. *
  4754. * Return: void
  4755. */
  4756. static inline void
  4757. dp_print_pdev_rx_mon_stats(struct dp_pdev *pdev)
  4758. {
  4759. struct cdp_pdev_mon_stats *rx_mon_stats;
  4760. rx_mon_stats = &pdev->rx_mon_stats;
  4761. DP_PRINT_STATS("PDEV Rx Monitor Stats:\n");
  4762. dp_rx_mon_print_dbg_ppdu_stats(rx_mon_stats);
  4763. DP_PRINT_STATS("status_ppdu_done_cnt = %d",
  4764. rx_mon_stats->status_ppdu_done);
  4765. DP_PRINT_STATS("dest_ppdu_done_cnt = %d",
  4766. rx_mon_stats->dest_ppdu_done);
  4767. DP_PRINT_STATS("dest_mpdu_done_cnt = %d",
  4768. rx_mon_stats->dest_mpdu_done);
  4769. DP_PRINT_STATS("dest_mpdu_drop_cnt = %d",
  4770. rx_mon_stats->dest_mpdu_drop);
  4771. }
  4772. /**
  4773. * dp_print_soc_tx_stats(): Print SOC level stats
  4774. * @soc DP_SOC Handle
  4775. *
  4776. * Return: void
  4777. */
  4778. static inline void
  4779. dp_print_soc_tx_stats(struct dp_soc *soc)
  4780. {
  4781. uint8_t desc_pool_id;
  4782. soc->stats.tx.desc_in_use = 0;
  4783. DP_PRINT_STATS("SOC Tx Stats:\n");
  4784. for (desc_pool_id = 0;
  4785. desc_pool_id < wlan_cfg_get_num_tx_desc_pool(soc->wlan_cfg_ctx);
  4786. desc_pool_id++)
  4787. soc->stats.tx.desc_in_use +=
  4788. soc->tx_desc[desc_pool_id].num_allocated;
  4789. DP_PRINT_STATS("Tx Descriptors In Use = %d",
  4790. soc->stats.tx.desc_in_use);
  4791. DP_PRINT_STATS("Invalid peer:");
  4792. DP_PRINT_STATS(" Packets = %d",
  4793. soc->stats.tx.tx_invalid_peer.num);
  4794. DP_PRINT_STATS(" Bytes = %llu",
  4795. soc->stats.tx.tx_invalid_peer.bytes);
  4796. DP_PRINT_STATS("Packets dropped due to TCL ring full = %d %d %d",
  4797. soc->stats.tx.tcl_ring_full[0],
  4798. soc->stats.tx.tcl_ring_full[1],
  4799. soc->stats.tx.tcl_ring_full[2]);
  4800. }
  4801. /**
  4802. * dp_print_soc_rx_stats: Print SOC level Rx stats
  4803. * @soc: DP_SOC Handle
  4804. *
  4805. * Return:void
  4806. */
  4807. static inline void
  4808. dp_print_soc_rx_stats(struct dp_soc *soc)
  4809. {
  4810. uint32_t i;
  4811. char reo_error[DP_REO_ERR_LENGTH];
  4812. char rxdma_error[DP_RXDMA_ERR_LENGTH];
  4813. uint8_t index = 0;
  4814. DP_PRINT_STATS("SOC Rx Stats:\n");
  4815. DP_PRINT_STATS("Errors:\n");
  4816. DP_PRINT_STATS("Rx Decrypt Errors = %d",
  4817. (soc->stats.rx.err.rxdma_error[HAL_RXDMA_ERR_DECRYPT] +
  4818. soc->stats.rx.err.rxdma_error[HAL_RXDMA_ERR_TKIP_MIC]));
  4819. DP_PRINT_STATS("Invalid RBM = %d",
  4820. soc->stats.rx.err.invalid_rbm);
  4821. DP_PRINT_STATS("Invalid Vdev = %d",
  4822. soc->stats.rx.err.invalid_vdev);
  4823. DP_PRINT_STATS("Invalid Pdev = %d",
  4824. soc->stats.rx.err.invalid_pdev);
  4825. DP_PRINT_STATS("Invalid Peer = %d",
  4826. soc->stats.rx.err.rx_invalid_peer.num);
  4827. DP_PRINT_STATS("HAL Ring Access Fail = %d",
  4828. soc->stats.rx.err.hal_ring_access_fail);
  4829. for (i = 0; i < HAL_RXDMA_ERR_MAX; i++) {
  4830. index += qdf_snprint(&rxdma_error[index],
  4831. DP_RXDMA_ERR_LENGTH - index,
  4832. " %d", soc->stats.rx.err.rxdma_error[i]);
  4833. }
  4834. DP_PRINT_STATS("RXDMA Error (0-31):%s",
  4835. rxdma_error);
  4836. index = 0;
  4837. for (i = 0; i < HAL_REO_ERR_MAX; i++) {
  4838. index += qdf_snprint(&reo_error[index],
  4839. DP_REO_ERR_LENGTH - index,
  4840. " %d", soc->stats.rx.err.reo_error[i]);
  4841. }
  4842. DP_PRINT_STATS("REO Error(0-14):%s",
  4843. reo_error);
  4844. }
  4845. /**
  4846. * dp_print_ring_stat_from_hal(): Print hal level ring stats
  4847. * @soc: DP_SOC handle
  4848. * @srng: DP_SRNG handle
  4849. * @ring_name: SRNG name
  4850. *
  4851. * Return: void
  4852. */
  4853. static inline void
  4854. dp_print_ring_stat_from_hal(struct dp_soc *soc, struct dp_srng *srng,
  4855. char *ring_name)
  4856. {
  4857. uint32_t tailp;
  4858. uint32_t headp;
  4859. if (srng->hal_srng != NULL) {
  4860. hal_api_get_tphp(soc->hal_soc, srng->hal_srng, &tailp, &headp);
  4861. DP_PRINT_STATS("%s : Head pointer = %d Tail Pointer = %d\n",
  4862. ring_name, headp, tailp);
  4863. }
  4864. }
  4865. /**
  4866. * dp_print_ring_stats(): Print tail and head pointer
  4867. * @pdev: DP_PDEV handle
  4868. *
  4869. * Return:void
  4870. */
  4871. static inline void
  4872. dp_print_ring_stats(struct dp_pdev *pdev)
  4873. {
  4874. uint32_t i;
  4875. char ring_name[STR_MAXLEN + 1];
  4876. int mac_id;
  4877. dp_print_ring_stat_from_hal(pdev->soc,
  4878. &pdev->soc->reo_exception_ring,
  4879. "Reo Exception Ring");
  4880. dp_print_ring_stat_from_hal(pdev->soc,
  4881. &pdev->soc->reo_reinject_ring,
  4882. "Reo Inject Ring");
  4883. dp_print_ring_stat_from_hal(pdev->soc,
  4884. &pdev->soc->reo_cmd_ring,
  4885. "Reo Command Ring");
  4886. dp_print_ring_stat_from_hal(pdev->soc,
  4887. &pdev->soc->reo_status_ring,
  4888. "Reo Status Ring");
  4889. dp_print_ring_stat_from_hal(pdev->soc,
  4890. &pdev->soc->rx_rel_ring,
  4891. "Rx Release ring");
  4892. dp_print_ring_stat_from_hal(pdev->soc,
  4893. &pdev->soc->tcl_cmd_ring,
  4894. "Tcl command Ring");
  4895. dp_print_ring_stat_from_hal(pdev->soc,
  4896. &pdev->soc->tcl_status_ring,
  4897. "Tcl Status Ring");
  4898. dp_print_ring_stat_from_hal(pdev->soc,
  4899. &pdev->soc->wbm_desc_rel_ring,
  4900. "Wbm Desc Rel Ring");
  4901. for (i = 0; i < MAX_REO_DEST_RINGS; i++) {
  4902. snprintf(ring_name, STR_MAXLEN, "Reo Dest Ring %d", i);
  4903. dp_print_ring_stat_from_hal(pdev->soc,
  4904. &pdev->soc->reo_dest_ring[i],
  4905. ring_name);
  4906. }
  4907. for (i = 0; i < pdev->soc->num_tcl_data_rings; i++) {
  4908. snprintf(ring_name, STR_MAXLEN, "Tcl Data Ring %d", i);
  4909. dp_print_ring_stat_from_hal(pdev->soc,
  4910. &pdev->soc->tcl_data_ring[i],
  4911. ring_name);
  4912. }
  4913. for (i = 0; i < MAX_TCL_DATA_RINGS; i++) {
  4914. snprintf(ring_name, STR_MAXLEN, "Tx Comp Ring %d", i);
  4915. dp_print_ring_stat_from_hal(pdev->soc,
  4916. &pdev->soc->tx_comp_ring[i],
  4917. ring_name);
  4918. }
  4919. dp_print_ring_stat_from_hal(pdev->soc,
  4920. &pdev->rx_refill_buf_ring,
  4921. "Rx Refill Buf Ring");
  4922. dp_print_ring_stat_from_hal(pdev->soc,
  4923. &pdev->rx_refill_buf_ring2,
  4924. "Second Rx Refill Buf Ring");
  4925. for (mac_id = 0; mac_id < NUM_RXDMA_RINGS_PER_PDEV; mac_id++) {
  4926. dp_print_ring_stat_from_hal(pdev->soc,
  4927. &pdev->rxdma_mon_buf_ring[mac_id],
  4928. "Rxdma Mon Buf Ring");
  4929. dp_print_ring_stat_from_hal(pdev->soc,
  4930. &pdev->rxdma_mon_dst_ring[mac_id],
  4931. "Rxdma Mon Dst Ring");
  4932. dp_print_ring_stat_from_hal(pdev->soc,
  4933. &pdev->rxdma_mon_status_ring[mac_id],
  4934. "Rxdma Mon Status Ring");
  4935. dp_print_ring_stat_from_hal(pdev->soc,
  4936. &pdev->rxdma_mon_desc_ring[mac_id],
  4937. "Rxdma mon desc Ring");
  4938. }
  4939. for (i = 0; i < NUM_RXDMA_RINGS_PER_PDEV; i++) {
  4940. snprintf(ring_name, STR_MAXLEN, "Rxdma err dst ring %d", i);
  4941. dp_print_ring_stat_from_hal(pdev->soc,
  4942. &pdev->rxdma_err_dst_ring[i],
  4943. ring_name);
  4944. }
  4945. for (i = 0; i < MAX_RX_MAC_RINGS; i++) {
  4946. snprintf(ring_name, STR_MAXLEN, "Rx mac buf ring %d", i);
  4947. dp_print_ring_stat_from_hal(pdev->soc,
  4948. &pdev->rx_mac_buf_ring[i],
  4949. ring_name);
  4950. }
  4951. }
  4952. /**
  4953. * dp_txrx_host_stats_clr(): Reinitialize the txrx stats
  4954. * @vdev: DP_VDEV handle
  4955. *
  4956. * Return:void
  4957. */
  4958. static inline void
  4959. dp_txrx_host_stats_clr(struct dp_vdev *vdev)
  4960. {
  4961. struct dp_peer *peer = NULL;
  4962. struct dp_soc *soc = (struct dp_soc *)vdev->pdev->soc;
  4963. DP_STATS_CLR(vdev->pdev);
  4964. DP_STATS_CLR(vdev->pdev->soc);
  4965. DP_STATS_CLR(vdev);
  4966. TAILQ_FOREACH(peer, &vdev->peer_list, peer_list_elem) {
  4967. if (!peer)
  4968. return;
  4969. DP_STATS_CLR(peer);
  4970. if (soc->cdp_soc.ol_ops->update_dp_stats) {
  4971. soc->cdp_soc.ol_ops->update_dp_stats(
  4972. vdev->pdev->ctrl_pdev,
  4973. &peer->stats,
  4974. peer->peer_ids[0],
  4975. UPDATE_PEER_STATS);
  4976. }
  4977. }
  4978. if (soc->cdp_soc.ol_ops->update_dp_stats)
  4979. soc->cdp_soc.ol_ops->update_dp_stats(vdev->pdev->ctrl_pdev,
  4980. &vdev->stats, (uint16_t)vdev->vdev_id,
  4981. UPDATE_VDEV_STATS);
  4982. }
  4983. /**
  4984. * dp_print_rx_rates(): Print Rx rate stats
  4985. * @vdev: DP_VDEV handle
  4986. *
  4987. * Return:void
  4988. */
  4989. static inline void
  4990. dp_print_rx_rates(struct dp_vdev *vdev)
  4991. {
  4992. struct dp_pdev *pdev = (struct dp_pdev *)vdev->pdev;
  4993. uint8_t i, mcs, pkt_type;
  4994. uint8_t index = 0;
  4995. char nss[DP_NSS_LENGTH];
  4996. DP_PRINT_STATS("Rx Rate Info:\n");
  4997. for (pkt_type = 0; pkt_type < DOT11_MAX; pkt_type++) {
  4998. index = 0;
  4999. for (mcs = 0; mcs < MAX_MCS; mcs++) {
  5000. if (!dp_rate_string[pkt_type][mcs].valid)
  5001. continue;
  5002. DP_PRINT_STATS(" %s = %d",
  5003. dp_rate_string[pkt_type][mcs].mcs_type,
  5004. pdev->stats.rx.pkt_type[pkt_type].
  5005. mcs_count[mcs]);
  5006. }
  5007. DP_PRINT_STATS("\n");
  5008. }
  5009. index = 0;
  5010. for (i = 0; i < SS_COUNT; i++) {
  5011. index += qdf_snprint(&nss[index], DP_NSS_LENGTH - index,
  5012. " %d", pdev->stats.rx.nss[i]);
  5013. }
  5014. DP_PRINT_STATS("NSS(1-8) = %s",
  5015. nss);
  5016. DP_PRINT_STATS("SGI ="
  5017. " 0.8us %d,"
  5018. " 0.4us %d,"
  5019. " 1.6us %d,"
  5020. " 3.2us %d,",
  5021. pdev->stats.rx.sgi_count[0],
  5022. pdev->stats.rx.sgi_count[1],
  5023. pdev->stats.rx.sgi_count[2],
  5024. pdev->stats.rx.sgi_count[3]);
  5025. DP_PRINT_STATS("BW Counts = 20MHZ %d, 40MHZ %d, 80MHZ %d, 160MHZ %d",
  5026. pdev->stats.rx.bw[0], pdev->stats.rx.bw[1],
  5027. pdev->stats.rx.bw[2], pdev->stats.rx.bw[3]);
  5028. DP_PRINT_STATS("Reception Type ="
  5029. " SU: %d,"
  5030. " MU_MIMO:%d,"
  5031. " MU_OFDMA:%d,"
  5032. " MU_OFDMA_MIMO:%d\n",
  5033. pdev->stats.rx.reception_type[0],
  5034. pdev->stats.rx.reception_type[1],
  5035. pdev->stats.rx.reception_type[2],
  5036. pdev->stats.rx.reception_type[3]);
  5037. DP_PRINT_STATS("Aggregation:\n");
  5038. DP_PRINT_STATS("Number of Msdu's Part of Ampdus = %d",
  5039. pdev->stats.rx.ampdu_cnt);
  5040. DP_PRINT_STATS("Number of Msdu's With No Mpdu Level Aggregation : %d",
  5041. pdev->stats.rx.non_ampdu_cnt);
  5042. DP_PRINT_STATS("Number of Msdu's Part of Amsdu: %d",
  5043. pdev->stats.rx.amsdu_cnt);
  5044. DP_PRINT_STATS("Number of Msdu's With No Msdu Level Aggregation: %d",
  5045. pdev->stats.rx.non_amsdu_cnt);
  5046. }
  5047. /**
  5048. * dp_print_tx_rates(): Print tx rates
  5049. * @vdev: DP_VDEV handle
  5050. *
  5051. * Return:void
  5052. */
  5053. static inline void
  5054. dp_print_tx_rates(struct dp_vdev *vdev)
  5055. {
  5056. struct dp_pdev *pdev = (struct dp_pdev *)vdev->pdev;
  5057. uint8_t mcs, pkt_type;
  5058. uint8_t index;
  5059. char nss[DP_NSS_LENGTH];
  5060. int nss_index;
  5061. DP_PRINT_STATS("Tx Rate Info:\n");
  5062. for (pkt_type = 0; pkt_type < DOT11_MAX; pkt_type++) {
  5063. index = 0;
  5064. for (mcs = 0; mcs < MAX_MCS; mcs++) {
  5065. if (!dp_rate_string[pkt_type][mcs].valid)
  5066. continue;
  5067. DP_PRINT_STATS(" %s = %d",
  5068. dp_rate_string[pkt_type][mcs].mcs_type,
  5069. pdev->stats.tx.pkt_type[pkt_type].
  5070. mcs_count[mcs]);
  5071. }
  5072. DP_PRINT_STATS("\n");
  5073. }
  5074. DP_PRINT_STATS("SGI ="
  5075. " 0.8us %d"
  5076. " 0.4us %d"
  5077. " 1.6us %d"
  5078. " 3.2us %d",
  5079. pdev->stats.tx.sgi_count[0],
  5080. pdev->stats.tx.sgi_count[1],
  5081. pdev->stats.tx.sgi_count[2],
  5082. pdev->stats.tx.sgi_count[3]);
  5083. DP_PRINT_STATS("BW Counts = 20MHZ %d, 40MHZ %d, 80MHZ %d, 160MHZ %d",
  5084. pdev->stats.tx.bw[0], pdev->stats.tx.bw[1],
  5085. pdev->stats.tx.bw[2], pdev->stats.tx.bw[3]);
  5086. index = 0;
  5087. for (nss_index = 0; nss_index < SS_COUNT; nss_index++) {
  5088. index += qdf_snprint(&nss[index], DP_NSS_LENGTH - index,
  5089. " %d", pdev->stats.tx.nss[nss_index]);
  5090. }
  5091. DP_PRINT_STATS("NSS(1-8) = %s", nss);
  5092. DP_PRINT_STATS("OFDMA = %d", pdev->stats.tx.ofdma);
  5093. DP_PRINT_STATS("STBC = %d", pdev->stats.tx.stbc);
  5094. DP_PRINT_STATS("LDPC = %d", pdev->stats.tx.ldpc);
  5095. DP_PRINT_STATS("Retries = %d", pdev->stats.tx.retries);
  5096. DP_PRINT_STATS("Last ack rssi = %d\n", pdev->stats.tx.last_ack_rssi);
  5097. DP_PRINT_STATS("Aggregation:\n");
  5098. DP_PRINT_STATS("Number of Msdu's Part of Amsdu = %d",
  5099. pdev->stats.tx.amsdu_cnt);
  5100. DP_PRINT_STATS("Number of Msdu's With No Msdu Level Aggregation = %d",
  5101. pdev->stats.tx.non_amsdu_cnt);
  5102. }
  5103. /**
  5104. * dp_print_peer_stats():print peer stats
  5105. * @peer: DP_PEER handle
  5106. *
  5107. * return void
  5108. */
  5109. static inline void dp_print_peer_stats(struct dp_peer *peer)
  5110. {
  5111. uint8_t i, mcs, pkt_type;
  5112. uint32_t index;
  5113. char nss[DP_NSS_LENGTH];
  5114. DP_PRINT_STATS("Node Tx Stats:\n");
  5115. DP_PRINT_STATS("Total Packet Completions = %d",
  5116. peer->stats.tx.comp_pkt.num);
  5117. DP_PRINT_STATS("Total Bytes Completions = %llu",
  5118. peer->stats.tx.comp_pkt.bytes);
  5119. DP_PRINT_STATS("Success Packets = %d",
  5120. peer->stats.tx.tx_success.num);
  5121. DP_PRINT_STATS("Success Bytes = %llu",
  5122. peer->stats.tx.tx_success.bytes);
  5123. DP_PRINT_STATS("Unicast Success Packets = %d",
  5124. peer->stats.tx.ucast.num);
  5125. DP_PRINT_STATS("Unicast Success Bytes = %llu",
  5126. peer->stats.tx.ucast.bytes);
  5127. DP_PRINT_STATS("Multicast Success Packets = %d",
  5128. peer->stats.tx.mcast.num);
  5129. DP_PRINT_STATS("Multicast Success Bytes = %llu",
  5130. peer->stats.tx.mcast.bytes);
  5131. DP_PRINT_STATS("Broadcast Success Packets = %d",
  5132. peer->stats.tx.bcast.num);
  5133. DP_PRINT_STATS("Broadcast Success Bytes = %llu",
  5134. peer->stats.tx.bcast.bytes);
  5135. DP_PRINT_STATS("Packets Failed = %d",
  5136. peer->stats.tx.tx_failed);
  5137. DP_PRINT_STATS("Packets In OFDMA = %d",
  5138. peer->stats.tx.ofdma);
  5139. DP_PRINT_STATS("Packets In STBC = %d",
  5140. peer->stats.tx.stbc);
  5141. DP_PRINT_STATS("Packets In LDPC = %d",
  5142. peer->stats.tx.ldpc);
  5143. DP_PRINT_STATS("Packet Retries = %d",
  5144. peer->stats.tx.retries);
  5145. DP_PRINT_STATS("MSDU's Part of AMSDU = %d",
  5146. peer->stats.tx.amsdu_cnt);
  5147. DP_PRINT_STATS("Last Packet RSSI = %d",
  5148. peer->stats.tx.last_ack_rssi);
  5149. DP_PRINT_STATS("Dropped At FW: Removed = %d",
  5150. peer->stats.tx.dropped.fw_rem);
  5151. DP_PRINT_STATS("Dropped At FW: Removed transmitted = %d",
  5152. peer->stats.tx.dropped.fw_rem_tx);
  5153. DP_PRINT_STATS("Dropped At FW: Removed Untransmitted = %d",
  5154. peer->stats.tx.dropped.fw_rem_notx);
  5155. DP_PRINT_STATS("Dropped : Age Out = %d",
  5156. peer->stats.tx.dropped.age_out);
  5157. DP_PRINT_STATS("NAWDS : ");
  5158. DP_PRINT_STATS(" Nawds multicast Drop Tx Packet = %d",
  5159. peer->stats.tx.nawds_mcast_drop);
  5160. DP_PRINT_STATS(" Nawds multicast Tx Packet Count = %d",
  5161. peer->stats.tx.nawds_mcast.num);
  5162. DP_PRINT_STATS(" Nawds multicast Tx Packet Bytes = %llu",
  5163. peer->stats.tx.nawds_mcast.bytes);
  5164. DP_PRINT_STATS("Rate Info:");
  5165. for (pkt_type = 0; pkt_type < DOT11_MAX; pkt_type++) {
  5166. index = 0;
  5167. for (mcs = 0; mcs < MAX_MCS; mcs++) {
  5168. if (!dp_rate_string[pkt_type][mcs].valid)
  5169. continue;
  5170. DP_PRINT_STATS(" %s = %d",
  5171. dp_rate_string[pkt_type][mcs].mcs_type,
  5172. peer->stats.tx.pkt_type[pkt_type].
  5173. mcs_count[mcs]);
  5174. }
  5175. DP_PRINT_STATS("\n");
  5176. }
  5177. DP_PRINT_STATS("SGI = "
  5178. " 0.8us %d"
  5179. " 0.4us %d"
  5180. " 1.6us %d"
  5181. " 3.2us %d",
  5182. peer->stats.tx.sgi_count[0],
  5183. peer->stats.tx.sgi_count[1],
  5184. peer->stats.tx.sgi_count[2],
  5185. peer->stats.tx.sgi_count[3]);
  5186. DP_PRINT_STATS("Excess Retries per AC ");
  5187. DP_PRINT_STATS(" Best effort = %d",
  5188. peer->stats.tx.excess_retries_per_ac[0]);
  5189. DP_PRINT_STATS(" Background= %d",
  5190. peer->stats.tx.excess_retries_per_ac[1]);
  5191. DP_PRINT_STATS(" Video = %d",
  5192. peer->stats.tx.excess_retries_per_ac[2]);
  5193. DP_PRINT_STATS(" Voice = %d",
  5194. peer->stats.tx.excess_retries_per_ac[3]);
  5195. DP_PRINT_STATS("BW Counts = 20MHZ %d 40MHZ %d 80MHZ %d 160MHZ %d\n",
  5196. peer->stats.tx.bw[2], peer->stats.tx.bw[3],
  5197. peer->stats.tx.bw[4], peer->stats.tx.bw[5]);
  5198. index = 0;
  5199. for (i = 0; i < SS_COUNT; i++) {
  5200. index += qdf_snprint(&nss[index], DP_NSS_LENGTH - index,
  5201. " %d", peer->stats.tx.nss[i]);
  5202. }
  5203. DP_PRINT_STATS("NSS(1-8) = %s",
  5204. nss);
  5205. DP_PRINT_STATS("Aggregation:");
  5206. DP_PRINT_STATS(" Number of Msdu's Part of Amsdu = %d",
  5207. peer->stats.tx.amsdu_cnt);
  5208. DP_PRINT_STATS(" Number of Msdu's With No Msdu Level Aggregation = %d\n",
  5209. peer->stats.tx.non_amsdu_cnt);
  5210. DP_PRINT_STATS("Node Rx Stats:");
  5211. DP_PRINT_STATS("Packets Sent To Stack = %d",
  5212. peer->stats.rx.to_stack.num);
  5213. DP_PRINT_STATS("Bytes Sent To Stack = %llu",
  5214. peer->stats.rx.to_stack.bytes);
  5215. for (i = 0; i < CDP_MAX_RX_RINGS; i++) {
  5216. DP_PRINT_STATS("Ring Id = %d", i);
  5217. DP_PRINT_STATS(" Packets Received = %d",
  5218. peer->stats.rx.rcvd_reo[i].num);
  5219. DP_PRINT_STATS(" Bytes Received = %llu",
  5220. peer->stats.rx.rcvd_reo[i].bytes);
  5221. }
  5222. DP_PRINT_STATS("Multicast Packets Received = %d",
  5223. peer->stats.rx.multicast.num);
  5224. DP_PRINT_STATS("Multicast Bytes Received = %llu",
  5225. peer->stats.rx.multicast.bytes);
  5226. DP_PRINT_STATS("Broadcast Packets Received = %d",
  5227. peer->stats.rx.bcast.num);
  5228. DP_PRINT_STATS("Broadcast Bytes Received = %llu",
  5229. peer->stats.rx.bcast.bytes);
  5230. DP_PRINT_STATS("Intra BSS Packets Received = %d",
  5231. peer->stats.rx.intra_bss.pkts.num);
  5232. DP_PRINT_STATS("Intra BSS Bytes Received = %llu",
  5233. peer->stats.rx.intra_bss.pkts.bytes);
  5234. DP_PRINT_STATS("Raw Packets Received = %d",
  5235. peer->stats.rx.raw.num);
  5236. DP_PRINT_STATS("Raw Bytes Received = %llu",
  5237. peer->stats.rx.raw.bytes);
  5238. DP_PRINT_STATS("Errors: MIC Errors = %d",
  5239. peer->stats.rx.err.mic_err);
  5240. DP_PRINT_STATS("Erros: Decryption Errors = %d",
  5241. peer->stats.rx.err.decrypt_err);
  5242. DP_PRINT_STATS("Msdu's Received As Part of Ampdu = %d",
  5243. peer->stats.rx.non_ampdu_cnt);
  5244. DP_PRINT_STATS("Msdu's Recived As Ampdu = %d",
  5245. peer->stats.rx.ampdu_cnt);
  5246. DP_PRINT_STATS("Msdu's Received Not Part of Amsdu's = %d",
  5247. peer->stats.rx.non_amsdu_cnt);
  5248. DP_PRINT_STATS("MSDUs Received As Part of Amsdu = %d",
  5249. peer->stats.rx.amsdu_cnt);
  5250. DP_PRINT_STATS("NAWDS : ");
  5251. DP_PRINT_STATS(" Nawds multicast Drop Rx Packet = %d",
  5252. peer->stats.rx.nawds_mcast_drop);
  5253. DP_PRINT_STATS("SGI ="
  5254. " 0.8us %d"
  5255. " 0.4us %d"
  5256. " 1.6us %d"
  5257. " 3.2us %d",
  5258. peer->stats.rx.sgi_count[0],
  5259. peer->stats.rx.sgi_count[1],
  5260. peer->stats.rx.sgi_count[2],
  5261. peer->stats.rx.sgi_count[3]);
  5262. DP_PRINT_STATS("BW Counts = 20MHZ %d 40MHZ %d 80MHZ %d 160MHZ %d",
  5263. peer->stats.rx.bw[0], peer->stats.rx.bw[1],
  5264. peer->stats.rx.bw[2], peer->stats.rx.bw[3]);
  5265. DP_PRINT_STATS("Reception Type ="
  5266. " SU %d,"
  5267. " MU_MIMO %d,"
  5268. " MU_OFDMA %d,"
  5269. " MU_OFDMA_MIMO %d",
  5270. peer->stats.rx.reception_type[0],
  5271. peer->stats.rx.reception_type[1],
  5272. peer->stats.rx.reception_type[2],
  5273. peer->stats.rx.reception_type[3]);
  5274. for (pkt_type = 0; pkt_type < DOT11_MAX; pkt_type++) {
  5275. index = 0;
  5276. for (mcs = 0; mcs < MAX_MCS; mcs++) {
  5277. if (!dp_rate_string[pkt_type][mcs].valid)
  5278. continue;
  5279. DP_PRINT_STATS(" %s = %d",
  5280. dp_rate_string[pkt_type][mcs].mcs_type,
  5281. peer->stats.rx.pkt_type[pkt_type].
  5282. mcs_count[mcs]);
  5283. }
  5284. DP_PRINT_STATS("\n");
  5285. }
  5286. index = 0;
  5287. for (i = 0; i < SS_COUNT; i++) {
  5288. index += qdf_snprint(&nss[index], DP_NSS_LENGTH - index,
  5289. " %d", peer->stats.rx.nss[i]);
  5290. }
  5291. DP_PRINT_STATS("NSS(1-8) = %s",
  5292. nss);
  5293. DP_PRINT_STATS("Aggregation:");
  5294. DP_PRINT_STATS(" Msdu's Part of Ampdu = %d",
  5295. peer->stats.rx.ampdu_cnt);
  5296. DP_PRINT_STATS(" Msdu's With No Mpdu Level Aggregation = %d",
  5297. peer->stats.rx.non_ampdu_cnt);
  5298. DP_PRINT_STATS(" Msdu's Part of Amsdu = %d",
  5299. peer->stats.rx.amsdu_cnt);
  5300. DP_PRINT_STATS(" Msdu's With No Msdu Level Aggregation = %d",
  5301. peer->stats.rx.non_amsdu_cnt);
  5302. }
  5303. /**
  5304. * dp_print_host_stats()- Function to print the stats aggregated at host
  5305. * @vdev_handle: DP_VDEV handle
  5306. * @type: host stats type
  5307. *
  5308. * Available Stat types
  5309. * TXRX_CLEAR_STATS : Clear the stats
  5310. * TXRX_RX_RATE_STATS: Print Rx Rate Info
  5311. * TXRX_TX_RATE_STATS: Print Tx Rate Info
  5312. * TXRX_TX_HOST_STATS: Print Tx Stats
  5313. * TXRX_RX_HOST_STATS: Print Rx Stats
  5314. * TXRX_AST_STATS: Print AST Stats
  5315. * TXRX_SRNG_PTR_STATS: Print SRNG ring pointer stats
  5316. *
  5317. * Return: 0 on success, print error message in case of failure
  5318. */
  5319. static int
  5320. dp_print_host_stats(struct cdp_vdev *vdev_handle, enum cdp_host_txrx_stats type)
  5321. {
  5322. struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle;
  5323. struct dp_pdev *pdev = (struct dp_pdev *)vdev->pdev;
  5324. dp_aggregate_pdev_stats(pdev);
  5325. switch (type) {
  5326. case TXRX_CLEAR_STATS:
  5327. dp_txrx_host_stats_clr(vdev);
  5328. break;
  5329. case TXRX_RX_RATE_STATS:
  5330. dp_print_rx_rates(vdev);
  5331. break;
  5332. case TXRX_TX_RATE_STATS:
  5333. dp_print_tx_rates(vdev);
  5334. break;
  5335. case TXRX_TX_HOST_STATS:
  5336. dp_print_pdev_tx_stats(pdev);
  5337. dp_print_soc_tx_stats(pdev->soc);
  5338. break;
  5339. case TXRX_RX_HOST_STATS:
  5340. dp_print_pdev_rx_stats(pdev);
  5341. dp_print_soc_rx_stats(pdev->soc);
  5342. break;
  5343. case TXRX_AST_STATS:
  5344. dp_print_ast_stats(pdev->soc);
  5345. dp_print_peer_table(vdev);
  5346. break;
  5347. case TXRX_SRNG_PTR_STATS:
  5348. dp_print_ring_stats(pdev);
  5349. break;
  5350. case TXRX_RX_MON_STATS:
  5351. dp_print_pdev_rx_mon_stats(pdev);
  5352. break;
  5353. default:
  5354. DP_TRACE(FATAL, "Wrong Input For TxRx Host Stats");
  5355. break;
  5356. }
  5357. return 0;
  5358. }
  5359. /*
  5360. * dp_get_host_peer_stats()- function to print peer stats
  5361. * @pdev_handle: DP_PDEV handle
  5362. * @mac_addr: mac address of the peer
  5363. *
  5364. * Return: void
  5365. */
  5366. static void
  5367. dp_get_host_peer_stats(struct cdp_pdev *pdev_handle, char *mac_addr)
  5368. {
  5369. struct dp_peer *peer;
  5370. uint8_t local_id;
  5371. peer = (struct dp_peer *)dp_find_peer_by_addr(pdev_handle, mac_addr,
  5372. &local_id);
  5373. if (!peer) {
  5374. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  5375. "%s: Invalid peer\n", __func__);
  5376. return;
  5377. }
  5378. dp_print_peer_stats(peer);
  5379. dp_peer_rxtid_stats(peer, dp_rx_tid_stats_cb, NULL);
  5380. return;
  5381. }
  5382. /*
  5383. * dp_ppdu_ring_reset()- Reset PPDU Stats ring
  5384. * @pdev: DP_PDEV handle
  5385. *
  5386. * Return: void
  5387. */
  5388. static void
  5389. dp_ppdu_ring_reset(struct dp_pdev *pdev)
  5390. {
  5391. struct htt_rx_ring_tlv_filter htt_tlv_filter;
  5392. int mac_id;
  5393. qdf_mem_set(&(htt_tlv_filter), sizeof(htt_tlv_filter), 0x0);
  5394. for (mac_id = 0; mac_id < NUM_RXDMA_RINGS_PER_PDEV; mac_id++) {
  5395. int mac_for_pdev = dp_get_mac_id_for_pdev(mac_id,
  5396. pdev->pdev_id);
  5397. htt_h2t_rx_ring_cfg(pdev->soc->htt_handle, mac_for_pdev,
  5398. pdev->rxdma_mon_status_ring[mac_id].hal_srng,
  5399. RXDMA_MONITOR_STATUS, RX_BUFFER_SIZE, &htt_tlv_filter);
  5400. }
  5401. }
  5402. /*
  5403. * dp_ppdu_ring_cfg()- Configure PPDU Stats ring
  5404. * @pdev: DP_PDEV handle
  5405. *
  5406. * Return: void
  5407. */
  5408. static void
  5409. dp_ppdu_ring_cfg(struct dp_pdev *pdev)
  5410. {
  5411. struct htt_rx_ring_tlv_filter htt_tlv_filter = {0};
  5412. int mac_id;
  5413. htt_tlv_filter.mpdu_start = 1;
  5414. htt_tlv_filter.msdu_start = 0;
  5415. htt_tlv_filter.packet = 0;
  5416. htt_tlv_filter.msdu_end = 0;
  5417. htt_tlv_filter.mpdu_end = 0;
  5418. htt_tlv_filter.attention = 0;
  5419. htt_tlv_filter.ppdu_start = 1;
  5420. htt_tlv_filter.ppdu_end = 1;
  5421. htt_tlv_filter.ppdu_end_user_stats = 1;
  5422. htt_tlv_filter.ppdu_end_user_stats_ext = 1;
  5423. htt_tlv_filter.ppdu_end_status_done = 1;
  5424. htt_tlv_filter.enable_fp = 1;
  5425. htt_tlv_filter.enable_md = 0;
  5426. if (pdev->mcopy_mode) {
  5427. htt_tlv_filter.packet_header = 1;
  5428. htt_tlv_filter.enable_mo = 1;
  5429. }
  5430. htt_tlv_filter.fp_mgmt_filter = FILTER_MGMT_ALL;
  5431. htt_tlv_filter.fp_ctrl_filter = FILTER_CTRL_ALL;
  5432. htt_tlv_filter.fp_data_filter = FILTER_DATA_ALL;
  5433. htt_tlv_filter.mo_mgmt_filter = FILTER_MGMT_ALL;
  5434. htt_tlv_filter.mo_ctrl_filter = FILTER_CTRL_ALL;
  5435. htt_tlv_filter.mo_data_filter = FILTER_DATA_ALL;
  5436. for (mac_id = 0; mac_id < NUM_RXDMA_RINGS_PER_PDEV; mac_id++) {
  5437. int mac_for_pdev = dp_get_mac_id_for_pdev(mac_id,
  5438. pdev->pdev_id);
  5439. htt_h2t_rx_ring_cfg(pdev->soc->htt_handle, mac_for_pdev,
  5440. pdev->rxdma_mon_status_ring[mac_id].hal_srng,
  5441. RXDMA_MONITOR_STATUS, RX_BUFFER_SIZE, &htt_tlv_filter);
  5442. }
  5443. }
  5444. /*
  5445. *dp_set_bpr_enable() - API to enable/disable bpr feature
  5446. *@pdev_handle: DP_PDEV handle.
  5447. *@val: Provided value.
  5448. *
  5449. *Return: void
  5450. */
  5451. static void
  5452. dp_set_bpr_enable(struct cdp_pdev *pdev_handle, int val)
  5453. {
  5454. struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
  5455. switch (val) {
  5456. case CDP_BPR_DISABLE:
  5457. pdev->bpr_enable = CDP_BPR_DISABLE;
  5458. if (!pdev->pktlog_ppdu_stats && !pdev->enhanced_stats_en &&
  5459. !pdev->tx_sniffer_enable && !pdev->mcopy_mode) {
  5460. dp_h2t_cfg_stats_msg_send(pdev, 0, pdev->pdev_id);
  5461. } else if (pdev->enhanced_stats_en &&
  5462. !pdev->tx_sniffer_enable && !pdev->mcopy_mode &&
  5463. !pdev->pktlog_ppdu_stats) {
  5464. dp_h2t_cfg_stats_msg_send(pdev,
  5465. DP_PPDU_STATS_CFG_ENH_STATS,
  5466. pdev->pdev_id);
  5467. }
  5468. break;
  5469. case CDP_BPR_ENABLE:
  5470. pdev->bpr_enable = CDP_BPR_ENABLE;
  5471. if (!pdev->enhanced_stats_en && !pdev->tx_sniffer_enable &&
  5472. !pdev->mcopy_mode && !pdev->pktlog_ppdu_stats) {
  5473. dp_h2t_cfg_stats_msg_send(pdev,
  5474. DP_PPDU_STATS_CFG_BPR,
  5475. pdev->pdev_id);
  5476. } else if (pdev->enhanced_stats_en &&
  5477. !pdev->tx_sniffer_enable && !pdev->mcopy_mode &&
  5478. !pdev->pktlog_ppdu_stats) {
  5479. dp_h2t_cfg_stats_msg_send(pdev,
  5480. DP_PPDU_STATS_CFG_BPR_ENH,
  5481. pdev->pdev_id);
  5482. } else if (pdev->pktlog_ppdu_stats) {
  5483. dp_h2t_cfg_stats_msg_send(pdev,
  5484. DP_PPDU_STATS_CFG_BPR_PKTLOG,
  5485. pdev->pdev_id);
  5486. }
  5487. break;
  5488. default:
  5489. break;
  5490. }
  5491. }
  5492. /*
  5493. * dp_config_debug_sniffer()- API to enable/disable debug sniffer
  5494. * @pdev_handle: DP_PDEV handle
  5495. * @val: user provided value
  5496. *
  5497. * Return: void
  5498. */
  5499. static void
  5500. dp_config_debug_sniffer(struct cdp_pdev *pdev_handle, int val)
  5501. {
  5502. struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
  5503. switch (val) {
  5504. case 0:
  5505. pdev->tx_sniffer_enable = 0;
  5506. pdev->mcopy_mode = 0;
  5507. if (!pdev->pktlog_ppdu_stats && !pdev->enhanced_stats_en) {
  5508. dp_h2t_cfg_stats_msg_send(pdev, 0, pdev->pdev_id);
  5509. dp_ppdu_ring_reset(pdev);
  5510. } else if (pdev->enhanced_stats_en) {
  5511. dp_h2t_cfg_stats_msg_send(pdev,
  5512. DP_PPDU_STATS_CFG_ENH_STATS, pdev->pdev_id);
  5513. }
  5514. break;
  5515. case 1:
  5516. pdev->tx_sniffer_enable = 1;
  5517. pdev->mcopy_mode = 0;
  5518. if (!pdev->pktlog_ppdu_stats)
  5519. dp_h2t_cfg_stats_msg_send(pdev,
  5520. DP_PPDU_STATS_CFG_SNIFFER, pdev->pdev_id);
  5521. break;
  5522. case 2:
  5523. pdev->mcopy_mode = 1;
  5524. pdev->tx_sniffer_enable = 0;
  5525. dp_ppdu_ring_cfg(pdev);
  5526. if (!pdev->pktlog_ppdu_stats)
  5527. dp_h2t_cfg_stats_msg_send(pdev,
  5528. DP_PPDU_STATS_CFG_SNIFFER, pdev->pdev_id);
  5529. break;
  5530. default:
  5531. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  5532. "Invalid value\n");
  5533. break;
  5534. }
  5535. }
  5536. /*
  5537. * dp_enable_enhanced_stats()- API to enable enhanced statistcs
  5538. * @pdev_handle: DP_PDEV handle
  5539. *
  5540. * Return: void
  5541. */
  5542. static void
  5543. dp_enable_enhanced_stats(struct cdp_pdev *pdev_handle)
  5544. {
  5545. struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
  5546. pdev->enhanced_stats_en = 1;
  5547. if (!pdev->mcopy_mode)
  5548. dp_ppdu_ring_cfg(pdev);
  5549. if (!pdev->pktlog_ppdu_stats && !pdev->tx_sniffer_enable && !pdev->mcopy_mode)
  5550. dp_h2t_cfg_stats_msg_send(pdev, DP_PPDU_STATS_CFG_ENH_STATS, pdev->pdev_id);
  5551. }
  5552. /*
  5553. * dp_disable_enhanced_stats()- API to disable enhanced statistcs
  5554. * @pdev_handle: DP_PDEV handle
  5555. *
  5556. * Return: void
  5557. */
  5558. static void
  5559. dp_disable_enhanced_stats(struct cdp_pdev *pdev_handle)
  5560. {
  5561. struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
  5562. pdev->enhanced_stats_en = 0;
  5563. if (!pdev->pktlog_ppdu_stats && !pdev->tx_sniffer_enable && !pdev->mcopy_mode)
  5564. dp_h2t_cfg_stats_msg_send(pdev, 0, pdev->pdev_id);
  5565. if (!pdev->mcopy_mode)
  5566. dp_ppdu_ring_reset(pdev);
  5567. }
  5568. /*
  5569. * dp_get_fw_peer_stats()- function to print peer stats
  5570. * @pdev_handle: DP_PDEV handle
  5571. * @mac_addr: mac address of the peer
  5572. * @cap: Type of htt stats requested
  5573. *
  5574. * Currently Supporting only MAC ID based requests Only
  5575. * 1: HTT_PEER_STATS_REQ_MODE_NO_QUERY
  5576. * 2: HTT_PEER_STATS_REQ_MODE_QUERY_TQM
  5577. * 3: HTT_PEER_STATS_REQ_MODE_FLUSH_TQM
  5578. *
  5579. * Return: void
  5580. */
  5581. static void
  5582. dp_get_fw_peer_stats(struct cdp_pdev *pdev_handle, uint8_t *mac_addr,
  5583. uint32_t cap)
  5584. {
  5585. struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
  5586. int i;
  5587. uint32_t config_param0 = 0;
  5588. uint32_t config_param1 = 0;
  5589. uint32_t config_param2 = 0;
  5590. uint32_t config_param3 = 0;
  5591. HTT_DBG_EXT_STATS_PEER_INFO_IS_MAC_ADDR_SET(config_param0, 1);
  5592. config_param0 |= (1 << (cap + 1));
  5593. for (i = 0; i < HTT_PEER_STATS_MAX_TLV; i++) {
  5594. config_param1 |= (1 << i);
  5595. }
  5596. config_param2 |= (mac_addr[0] & 0x000000ff);
  5597. config_param2 |= ((mac_addr[1] << 8) & 0x0000ff00);
  5598. config_param2 |= ((mac_addr[2] << 16) & 0x00ff0000);
  5599. config_param2 |= ((mac_addr[3] << 24) & 0xff000000);
  5600. config_param3 |= (mac_addr[4] & 0x000000ff);
  5601. config_param3 |= ((mac_addr[5] << 8) & 0x0000ff00);
  5602. dp_h2t_ext_stats_msg_send(pdev, HTT_DBG_EXT_STATS_PEER_INFO,
  5603. config_param0, config_param1, config_param2,
  5604. config_param3, 0, 0, 0);
  5605. }
  5606. /* This struct definition will be removed from here
  5607. * once it get added in FW headers*/
  5608. struct httstats_cmd_req {
  5609. uint32_t config_param0;
  5610. uint32_t config_param1;
  5611. uint32_t config_param2;
  5612. uint32_t config_param3;
  5613. int cookie;
  5614. u_int8_t stats_id;
  5615. };
  5616. /*
  5617. * dp_get_htt_stats: function to process the httstas request
  5618. * @pdev_handle: DP pdev handle
  5619. * @data: pointer to request data
  5620. * @data_len: length for request data
  5621. *
  5622. * return: void
  5623. */
  5624. static void
  5625. dp_get_htt_stats(struct cdp_pdev *pdev_handle, void *data, uint32_t data_len)
  5626. {
  5627. struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
  5628. struct httstats_cmd_req *req = (struct httstats_cmd_req *)data;
  5629. QDF_ASSERT(data_len == sizeof(struct httstats_cmd_req));
  5630. dp_h2t_ext_stats_msg_send(pdev, req->stats_id,
  5631. req->config_param0, req->config_param1,
  5632. req->config_param2, req->config_param3,
  5633. req->cookie, 0, 0);
  5634. }
  5635. /*
  5636. * dp_set_pdev_param: function to set parameters in pdev
  5637. * @pdev_handle: DP pdev handle
  5638. * @param: parameter type to be set
  5639. * @val: value of parameter to be set
  5640. *
  5641. * return: void
  5642. */
  5643. static void dp_set_pdev_param(struct cdp_pdev *pdev_handle,
  5644. enum cdp_pdev_param_type param, uint8_t val)
  5645. {
  5646. switch (param) {
  5647. case CDP_CONFIG_DEBUG_SNIFFER:
  5648. dp_config_debug_sniffer(pdev_handle, val);
  5649. break;
  5650. case CDP_CONFIG_BPR_ENABLE:
  5651. dp_set_bpr_enable(pdev_handle, val);
  5652. break;
  5653. default:
  5654. break;
  5655. }
  5656. }
  5657. /*
  5658. * dp_set_vdev_param: function to set parameters in vdev
  5659. * @param: parameter type to be set
  5660. * @val: value of parameter to be set
  5661. *
  5662. * return: void
  5663. */
  5664. static void dp_set_vdev_param(struct cdp_vdev *vdev_handle,
  5665. enum cdp_vdev_param_type param, uint32_t val)
  5666. {
  5667. struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle;
  5668. switch (param) {
  5669. case CDP_ENABLE_WDS:
  5670. vdev->wds_enabled = val;
  5671. break;
  5672. case CDP_ENABLE_NAWDS:
  5673. vdev->nawds_enabled = val;
  5674. break;
  5675. case CDP_ENABLE_MCAST_EN:
  5676. vdev->mcast_enhancement_en = val;
  5677. break;
  5678. case CDP_ENABLE_PROXYSTA:
  5679. vdev->proxysta_vdev = val;
  5680. break;
  5681. case CDP_UPDATE_TDLS_FLAGS:
  5682. vdev->tdls_link_connected = val;
  5683. break;
  5684. case CDP_CFG_WDS_AGING_TIMER:
  5685. if (val == 0)
  5686. qdf_timer_stop(&vdev->pdev->soc->wds_aging_timer);
  5687. else if (val != vdev->wds_aging_timer_val)
  5688. qdf_timer_mod(&vdev->pdev->soc->wds_aging_timer, val);
  5689. vdev->wds_aging_timer_val = val;
  5690. break;
  5691. case CDP_ENABLE_AP_BRIDGE:
  5692. if (wlan_op_mode_sta != vdev->opmode)
  5693. vdev->ap_bridge_enabled = val;
  5694. else
  5695. vdev->ap_bridge_enabled = false;
  5696. break;
  5697. case CDP_ENABLE_CIPHER:
  5698. vdev->sec_type = val;
  5699. break;
  5700. case CDP_ENABLE_QWRAP_ISOLATION:
  5701. vdev->isolation_vdev = val;
  5702. break;
  5703. default:
  5704. break;
  5705. }
  5706. dp_tx_vdev_update_search_flags(vdev);
  5707. }
  5708. /**
  5709. * dp_peer_set_nawds: set nawds bit in peer
  5710. * @peer_handle: pointer to peer
  5711. * @value: enable/disable nawds
  5712. *
  5713. * return: void
  5714. */
  5715. static void dp_peer_set_nawds(struct cdp_peer *peer_handle, uint8_t value)
  5716. {
  5717. struct dp_peer *peer = (struct dp_peer *)peer_handle;
  5718. peer->nawds_enabled = value;
  5719. }
  5720. /*
  5721. * dp_set_vdev_dscp_tid_map_wifi3(): Update Map ID selected for particular vdev
  5722. * @vdev_handle: DP_VDEV handle
  5723. * @map_id:ID of map that needs to be updated
  5724. *
  5725. * Return: void
  5726. */
  5727. static void dp_set_vdev_dscp_tid_map_wifi3(struct cdp_vdev *vdev_handle,
  5728. uint8_t map_id)
  5729. {
  5730. struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle;
  5731. vdev->dscp_tid_map_id = map_id;
  5732. return;
  5733. }
  5734. /*
  5735. * dp_txrx_stats_publish(): publish pdev stats into a buffer
  5736. * @pdev_handle: DP_PDEV handle
  5737. * @buf: to hold pdev_stats
  5738. *
  5739. * Return: int
  5740. */
  5741. static int
  5742. dp_txrx_stats_publish(struct cdp_pdev *pdev_handle, void *buf)
  5743. {
  5744. struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
  5745. struct cdp_pdev_stats *buffer = (struct cdp_pdev_stats *) buf;
  5746. struct cdp_txrx_stats_req req = {0,};
  5747. dp_aggregate_pdev_stats(pdev);
  5748. req.stats = HTT_DBG_EXT_STATS_PDEV_TX;
  5749. req.cookie_val = 1;
  5750. dp_h2t_ext_stats_msg_send(pdev, req.stats, req.param0,
  5751. req.param1, req.param2, req.param3, 0,
  5752. req.cookie_val, 0);
  5753. msleep(DP_MAX_SLEEP_TIME);
  5754. req.stats = HTT_DBG_EXT_STATS_PDEV_RX;
  5755. req.cookie_val = 1;
  5756. dp_h2t_ext_stats_msg_send(pdev, req.stats, req.param0,
  5757. req.param1, req.param2, req.param3, 0,
  5758. req.cookie_val, 0);
  5759. msleep(DP_MAX_SLEEP_TIME);
  5760. qdf_mem_copy(buffer, &pdev->stats, sizeof(pdev->stats));
  5761. return TXRX_STATS_LEVEL;
  5762. }
  5763. /**
  5764. * dp_set_pdev_dscp_tid_map_wifi3(): update dscp tid map in pdev
  5765. * @pdev: DP_PDEV handle
  5766. * @map_id: ID of map that needs to be updated
  5767. * @tos: index value in map
  5768. * @tid: tid value passed by the user
  5769. *
  5770. * Return: void
  5771. */
  5772. static void dp_set_pdev_dscp_tid_map_wifi3(struct cdp_pdev *pdev_handle,
  5773. uint8_t map_id, uint8_t tos, uint8_t tid)
  5774. {
  5775. uint8_t dscp;
  5776. struct dp_pdev *pdev = (struct dp_pdev *) pdev_handle;
  5777. dscp = (tos >> DP_IP_DSCP_SHIFT) & DP_IP_DSCP_MASK;
  5778. pdev->dscp_tid_map[map_id][dscp] = tid;
  5779. if (map_id < HAL_MAX_HW_DSCP_TID_MAPS)
  5780. hal_tx_update_dscp_tid(pdev->soc->hal_soc, tid,
  5781. map_id, dscp);
  5782. return;
  5783. }
  5784. /**
  5785. * dp_fw_stats_process(): Process TxRX FW stats request
  5786. * @vdev_handle: DP VDEV handle
  5787. * @req: stats request
  5788. *
  5789. * return: int
  5790. */
  5791. static int dp_fw_stats_process(struct cdp_vdev *vdev_handle,
  5792. struct cdp_txrx_stats_req *req)
  5793. {
  5794. struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle;
  5795. struct dp_pdev *pdev = NULL;
  5796. uint32_t stats = req->stats;
  5797. uint8_t mac_id = req->mac_id;
  5798. if (!vdev) {
  5799. DP_TRACE(NONE, "VDEV not found");
  5800. return 1;
  5801. }
  5802. pdev = vdev->pdev;
  5803. /*
  5804. * For HTT_DBG_EXT_STATS_RESET command, FW need to config
  5805. * from param0 to param3 according to below rule:
  5806. *
  5807. * PARAM:
  5808. * - config_param0 : start_offset (stats type)
  5809. * - config_param1 : stats bmask from start offset
  5810. * - config_param2 : stats bmask from start offset + 32
  5811. * - config_param3 : stats bmask from start offset + 64
  5812. */
  5813. if (req->stats == CDP_TXRX_STATS_0) {
  5814. req->param0 = HTT_DBG_EXT_STATS_PDEV_TX;
  5815. req->param1 = 0xFFFFFFFF;
  5816. req->param2 = 0xFFFFFFFF;
  5817. req->param3 = 0xFFFFFFFF;
  5818. }
  5819. return dp_h2t_ext_stats_msg_send(pdev, stats, req->param0,
  5820. req->param1, req->param2, req->param3,
  5821. 0, 0, mac_id);
  5822. }
  5823. /**
  5824. * dp_txrx_stats_request - function to map to firmware and host stats
  5825. * @vdev: virtual handle
  5826. * @req: stats request
  5827. *
  5828. * Return: integer
  5829. */
  5830. static int dp_txrx_stats_request(struct cdp_vdev *vdev,
  5831. struct cdp_txrx_stats_req *req)
  5832. {
  5833. int host_stats;
  5834. int fw_stats;
  5835. enum cdp_stats stats;
  5836. if (!vdev || !req) {
  5837. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  5838. "Invalid vdev/req instance");
  5839. return 0;
  5840. }
  5841. stats = req->stats;
  5842. if (stats >= CDP_TXRX_MAX_STATS)
  5843. return 0;
  5844. /*
  5845. * DP_CURR_FW_STATS_AVAIL: no of FW stats currently available
  5846. * has to be updated if new FW HTT stats added
  5847. */
  5848. if (stats > CDP_TXRX_STATS_HTT_MAX)
  5849. stats = stats + DP_CURR_FW_STATS_AVAIL - DP_HTT_DBG_EXT_STATS_MAX;
  5850. fw_stats = dp_stats_mapping_table[stats][STATS_FW];
  5851. host_stats = dp_stats_mapping_table[stats][STATS_HOST];
  5852. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  5853. "stats: %u fw_stats_type: %d host_stats_type: %d",
  5854. stats, fw_stats, host_stats);
  5855. if (fw_stats != TXRX_FW_STATS_INVALID) {
  5856. /* update request with FW stats type */
  5857. req->stats = fw_stats;
  5858. return dp_fw_stats_process(vdev, req);
  5859. }
  5860. if ((host_stats != TXRX_HOST_STATS_INVALID) &&
  5861. (host_stats <= TXRX_HOST_STATS_MAX))
  5862. return dp_print_host_stats(vdev, host_stats);
  5863. else
  5864. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  5865. "Wrong Input for TxRx Stats");
  5866. return 0;
  5867. }
  5868. /*
  5869. * dp_print_napi_stats(): NAPI stats
  5870. * @soc - soc handle
  5871. */
  5872. static void dp_print_napi_stats(struct dp_soc *soc)
  5873. {
  5874. hif_print_napi_stats(soc->hif_handle);
  5875. }
  5876. /*
  5877. * dp_print_per_ring_stats(): Packet count per ring
  5878. * @soc - soc handle
  5879. */
  5880. static void dp_print_per_ring_stats(struct dp_soc *soc)
  5881. {
  5882. uint8_t ring;
  5883. uint16_t core;
  5884. uint64_t total_packets;
  5885. DP_TRACE(FATAL, "Reo packets per ring:");
  5886. for (ring = 0; ring < MAX_REO_DEST_RINGS; ring++) {
  5887. total_packets = 0;
  5888. DP_TRACE(FATAL, "Packets on ring %u:", ring);
  5889. for (core = 0; core < NR_CPUS; core++) {
  5890. DP_TRACE(FATAL, "Packets arriving on core %u: %llu",
  5891. core, soc->stats.rx.ring_packets[core][ring]);
  5892. total_packets += soc->stats.rx.ring_packets[core][ring];
  5893. }
  5894. DP_TRACE(FATAL, "Total packets on ring %u: %llu",
  5895. ring, total_packets);
  5896. }
  5897. }
  5898. /*
  5899. * dp_txrx_path_stats() - Function to display dump stats
  5900. * @soc - soc handle
  5901. *
  5902. * return: none
  5903. */
  5904. static void dp_txrx_path_stats(struct dp_soc *soc)
  5905. {
  5906. uint8_t error_code;
  5907. uint8_t loop_pdev;
  5908. struct dp_pdev *pdev;
  5909. uint8_t i;
  5910. for (loop_pdev = 0; loop_pdev < soc->pdev_count; loop_pdev++) {
  5911. pdev = soc->pdev_list[loop_pdev];
  5912. dp_aggregate_pdev_stats(pdev);
  5913. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  5914. "Tx path Statistics:");
  5915. DP_TRACE(FATAL, "from stack: %u msdus (%llu bytes)",
  5916. pdev->stats.tx_i.rcvd.num,
  5917. pdev->stats.tx_i.rcvd.bytes);
  5918. DP_TRACE(FATAL, "processed from host: %u msdus (%llu bytes)",
  5919. pdev->stats.tx_i.processed.num,
  5920. pdev->stats.tx_i.processed.bytes);
  5921. DP_TRACE(FATAL, "successfully transmitted: %u msdus (%llu bytes)",
  5922. pdev->stats.tx.tx_success.num,
  5923. pdev->stats.tx.tx_success.bytes);
  5924. DP_TRACE(FATAL, "Dropped in host:");
  5925. DP_TRACE(FATAL, "Total packets dropped: %u,",
  5926. pdev->stats.tx_i.dropped.dropped_pkt.num);
  5927. DP_TRACE(FATAL, "Descriptor not available: %u",
  5928. pdev->stats.tx_i.dropped.desc_na.num);
  5929. DP_TRACE(FATAL, "Ring full: %u",
  5930. pdev->stats.tx_i.dropped.ring_full);
  5931. DP_TRACE(FATAL, "Enqueue fail: %u",
  5932. pdev->stats.tx_i.dropped.enqueue_fail);
  5933. DP_TRACE(FATAL, "DMA Error: %u",
  5934. pdev->stats.tx_i.dropped.dma_error);
  5935. DP_TRACE(FATAL, "Dropped in hardware:");
  5936. DP_TRACE(FATAL, "total packets dropped: %u",
  5937. pdev->stats.tx.tx_failed);
  5938. DP_TRACE(FATAL, "mpdu age out: %u",
  5939. pdev->stats.tx.dropped.age_out);
  5940. DP_TRACE(FATAL, "firmware removed: %u",
  5941. pdev->stats.tx.dropped.fw_rem);
  5942. DP_TRACE(FATAL, "firmware removed tx: %u",
  5943. pdev->stats.tx.dropped.fw_rem_tx);
  5944. DP_TRACE(FATAL, "firmware removed notx %u",
  5945. pdev->stats.tx.dropped.fw_rem_notx);
  5946. DP_TRACE(FATAL, "peer_invalid: %u",
  5947. pdev->soc->stats.tx.tx_invalid_peer.num);
  5948. DP_TRACE(FATAL, "Tx packets sent per interrupt:");
  5949. DP_TRACE(FATAL, "Single Packet: %u",
  5950. pdev->stats.tx_comp_histogram.pkts_1);
  5951. DP_TRACE(FATAL, "2-20 Packets: %u",
  5952. pdev->stats.tx_comp_histogram.pkts_2_20);
  5953. DP_TRACE(FATAL, "21-40 Packets: %u",
  5954. pdev->stats.tx_comp_histogram.pkts_21_40);
  5955. DP_TRACE(FATAL, "41-60 Packets: %u",
  5956. pdev->stats.tx_comp_histogram.pkts_41_60);
  5957. DP_TRACE(FATAL, "61-80 Packets: %u",
  5958. pdev->stats.tx_comp_histogram.pkts_61_80);
  5959. DP_TRACE(FATAL, "81-100 Packets: %u",
  5960. pdev->stats.tx_comp_histogram.pkts_81_100);
  5961. DP_TRACE(FATAL, "101-200 Packets: %u",
  5962. pdev->stats.tx_comp_histogram.pkts_101_200);
  5963. DP_TRACE(FATAL, " 201+ Packets: %u",
  5964. pdev->stats.tx_comp_histogram.pkts_201_plus);
  5965. DP_TRACE(FATAL, "Rx path statistics");
  5966. DP_TRACE(FATAL, "delivered %u msdus ( %llu bytes),",
  5967. pdev->stats.rx.to_stack.num,
  5968. pdev->stats.rx.to_stack.bytes);
  5969. for (i = 0; i < CDP_MAX_RX_RINGS; i++)
  5970. DP_TRACE(FATAL, "received on reo[%d] %u msdus ( %llu bytes),",
  5971. i, pdev->stats.rx.rcvd_reo[i].num,
  5972. pdev->stats.rx.rcvd_reo[i].bytes);
  5973. DP_TRACE(FATAL, "intra-bss packets %u msdus ( %llu bytes),",
  5974. pdev->stats.rx.intra_bss.pkts.num,
  5975. pdev->stats.rx.intra_bss.pkts.bytes);
  5976. DP_TRACE(FATAL, "intra-bss fails %u msdus ( %llu bytes),",
  5977. pdev->stats.rx.intra_bss.fail.num,
  5978. pdev->stats.rx.intra_bss.fail.bytes);
  5979. DP_TRACE(FATAL, "raw packets %u msdus ( %llu bytes),",
  5980. pdev->stats.rx.raw.num,
  5981. pdev->stats.rx.raw.bytes);
  5982. DP_TRACE(FATAL, "dropped: error %u msdus",
  5983. pdev->stats.rx.err.mic_err);
  5984. DP_TRACE(FATAL, "peer invalid %u",
  5985. pdev->soc->stats.rx.err.rx_invalid_peer.num);
  5986. DP_TRACE(FATAL, "Reo Statistics");
  5987. DP_TRACE(FATAL, "rbm error: %u msdus",
  5988. pdev->soc->stats.rx.err.invalid_rbm);
  5989. DP_TRACE(FATAL, "hal ring access fail: %u msdus",
  5990. pdev->soc->stats.rx.err.hal_ring_access_fail);
  5991. for (error_code = 0; error_code < HAL_REO_ERR_MAX;
  5992. error_code++) {
  5993. if (!pdev->soc->stats.rx.err.reo_error[error_code])
  5994. continue;
  5995. DP_TRACE(FATAL, "Reo error number (%u): %u msdus",
  5996. error_code,
  5997. pdev->soc->stats.rx.err.reo_error[error_code]);
  5998. }
  5999. for (error_code = 0; error_code < HAL_RXDMA_ERR_MAX;
  6000. error_code++) {
  6001. if (!pdev->soc->stats.rx.err.rxdma_error[error_code])
  6002. continue;
  6003. DP_TRACE(FATAL, "Rxdma error number (%u): %u msdus",
  6004. error_code,
  6005. pdev->soc->stats.rx.err
  6006. .rxdma_error[error_code]);
  6007. }
  6008. DP_TRACE(FATAL, "Rx packets reaped per interrupt:");
  6009. DP_TRACE(FATAL, "Single Packet: %u",
  6010. pdev->stats.rx_ind_histogram.pkts_1);
  6011. DP_TRACE(FATAL, "2-20 Packets: %u",
  6012. pdev->stats.rx_ind_histogram.pkts_2_20);
  6013. DP_TRACE(FATAL, "21-40 Packets: %u",
  6014. pdev->stats.rx_ind_histogram.pkts_21_40);
  6015. DP_TRACE(FATAL, "41-60 Packets: %u",
  6016. pdev->stats.rx_ind_histogram.pkts_41_60);
  6017. DP_TRACE(FATAL, "61-80 Packets: %u",
  6018. pdev->stats.rx_ind_histogram.pkts_61_80);
  6019. DP_TRACE(FATAL, "81-100 Packets: %u",
  6020. pdev->stats.rx_ind_histogram.pkts_81_100);
  6021. DP_TRACE(FATAL, "101-200 Packets: %u",
  6022. pdev->stats.rx_ind_histogram.pkts_101_200);
  6023. DP_TRACE(FATAL, " 201+ Packets: %u",
  6024. pdev->stats.rx_ind_histogram.pkts_201_plus);
  6025. DP_TRACE_STATS(ERROR, "%s: tso_enable: %u lro_enable: %u rx_hash: %u napi_enable: %u",
  6026. __func__,
  6027. pdev->soc->wlan_cfg_ctx->tso_enabled,
  6028. pdev->soc->wlan_cfg_ctx->lro_enabled,
  6029. pdev->soc->wlan_cfg_ctx->rx_hash,
  6030. pdev->soc->wlan_cfg_ctx->napi_enabled);
  6031. #ifdef QCA_LL_TX_FLOW_CONTROL_V2
  6032. DP_TRACE_STATS(ERROR, "%s: Tx flow stop queue: %u tx flow start queue offset: %u",
  6033. __func__,
  6034. pdev->soc->wlan_cfg_ctx->tx_flow_stop_queue_threshold,
  6035. pdev->soc->wlan_cfg_ctx->tx_flow_start_queue_offset);
  6036. #endif
  6037. }
  6038. }
  6039. /*
  6040. * dp_txrx_dump_stats() - Dump statistics
  6041. * @value - Statistics option
  6042. */
  6043. static QDF_STATUS dp_txrx_dump_stats(void *psoc, uint16_t value,
  6044. enum qdf_stats_verbosity_level level)
  6045. {
  6046. struct dp_soc *soc =
  6047. (struct dp_soc *)psoc;
  6048. QDF_STATUS status = QDF_STATUS_SUCCESS;
  6049. if (!soc) {
  6050. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  6051. "%s: soc is NULL", __func__);
  6052. return QDF_STATUS_E_INVAL;
  6053. }
  6054. switch (value) {
  6055. case CDP_TXRX_PATH_STATS:
  6056. dp_txrx_path_stats(soc);
  6057. break;
  6058. case CDP_RX_RING_STATS:
  6059. dp_print_per_ring_stats(soc);
  6060. break;
  6061. case CDP_TXRX_TSO_STATS:
  6062. /* TODO: NOT IMPLEMENTED */
  6063. break;
  6064. case CDP_DUMP_TX_FLOW_POOL_INFO:
  6065. cdp_dump_flow_pool_info((struct cdp_soc_t *)soc);
  6066. break;
  6067. case CDP_DP_NAPI_STATS:
  6068. dp_print_napi_stats(soc);
  6069. break;
  6070. case CDP_TXRX_DESC_STATS:
  6071. /* TODO: NOT IMPLEMENTED */
  6072. break;
  6073. default:
  6074. status = QDF_STATUS_E_INVAL;
  6075. break;
  6076. }
  6077. return status;
  6078. }
  6079. #ifdef QCA_LL_TX_FLOW_CONTROL_V2
  6080. /**
  6081. * dp_update_flow_control_parameters() - API to store datapath
  6082. * config parameters
  6083. * @soc: soc handle
  6084. * @cfg: ini parameter handle
  6085. *
  6086. * Return: void
  6087. */
  6088. static inline
  6089. void dp_update_flow_control_parameters(struct dp_soc *soc,
  6090. struct cdp_config_params *params)
  6091. {
  6092. soc->wlan_cfg_ctx->tx_flow_stop_queue_threshold =
  6093. params->tx_flow_stop_queue_threshold;
  6094. soc->wlan_cfg_ctx->tx_flow_start_queue_offset =
  6095. params->tx_flow_start_queue_offset;
  6096. }
  6097. #else
  6098. static inline
  6099. void dp_update_flow_control_parameters(struct dp_soc *soc,
  6100. struct cdp_config_params *params)
  6101. {
  6102. }
  6103. #endif
  6104. /**
  6105. * dp_update_config_parameters() - API to store datapath
  6106. * config parameters
  6107. * @soc: soc handle
  6108. * @cfg: ini parameter handle
  6109. *
  6110. * Return: status
  6111. */
  6112. static
  6113. QDF_STATUS dp_update_config_parameters(struct cdp_soc *psoc,
  6114. struct cdp_config_params *params)
  6115. {
  6116. struct dp_soc *soc = (struct dp_soc *)psoc;
  6117. if (!(soc)) {
  6118. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  6119. "%s: Invalid handle", __func__);
  6120. return QDF_STATUS_E_INVAL;
  6121. }
  6122. soc->wlan_cfg_ctx->tso_enabled = params->tso_enable;
  6123. soc->wlan_cfg_ctx->lro_enabled = params->lro_enable;
  6124. soc->wlan_cfg_ctx->rx_hash = params->flow_steering_enable;
  6125. soc->wlan_cfg_ctx->tcp_udp_checksumoffload =
  6126. params->tcp_udp_checksumoffload;
  6127. soc->wlan_cfg_ctx->napi_enabled = params->napi_enable;
  6128. dp_update_flow_control_parameters(soc, params);
  6129. return QDF_STATUS_SUCCESS;
  6130. }
  6131. /**
  6132. * dp_txrx_set_wds_rx_policy() - API to store datapath
  6133. * config parameters
  6134. * @vdev_handle - datapath vdev handle
  6135. * @cfg: ini parameter handle
  6136. *
  6137. * Return: status
  6138. */
  6139. #ifdef WDS_VENDOR_EXTENSION
  6140. void
  6141. dp_txrx_set_wds_rx_policy(
  6142. struct cdp_vdev *vdev_handle,
  6143. u_int32_t val)
  6144. {
  6145. struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle;
  6146. struct dp_peer *peer;
  6147. if (vdev->opmode == wlan_op_mode_ap) {
  6148. /* for ap, set it on bss_peer */
  6149. TAILQ_FOREACH(peer, &vdev->peer_list, peer_list_elem) {
  6150. if (peer->bss_peer) {
  6151. peer->wds_ecm.wds_rx_filter = 1;
  6152. peer->wds_ecm.wds_rx_ucast_4addr = (val & WDS_POLICY_RX_UCAST_4ADDR) ? 1:0;
  6153. peer->wds_ecm.wds_rx_mcast_4addr = (val & WDS_POLICY_RX_MCAST_4ADDR) ? 1:0;
  6154. break;
  6155. }
  6156. }
  6157. } else if (vdev->opmode == wlan_op_mode_sta) {
  6158. peer = TAILQ_FIRST(&vdev->peer_list);
  6159. peer->wds_ecm.wds_rx_filter = 1;
  6160. peer->wds_ecm.wds_rx_ucast_4addr = (val & WDS_POLICY_RX_UCAST_4ADDR) ? 1:0;
  6161. peer->wds_ecm.wds_rx_mcast_4addr = (val & WDS_POLICY_RX_MCAST_4ADDR) ? 1:0;
  6162. }
  6163. }
  6164. /**
  6165. * dp_txrx_peer_wds_tx_policy_update() - API to set tx wds policy
  6166. *
  6167. * @peer_handle - datapath peer handle
  6168. * @wds_tx_ucast: policy for unicast transmission
  6169. * @wds_tx_mcast: policy for multicast transmission
  6170. *
  6171. * Return: void
  6172. */
  6173. void
  6174. dp_txrx_peer_wds_tx_policy_update(struct cdp_peer *peer_handle,
  6175. int wds_tx_ucast, int wds_tx_mcast)
  6176. {
  6177. struct dp_peer *peer = (struct dp_peer *)peer_handle;
  6178. if (wds_tx_ucast || wds_tx_mcast) {
  6179. peer->wds_enabled = 1;
  6180. peer->wds_ecm.wds_tx_ucast_4addr = wds_tx_ucast;
  6181. peer->wds_ecm.wds_tx_mcast_4addr = wds_tx_mcast;
  6182. } else {
  6183. peer->wds_enabled = 0;
  6184. peer->wds_ecm.wds_tx_ucast_4addr = 0;
  6185. peer->wds_ecm.wds_tx_mcast_4addr = 0;
  6186. }
  6187. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  6188. FL("Policy Update set to :\
  6189. peer->wds_enabled %d\
  6190. peer->wds_ecm.wds_tx_ucast_4addr %d\
  6191. peer->wds_ecm.wds_tx_mcast_4addr %d\n"),
  6192. peer->wds_enabled, peer->wds_ecm.wds_tx_ucast_4addr,
  6193. peer->wds_ecm.wds_tx_mcast_4addr);
  6194. return;
  6195. }
  6196. #endif
  6197. static struct cdp_wds_ops dp_ops_wds = {
  6198. .vdev_set_wds = dp_vdev_set_wds,
  6199. #ifdef WDS_VENDOR_EXTENSION
  6200. .txrx_set_wds_rx_policy = dp_txrx_set_wds_rx_policy,
  6201. .txrx_wds_peer_tx_policy_update = dp_txrx_peer_wds_tx_policy_update,
  6202. #endif
  6203. };
  6204. /*
  6205. * dp_txrx_data_tx_cb_set(): set the callback for non standard tx
  6206. * @vdev_handle - datapath vdev handle
  6207. * @callback - callback function
  6208. * @ctxt: callback context
  6209. *
  6210. */
  6211. static void
  6212. dp_txrx_data_tx_cb_set(struct cdp_vdev *vdev_handle,
  6213. ol_txrx_data_tx_cb callback, void *ctxt)
  6214. {
  6215. struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle;
  6216. vdev->tx_non_std_data_callback.func = callback;
  6217. vdev->tx_non_std_data_callback.ctxt = ctxt;
  6218. }
  6219. /**
  6220. * dp_pdev_get_dp_txrx_handle() - get dp handle from pdev
  6221. * @pdev_hdl: datapath pdev handle
  6222. *
  6223. * Return: opaque pointer to dp txrx handle
  6224. */
  6225. static void *dp_pdev_get_dp_txrx_handle(struct cdp_pdev *pdev_hdl)
  6226. {
  6227. struct dp_pdev *pdev = (struct dp_pdev *)pdev_hdl;
  6228. return pdev->dp_txrx_handle;
  6229. }
  6230. /**
  6231. * dp_pdev_set_dp_txrx_handle() - set dp handle in pdev
  6232. * @pdev_hdl: datapath pdev handle
  6233. * @dp_txrx_hdl: opaque pointer for dp_txrx_handle
  6234. *
  6235. * Return: void
  6236. */
  6237. static void
  6238. dp_pdev_set_dp_txrx_handle(struct cdp_pdev *pdev_hdl, void *dp_txrx_hdl)
  6239. {
  6240. struct dp_pdev *pdev = (struct dp_pdev *)pdev_hdl;
  6241. pdev->dp_txrx_handle = dp_txrx_hdl;
  6242. }
  6243. /**
  6244. * dp_soc_get_dp_txrx_handle() - get context for external-dp from dp soc
  6245. * @soc_handle: datapath soc handle
  6246. *
  6247. * Return: opaque pointer to external dp (non-core DP)
  6248. */
  6249. static void *dp_soc_get_dp_txrx_handle(struct cdp_soc *soc_handle)
  6250. {
  6251. struct dp_soc *soc = (struct dp_soc *)soc_handle;
  6252. return soc->external_txrx_handle;
  6253. }
  6254. /**
  6255. * dp_soc_set_dp_txrx_handle() - set external dp handle in soc
  6256. * @soc_handle: datapath soc handle
  6257. * @txrx_handle: opaque pointer to external dp (non-core DP)
  6258. *
  6259. * Return: void
  6260. */
  6261. static void
  6262. dp_soc_set_dp_txrx_handle(struct cdp_soc *soc_handle, void *txrx_handle)
  6263. {
  6264. struct dp_soc *soc = (struct dp_soc *)soc_handle;
  6265. soc->external_txrx_handle = txrx_handle;
  6266. }
  6267. #ifdef FEATURE_AST
  6268. static void dp_peer_teardown_wifi3(struct cdp_vdev *vdev_hdl, void *peer_hdl)
  6269. {
  6270. struct dp_vdev *vdev = (struct dp_vdev *) vdev_hdl;
  6271. struct dp_peer *peer = (struct dp_peer *) peer_hdl;
  6272. struct dp_soc *soc = (struct dp_soc *) vdev->pdev->soc;
  6273. /*
  6274. * For BSS peer, new peer is not created on alloc_node if the
  6275. * peer with same address already exists , instead refcnt is
  6276. * increased for existing peer. Correspondingly in delete path,
  6277. * only refcnt is decreased; and peer is only deleted , when all
  6278. * references are deleted. So delete_in_progress should not be set
  6279. * for bss_peer, unless only 2 reference remains (peer map reference
  6280. * and peer hash table reference).
  6281. */
  6282. if (peer->bss_peer && (qdf_atomic_read(&peer->ref_cnt) > 2)) {
  6283. return;
  6284. }
  6285. peer->delete_in_progress = true;
  6286. dp_peer_delete_ast_entries(soc, peer);
  6287. }
  6288. #endif
  6289. #ifdef ATH_SUPPORT_NAC_RSSI
  6290. static QDF_STATUS dp_config_for_nac_rssi(struct cdp_vdev *vdev_handle,
  6291. enum cdp_nac_param_cmd cmd, char *bssid, char *client_macaddr,
  6292. uint8_t chan_num)
  6293. {
  6294. struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle;
  6295. struct dp_pdev *pdev = (struct dp_pdev *)vdev->pdev;
  6296. struct dp_soc *soc = (struct dp_soc *) vdev->pdev->soc;
  6297. pdev->nac_rssi_filtering = 1;
  6298. /* Store address of NAC (neighbour peer) which will be checked
  6299. * against TA of received packets.
  6300. */
  6301. if (cmd == CDP_NAC_PARAM_ADD) {
  6302. qdf_mem_copy(vdev->cdp_nac_rssi.client_mac,
  6303. client_macaddr, DP_MAC_ADDR_LEN);
  6304. vdev->cdp_nac_rssi_enabled = 1;
  6305. } else if (cmd == CDP_NAC_PARAM_DEL) {
  6306. if (!qdf_mem_cmp(vdev->cdp_nac_rssi.client_mac,
  6307. client_macaddr, DP_MAC_ADDR_LEN)) {
  6308. /* delete this peer from the list */
  6309. qdf_mem_zero(vdev->cdp_nac_rssi.client_mac,
  6310. DP_MAC_ADDR_LEN);
  6311. }
  6312. vdev->cdp_nac_rssi_enabled = 0;
  6313. }
  6314. if (soc->cdp_soc.ol_ops->config_bssid_in_fw_for_nac_rssi)
  6315. soc->cdp_soc.ol_ops->config_bssid_in_fw_for_nac_rssi
  6316. ((void *)vdev->pdev->ctrl_pdev,
  6317. vdev->vdev_id, cmd, bssid);
  6318. return QDF_STATUS_SUCCESS;
  6319. }
  6320. #endif
  6321. static QDF_STATUS dp_peer_map_attach_wifi3(struct cdp_soc_t *soc_hdl,
  6322. uint32_t max_peers)
  6323. {
  6324. struct dp_soc *soc = (struct dp_soc *)soc_hdl;
  6325. soc->max_peers = max_peers;
  6326. qdf_print ("%s max_peers %u\n", __func__, max_peers);
  6327. if (dp_peer_find_attach(soc))
  6328. return QDF_STATUS_E_FAILURE;
  6329. return QDF_STATUS_SUCCESS;
  6330. }
  6331. /**
  6332. * dp_pdev_set_ctrl_pdev() - set ctrl pdev handle in dp pdev
  6333. * @dp_pdev: dp pdev handle
  6334. * @ctrl_pdev: UMAC ctrl pdev handle
  6335. *
  6336. * Return: void
  6337. */
  6338. static void dp_pdev_set_ctrl_pdev(struct cdp_pdev *dp_pdev,
  6339. struct cdp_ctrl_objmgr_pdev *ctrl_pdev)
  6340. {
  6341. struct dp_pdev *pdev = (struct dp_pdev *)dp_pdev;
  6342. pdev->ctrl_pdev = ctrl_pdev;
  6343. }
  6344. static struct cdp_cmn_ops dp_ops_cmn = {
  6345. .txrx_soc_attach_target = dp_soc_attach_target_wifi3,
  6346. .txrx_vdev_attach = dp_vdev_attach_wifi3,
  6347. .txrx_vdev_detach = dp_vdev_detach_wifi3,
  6348. .txrx_pdev_attach = dp_pdev_attach_wifi3,
  6349. .txrx_pdev_detach = dp_pdev_detach_wifi3,
  6350. .txrx_peer_create = dp_peer_create_wifi3,
  6351. .txrx_peer_setup = dp_peer_setup_wifi3,
  6352. #ifdef FEATURE_AST
  6353. .txrx_peer_teardown = dp_peer_teardown_wifi3,
  6354. #else
  6355. .txrx_peer_teardown = NULL,
  6356. #endif
  6357. .txrx_peer_add_ast = dp_peer_add_ast_wifi3,
  6358. .txrx_peer_del_ast = dp_peer_del_ast_wifi3,
  6359. .txrx_peer_update_ast = dp_peer_update_ast_wifi3,
  6360. .txrx_peer_ast_hash_find = dp_peer_ast_hash_find_wifi3,
  6361. .txrx_peer_ast_get_pdev_id = dp_peer_ast_get_pdev_id_wifi3,
  6362. .txrx_peer_ast_get_next_hop = dp_peer_ast_get_next_hop_wifi3,
  6363. .txrx_peer_ast_set_type = dp_peer_ast_set_type_wifi3,
  6364. .txrx_peer_delete = dp_peer_delete_wifi3,
  6365. .txrx_vdev_register = dp_vdev_register_wifi3,
  6366. .txrx_soc_detach = dp_soc_detach_wifi3,
  6367. .txrx_get_vdev_mac_addr = dp_get_vdev_mac_addr_wifi3,
  6368. .txrx_get_vdev_from_vdev_id = dp_get_vdev_from_vdev_id_wifi3,
  6369. .txrx_get_ctrl_pdev_from_vdev = dp_get_ctrl_pdev_from_vdev_wifi3,
  6370. .txrx_ath_getstats = dp_get_device_stats,
  6371. .addba_requestprocess = dp_addba_requestprocess_wifi3,
  6372. .addba_responsesetup = dp_addba_responsesetup_wifi3,
  6373. .delba_process = dp_delba_process_wifi3,
  6374. .set_addba_response = dp_set_addba_response,
  6375. .get_peer_mac_addr_frm_id = dp_get_peer_mac_addr_frm_id,
  6376. .flush_cache_rx_queue = NULL,
  6377. /* TODO: get API's for dscp-tid need to be added*/
  6378. .set_vdev_dscp_tid_map = dp_set_vdev_dscp_tid_map_wifi3,
  6379. .set_pdev_dscp_tid_map = dp_set_pdev_dscp_tid_map_wifi3,
  6380. .txrx_stats_request = dp_txrx_stats_request,
  6381. .txrx_set_monitor_mode = dp_vdev_set_monitor_mode,
  6382. .txrx_get_pdev_id_frm_pdev = dp_get_pdev_id_frm_pdev,
  6383. .txrx_set_nac = dp_set_nac,
  6384. .txrx_get_tx_pending = dp_get_tx_pending,
  6385. .txrx_set_pdev_tx_capture = dp_config_debug_sniffer,
  6386. .txrx_get_peer_mac_from_peer_id = dp_get_peer_mac_from_peer_id,
  6387. .display_stats = dp_txrx_dump_stats,
  6388. .txrx_soc_set_nss_cfg = dp_soc_set_nss_cfg_wifi3,
  6389. .txrx_soc_get_nss_cfg = dp_soc_get_nss_cfg_wifi3,
  6390. .txrx_intr_attach = dp_soc_interrupt_attach_wrapper,
  6391. .txrx_intr_detach = dp_soc_interrupt_detach,
  6392. .set_pn_check = dp_set_pn_check_wifi3,
  6393. .update_config_parameters = dp_update_config_parameters,
  6394. /* TODO: Add other functions */
  6395. .txrx_data_tx_cb_set = dp_txrx_data_tx_cb_set,
  6396. .get_dp_txrx_handle = dp_pdev_get_dp_txrx_handle,
  6397. .set_dp_txrx_handle = dp_pdev_set_dp_txrx_handle,
  6398. .get_soc_dp_txrx_handle = dp_soc_get_dp_txrx_handle,
  6399. .set_soc_dp_txrx_handle = dp_soc_set_dp_txrx_handle,
  6400. .tx_send = dp_tx_send,
  6401. .txrx_peer_reset_ast = dp_wds_reset_ast_wifi3,
  6402. .txrx_peer_reset_ast_table = dp_wds_reset_ast_table_wifi3,
  6403. .txrx_peer_flush_ast_table = dp_wds_flush_ast_table_wifi3,
  6404. .txrx_peer_map_attach = dp_peer_map_attach_wifi3,
  6405. .txrx_pdev_set_ctrl_pdev = dp_pdev_set_ctrl_pdev,
  6406. };
  6407. static struct cdp_ctrl_ops dp_ops_ctrl = {
  6408. .txrx_peer_authorize = dp_peer_authorize,
  6409. #ifdef QCA_SUPPORT_SON
  6410. .txrx_set_inact_params = dp_set_inact_params,
  6411. .txrx_start_inact_timer = dp_start_inact_timer,
  6412. .txrx_set_overload = dp_set_overload,
  6413. .txrx_peer_is_inact = dp_peer_is_inact,
  6414. .txrx_mark_peer_inact = dp_mark_peer_inact,
  6415. #endif
  6416. .txrx_set_vdev_rx_decap_type = dp_set_vdev_rx_decap_type,
  6417. .txrx_set_tx_encap_type = dp_set_vdev_tx_encap_type,
  6418. #ifdef MESH_MODE_SUPPORT
  6419. .txrx_set_mesh_mode = dp_peer_set_mesh_mode,
  6420. .txrx_set_mesh_rx_filter = dp_peer_set_mesh_rx_filter,
  6421. #endif
  6422. .txrx_set_vdev_param = dp_set_vdev_param,
  6423. .txrx_peer_set_nawds = dp_peer_set_nawds,
  6424. .txrx_set_pdev_reo_dest = dp_set_pdev_reo_dest,
  6425. .txrx_get_pdev_reo_dest = dp_get_pdev_reo_dest,
  6426. .txrx_set_filter_neighbour_peers = dp_set_filter_neighbour_peers,
  6427. .txrx_update_filter_neighbour_peers =
  6428. dp_update_filter_neighbour_peers,
  6429. .txrx_get_sec_type = dp_get_sec_type,
  6430. /* TODO: Add other functions */
  6431. .txrx_wdi_event_sub = dp_wdi_event_sub,
  6432. .txrx_wdi_event_unsub = dp_wdi_event_unsub,
  6433. #ifdef WDI_EVENT_ENABLE
  6434. .txrx_get_pldev = dp_get_pldev,
  6435. #endif
  6436. .txrx_set_pdev_param = dp_set_pdev_param,
  6437. #ifdef ATH_SUPPORT_NAC_RSSI
  6438. .txrx_vdev_config_for_nac_rssi = dp_config_for_nac_rssi,
  6439. #endif
  6440. .set_key = dp_set_michael_key,
  6441. };
  6442. static struct cdp_me_ops dp_ops_me = {
  6443. #ifdef ATH_SUPPORT_IQUE
  6444. .tx_me_alloc_descriptor = dp_tx_me_alloc_descriptor,
  6445. .tx_me_free_descriptor = dp_tx_me_free_descriptor,
  6446. .tx_me_convert_ucast = dp_tx_me_send_convert_ucast,
  6447. #endif
  6448. };
  6449. static struct cdp_mon_ops dp_ops_mon = {
  6450. .txrx_monitor_set_filter_ucast_data = NULL,
  6451. .txrx_monitor_set_filter_mcast_data = NULL,
  6452. .txrx_monitor_set_filter_non_data = NULL,
  6453. .txrx_monitor_get_filter_ucast_data = dp_vdev_get_filter_ucast_data,
  6454. .txrx_monitor_get_filter_mcast_data = dp_vdev_get_filter_mcast_data,
  6455. .txrx_monitor_get_filter_non_data = dp_vdev_get_filter_non_data,
  6456. .txrx_reset_monitor_mode = dp_reset_monitor_mode,
  6457. /* Added support for HK advance filter */
  6458. .txrx_set_advance_monitor_filter = dp_pdev_set_advance_monitor_filter,
  6459. };
  6460. static struct cdp_host_stats_ops dp_ops_host_stats = {
  6461. .txrx_per_peer_stats = dp_get_host_peer_stats,
  6462. .get_fw_peer_stats = dp_get_fw_peer_stats,
  6463. .get_htt_stats = dp_get_htt_stats,
  6464. .txrx_enable_enhanced_stats = dp_enable_enhanced_stats,
  6465. .txrx_disable_enhanced_stats = dp_disable_enhanced_stats,
  6466. .txrx_stats_publish = dp_txrx_stats_publish,
  6467. /* TODO */
  6468. };
  6469. static struct cdp_raw_ops dp_ops_raw = {
  6470. /* TODO */
  6471. };
  6472. #ifdef CONFIG_WIN
  6473. static struct cdp_pflow_ops dp_ops_pflow = {
  6474. /* TODO */
  6475. };
  6476. #endif /* CONFIG_WIN */
  6477. #ifdef FEATURE_RUNTIME_PM
  6478. /**
  6479. * dp_runtime_suspend() - ensure DP is ready to runtime suspend
  6480. * @opaque_pdev: DP pdev context
  6481. *
  6482. * DP is ready to runtime suspend if there are no pending TX packets.
  6483. *
  6484. * Return: QDF_STATUS
  6485. */
  6486. static QDF_STATUS dp_runtime_suspend(struct cdp_pdev *opaque_pdev)
  6487. {
  6488. struct dp_pdev *pdev = (struct dp_pdev *)opaque_pdev;
  6489. struct dp_soc *soc = pdev->soc;
  6490. /* Call DP TX flow control API to check if there is any
  6491. pending packets */
  6492. if (soc->intr_mode == DP_INTR_POLL)
  6493. qdf_timer_stop(&soc->int_timer);
  6494. return QDF_STATUS_SUCCESS;
  6495. }
  6496. /**
  6497. * dp_runtime_resume() - ensure DP is ready to runtime resume
  6498. * @opaque_pdev: DP pdev context
  6499. *
  6500. * Resume DP for runtime PM.
  6501. *
  6502. * Return: QDF_STATUS
  6503. */
  6504. static QDF_STATUS dp_runtime_resume(struct cdp_pdev *opaque_pdev)
  6505. {
  6506. struct dp_pdev *pdev = (struct dp_pdev *)opaque_pdev;
  6507. struct dp_soc *soc = pdev->soc;
  6508. void *hal_srng;
  6509. int i;
  6510. if (soc->intr_mode == DP_INTR_POLL)
  6511. qdf_timer_mod(&soc->int_timer, DP_INTR_POLL_TIMER_MS);
  6512. for (i = 0; i < MAX_TCL_DATA_RINGS; i++) {
  6513. hal_srng = soc->tcl_data_ring[i].hal_srng;
  6514. if (hal_srng) {
  6515. /* We actually only need to acquire the lock */
  6516. hal_srng_access_start(soc->hal_soc, hal_srng);
  6517. /* Update SRC ring head pointer for HW to send
  6518. all pending packets */
  6519. hal_srng_access_end(soc->hal_soc, hal_srng);
  6520. }
  6521. }
  6522. return QDF_STATUS_SUCCESS;
  6523. }
  6524. #endif /* FEATURE_RUNTIME_PM */
  6525. static QDF_STATUS dp_bus_suspend(struct cdp_pdev *opaque_pdev)
  6526. {
  6527. struct dp_pdev *pdev = (struct dp_pdev *)opaque_pdev;
  6528. struct dp_soc *soc = pdev->soc;
  6529. if (soc->intr_mode == DP_INTR_POLL)
  6530. qdf_timer_stop(&soc->int_timer);
  6531. return QDF_STATUS_SUCCESS;
  6532. }
  6533. static QDF_STATUS dp_bus_resume(struct cdp_pdev *opaque_pdev)
  6534. {
  6535. struct dp_pdev *pdev = (struct dp_pdev *)opaque_pdev;
  6536. struct dp_soc *soc = pdev->soc;
  6537. if (soc->intr_mode == DP_INTR_POLL)
  6538. qdf_timer_mod(&soc->int_timer, DP_INTR_POLL_TIMER_MS);
  6539. return QDF_STATUS_SUCCESS;
  6540. }
  6541. #ifndef CONFIG_WIN
  6542. static struct cdp_misc_ops dp_ops_misc = {
  6543. .tx_non_std = dp_tx_non_std,
  6544. .get_opmode = dp_get_opmode,
  6545. #ifdef FEATURE_RUNTIME_PM
  6546. .runtime_suspend = dp_runtime_suspend,
  6547. .runtime_resume = dp_runtime_resume,
  6548. #endif /* FEATURE_RUNTIME_PM */
  6549. .pkt_log_init = dp_pkt_log_init,
  6550. .pkt_log_con_service = dp_pkt_log_con_service,
  6551. };
  6552. static struct cdp_flowctl_ops dp_ops_flowctl = {
  6553. /* WIFI 3.0 DP implement as required. */
  6554. #ifdef QCA_LL_TX_FLOW_CONTROL_V2
  6555. .flow_pool_map_handler = dp_tx_flow_pool_map,
  6556. .flow_pool_unmap_handler = dp_tx_flow_pool_unmap,
  6557. .register_pause_cb = dp_txrx_register_pause_cb,
  6558. .dump_flow_pool_info = dp_tx_dump_flow_pool_info,
  6559. #endif /* QCA_LL_TX_FLOW_CONTROL_V2 */
  6560. };
  6561. static struct cdp_lflowctl_ops dp_ops_l_flowctl = {
  6562. /* WIFI 3.0 DP NOT IMPLEMENTED YET */
  6563. };
  6564. #ifdef IPA_OFFLOAD
  6565. static struct cdp_ipa_ops dp_ops_ipa = {
  6566. .ipa_get_resource = dp_ipa_get_resource,
  6567. .ipa_set_doorbell_paddr = dp_ipa_set_doorbell_paddr,
  6568. .ipa_op_response = dp_ipa_op_response,
  6569. .ipa_register_op_cb = dp_ipa_register_op_cb,
  6570. .ipa_get_stat = dp_ipa_get_stat,
  6571. .ipa_tx_data_frame = dp_tx_send_ipa_data_frame,
  6572. .ipa_enable_autonomy = dp_ipa_enable_autonomy,
  6573. .ipa_disable_autonomy = dp_ipa_disable_autonomy,
  6574. .ipa_setup = dp_ipa_setup,
  6575. .ipa_cleanup = dp_ipa_cleanup,
  6576. .ipa_setup_iface = dp_ipa_setup_iface,
  6577. .ipa_cleanup_iface = dp_ipa_cleanup_iface,
  6578. .ipa_enable_pipes = dp_ipa_enable_pipes,
  6579. .ipa_disable_pipes = dp_ipa_disable_pipes,
  6580. .ipa_set_perf_level = dp_ipa_set_perf_level
  6581. };
  6582. #endif
  6583. static struct cdp_bus_ops dp_ops_bus = {
  6584. .bus_suspend = dp_bus_suspend,
  6585. .bus_resume = dp_bus_resume
  6586. };
  6587. static struct cdp_ocb_ops dp_ops_ocb = {
  6588. /* WIFI 3.0 DP NOT IMPLEMENTED YET */
  6589. };
  6590. static struct cdp_throttle_ops dp_ops_throttle = {
  6591. /* WIFI 3.0 DP NOT IMPLEMENTED YET */
  6592. };
  6593. static struct cdp_mob_stats_ops dp_ops_mob_stats = {
  6594. /* WIFI 3.0 DP NOT IMPLEMENTED YET */
  6595. };
  6596. static struct cdp_cfg_ops dp_ops_cfg = {
  6597. /* WIFI 3.0 DP NOT IMPLEMENTED YET */
  6598. };
  6599. /*
  6600. * dp_wrapper_peer_get_ref_by_addr - wrapper function to get to peer
  6601. * @dev: physical device instance
  6602. * @peer_mac_addr: peer mac address
  6603. * @local_id: local id for the peer
  6604. * @debug_id: to track enum peer access
  6605. * Return: peer instance pointer
  6606. */
  6607. static inline void *
  6608. dp_wrapper_peer_get_ref_by_addr(struct cdp_pdev *dev, u8 *peer_mac_addr,
  6609. u8 *local_id,
  6610. enum peer_debug_id_type debug_id)
  6611. {
  6612. /*
  6613. * Currently this function does not implement the "get ref"
  6614. * functionality and is mapped to dp_find_peer_by_addr which does not
  6615. * increment the peer ref count. So the peer state is uncertain after
  6616. * calling this API. The functionality needs to be implemented.
  6617. * Accordingly the corresponding release_ref function is NULL.
  6618. */
  6619. return dp_find_peer_by_addr(dev, peer_mac_addr, local_id);
  6620. }
  6621. static struct cdp_peer_ops dp_ops_peer = {
  6622. .register_peer = dp_register_peer,
  6623. .clear_peer = dp_clear_peer,
  6624. .find_peer_by_addr = dp_find_peer_by_addr,
  6625. .find_peer_by_addr_and_vdev = dp_find_peer_by_addr_and_vdev,
  6626. .peer_get_ref_by_addr = dp_wrapper_peer_get_ref_by_addr,
  6627. .peer_release_ref = NULL,
  6628. .local_peer_id = dp_local_peer_id,
  6629. .peer_find_by_local_id = dp_peer_find_by_local_id,
  6630. .peer_state_update = dp_peer_state_update,
  6631. .get_vdevid = dp_get_vdevid,
  6632. .get_vdev_by_sta_id = dp_get_vdev_by_sta_id,
  6633. .peer_get_peer_mac_addr = dp_peer_get_peer_mac_addr,
  6634. .get_vdev_for_peer = dp_get_vdev_for_peer,
  6635. .get_peer_state = dp_get_peer_state,
  6636. .get_last_mgmt_timestamp = dp_get_last_mgmt_timestamp,
  6637. .update_last_mgmt_timestamp = dp_update_last_mgmt_timestamp,
  6638. };
  6639. #endif
  6640. static struct cdp_ops dp_txrx_ops = {
  6641. .cmn_drv_ops = &dp_ops_cmn,
  6642. .ctrl_ops = &dp_ops_ctrl,
  6643. .me_ops = &dp_ops_me,
  6644. .mon_ops = &dp_ops_mon,
  6645. .host_stats_ops = &dp_ops_host_stats,
  6646. .wds_ops = &dp_ops_wds,
  6647. .raw_ops = &dp_ops_raw,
  6648. #ifdef CONFIG_WIN
  6649. .pflow_ops = &dp_ops_pflow,
  6650. #endif /* CONFIG_WIN */
  6651. #ifndef CONFIG_WIN
  6652. .misc_ops = &dp_ops_misc,
  6653. .cfg_ops = &dp_ops_cfg,
  6654. .flowctl_ops = &dp_ops_flowctl,
  6655. .l_flowctl_ops = &dp_ops_l_flowctl,
  6656. #ifdef IPA_OFFLOAD
  6657. .ipa_ops = &dp_ops_ipa,
  6658. #endif
  6659. .bus_ops = &dp_ops_bus,
  6660. .ocb_ops = &dp_ops_ocb,
  6661. .peer_ops = &dp_ops_peer,
  6662. .throttle_ops = &dp_ops_throttle,
  6663. .mob_stats_ops = &dp_ops_mob_stats,
  6664. #endif
  6665. };
  6666. /*
  6667. * dp_soc_set_txrx_ring_map()
  6668. * @dp_soc: DP handler for soc
  6669. *
  6670. * Return: Void
  6671. */
  6672. static void dp_soc_set_txrx_ring_map(struct dp_soc *soc)
  6673. {
  6674. uint32_t i;
  6675. for (i = 0; i < WLAN_CFG_INT_NUM_CONTEXTS; i++) {
  6676. soc->tx_ring_map[i] = dp_cpu_ring_map[DP_DEFAULT_MAP][i];
  6677. }
  6678. }
  6679. /*
  6680. * dp_soc_attach_wifi3() - Attach txrx SOC
  6681. * @ctrl_psoc: Opaque SOC handle from control plane
  6682. * @htc_handle: Opaque HTC handle
  6683. * @hif_handle: Opaque HIF handle
  6684. * @qdf_osdev: QDF device
  6685. *
  6686. * Return: DP SOC handle on success, NULL on failure
  6687. */
  6688. /*
  6689. * Local prototype added to temporarily address warning caused by
  6690. * -Wmissing-prototypes. A more correct solution, namely to expose
  6691. * a prototype in an appropriate header file, will come later.
  6692. */
  6693. void *dp_soc_attach_wifi3(void *ctrl_psoc, void *hif_handle,
  6694. HTC_HANDLE htc_handle, qdf_device_t qdf_osdev,
  6695. struct ol_if_ops *ol_ops);
  6696. void *dp_soc_attach_wifi3(void *ctrl_psoc, void *hif_handle,
  6697. HTC_HANDLE htc_handle, qdf_device_t qdf_osdev,
  6698. struct ol_if_ops *ol_ops)
  6699. {
  6700. struct dp_soc *soc = qdf_mem_malloc(sizeof(*soc));
  6701. int target_type;
  6702. if (!soc) {
  6703. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  6704. FL("DP SOC memory allocation failed"));
  6705. goto fail0;
  6706. }
  6707. soc->cdp_soc.ops = &dp_txrx_ops;
  6708. soc->cdp_soc.ol_ops = ol_ops;
  6709. soc->ctrl_psoc = ctrl_psoc;
  6710. soc->osdev = qdf_osdev;
  6711. soc->hif_handle = hif_handle;
  6712. soc->hal_soc = hif_get_hal_handle(hif_handle);
  6713. soc->htt_handle = htt_soc_attach(soc, ctrl_psoc, htc_handle,
  6714. soc->hal_soc, qdf_osdev);
  6715. if (!soc->htt_handle) {
  6716. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  6717. FL("HTT attach failed"));
  6718. goto fail1;
  6719. }
  6720. soc->wlan_cfg_ctx = wlan_cfg_soc_attach(soc->ctrl_psoc);
  6721. if (!soc->wlan_cfg_ctx) {
  6722. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  6723. FL("wlan_cfg_soc_attach failed"));
  6724. goto fail2;
  6725. }
  6726. target_type = hal_get_target_type(soc->hal_soc);
  6727. switch (target_type) {
  6728. case TARGET_TYPE_QCA6290:
  6729. #ifdef QCA_WIFI_QCA6390
  6730. case TARGET_TYPE_QCA6390:
  6731. #endif
  6732. wlan_cfg_set_reo_dst_ring_size(soc->wlan_cfg_ctx,
  6733. REO_DST_RING_SIZE_QCA6290);
  6734. break;
  6735. case TARGET_TYPE_QCA8074:
  6736. wlan_cfg_set_reo_dst_ring_size(soc->wlan_cfg_ctx,
  6737. REO_DST_RING_SIZE_QCA8074);
  6738. break;
  6739. default:
  6740. qdf_print("%s: Unknown tgt type %d\n", __func__, target_type);
  6741. qdf_assert_always(0);
  6742. break;
  6743. }
  6744. wlan_cfg_set_rx_hash(soc->wlan_cfg_ctx,
  6745. cfg_get(ctrl_psoc, CFG_DP_RX_HASH));
  6746. soc->cce_disable = false;
  6747. if (soc->cdp_soc.ol_ops->get_dp_cfg_param) {
  6748. int ret = soc->cdp_soc.ol_ops->get_dp_cfg_param(soc->ctrl_psoc,
  6749. CDP_CFG_MAX_PEER_ID);
  6750. if (ret != -EINVAL) {
  6751. wlan_cfg_set_max_peer_id(soc->wlan_cfg_ctx, ret);
  6752. }
  6753. ret = soc->cdp_soc.ol_ops->get_dp_cfg_param(soc->ctrl_psoc,
  6754. CDP_CFG_CCE_DISABLE);
  6755. if (ret == 1)
  6756. soc->cce_disable = true;
  6757. }
  6758. qdf_spinlock_create(&soc->peer_ref_mutex);
  6759. qdf_spinlock_create(&soc->reo_desc_freelist_lock);
  6760. qdf_list_create(&soc->reo_desc_freelist, REO_DESC_FREELIST_SIZE);
  6761. /* fill the tx/rx cpu ring map*/
  6762. dp_soc_set_txrx_ring_map(soc);
  6763. qdf_spinlock_create(&soc->htt_stats.lock);
  6764. /* initialize work queue for stats processing */
  6765. qdf_create_work(0, &soc->htt_stats.work, htt_t2h_stats_handler, soc);
  6766. /*Initialize inactivity timer for wifison */
  6767. dp_init_inact_timer(soc);
  6768. return (void *)soc;
  6769. fail2:
  6770. htt_soc_detach(soc->htt_handle);
  6771. fail1:
  6772. qdf_mem_free(soc);
  6773. fail0:
  6774. return NULL;
  6775. }
  6776. /*
  6777. * dp_get_pdev_for_mac_id() - Return pdev for mac_id
  6778. *
  6779. * @soc: handle to DP soc
  6780. * @mac_id: MAC id
  6781. *
  6782. * Return: Return pdev corresponding to MAC
  6783. */
  6784. void *dp_get_pdev_for_mac_id(struct dp_soc *soc, uint32_t mac_id)
  6785. {
  6786. if (wlan_cfg_per_pdev_lmac_ring(soc->wlan_cfg_ctx))
  6787. return soc->pdev_list[mac_id];
  6788. /* Typically for MCL as there only 1 PDEV*/
  6789. return soc->pdev_list[0];
  6790. }
  6791. /*
  6792. * dp_is_hw_dbs_enable() - Procedure to check if DBS is supported
  6793. * @soc: DP SoC context
  6794. * @max_mac_rings: No of MAC rings
  6795. *
  6796. * Return: None
  6797. */
  6798. static
  6799. void dp_is_hw_dbs_enable(struct dp_soc *soc,
  6800. int *max_mac_rings)
  6801. {
  6802. bool dbs_enable = false;
  6803. if (soc->cdp_soc.ol_ops->is_hw_dbs_2x2_capable)
  6804. dbs_enable = soc->cdp_soc.ol_ops->
  6805. is_hw_dbs_2x2_capable(soc->ctrl_psoc);
  6806. *max_mac_rings = (dbs_enable)?(*max_mac_rings):1;
  6807. }
  6808. /*
  6809. * dp_set_pktlog_wifi3() - attach txrx vdev
  6810. * @pdev: Datapath PDEV handle
  6811. * @event: which event's notifications are being subscribed to
  6812. * @enable: WDI event subscribe or not. (True or False)
  6813. *
  6814. * Return: Success, NULL on failure
  6815. */
  6816. #ifdef WDI_EVENT_ENABLE
  6817. int dp_set_pktlog_wifi3(struct dp_pdev *pdev, uint32_t event,
  6818. bool enable)
  6819. {
  6820. struct dp_soc *soc = pdev->soc;
  6821. struct htt_rx_ring_tlv_filter htt_tlv_filter = {0};
  6822. int max_mac_rings = wlan_cfg_get_num_mac_rings
  6823. (pdev->wlan_cfg_ctx);
  6824. uint8_t mac_id = 0;
  6825. dp_is_hw_dbs_enable(soc, &max_mac_rings);
  6826. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_DEBUG,
  6827. FL("Max_mac_rings %d \n"),
  6828. max_mac_rings);
  6829. if (enable) {
  6830. switch (event) {
  6831. case WDI_EVENT_RX_DESC:
  6832. if (pdev->monitor_vdev) {
  6833. /* Nothing needs to be done if monitor mode is
  6834. * enabled
  6835. */
  6836. return 0;
  6837. }
  6838. if (pdev->rx_pktlog_mode != DP_RX_PKTLOG_FULL) {
  6839. pdev->rx_pktlog_mode = DP_RX_PKTLOG_FULL;
  6840. htt_tlv_filter.mpdu_start = 1;
  6841. htt_tlv_filter.msdu_start = 1;
  6842. htt_tlv_filter.msdu_end = 1;
  6843. htt_tlv_filter.mpdu_end = 1;
  6844. htt_tlv_filter.packet_header = 1;
  6845. htt_tlv_filter.attention = 1;
  6846. htt_tlv_filter.ppdu_start = 1;
  6847. htt_tlv_filter.ppdu_end = 1;
  6848. htt_tlv_filter.ppdu_end_user_stats = 1;
  6849. htt_tlv_filter.ppdu_end_user_stats_ext = 1;
  6850. htt_tlv_filter.ppdu_end_status_done = 1;
  6851. htt_tlv_filter.enable_fp = 1;
  6852. htt_tlv_filter.fp_mgmt_filter = FILTER_MGMT_ALL;
  6853. htt_tlv_filter.fp_ctrl_filter = FILTER_CTRL_ALL;
  6854. htt_tlv_filter.fp_data_filter = FILTER_DATA_ALL;
  6855. htt_tlv_filter.mo_mgmt_filter = FILTER_MGMT_ALL;
  6856. htt_tlv_filter.mo_ctrl_filter = FILTER_CTRL_ALL;
  6857. htt_tlv_filter.mo_data_filter = FILTER_DATA_ALL;
  6858. for (mac_id = 0; mac_id < max_mac_rings;
  6859. mac_id++) {
  6860. int mac_for_pdev =
  6861. dp_get_mac_id_for_pdev(mac_id,
  6862. pdev->pdev_id);
  6863. htt_h2t_rx_ring_cfg(soc->htt_handle,
  6864. mac_for_pdev,
  6865. pdev->rxdma_mon_status_ring[mac_id]
  6866. .hal_srng,
  6867. RXDMA_MONITOR_STATUS,
  6868. RX_BUFFER_SIZE,
  6869. &htt_tlv_filter);
  6870. }
  6871. if (soc->reap_timer_init)
  6872. qdf_timer_mod(&soc->mon_reap_timer,
  6873. DP_INTR_POLL_TIMER_MS);
  6874. }
  6875. break;
  6876. case WDI_EVENT_LITE_RX:
  6877. if (pdev->monitor_vdev) {
  6878. /* Nothing needs to be done if monitor mode is
  6879. * enabled
  6880. */
  6881. return 0;
  6882. }
  6883. if (pdev->rx_pktlog_mode != DP_RX_PKTLOG_LITE) {
  6884. pdev->rx_pktlog_mode = DP_RX_PKTLOG_LITE;
  6885. htt_tlv_filter.ppdu_start = 1;
  6886. htt_tlv_filter.ppdu_end = 1;
  6887. htt_tlv_filter.ppdu_end_user_stats = 1;
  6888. htt_tlv_filter.ppdu_end_user_stats_ext = 1;
  6889. htt_tlv_filter.ppdu_end_status_done = 1;
  6890. htt_tlv_filter.mpdu_start = 1;
  6891. htt_tlv_filter.enable_fp = 1;
  6892. htt_tlv_filter.fp_mgmt_filter = FILTER_MGMT_ALL;
  6893. htt_tlv_filter.fp_ctrl_filter = FILTER_CTRL_ALL;
  6894. htt_tlv_filter.fp_data_filter = FILTER_DATA_ALL;
  6895. htt_tlv_filter.mo_mgmt_filter = FILTER_MGMT_ALL;
  6896. htt_tlv_filter.mo_ctrl_filter = FILTER_CTRL_ALL;
  6897. htt_tlv_filter.mo_data_filter = FILTER_DATA_ALL;
  6898. for (mac_id = 0; mac_id < max_mac_rings;
  6899. mac_id++) {
  6900. int mac_for_pdev =
  6901. dp_get_mac_id_for_pdev(mac_id,
  6902. pdev->pdev_id);
  6903. htt_h2t_rx_ring_cfg(soc->htt_handle,
  6904. mac_for_pdev,
  6905. pdev->rxdma_mon_status_ring[mac_id]
  6906. .hal_srng,
  6907. RXDMA_MONITOR_STATUS,
  6908. RX_BUFFER_SIZE_PKTLOG_LITE,
  6909. &htt_tlv_filter);
  6910. }
  6911. if (soc->reap_timer_init)
  6912. qdf_timer_mod(&soc->mon_reap_timer,
  6913. DP_INTR_POLL_TIMER_MS);
  6914. }
  6915. break;
  6916. case WDI_EVENT_LITE_T2H:
  6917. if (pdev->monitor_vdev) {
  6918. /* Nothing needs to be done if monitor mode is
  6919. * enabled
  6920. */
  6921. return 0;
  6922. }
  6923. for (mac_id = 0; mac_id < max_mac_rings; mac_id++) {
  6924. int mac_for_pdev = dp_get_mac_id_for_pdev(
  6925. mac_id, pdev->pdev_id);
  6926. pdev->pktlog_ppdu_stats = true;
  6927. dp_h2t_cfg_stats_msg_send(pdev,
  6928. DP_PPDU_TXLITE_STATS_BITMASK_CFG,
  6929. mac_for_pdev);
  6930. }
  6931. break;
  6932. default:
  6933. /* Nothing needs to be done for other pktlog types */
  6934. break;
  6935. }
  6936. } else {
  6937. switch (event) {
  6938. case WDI_EVENT_RX_DESC:
  6939. case WDI_EVENT_LITE_RX:
  6940. if (pdev->monitor_vdev) {
  6941. /* Nothing needs to be done if monitor mode is
  6942. * enabled
  6943. */
  6944. return 0;
  6945. }
  6946. if (pdev->rx_pktlog_mode != DP_RX_PKTLOG_DISABLED) {
  6947. pdev->rx_pktlog_mode = DP_RX_PKTLOG_DISABLED;
  6948. for (mac_id = 0; mac_id < max_mac_rings;
  6949. mac_id++) {
  6950. int mac_for_pdev =
  6951. dp_get_mac_id_for_pdev(mac_id,
  6952. pdev->pdev_id);
  6953. htt_h2t_rx_ring_cfg(soc->htt_handle,
  6954. mac_for_pdev,
  6955. pdev->rxdma_mon_status_ring[mac_id]
  6956. .hal_srng,
  6957. RXDMA_MONITOR_STATUS,
  6958. RX_BUFFER_SIZE,
  6959. &htt_tlv_filter);
  6960. }
  6961. if (soc->reap_timer_init)
  6962. qdf_timer_stop(&soc->mon_reap_timer);
  6963. }
  6964. break;
  6965. case WDI_EVENT_LITE_T2H:
  6966. if (pdev->monitor_vdev) {
  6967. /* Nothing needs to be done if monitor mode is
  6968. * enabled
  6969. */
  6970. return 0;
  6971. }
  6972. /* To disable HTT_H2T_MSG_TYPE_PPDU_STATS_CFG in FW
  6973. * passing value 0. Once these macros will define in htt
  6974. * header file will use proper macros
  6975. */
  6976. for (mac_id = 0; mac_id < max_mac_rings; mac_id++) {
  6977. int mac_for_pdev =
  6978. dp_get_mac_id_for_pdev(mac_id,
  6979. pdev->pdev_id);
  6980. pdev->pktlog_ppdu_stats = false;
  6981. if (!pdev->enhanced_stats_en && !pdev->tx_sniffer_enable && !pdev->mcopy_mode) {
  6982. dp_h2t_cfg_stats_msg_send(pdev, 0,
  6983. mac_for_pdev);
  6984. } else if (pdev->tx_sniffer_enable || pdev->mcopy_mode) {
  6985. dp_h2t_cfg_stats_msg_send(pdev, DP_PPDU_STATS_CFG_SNIFFER,
  6986. mac_for_pdev);
  6987. } else if (pdev->enhanced_stats_en) {
  6988. dp_h2t_cfg_stats_msg_send(pdev, DP_PPDU_STATS_CFG_ENH_STATS,
  6989. mac_for_pdev);
  6990. }
  6991. }
  6992. break;
  6993. default:
  6994. /* Nothing needs to be done for other pktlog types */
  6995. break;
  6996. }
  6997. }
  6998. return 0;
  6999. }
  7000. #endif