dp_rings_main.c 143 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259
  1. /*
  2. * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for
  6. * any purpose with or without fee is hereby granted, provided that the
  7. * above copyright notice and this permission notice appear in all
  8. * copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  11. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  12. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  13. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  14. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  15. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  16. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  17. * PERFORMANCE OF THIS SOFTWARE.
  18. */
  19. #include <wlan_ipa_obj_mgmt_api.h>
  20. #include <qdf_types.h>
  21. #include <qdf_lock.h>
  22. #include <qdf_net_types.h>
  23. #include <qdf_lro.h>
  24. #include <qdf_module.h>
  25. #include <hal_hw_headers.h>
  26. #include <hal_api.h>
  27. #include <hif.h>
  28. #include <htt.h>
  29. #include <wdi_event.h>
  30. #include <queue.h>
  31. #include "dp_types.h"
  32. #include "dp_rings.h"
  33. #include "dp_internal.h"
  34. #include "dp_tx.h"
  35. #include "dp_tx_desc.h"
  36. #include "dp_rx.h"
  37. #ifdef DP_RATETABLE_SUPPORT
  38. #include "dp_ratetable.h"
  39. #endif
  40. #include <cdp_txrx_handle.h>
  41. #include <wlan_cfg.h>
  42. #include <wlan_utility.h>
  43. #include "cdp_txrx_cmn_struct.h"
  44. #include "cdp_txrx_stats_struct.h"
  45. #include "cdp_txrx_cmn_reg.h"
  46. #include <qdf_util.h>
  47. #include "dp_peer.h"
  48. #include "htt_stats.h"
  49. #include "dp_htt.h"
  50. #include "htt_ppdu_stats.h"
  51. #include "qdf_mem.h" /* qdf_mem_malloc,free */
  52. #include "cfg_ucfg_api.h"
  53. #include <wlan_module_ids.h>
  54. #ifdef WIFI_MONITOR_SUPPORT
  55. #include <dp_mon.h>
  56. #endif
  57. #ifdef WLAN_FEATURE_STATS_EXT
  58. #define INIT_RX_HW_STATS_LOCK(_soc) \
  59. qdf_spinlock_create(&(_soc)->rx_hw_stats_lock)
  60. #define DEINIT_RX_HW_STATS_LOCK(_soc) \
  61. qdf_spinlock_destroy(&(_soc)->rx_hw_stats_lock)
  62. #else
  63. #define INIT_RX_HW_STATS_LOCK(_soc) /* no op */
  64. #define DEINIT_RX_HW_STATS_LOCK(_soc) /* no op */
  65. #endif
  66. #ifdef QCA_DP_ENABLE_TX_COMP_RING4
  67. #define TXCOMP_RING4_NUM 3
  68. #else
  69. #define TXCOMP_RING4_NUM WBM2SW_TXCOMP_RING4_NUM
  70. #endif
  71. static QDF_STATUS dp_init_tx_ring_pair_by_index(struct dp_soc *soc,
  72. uint8_t index);
  73. static void dp_deinit_tx_pair_by_index(struct dp_soc *soc, int index);
  74. static void dp_free_tx_ring_pair_by_index(struct dp_soc *soc, uint8_t index);
  75. static QDF_STATUS dp_alloc_tx_ring_pair_by_index(struct dp_soc *soc,
  76. uint8_t index);
  77. /* default_dscp_tid_map - Default DSCP-TID mapping
  78. *
  79. * DSCP TID
  80. * 000000 0
  81. * 001000 1
  82. * 010000 2
  83. * 011000 3
  84. * 100000 4
  85. * 101000 5
  86. * 110000 6
  87. * 111000 7
  88. */
  89. static uint8_t default_dscp_tid_map[DSCP_TID_MAP_MAX] = {
  90. 0, 0, 0, 0, 0, 0, 0, 0,
  91. 1, 1, 1, 1, 1, 1, 1, 1,
  92. 2, 2, 2, 2, 2, 2, 2, 2,
  93. 3, 3, 3, 3, 3, 3, 3, 3,
  94. 4, 4, 4, 4, 4, 4, 4, 4,
  95. 5, 5, 5, 5, 5, 5, 5, 5,
  96. 6, 6, 6, 6, 6, 6, 6, 6,
  97. 7, 7, 7, 7, 7, 7, 7, 7,
  98. };
  99. /* default_pcp_tid_map - Default PCP-TID mapping
  100. *
  101. * PCP TID
  102. * 000 0
  103. * 001 1
  104. * 010 2
  105. * 011 3
  106. * 100 4
  107. * 101 5
  108. * 110 6
  109. * 111 7
  110. */
  111. static uint8_t default_pcp_tid_map[PCP_TID_MAP_MAX] = {
  112. 0, 1, 2, 3, 4, 5, 6, 7,
  113. };
  114. uint8_t
  115. dp_cpu_ring_map[DP_NSS_CPU_RING_MAP_MAX][WLAN_CFG_INT_NUM_CONTEXTS_MAX] = {
  116. {0x0, 0x1, 0x2, 0x0, 0x0, 0x1, 0x2, 0x0, 0x0, 0x1, 0x2},
  117. {0x1, 0x2, 0x1, 0x2, 0x1, 0x2, 0x1, 0x2, 0x1, 0x2, 0x1},
  118. {0x0, 0x2, 0x0, 0x2, 0x0, 0x2, 0x0, 0x2, 0x0, 0x2, 0x0},
  119. {0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2},
  120. {0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3},
  121. #ifdef WLAN_TX_PKT_CAPTURE_ENH
  122. {0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1}
  123. #endif
  124. };
  125. qdf_export_symbol(dp_cpu_ring_map);
  126. /**
  127. * dp_soc_ring_if_nss_offloaded() - find if ring is offloaded to NSS
  128. * @soc: DP soc handle
  129. * @ring_type: ring type
  130. * @ring_num: ring_num
  131. *
  132. * Return: 0 if the ring is not offloaded, non-0 if it is offloaded
  133. */
  134. static uint8_t dp_soc_ring_if_nss_offloaded(struct dp_soc *soc,
  135. enum hal_ring_type ring_type,
  136. int ring_num)
  137. {
  138. uint8_t nss_config = wlan_cfg_get_dp_soc_nss_cfg(soc->wlan_cfg_ctx);
  139. uint8_t status = 0;
  140. switch (ring_type) {
  141. case WBM2SW_RELEASE:
  142. case REO_DST:
  143. case RXDMA_BUF:
  144. case REO_EXCEPTION:
  145. status = ((nss_config) & (1 << ring_num));
  146. break;
  147. default:
  148. break;
  149. }
  150. return status;
  151. }
  152. /* MCL specific functions */
  153. #if defined(DP_CON_MON)
  154. #ifdef DP_CON_MON_MSI_ENABLED
  155. /**
  156. * dp_soc_get_mon_mask_for_interrupt_mode() - get mon mode mask for intr mode
  157. * @soc: pointer to dp_soc handle
  158. * @intr_ctx_num: interrupt context number for which mon mask is needed
  159. *
  160. * For MCL, monitor mode rings are being processed in timer contexts (polled).
  161. * This function is returning 0, since in interrupt mode(softirq based RX),
  162. * we donot want to process monitor mode rings in a softirq.
  163. *
  164. * So, in case packet log is enabled for SAP/STA/P2P modes,
  165. * regular interrupt processing will not process monitor mode rings. It would be
  166. * done in a separate timer context.
  167. *
  168. * Return: 0
  169. */
  170. static inline uint32_t
  171. dp_soc_get_mon_mask_for_interrupt_mode(struct dp_soc *soc, int intr_ctx_num)
  172. {
  173. return wlan_cfg_get_rx_mon_ring_mask(soc->wlan_cfg_ctx, intr_ctx_num);
  174. }
  175. #else
  176. /**
  177. * dp_soc_get_mon_mask_for_interrupt_mode() - get mon mode mask for intr mode
  178. * @soc: pointer to dp_soc handle
  179. * @intr_ctx_num: interrupt context number for which mon mask is needed
  180. *
  181. * For MCL, monitor mode rings are being processed in timer contexts (polled).
  182. * This function is returning 0, since in interrupt mode(softirq based RX),
  183. * we donot want to process monitor mode rings in a softirq.
  184. *
  185. * So, in case packet log is enabled for SAP/STA/P2P modes,
  186. * regular interrupt processing will not process monitor mode rings. It would be
  187. * done in a separate timer context.
  188. *
  189. * Return: 0
  190. */
  191. static inline uint32_t
  192. dp_soc_get_mon_mask_for_interrupt_mode(struct dp_soc *soc, int intr_ctx_num)
  193. {
  194. return 0;
  195. }
  196. #endif
  197. #else
  198. /**
  199. * dp_soc_get_mon_mask_for_interrupt_mode() - get mon mode mask for intr mode
  200. * @soc: pointer to dp_soc handle
  201. * @intr_ctx_num: interrupt context number for which mon mask is needed
  202. *
  203. * Return: mon mask value
  204. */
  205. static inline
  206. uint32_t dp_soc_get_mon_mask_for_interrupt_mode(struct dp_soc *soc,
  207. int intr_ctx_num)
  208. {
  209. return wlan_cfg_get_rx_mon_ring_mask(soc->wlan_cfg_ctx, intr_ctx_num);
  210. }
  211. void dp_soc_reset_mon_intr_mask(struct dp_soc *soc)
  212. {
  213. int i;
  214. for (i = 0; i < wlan_cfg_get_num_contexts(soc->wlan_cfg_ctx); i++) {
  215. soc->intr_ctx[i].rx_mon_ring_mask = 0;
  216. soc->intr_ctx[i].host2rxdma_mon_ring_mask = 0;
  217. }
  218. }
  219. qdf_export_symbol(dp_soc_reset_mon_intr_mask);
  220. void dp_service_lmac_rings(void *arg)
  221. {
  222. struct dp_soc *soc = (struct dp_soc *)arg;
  223. int ring = 0, i;
  224. struct dp_pdev *pdev = NULL;
  225. union dp_rx_desc_list_elem_t *desc_list = NULL;
  226. union dp_rx_desc_list_elem_t *tail = NULL;
  227. /* Process LMAC interrupts */
  228. for (ring = 0 ; ring < MAX_NUM_LMAC_HW; ring++) {
  229. int mac_for_pdev = ring;
  230. struct dp_srng *rx_refill_buf_ring;
  231. pdev = dp_get_pdev_for_lmac_id(soc, mac_for_pdev);
  232. if (!pdev)
  233. continue;
  234. rx_refill_buf_ring = &soc->rx_refill_buf_ring[mac_for_pdev];
  235. dp_monitor_process(soc, NULL, mac_for_pdev,
  236. QCA_NAPI_BUDGET);
  237. for (i = 0;
  238. i < wlan_cfg_get_num_contexts(soc->wlan_cfg_ctx); i++)
  239. dp_rxdma_err_process(&soc->intr_ctx[i], soc,
  240. mac_for_pdev,
  241. QCA_NAPI_BUDGET);
  242. if (!dp_soc_ring_if_nss_offloaded(soc, RXDMA_BUF,
  243. mac_for_pdev))
  244. dp_rx_buffers_replenish(soc, mac_for_pdev,
  245. rx_refill_buf_ring,
  246. &soc->rx_desc_buf[mac_for_pdev],
  247. 0, &desc_list, &tail, false);
  248. }
  249. qdf_timer_mod(&soc->lmac_reap_timer, DP_INTR_POLL_TIMER_MS);
  250. }
  251. #endif
  252. /**
  253. * dp_srng_find_ring_in_mask() - find which ext_group a ring belongs
  254. * @ring_num: ring num of the ring being queried
  255. * @grp_mask: the grp_mask array for the ring type in question.
  256. *
  257. * The grp_mask array is indexed by group number and the bit fields correspond
  258. * to ring numbers. We are finding which interrupt group a ring belongs to.
  259. *
  260. * Return: the index in the grp_mask array with the ring number.
  261. * -QDF_STATUS_E_NOENT if no entry is found
  262. */
  263. static int dp_srng_find_ring_in_mask(int ring_num, uint8_t *grp_mask)
  264. {
  265. int ext_group_num;
  266. uint8_t mask = 1 << ring_num;
  267. for (ext_group_num = 0; ext_group_num < WLAN_CFG_INT_NUM_CONTEXTS;
  268. ext_group_num++) {
  269. if (mask & grp_mask[ext_group_num])
  270. return ext_group_num;
  271. }
  272. return -QDF_STATUS_E_NOENT;
  273. }
  274. /**
  275. * dp_is_msi_group_number_invalid() - check msi_group_number valid or not
  276. * @soc: dp_soc
  277. * @msi_group_number: MSI group number.
  278. * @msi_data_count: MSI data count.
  279. *
  280. * Return: true if msi_group_number is invalid.
  281. */
  282. static bool dp_is_msi_group_number_invalid(struct dp_soc *soc,
  283. int msi_group_number,
  284. int msi_data_count)
  285. {
  286. if (soc && soc->osdev && soc->osdev->dev &&
  287. pld_is_one_msi(soc->osdev->dev))
  288. return false;
  289. return msi_group_number > msi_data_count;
  290. }
  291. #ifdef WLAN_FEATURE_NEAR_FULL_IRQ
  292. /**
  293. * dp_is_reo_ring_num_in_nf_grp1() - Check if the current reo ring is part of
  294. * rx_near_full_grp1 mask
  295. * @soc: Datapath SoC Handle
  296. * @ring_num: REO ring number
  297. *
  298. * Return: 1 if the ring_num belongs to reo_nf_grp1,
  299. * 0, otherwise.
  300. */
  301. static inline int
  302. dp_is_reo_ring_num_in_nf_grp1(struct dp_soc *soc, int ring_num)
  303. {
  304. return (WLAN_CFG_RX_NEAR_FULL_IRQ_MASK_1 & (1 << ring_num));
  305. }
  306. /**
  307. * dp_is_reo_ring_num_in_nf_grp2() - Check if the current reo ring is part of
  308. * rx_near_full_grp2 mask
  309. * @soc: Datapath SoC Handle
  310. * @ring_num: REO ring number
  311. *
  312. * Return: 1 if the ring_num belongs to reo_nf_grp2,
  313. * 0, otherwise.
  314. */
  315. static inline int
  316. dp_is_reo_ring_num_in_nf_grp2(struct dp_soc *soc, int ring_num)
  317. {
  318. return (WLAN_CFG_RX_NEAR_FULL_IRQ_MASK_2 & (1 << ring_num));
  319. }
  320. /**
  321. * dp_srng_get_near_full_irq_mask() - Get near-full irq mask for a particular
  322. * ring type and number
  323. * @soc: Datapath SoC handle
  324. * @ring_type: SRNG type
  325. * @ring_num: ring num
  326. *
  327. * Return: near-full irq mask pointer
  328. */
  329. static inline
  330. uint8_t *dp_srng_get_near_full_irq_mask(struct dp_soc *soc,
  331. enum hal_ring_type ring_type,
  332. int ring_num)
  333. {
  334. struct wlan_cfg_dp_soc_ctxt *cfg_ctx = soc->wlan_cfg_ctx;
  335. uint8_t wbm2_sw_rx_rel_ring_id;
  336. uint8_t *nf_irq_mask = NULL;
  337. switch (ring_type) {
  338. case WBM2SW_RELEASE:
  339. wbm2_sw_rx_rel_ring_id =
  340. wlan_cfg_get_rx_rel_ring_id(cfg_ctx);
  341. if (ring_num != wbm2_sw_rx_rel_ring_id) {
  342. nf_irq_mask = &soc->wlan_cfg_ctx->
  343. int_tx_ring_near_full_irq_mask[0];
  344. }
  345. break;
  346. case REO_DST:
  347. if (dp_is_reo_ring_num_in_nf_grp1(soc, ring_num))
  348. nf_irq_mask =
  349. &soc->wlan_cfg_ctx->int_rx_ring_near_full_irq_1_mask[0];
  350. else if (dp_is_reo_ring_num_in_nf_grp2(soc, ring_num))
  351. nf_irq_mask =
  352. &soc->wlan_cfg_ctx->int_rx_ring_near_full_irq_2_mask[0];
  353. else
  354. qdf_assert(0);
  355. break;
  356. default:
  357. break;
  358. }
  359. return nf_irq_mask;
  360. }
  361. /**
  362. * dp_srng_set_msi2_ring_params() - Set the msi2 addr/data in the ring params
  363. * @soc: Datapath SoC handle
  364. * @ring_params: srng params handle
  365. * @msi2_addr: MSI2 addr to be set for the SRNG
  366. * @msi2_data: MSI2 data to be set for the SRNG
  367. *
  368. * Return: None
  369. */
  370. static inline
  371. void dp_srng_set_msi2_ring_params(struct dp_soc *soc,
  372. struct hal_srng_params *ring_params,
  373. qdf_dma_addr_t msi2_addr,
  374. uint32_t msi2_data)
  375. {
  376. ring_params->msi2_addr = msi2_addr;
  377. ring_params->msi2_data = msi2_data;
  378. }
  379. /**
  380. * dp_srng_msi2_setup() - Setup MSI2 details for near full IRQ of an SRNG
  381. * @soc: Datapath SoC handle
  382. * @ring_params: ring_params for SRNG
  383. * @ring_type: SENG type
  384. * @ring_num: ring number for the SRNG
  385. * @nf_msi_grp_num: near full msi group number
  386. *
  387. * Return: None
  388. */
  389. static inline void
  390. dp_srng_msi2_setup(struct dp_soc *soc,
  391. struct hal_srng_params *ring_params,
  392. int ring_type, int ring_num, int nf_msi_grp_num)
  393. {
  394. uint32_t msi_data_start, msi_irq_start, addr_low, addr_high;
  395. int msi_data_count, ret;
  396. ret = pld_get_user_msi_assignment(soc->osdev->dev, "DP",
  397. &msi_data_count, &msi_data_start,
  398. &msi_irq_start);
  399. if (ret)
  400. return;
  401. if (nf_msi_grp_num < 0) {
  402. dp_init_info("%pK: ring near full IRQ not part of an ext_group; ring_type: %d,ring_num %d",
  403. soc, ring_type, ring_num);
  404. ring_params->msi2_addr = 0;
  405. ring_params->msi2_data = 0;
  406. return;
  407. }
  408. if (dp_is_msi_group_number_invalid(soc, nf_msi_grp_num,
  409. msi_data_count)) {
  410. dp_init_warn("%pK: 2 msi_groups will share an msi for near full IRQ; msi_group_num %d",
  411. soc, nf_msi_grp_num);
  412. QDF_ASSERT(0);
  413. }
  414. pld_get_msi_address(soc->osdev->dev, &addr_low, &addr_high);
  415. ring_params->nf_irq_support = 1;
  416. ring_params->msi2_addr = addr_low;
  417. ring_params->msi2_addr |= (qdf_dma_addr_t)(((uint64_t)addr_high) << 32);
  418. ring_params->msi2_data = (nf_msi_grp_num % msi_data_count)
  419. + msi_data_start;
  420. ring_params->flags |= HAL_SRNG_MSI_INTR;
  421. }
  422. /* Percentage of ring entries considered as nearly full */
  423. #define DP_NF_HIGH_THRESH_PERCENTAGE 75
  424. /* Percentage of ring entries considered as critically full */
  425. #define DP_NF_CRIT_THRESH_PERCENTAGE 90
  426. /* Percentage of ring entries considered as safe threshold */
  427. #define DP_NF_SAFE_THRESH_PERCENTAGE 50
  428. /**
  429. * dp_srng_configure_nf_interrupt_thresholds() - Configure the thresholds for
  430. * near full irq
  431. * @soc: Datapath SoC handle
  432. * @ring_params: ring params for SRNG
  433. * @ring_type: ring type
  434. */
  435. static inline void
  436. dp_srng_configure_nf_interrupt_thresholds(struct dp_soc *soc,
  437. struct hal_srng_params *ring_params,
  438. int ring_type)
  439. {
  440. if (ring_params->nf_irq_support) {
  441. ring_params->high_thresh = (ring_params->num_entries *
  442. DP_NF_HIGH_THRESH_PERCENTAGE) / 100;
  443. ring_params->crit_thresh = (ring_params->num_entries *
  444. DP_NF_CRIT_THRESH_PERCENTAGE) / 100;
  445. ring_params->safe_thresh = (ring_params->num_entries *
  446. DP_NF_SAFE_THRESH_PERCENTAGE) /100;
  447. }
  448. }
  449. /**
  450. * dp_srng_set_nf_thresholds() - Set the near full thresholds to srng data
  451. * structure from the ring params
  452. * @soc: Datapath SoC handle
  453. * @srng: SRNG handle
  454. * @ring_params: ring params for a SRNG
  455. *
  456. * Return: None
  457. */
  458. static inline void
  459. dp_srng_set_nf_thresholds(struct dp_soc *soc, struct dp_srng *srng,
  460. struct hal_srng_params *ring_params)
  461. {
  462. srng->crit_thresh = ring_params->crit_thresh;
  463. srng->safe_thresh = ring_params->safe_thresh;
  464. }
  465. #else
  466. static inline
  467. uint8_t *dp_srng_get_near_full_irq_mask(struct dp_soc *soc,
  468. enum hal_ring_type ring_type,
  469. int ring_num)
  470. {
  471. return NULL;
  472. }
  473. static inline
  474. void dp_srng_set_msi2_ring_params(struct dp_soc *soc,
  475. struct hal_srng_params *ring_params,
  476. qdf_dma_addr_t msi2_addr,
  477. uint32_t msi2_data)
  478. {
  479. }
  480. static inline void
  481. dp_srng_msi2_setup(struct dp_soc *soc,
  482. struct hal_srng_params *ring_params,
  483. int ring_type, int ring_num, int nf_msi_grp_num)
  484. {
  485. }
  486. static inline void
  487. dp_srng_configure_nf_interrupt_thresholds(struct dp_soc *soc,
  488. struct hal_srng_params *ring_params,
  489. int ring_type)
  490. {
  491. }
  492. static inline void
  493. dp_srng_set_nf_thresholds(struct dp_soc *soc, struct dp_srng *srng,
  494. struct hal_srng_params *ring_params)
  495. {
  496. }
  497. #endif
  498. static int dp_srng_calculate_msi_group(struct dp_soc *soc,
  499. enum hal_ring_type ring_type,
  500. int ring_num,
  501. int *reg_msi_grp_num,
  502. bool nf_irq_support,
  503. int *nf_msi_grp_num)
  504. {
  505. struct wlan_cfg_dp_soc_ctxt *cfg_ctx = soc->wlan_cfg_ctx;
  506. uint8_t *grp_mask, *nf_irq_mask = NULL;
  507. bool nf_irq_enabled = false;
  508. uint8_t wbm2_sw_rx_rel_ring_id;
  509. switch (ring_type) {
  510. case WBM2SW_RELEASE:
  511. wbm2_sw_rx_rel_ring_id =
  512. wlan_cfg_get_rx_rel_ring_id(cfg_ctx);
  513. if (ring_num == wbm2_sw_rx_rel_ring_id) {
  514. /* dp_rx_wbm_err_process - soc->rx_rel_ring */
  515. grp_mask = &cfg_ctx->int_rx_wbm_rel_ring_mask[0];
  516. ring_num = 0;
  517. } else if (ring_num == WBM2_SW_PPE_REL_RING_ID) {
  518. grp_mask = &cfg_ctx->int_ppeds_wbm_release_ring_mask[0];
  519. ring_num = 0;
  520. } else { /* dp_tx_comp_handler - soc->tx_comp_ring */
  521. grp_mask = &soc->wlan_cfg_ctx->int_tx_ring_mask[0];
  522. nf_irq_mask = dp_srng_get_near_full_irq_mask(soc,
  523. ring_type,
  524. ring_num);
  525. if (nf_irq_mask)
  526. nf_irq_enabled = true;
  527. /*
  528. * Using ring 4 as 4th tx completion ring since ring 3
  529. * is Rx error ring
  530. */
  531. if (ring_num == WBM2SW_TXCOMP_RING4_NUM)
  532. ring_num = TXCOMP_RING4_NUM;
  533. }
  534. break;
  535. case REO_EXCEPTION:
  536. /* dp_rx_err_process - &soc->reo_exception_ring */
  537. grp_mask = &soc->wlan_cfg_ctx->int_rx_err_ring_mask[0];
  538. break;
  539. case REO_DST:
  540. /* dp_rx_process - soc->reo_dest_ring */
  541. grp_mask = &soc->wlan_cfg_ctx->int_rx_ring_mask[0];
  542. nf_irq_mask = dp_srng_get_near_full_irq_mask(soc, ring_type,
  543. ring_num);
  544. if (nf_irq_mask)
  545. nf_irq_enabled = true;
  546. break;
  547. case REO_STATUS:
  548. /* dp_reo_status_ring_handler - soc->reo_status_ring */
  549. grp_mask = &soc->wlan_cfg_ctx->int_reo_status_ring_mask[0];
  550. break;
  551. /* dp_rx_mon_status_srng_process - pdev->rxdma_mon_status_ring*/
  552. case RXDMA_MONITOR_STATUS:
  553. /* dp_rx_mon_dest_process - pdev->rxdma_mon_dst_ring */
  554. case RXDMA_MONITOR_DST:
  555. /* dp_mon_process */
  556. grp_mask = &soc->wlan_cfg_ctx->int_rx_mon_ring_mask[0];
  557. break;
  558. case TX_MONITOR_DST:
  559. /* dp_tx_mon_process */
  560. grp_mask = &soc->wlan_cfg_ctx->int_tx_mon_ring_mask[0];
  561. break;
  562. case RXDMA_DST:
  563. /* dp_rxdma_err_process */
  564. grp_mask = &soc->wlan_cfg_ctx->int_rxdma2host_ring_mask[0];
  565. break;
  566. case RXDMA_BUF:
  567. grp_mask = &soc->wlan_cfg_ctx->int_host2rxdma_ring_mask[0];
  568. break;
  569. case RXDMA_MONITOR_BUF:
  570. grp_mask = &soc->wlan_cfg_ctx->int_host2rxdma_mon_ring_mask[0];
  571. break;
  572. case TX_MONITOR_BUF:
  573. grp_mask = &soc->wlan_cfg_ctx->int_host2txmon_ring_mask[0];
  574. break;
  575. case REO2PPE:
  576. grp_mask = &soc->wlan_cfg_ctx->int_reo2ppe_ring_mask[0];
  577. break;
  578. case PPE2TCL:
  579. grp_mask = &soc->wlan_cfg_ctx->int_ppe2tcl_ring_mask[0];
  580. break;
  581. case TCL_DATA:
  582. /* CMD_CREDIT_RING is used as command in 8074 and credit in 9000 */
  583. case TCL_CMD_CREDIT:
  584. case REO_CMD:
  585. case SW2WBM_RELEASE:
  586. case WBM_IDLE_LINK:
  587. /* normally empty SW_TO_HW rings */
  588. return -QDF_STATUS_E_NOENT;
  589. break;
  590. case TCL_STATUS:
  591. case REO_REINJECT:
  592. /* misc unused rings */
  593. return -QDF_STATUS_E_NOENT;
  594. break;
  595. case CE_SRC:
  596. case CE_DST:
  597. case CE_DST_STATUS:
  598. /* CE_rings - currently handled by hif */
  599. default:
  600. return -QDF_STATUS_E_NOENT;
  601. break;
  602. }
  603. *reg_msi_grp_num = dp_srng_find_ring_in_mask(ring_num, grp_mask);
  604. if (nf_irq_support && nf_irq_enabled) {
  605. *nf_msi_grp_num = dp_srng_find_ring_in_mask(ring_num,
  606. nf_irq_mask);
  607. }
  608. return QDF_STATUS_SUCCESS;
  609. }
  610. /**
  611. * dp_get_num_msi_available()- API to get number of MSIs available
  612. * @soc: DP soc Handle
  613. * @interrupt_mode: Mode of interrupts
  614. *
  615. * Return: Number of MSIs available or 0 in case of integrated
  616. */
  617. #if defined(WLAN_MAX_PDEVS) && (WLAN_MAX_PDEVS == 1)
  618. static int dp_get_num_msi_available(struct dp_soc *soc, int interrupt_mode)
  619. {
  620. return 0;
  621. }
  622. #else
  623. static int dp_get_num_msi_available(struct dp_soc *soc, int interrupt_mode)
  624. {
  625. int msi_data_count;
  626. int msi_data_start;
  627. int msi_irq_start;
  628. int ret;
  629. if (interrupt_mode == DP_INTR_INTEGRATED) {
  630. return 0;
  631. } else if (interrupt_mode == DP_INTR_MSI || interrupt_mode ==
  632. DP_INTR_POLL) {
  633. ret = pld_get_user_msi_assignment(soc->osdev->dev, "DP",
  634. &msi_data_count,
  635. &msi_data_start,
  636. &msi_irq_start);
  637. if (ret) {
  638. qdf_err("Unable to get DP MSI assignment %d",
  639. interrupt_mode);
  640. return -EINVAL;
  641. }
  642. return msi_data_count;
  643. }
  644. qdf_err("Interrupt mode invalid %d", interrupt_mode);
  645. return -EINVAL;
  646. }
  647. #endif
  648. #if defined(IPA_OFFLOAD) && defined(IPA_WDI3_VLAN_SUPPORT)
  649. static void
  650. dp_ipa_vlan_srng_msi_setup(struct hal_srng_params *ring_params, int ring_type,
  651. int ring_num)
  652. {
  653. if (wlan_ipa_is_vlan_enabled()) {
  654. if ((ring_type == REO_DST) &&
  655. (ring_num == IPA_ALT_REO_DEST_RING_IDX)) {
  656. ring_params->msi_addr = 0;
  657. ring_params->msi_data = 0;
  658. ring_params->flags &= ~HAL_SRNG_MSI_INTR;
  659. }
  660. }
  661. }
  662. #else
  663. static inline void
  664. dp_ipa_vlan_srng_msi_setup(struct hal_srng_params *ring_params, int ring_type,
  665. int ring_num)
  666. {
  667. }
  668. #endif
  669. static void dp_srng_msi_setup(struct dp_soc *soc, struct dp_srng *srng,
  670. struct hal_srng_params *ring_params,
  671. int ring_type, int ring_num)
  672. {
  673. int reg_msi_grp_num;
  674. /*
  675. * nf_msi_grp_num needs to be initialized with negative value,
  676. * to avoid configuring near-full msi for WBM2SW3 ring
  677. */
  678. int nf_msi_grp_num = -1;
  679. int msi_data_count;
  680. int ret;
  681. uint32_t msi_data_start, msi_irq_start, addr_low, addr_high;
  682. bool nf_irq_support;
  683. int vector;
  684. ret = pld_get_user_msi_assignment(soc->osdev->dev, "DP",
  685. &msi_data_count, &msi_data_start,
  686. &msi_irq_start);
  687. if (ret)
  688. return;
  689. nf_irq_support = hal_srng_is_near_full_irq_supported(soc->hal_soc,
  690. ring_type,
  691. ring_num);
  692. ret = dp_srng_calculate_msi_group(soc, ring_type, ring_num,
  693. &reg_msi_grp_num,
  694. nf_irq_support,
  695. &nf_msi_grp_num);
  696. if (ret < 0) {
  697. dp_init_info("%pK: ring not part of an ext_group; ring_type: %d,ring_num %d",
  698. soc, ring_type, ring_num);
  699. ring_params->msi_addr = 0;
  700. ring_params->msi_data = 0;
  701. dp_srng_set_msi2_ring_params(soc, ring_params, 0, 0);
  702. return;
  703. }
  704. if (reg_msi_grp_num < 0) {
  705. dp_init_info("%pK: ring not part of an ext_group; ring_type: %d,ring_num %d",
  706. soc, ring_type, ring_num);
  707. ring_params->msi_addr = 0;
  708. ring_params->msi_data = 0;
  709. goto configure_msi2;
  710. }
  711. if (dp_is_msi_group_number_invalid(soc, reg_msi_grp_num,
  712. msi_data_count)) {
  713. dp_init_warn("%pK: 2 msi_groups will share an msi; msi_group_num %d",
  714. soc, reg_msi_grp_num);
  715. QDF_ASSERT(0);
  716. }
  717. pld_get_msi_address(soc->osdev->dev, &addr_low, &addr_high);
  718. ring_params->msi_addr = addr_low;
  719. ring_params->msi_addr |= (qdf_dma_addr_t)(((uint64_t)addr_high) << 32);
  720. ring_params->msi_data = (reg_msi_grp_num % msi_data_count)
  721. + msi_data_start;
  722. ring_params->flags |= HAL_SRNG_MSI_INTR;
  723. dp_ipa_vlan_srng_msi_setup(ring_params, ring_type, ring_num);
  724. dp_debug("ring type %u ring_num %u msi->data %u msi_addr %llx",
  725. ring_type, ring_num, ring_params->msi_data,
  726. (uint64_t)ring_params->msi_addr);
  727. vector = msi_irq_start + (reg_msi_grp_num % msi_data_count);
  728. /*
  729. * During umac reset ppeds interrupts free is not called.
  730. * Avoid registering interrupts again.
  731. *
  732. */
  733. if (dp_check_umac_reset_in_progress(soc))
  734. goto configure_msi2;
  735. if (soc->arch_ops.dp_register_ppeds_interrupts)
  736. if (soc->arch_ops.dp_register_ppeds_interrupts(soc, srng,
  737. vector,
  738. ring_type,
  739. ring_num))
  740. return;
  741. configure_msi2:
  742. if (!nf_irq_support) {
  743. dp_srng_set_msi2_ring_params(soc, ring_params, 0, 0);
  744. return;
  745. }
  746. dp_srng_msi2_setup(soc, ring_params, ring_type, ring_num,
  747. nf_msi_grp_num);
  748. }
  749. /**
  750. * dp_srng_configure_pointer_update_thresholds() - Retrieve pointer
  751. * update threshold value from wlan_cfg_ctx
  752. * @soc: device handle
  753. * @ring_params: per ring specific parameters
  754. * @ring_type: Ring type
  755. * @ring_num: Ring number for a given ring type
  756. * @num_entries: number of entries to fill
  757. *
  758. * Fill the ring params with the pointer update threshold
  759. * configuration parameters available in wlan_cfg_ctx
  760. *
  761. * Return: None
  762. */
  763. static void
  764. dp_srng_configure_pointer_update_thresholds(
  765. struct dp_soc *soc,
  766. struct hal_srng_params *ring_params,
  767. int ring_type, int ring_num,
  768. int num_entries)
  769. {
  770. if (ring_type == REO_DST) {
  771. ring_params->pointer_timer_threshold =
  772. wlan_cfg_get_pointer_timer_threshold_rx(
  773. soc->wlan_cfg_ctx);
  774. ring_params->pointer_num_threshold =
  775. wlan_cfg_get_pointer_num_threshold_rx(
  776. soc->wlan_cfg_ctx);
  777. }
  778. }
  779. #ifdef WLAN_DP_PER_RING_TYPE_CONFIG
  780. /**
  781. * dp_srng_configure_interrupt_thresholds() - Retrieve interrupt
  782. * threshold values from the wlan_srng_cfg table for each ring type
  783. * @soc: device handle
  784. * @ring_params: per ring specific parameters
  785. * @ring_type: Ring type
  786. * @ring_num: Ring number for a given ring type
  787. * @num_entries: number of entries to fill
  788. *
  789. * Fill the ring params with the interrupt threshold
  790. * configuration parameters available in the per ring type wlan_srng_cfg
  791. * table.
  792. *
  793. * Return: None
  794. */
  795. static void
  796. dp_srng_configure_interrupt_thresholds(struct dp_soc *soc,
  797. struct hal_srng_params *ring_params,
  798. int ring_type, int ring_num,
  799. int num_entries)
  800. {
  801. uint8_t wbm2_sw_rx_rel_ring_id;
  802. wbm2_sw_rx_rel_ring_id = wlan_cfg_get_rx_rel_ring_id(soc->wlan_cfg_ctx);
  803. if (ring_type == REO_DST) {
  804. ring_params->intr_timer_thres_us =
  805. wlan_cfg_get_int_timer_threshold_rx(soc->wlan_cfg_ctx);
  806. ring_params->intr_batch_cntr_thres_entries =
  807. wlan_cfg_get_int_batch_threshold_rx(soc->wlan_cfg_ctx);
  808. } else if (ring_type == WBM2SW_RELEASE &&
  809. (ring_num == wbm2_sw_rx_rel_ring_id)) {
  810. ring_params->intr_timer_thres_us =
  811. wlan_cfg_get_int_timer_threshold_other(soc->wlan_cfg_ctx);
  812. ring_params->intr_batch_cntr_thres_entries =
  813. wlan_cfg_get_int_batch_threshold_other(soc->wlan_cfg_ctx);
  814. } else {
  815. ring_params->intr_timer_thres_us =
  816. soc->wlan_srng_cfg[ring_type].timer_threshold;
  817. ring_params->intr_batch_cntr_thres_entries =
  818. soc->wlan_srng_cfg[ring_type].batch_count_threshold;
  819. }
  820. ring_params->low_threshold =
  821. soc->wlan_srng_cfg[ring_type].low_threshold;
  822. if (ring_params->low_threshold)
  823. ring_params->flags |= HAL_SRNG_LOW_THRES_INTR_ENABLE;
  824. dp_srng_configure_nf_interrupt_thresholds(soc, ring_params, ring_type);
  825. }
  826. #else
  827. static void
  828. dp_srng_configure_interrupt_thresholds(struct dp_soc *soc,
  829. struct hal_srng_params *ring_params,
  830. int ring_type, int ring_num,
  831. int num_entries)
  832. {
  833. uint8_t wbm2_sw_rx_rel_ring_id;
  834. bool rx_refill_lt_disable;
  835. wbm2_sw_rx_rel_ring_id = wlan_cfg_get_rx_rel_ring_id(soc->wlan_cfg_ctx);
  836. if (ring_type == REO_DST || ring_type == REO2PPE) {
  837. ring_params->intr_timer_thres_us =
  838. wlan_cfg_get_int_timer_threshold_rx(soc->wlan_cfg_ctx);
  839. ring_params->intr_batch_cntr_thres_entries =
  840. wlan_cfg_get_int_batch_threshold_rx(soc->wlan_cfg_ctx);
  841. } else if (ring_type == WBM2SW_RELEASE &&
  842. (ring_num < wbm2_sw_rx_rel_ring_id ||
  843. ring_num == WBM2SW_TXCOMP_RING4_NUM ||
  844. ring_num == WBM2_SW_PPE_REL_RING_ID)) {
  845. ring_params->intr_timer_thres_us =
  846. wlan_cfg_get_int_timer_threshold_tx(soc->wlan_cfg_ctx);
  847. ring_params->intr_batch_cntr_thres_entries =
  848. wlan_cfg_get_int_batch_threshold_tx(soc->wlan_cfg_ctx);
  849. } else if (ring_type == RXDMA_BUF) {
  850. rx_refill_lt_disable =
  851. wlan_cfg_get_dp_soc_rxdma_refill_lt_disable
  852. (soc->wlan_cfg_ctx);
  853. ring_params->intr_timer_thres_us =
  854. wlan_cfg_get_int_timer_threshold_rx(soc->wlan_cfg_ctx);
  855. if (!rx_refill_lt_disable) {
  856. ring_params->low_threshold = num_entries >> 3;
  857. ring_params->flags |= HAL_SRNG_LOW_THRES_INTR_ENABLE;
  858. ring_params->intr_batch_cntr_thres_entries = 0;
  859. }
  860. } else {
  861. ring_params->intr_timer_thres_us =
  862. wlan_cfg_get_int_timer_threshold_other(soc->wlan_cfg_ctx);
  863. ring_params->intr_batch_cntr_thres_entries =
  864. wlan_cfg_get_int_batch_threshold_other(soc->wlan_cfg_ctx);
  865. }
  866. /* These rings donot require interrupt to host. Make them zero */
  867. switch (ring_type) {
  868. case REO_REINJECT:
  869. case REO_CMD:
  870. case TCL_DATA:
  871. case TCL_CMD_CREDIT:
  872. case TCL_STATUS:
  873. case WBM_IDLE_LINK:
  874. case SW2WBM_RELEASE:
  875. case SW2RXDMA_NEW:
  876. ring_params->intr_timer_thres_us = 0;
  877. ring_params->intr_batch_cntr_thres_entries = 0;
  878. break;
  879. case PPE2TCL:
  880. ring_params->intr_timer_thres_us =
  881. wlan_cfg_get_int_timer_threshold_ppe2tcl(soc->wlan_cfg_ctx);
  882. ring_params->intr_batch_cntr_thres_entries =
  883. wlan_cfg_get_int_batch_threshold_ppe2tcl(soc->wlan_cfg_ctx);
  884. break;
  885. }
  886. /* Enable low threshold interrupts for rx buffer rings (regular and
  887. * monitor buffer rings.
  888. * TODO: See if this is required for any other ring
  889. */
  890. if ((ring_type == RXDMA_MONITOR_BUF) ||
  891. (ring_type == RXDMA_MONITOR_STATUS ||
  892. (ring_type == TX_MONITOR_BUF))) {
  893. /* TODO: Setting low threshold to 1/8th of ring size
  894. * see if this needs to be configurable
  895. */
  896. ring_params->low_threshold = num_entries >> 3;
  897. ring_params->intr_timer_thres_us =
  898. wlan_cfg_get_int_timer_threshold_rx(soc->wlan_cfg_ctx);
  899. ring_params->flags |= HAL_SRNG_LOW_THRES_INTR_ENABLE;
  900. ring_params->intr_batch_cntr_thres_entries = 0;
  901. }
  902. /* During initialisation monitor rings are only filled with
  903. * MON_BUF_MIN_ENTRIES entries. So low threshold needs to be set to
  904. * a value less than that. Low threshold value is reconfigured again
  905. * to 1/8th of the ring size when monitor vap is created.
  906. */
  907. if (ring_type == RXDMA_MONITOR_BUF)
  908. ring_params->low_threshold = MON_BUF_MIN_ENTRIES >> 1;
  909. /* In case of PCI chipsets, we dont have PPDU end interrupts,
  910. * so MONITOR STATUS ring is reaped by receiving MSI from srng.
  911. * Keep batch threshold as 8 so that interrupt is received for
  912. * every 4 packets in MONITOR_STATUS ring
  913. */
  914. if ((ring_type == RXDMA_MONITOR_STATUS) &&
  915. (soc->intr_mode == DP_INTR_MSI))
  916. ring_params->intr_batch_cntr_thres_entries = 4;
  917. }
  918. #endif
  919. #ifdef DISABLE_MON_RING_MSI_CFG
  920. /**
  921. * dp_skip_msi_cfg() - Check if msi cfg has to be skipped for ring_type
  922. * @soc: DP SoC context
  923. * @ring_type: sring type
  924. *
  925. * Return: True if msi cfg should be skipped for srng type else false
  926. */
  927. static inline bool dp_skip_msi_cfg(struct dp_soc *soc, int ring_type)
  928. {
  929. if (ring_type == RXDMA_MONITOR_STATUS)
  930. return true;
  931. return false;
  932. }
  933. #else
  934. #ifdef DP_CON_MON_MSI_ENABLED
  935. static inline bool dp_skip_msi_cfg(struct dp_soc *soc, int ring_type)
  936. {
  937. if (soc->cdp_soc.ol_ops->get_con_mode &&
  938. soc->cdp_soc.ol_ops->get_con_mode() == QDF_GLOBAL_MONITOR_MODE) {
  939. if (ring_type == REO_DST || ring_type == RXDMA_DST)
  940. return true;
  941. } else if (ring_type == RXDMA_MONITOR_STATUS &&
  942. !wlan_cfg_get_local_pkt_capture(soc->wlan_cfg_ctx)) {
  943. return true;
  944. }
  945. return false;
  946. }
  947. #else
  948. static inline bool dp_skip_msi_cfg(struct dp_soc *soc, int ring_type)
  949. {
  950. return false;
  951. }
  952. #endif /* DP_CON_MON_MSI_ENABLED */
  953. #endif /* DISABLE_MON_RING_MSI_CFG */
  954. QDF_STATUS dp_srng_init_idx(struct dp_soc *soc, struct dp_srng *srng,
  955. int ring_type, int ring_num, int mac_id,
  956. uint32_t idx)
  957. {
  958. bool idle_check;
  959. hal_soc_handle_t hal_soc = soc->hal_soc;
  960. struct hal_srng_params ring_params;
  961. if (srng->hal_srng) {
  962. dp_init_err("%pK: Ring type: %d, num:%d is already initialized",
  963. soc, ring_type, ring_num);
  964. return QDF_STATUS_SUCCESS;
  965. }
  966. /* memset the srng ring to zero */
  967. qdf_mem_zero(srng->base_vaddr_unaligned, srng->alloc_size);
  968. qdf_mem_zero(&ring_params, sizeof(struct hal_srng_params));
  969. ring_params.ring_base_paddr = srng->base_paddr_aligned;
  970. ring_params.ring_base_vaddr = srng->base_vaddr_aligned;
  971. ring_params.num_entries = srng->num_entries;
  972. dp_info("Ring type: %d, num:%d vaddr %pK paddr %pK entries %u",
  973. ring_type, ring_num,
  974. (void *)ring_params.ring_base_vaddr,
  975. (void *)ring_params.ring_base_paddr,
  976. ring_params.num_entries);
  977. if (soc->intr_mode == DP_INTR_MSI && !dp_skip_msi_cfg(soc, ring_type)) {
  978. dp_srng_msi_setup(soc, srng, &ring_params, ring_type, ring_num);
  979. dp_verbose_debug("Using MSI for ring_type: %d, ring_num %d",
  980. ring_type, ring_num);
  981. } else {
  982. ring_params.msi_data = 0;
  983. ring_params.msi_addr = 0;
  984. dp_srng_set_msi2_ring_params(soc, &ring_params, 0, 0);
  985. dp_verbose_debug("Skipping MSI for ring_type: %d, ring_num %d",
  986. ring_type, ring_num);
  987. }
  988. dp_srng_configure_interrupt_thresholds(soc, &ring_params,
  989. ring_type, ring_num,
  990. srng->num_entries);
  991. dp_srng_set_nf_thresholds(soc, srng, &ring_params);
  992. dp_srng_configure_pointer_update_thresholds(soc, &ring_params,
  993. ring_type, ring_num,
  994. srng->num_entries);
  995. if (srng->cached)
  996. ring_params.flags |= HAL_SRNG_CACHED_DESC;
  997. idle_check = dp_check_umac_reset_in_progress(soc);
  998. srng->hal_srng = hal_srng_setup_idx(hal_soc, ring_type, ring_num,
  999. mac_id, &ring_params, idle_check,
  1000. idx);
  1001. if (!srng->hal_srng) {
  1002. dp_srng_free(soc, srng);
  1003. return QDF_STATUS_E_FAILURE;
  1004. }
  1005. return QDF_STATUS_SUCCESS;
  1006. }
  1007. qdf_export_symbol(dp_srng_init_idx);
  1008. static int dp_process_rxdma_dst_ring(struct dp_soc *soc,
  1009. struct dp_intr *int_ctx,
  1010. int mac_for_pdev,
  1011. int total_budget)
  1012. {
  1013. uint32_t target_type;
  1014. target_type = hal_get_target_type(soc->hal_soc);
  1015. if (target_type == TARGET_TYPE_QCN9160)
  1016. return dp_monitor_process(soc, int_ctx,
  1017. mac_for_pdev, total_budget);
  1018. else
  1019. return dp_rxdma_err_process(int_ctx, soc, mac_for_pdev,
  1020. total_budget);
  1021. }
  1022. /**
  1023. * dp_process_lmac_rings() - Process LMAC rings
  1024. * @int_ctx: interrupt context
  1025. * @total_budget: budget of work which can be done
  1026. *
  1027. * Return: work done
  1028. */
  1029. static int dp_process_lmac_rings(struct dp_intr *int_ctx, int total_budget)
  1030. {
  1031. struct dp_intr_stats *intr_stats = &int_ctx->intr_stats;
  1032. struct dp_soc *soc = int_ctx->soc;
  1033. uint32_t remaining_quota = total_budget;
  1034. struct dp_pdev *pdev = NULL;
  1035. uint32_t work_done = 0;
  1036. int budget = total_budget;
  1037. int ring = 0;
  1038. bool rx_refill_lt_disable;
  1039. rx_refill_lt_disable =
  1040. wlan_cfg_get_dp_soc_rxdma_refill_lt_disable(soc->wlan_cfg_ctx);
  1041. /* Process LMAC interrupts */
  1042. for (ring = 0 ; ring < MAX_NUM_LMAC_HW; ring++) {
  1043. int mac_for_pdev = ring;
  1044. pdev = dp_get_pdev_for_lmac_id(soc, mac_for_pdev);
  1045. if (!pdev)
  1046. continue;
  1047. if (int_ctx->rx_mon_ring_mask & (1 << mac_for_pdev)) {
  1048. work_done = dp_monitor_process(soc, int_ctx,
  1049. mac_for_pdev,
  1050. remaining_quota);
  1051. if (work_done)
  1052. intr_stats->num_rx_mon_ring_masks++;
  1053. budget -= work_done;
  1054. if (budget <= 0)
  1055. goto budget_done;
  1056. remaining_quota = budget;
  1057. }
  1058. if (int_ctx->tx_mon_ring_mask & (1 << mac_for_pdev)) {
  1059. work_done = dp_tx_mon_process(soc, int_ctx,
  1060. mac_for_pdev,
  1061. remaining_quota);
  1062. if (work_done)
  1063. intr_stats->num_tx_mon_ring_masks++;
  1064. budget -= work_done;
  1065. if (budget <= 0)
  1066. goto budget_done;
  1067. remaining_quota = budget;
  1068. }
  1069. if (int_ctx->rxdma2host_ring_mask &
  1070. (1 << mac_for_pdev)) {
  1071. work_done = dp_process_rxdma_dst_ring(soc, int_ctx,
  1072. mac_for_pdev,
  1073. remaining_quota);
  1074. if (work_done)
  1075. intr_stats->num_rxdma2host_ring_masks++;
  1076. budget -= work_done;
  1077. if (budget <= 0)
  1078. goto budget_done;
  1079. remaining_quota = budget;
  1080. }
  1081. if (int_ctx->host2rxdma_ring_mask & (1 << mac_for_pdev)) {
  1082. union dp_rx_desc_list_elem_t *desc_list = NULL;
  1083. union dp_rx_desc_list_elem_t *tail = NULL;
  1084. struct dp_srng *rx_refill_buf_ring;
  1085. struct rx_desc_pool *rx_desc_pool;
  1086. rx_desc_pool = &soc->rx_desc_buf[mac_for_pdev];
  1087. if (wlan_cfg_per_pdev_lmac_ring(soc->wlan_cfg_ctx))
  1088. rx_refill_buf_ring =
  1089. &soc->rx_refill_buf_ring[mac_for_pdev];
  1090. else
  1091. rx_refill_buf_ring =
  1092. &soc->rx_refill_buf_ring[pdev->lmac_id];
  1093. intr_stats->num_host2rxdma_ring_masks++;
  1094. if (!rx_refill_lt_disable)
  1095. dp_rx_buffers_lt_replenish_simple(soc,
  1096. mac_for_pdev,
  1097. rx_refill_buf_ring,
  1098. rx_desc_pool,
  1099. 0,
  1100. &desc_list,
  1101. &tail);
  1102. }
  1103. }
  1104. if (int_ctx->host2rxdma_mon_ring_mask)
  1105. dp_rx_mon_buf_refill(int_ctx);
  1106. if (int_ctx->host2txmon_ring_mask)
  1107. dp_tx_mon_buf_refill(int_ctx);
  1108. budget_done:
  1109. return total_budget - budget;
  1110. }
  1111. #ifdef WLAN_FEATURE_NEAR_FULL_IRQ
  1112. /**
  1113. * dp_service_near_full_srngs() - Bottom half handler to process the near
  1114. * full IRQ on a SRNG
  1115. * @dp_ctx: Datapath SoC handle
  1116. * @dp_budget: Number of SRNGs which can be processed in a single attempt
  1117. * without rescheduling
  1118. * @cpu: cpu id
  1119. *
  1120. * Return: remaining budget/quota for the soc device
  1121. */
  1122. static
  1123. uint32_t dp_service_near_full_srngs(void *dp_ctx, uint32_t dp_budget, int cpu)
  1124. {
  1125. struct dp_intr *int_ctx = (struct dp_intr *)dp_ctx;
  1126. struct dp_soc *soc = int_ctx->soc;
  1127. /*
  1128. * dp_service_near_full_srngs arch ops should be initialized always
  1129. * if the NEAR FULL IRQ feature is enabled.
  1130. */
  1131. return soc->arch_ops.dp_service_near_full_srngs(soc, int_ctx,
  1132. dp_budget);
  1133. }
  1134. #endif
  1135. #ifndef QCA_HOST_MODE_WIFI_DISABLED
  1136. uint32_t dp_service_srngs(void *dp_ctx, uint32_t dp_budget, int cpu)
  1137. {
  1138. struct dp_intr *int_ctx = (struct dp_intr *)dp_ctx;
  1139. struct dp_intr_stats *intr_stats = &int_ctx->intr_stats;
  1140. struct dp_soc *soc = int_ctx->soc;
  1141. int ring = 0;
  1142. int index;
  1143. uint32_t work_done = 0;
  1144. int budget = dp_budget;
  1145. uint32_t remaining_quota = dp_budget;
  1146. uint8_t tx_mask = 0;
  1147. uint8_t rx_mask = 0;
  1148. uint8_t rx_err_mask = 0;
  1149. uint8_t rx_wbm_rel_mask = 0;
  1150. uint8_t reo_status_mask = 0;
  1151. qdf_atomic_set_bit(cpu, &soc->service_rings_running);
  1152. tx_mask = int_ctx->tx_ring_mask;
  1153. rx_mask = int_ctx->rx_ring_mask;
  1154. rx_err_mask = int_ctx->rx_err_ring_mask;
  1155. rx_wbm_rel_mask = int_ctx->rx_wbm_rel_ring_mask;
  1156. reo_status_mask = int_ctx->reo_status_ring_mask;
  1157. dp_verbose_debug("tx %x rx %x rx_err %x rx_wbm_rel %x reo_status %x rx_mon_ring %x host2rxdma %x rxdma2host %x",
  1158. tx_mask, rx_mask, rx_err_mask, rx_wbm_rel_mask,
  1159. reo_status_mask,
  1160. int_ctx->rx_mon_ring_mask,
  1161. int_ctx->host2rxdma_ring_mask,
  1162. int_ctx->rxdma2host_ring_mask);
  1163. /* Process Tx completion interrupts first to return back buffers */
  1164. for (index = 0; index < soc->num_tx_comp_rings; index++) {
  1165. if (!(1 << wlan_cfg_get_wbm_ring_num_for_index(soc->wlan_cfg_ctx, index) & tx_mask))
  1166. continue;
  1167. work_done = dp_tx_comp_handler(int_ctx,
  1168. soc,
  1169. soc->tx_comp_ring[index].hal_srng,
  1170. index, remaining_quota);
  1171. if (work_done) {
  1172. intr_stats->num_tx_ring_masks[index]++;
  1173. dp_verbose_debug("tx mask 0x%x index %d, budget %d, work_done %d",
  1174. tx_mask, index, budget,
  1175. work_done);
  1176. }
  1177. budget -= work_done;
  1178. if (budget <= 0)
  1179. goto budget_done;
  1180. remaining_quota = budget;
  1181. }
  1182. /* Process REO Exception ring interrupt */
  1183. if (rx_err_mask) {
  1184. work_done = dp_rx_err_process(int_ctx, soc,
  1185. soc->reo_exception_ring.hal_srng,
  1186. remaining_quota);
  1187. if (work_done) {
  1188. intr_stats->num_rx_err_ring_masks++;
  1189. dp_verbose_debug("REO Exception Ring: work_done %d budget %d",
  1190. work_done, budget);
  1191. }
  1192. budget -= work_done;
  1193. if (budget <= 0) {
  1194. goto budget_done;
  1195. }
  1196. remaining_quota = budget;
  1197. }
  1198. /* Process Rx WBM release ring interrupt */
  1199. if (rx_wbm_rel_mask) {
  1200. work_done = dp_rx_wbm_err_process(int_ctx, soc,
  1201. soc->rx_rel_ring.hal_srng,
  1202. remaining_quota);
  1203. if (work_done) {
  1204. intr_stats->num_rx_wbm_rel_ring_masks++;
  1205. dp_verbose_debug("WBM Release Ring: work_done %d budget %d",
  1206. work_done, budget);
  1207. }
  1208. budget -= work_done;
  1209. if (budget <= 0) {
  1210. goto budget_done;
  1211. }
  1212. remaining_quota = budget;
  1213. }
  1214. /* Process Rx interrupts */
  1215. if (rx_mask) {
  1216. for (ring = 0; ring < soc->num_reo_dest_rings; ring++) {
  1217. if (!(rx_mask & (1 << ring)))
  1218. continue;
  1219. work_done = soc->arch_ops.dp_rx_process(int_ctx,
  1220. soc->reo_dest_ring[ring].hal_srng,
  1221. ring,
  1222. remaining_quota);
  1223. if (work_done) {
  1224. intr_stats->num_rx_ring_masks[ring]++;
  1225. dp_verbose_debug("rx mask 0x%x ring %d, work_done %d budget %d",
  1226. rx_mask, ring,
  1227. work_done, budget);
  1228. budget -= work_done;
  1229. if (budget <= 0)
  1230. goto budget_done;
  1231. remaining_quota = budget;
  1232. }
  1233. }
  1234. }
  1235. if (reo_status_mask) {
  1236. if (dp_reo_status_ring_handler(int_ctx, soc))
  1237. int_ctx->intr_stats.num_reo_status_ring_masks++;
  1238. }
  1239. if (qdf_unlikely(!dp_monitor_is_vdev_timer_running(soc))) {
  1240. work_done = dp_process_lmac_rings(int_ctx, remaining_quota);
  1241. if (work_done) {
  1242. budget -= work_done;
  1243. if (budget <= 0)
  1244. goto budget_done;
  1245. remaining_quota = budget;
  1246. }
  1247. }
  1248. qdf_lro_flush(int_ctx->lro_ctx);
  1249. intr_stats->num_masks++;
  1250. budget_done:
  1251. qdf_atomic_clear_bit(cpu, &soc->service_rings_running);
  1252. if (soc->notify_fw_callback)
  1253. soc->notify_fw_callback(soc);
  1254. return dp_budget - budget;
  1255. }
  1256. #else /* QCA_HOST_MODE_WIFI_DISABLED */
  1257. uint32_t dp_service_srngs(void *dp_ctx, uint32_t dp_budget, int cpu)
  1258. {
  1259. struct dp_intr *int_ctx = (struct dp_intr *)dp_ctx;
  1260. struct dp_intr_stats *intr_stats = &int_ctx->intr_stats;
  1261. struct dp_soc *soc = int_ctx->soc;
  1262. uint32_t remaining_quota = dp_budget;
  1263. uint32_t work_done = 0;
  1264. int budget = dp_budget;
  1265. uint8_t reo_status_mask = int_ctx->reo_status_ring_mask;
  1266. if (reo_status_mask) {
  1267. if (dp_reo_status_ring_handler(int_ctx, soc))
  1268. int_ctx->intr_stats.num_reo_status_ring_masks++;
  1269. }
  1270. if (qdf_unlikely(!dp_monitor_is_vdev_timer_running(soc))) {
  1271. work_done = dp_process_lmac_rings(int_ctx, remaining_quota);
  1272. if (work_done) {
  1273. budget -= work_done;
  1274. if (budget <= 0)
  1275. goto budget_done;
  1276. remaining_quota = budget;
  1277. }
  1278. }
  1279. qdf_lro_flush(int_ctx->lro_ctx);
  1280. intr_stats->num_masks++;
  1281. budget_done:
  1282. return dp_budget - budget;
  1283. }
  1284. #endif /* QCA_HOST_MODE_WIFI_DISABLED */
  1285. #ifdef WLAN_FEATURE_DP_EVENT_HISTORY
  1286. static inline bool dp_is_mon_mask_valid(struct dp_soc *soc,
  1287. struct dp_intr *intr_ctx)
  1288. {
  1289. if (intr_ctx->rx_mon_ring_mask)
  1290. return true;
  1291. return false;
  1292. }
  1293. #else
  1294. static inline bool dp_is_mon_mask_valid(struct dp_soc *soc,
  1295. struct dp_intr *intr_ctx)
  1296. {
  1297. return false;
  1298. }
  1299. #endif
  1300. QDF_STATUS dp_soc_attach_poll(struct cdp_soc_t *txrx_soc)
  1301. {
  1302. struct dp_soc *soc = (struct dp_soc *)txrx_soc;
  1303. int i;
  1304. int lmac_id = 0;
  1305. qdf_mem_set(&soc->mon_intr_id_lmac_map,
  1306. sizeof(soc->mon_intr_id_lmac_map), DP_MON_INVALID_LMAC_ID);
  1307. soc->intr_mode = DP_INTR_POLL;
  1308. for (i = 0; i < wlan_cfg_get_num_contexts(soc->wlan_cfg_ctx); i++) {
  1309. soc->intr_ctx[i].dp_intr_id = i;
  1310. soc->intr_ctx[i].tx_ring_mask =
  1311. wlan_cfg_get_tx_ring_mask(soc->wlan_cfg_ctx, i);
  1312. soc->intr_ctx[i].rx_ring_mask =
  1313. wlan_cfg_get_rx_ring_mask(soc->wlan_cfg_ctx, i);
  1314. soc->intr_ctx[i].rx_mon_ring_mask =
  1315. wlan_cfg_get_rx_mon_ring_mask(soc->wlan_cfg_ctx, i);
  1316. soc->intr_ctx[i].rx_err_ring_mask =
  1317. wlan_cfg_get_rx_err_ring_mask(soc->wlan_cfg_ctx, i);
  1318. soc->intr_ctx[i].rx_wbm_rel_ring_mask =
  1319. wlan_cfg_get_rx_wbm_rel_ring_mask(soc->wlan_cfg_ctx, i);
  1320. soc->intr_ctx[i].reo_status_ring_mask =
  1321. wlan_cfg_get_reo_status_ring_mask(soc->wlan_cfg_ctx, i);
  1322. soc->intr_ctx[i].rxdma2host_ring_mask =
  1323. wlan_cfg_get_rxdma2host_ring_mask(soc->wlan_cfg_ctx, i);
  1324. soc->intr_ctx[i].soc = soc;
  1325. soc->intr_ctx[i].lro_ctx = qdf_lro_init();
  1326. if (dp_is_mon_mask_valid(soc, &soc->intr_ctx[i])) {
  1327. hif_event_history_init(soc->hif_handle, i);
  1328. soc->mon_intr_id_lmac_map[lmac_id] = i;
  1329. lmac_id++;
  1330. }
  1331. }
  1332. qdf_timer_init(soc->osdev, &soc->int_timer,
  1333. dp_interrupt_timer, (void *)soc,
  1334. QDF_TIMER_TYPE_WAKE_APPS);
  1335. return QDF_STATUS_SUCCESS;
  1336. }
  1337. void dp_soc_set_interrupt_mode(struct dp_soc *soc)
  1338. {
  1339. uint32_t msi_base_data, msi_vector_start;
  1340. int msi_vector_count, ret;
  1341. soc->intr_mode = DP_INTR_INTEGRATED;
  1342. if (!(soc->wlan_cfg_ctx->napi_enabled) ||
  1343. (dp_is_monitor_mode_using_poll(soc) &&
  1344. soc->cdp_soc.ol_ops->get_con_mode &&
  1345. soc->cdp_soc.ol_ops->get_con_mode() == QDF_GLOBAL_MONITOR_MODE)) {
  1346. soc->intr_mode = DP_INTR_POLL;
  1347. } else {
  1348. ret = pld_get_user_msi_assignment(soc->osdev->dev, "DP",
  1349. &msi_vector_count,
  1350. &msi_base_data,
  1351. &msi_vector_start);
  1352. if (ret)
  1353. return;
  1354. soc->intr_mode = DP_INTR_MSI;
  1355. }
  1356. }
  1357. #ifdef QCA_SUPPORT_LEGACY_INTERRUPTS
  1358. /**
  1359. * dp_soc_interrupt_map_calculate_wifi3_pci_legacy() -
  1360. * Calculate interrupt map for legacy interrupts
  1361. * @soc: DP soc handle
  1362. * @intr_ctx_num: Interrupt context number
  1363. * @irq_id_map: IRQ map
  1364. * @num_irq_r: Number of interrupts assigned for this context
  1365. *
  1366. * Return: void
  1367. */
  1368. static void dp_soc_interrupt_map_calculate_wifi3_pci_legacy(struct dp_soc *soc,
  1369. int intr_ctx_num,
  1370. int *irq_id_map,
  1371. int *num_irq_r)
  1372. {
  1373. int j;
  1374. int num_irq = 0;
  1375. int tx_mask = wlan_cfg_get_tx_ring_mask(
  1376. soc->wlan_cfg_ctx, intr_ctx_num);
  1377. int rx_mask = wlan_cfg_get_rx_ring_mask(
  1378. soc->wlan_cfg_ctx, intr_ctx_num);
  1379. int rx_mon_mask = wlan_cfg_get_rx_mon_ring_mask(
  1380. soc->wlan_cfg_ctx, intr_ctx_num);
  1381. int rx_err_ring_mask = wlan_cfg_get_rx_err_ring_mask(
  1382. soc->wlan_cfg_ctx, intr_ctx_num);
  1383. int rx_wbm_rel_ring_mask = wlan_cfg_get_rx_wbm_rel_ring_mask(
  1384. soc->wlan_cfg_ctx, intr_ctx_num);
  1385. int reo_status_ring_mask = wlan_cfg_get_reo_status_ring_mask(
  1386. soc->wlan_cfg_ctx, intr_ctx_num);
  1387. int rxdma2host_ring_mask = wlan_cfg_get_rxdma2host_ring_mask(
  1388. soc->wlan_cfg_ctx, intr_ctx_num);
  1389. int host2rxdma_ring_mask = wlan_cfg_get_host2rxdma_ring_mask(
  1390. soc->wlan_cfg_ctx, intr_ctx_num);
  1391. int host2rxdma_mon_ring_mask = wlan_cfg_get_host2rxdma_mon_ring_mask(
  1392. soc->wlan_cfg_ctx, intr_ctx_num);
  1393. int host2txmon_ring_mask = wlan_cfg_get_host2txmon_ring_mask(
  1394. soc->wlan_cfg_ctx, intr_ctx_num);
  1395. int txmon2host_mon_ring_mask = wlan_cfg_get_tx_mon_ring_mask(
  1396. soc->wlan_cfg_ctx, intr_ctx_num);
  1397. soc->intr_mode = DP_INTR_LEGACY_VIRTUAL_IRQ;
  1398. for (j = 0; j < HIF_MAX_GRP_IRQ; j++) {
  1399. if (tx_mask & (1 << j))
  1400. irq_id_map[num_irq++] = (wbm2sw0_release - j);
  1401. if (rx_mask & (1 << j))
  1402. irq_id_map[num_irq++] = (reo2sw1_intr - j);
  1403. if (rx_mon_mask & (1 << j))
  1404. irq_id_map[num_irq++] = (rxmon2sw_p0_dest0 - j);
  1405. if (rx_err_ring_mask & (1 << j))
  1406. irq_id_map[num_irq++] = (reo2sw0_intr - j);
  1407. if (rx_wbm_rel_ring_mask & (1 << j))
  1408. irq_id_map[num_irq++] = (wbm2sw5_release - j);
  1409. if (reo_status_ring_mask & (1 << j))
  1410. irq_id_map[num_irq++] = (reo_status - j);
  1411. if (rxdma2host_ring_mask & (1 << j))
  1412. irq_id_map[num_irq++] = (rxdma2sw_dst_ring0 - j);
  1413. if (host2rxdma_ring_mask & (1 << j))
  1414. irq_id_map[num_irq++] = (sw2rxdma_0 - j);
  1415. if (host2rxdma_mon_ring_mask & (1 << j))
  1416. irq_id_map[num_irq++] = (sw2rxmon_src_ring - j);
  1417. if (host2txmon_ring_mask & (1 << j))
  1418. irq_id_map[num_irq++] = sw2txmon_src_ring;
  1419. if (txmon2host_mon_ring_mask & (1 << j))
  1420. irq_id_map[num_irq++] = (txmon2sw_p0_dest0 - j);
  1421. }
  1422. *num_irq_r = num_irq;
  1423. }
  1424. #else
  1425. static void dp_soc_interrupt_map_calculate_wifi3_pci_legacy(struct dp_soc *soc,
  1426. int intr_ctx_num,
  1427. int *irq_id_map,
  1428. int *num_irq_r)
  1429. {
  1430. }
  1431. #endif
  1432. static void dp_soc_interrupt_map_calculate_integrated(struct dp_soc *soc,
  1433. int intr_ctx_num, int *irq_id_map, int *num_irq_r)
  1434. {
  1435. int j;
  1436. int num_irq = 0;
  1437. int tx_mask =
  1438. wlan_cfg_get_tx_ring_mask(soc->wlan_cfg_ctx, intr_ctx_num);
  1439. int rx_mask =
  1440. wlan_cfg_get_rx_ring_mask(soc->wlan_cfg_ctx, intr_ctx_num);
  1441. int rx_mon_mask =
  1442. wlan_cfg_get_rx_mon_ring_mask(soc->wlan_cfg_ctx, intr_ctx_num);
  1443. int rx_err_ring_mask = wlan_cfg_get_rx_err_ring_mask(
  1444. soc->wlan_cfg_ctx, intr_ctx_num);
  1445. int rx_wbm_rel_ring_mask = wlan_cfg_get_rx_wbm_rel_ring_mask(
  1446. soc->wlan_cfg_ctx, intr_ctx_num);
  1447. int reo_status_ring_mask = wlan_cfg_get_reo_status_ring_mask(
  1448. soc->wlan_cfg_ctx, intr_ctx_num);
  1449. int rxdma2host_ring_mask = wlan_cfg_get_rxdma2host_ring_mask(
  1450. soc->wlan_cfg_ctx, intr_ctx_num);
  1451. int host2rxdma_ring_mask = wlan_cfg_get_host2rxdma_ring_mask(
  1452. soc->wlan_cfg_ctx, intr_ctx_num);
  1453. int host2rxdma_mon_ring_mask = wlan_cfg_get_host2rxdma_mon_ring_mask(
  1454. soc->wlan_cfg_ctx, intr_ctx_num);
  1455. int host2txmon_ring_mask = wlan_cfg_get_host2txmon_ring_mask(
  1456. soc->wlan_cfg_ctx, intr_ctx_num);
  1457. int txmon2host_mon_ring_mask = wlan_cfg_get_tx_mon_ring_mask(
  1458. soc->wlan_cfg_ctx, intr_ctx_num);
  1459. soc->intr_mode = DP_INTR_INTEGRATED;
  1460. for (j = 0; j < HIF_MAX_GRP_IRQ; j++) {
  1461. if (tx_mask & (1 << j)) {
  1462. irq_id_map[num_irq++] =
  1463. (wbm2host_tx_completions_ring1 - j);
  1464. }
  1465. if (rx_mask & (1 << j)) {
  1466. irq_id_map[num_irq++] =
  1467. (reo2host_destination_ring1 - j);
  1468. }
  1469. if (rxdma2host_ring_mask & (1 << j)) {
  1470. irq_id_map[num_irq++] =
  1471. rxdma2host_destination_ring_mac1 - j;
  1472. }
  1473. if (host2rxdma_ring_mask & (1 << j)) {
  1474. irq_id_map[num_irq++] =
  1475. host2rxdma_host_buf_ring_mac1 - j;
  1476. }
  1477. if (host2rxdma_mon_ring_mask & (1 << j)) {
  1478. irq_id_map[num_irq++] =
  1479. host2rxdma_monitor_ring1 - j;
  1480. }
  1481. if (rx_mon_mask & (1 << j)) {
  1482. irq_id_map[num_irq++] =
  1483. ppdu_end_interrupts_mac1 - j;
  1484. irq_id_map[num_irq++] =
  1485. rxdma2host_monitor_status_ring_mac1 - j;
  1486. irq_id_map[num_irq++] =
  1487. rxdma2host_monitor_destination_mac1 - j;
  1488. }
  1489. if (rx_wbm_rel_ring_mask & (1 << j))
  1490. irq_id_map[num_irq++] = wbm2host_rx_release;
  1491. if (rx_err_ring_mask & (1 << j))
  1492. irq_id_map[num_irq++] = reo2host_exception;
  1493. if (reo_status_ring_mask & (1 << j))
  1494. irq_id_map[num_irq++] = reo2host_status;
  1495. if (host2txmon_ring_mask & (1 << j))
  1496. irq_id_map[num_irq++] = host2tx_monitor_ring1;
  1497. if (txmon2host_mon_ring_mask & (1 << j)) {
  1498. irq_id_map[num_irq++] =
  1499. (txmon2host_monitor_destination_mac1 - j);
  1500. }
  1501. }
  1502. *num_irq_r = num_irq;
  1503. }
  1504. static void dp_soc_interrupt_map_calculate_msi(struct dp_soc *soc,
  1505. int intr_ctx_num, int *irq_id_map, int *num_irq_r,
  1506. int msi_vector_count, int msi_vector_start)
  1507. {
  1508. int tx_mask = wlan_cfg_get_tx_ring_mask(
  1509. soc->wlan_cfg_ctx, intr_ctx_num);
  1510. int rx_mask = wlan_cfg_get_rx_ring_mask(
  1511. soc->wlan_cfg_ctx, intr_ctx_num);
  1512. int rx_mon_mask = wlan_cfg_get_rx_mon_ring_mask(
  1513. soc->wlan_cfg_ctx, intr_ctx_num);
  1514. int tx_mon_mask = wlan_cfg_get_tx_mon_ring_mask(
  1515. soc->wlan_cfg_ctx, intr_ctx_num);
  1516. int rx_err_ring_mask = wlan_cfg_get_rx_err_ring_mask(
  1517. soc->wlan_cfg_ctx, intr_ctx_num);
  1518. int rx_wbm_rel_ring_mask = wlan_cfg_get_rx_wbm_rel_ring_mask(
  1519. soc->wlan_cfg_ctx, intr_ctx_num);
  1520. int reo_status_ring_mask = wlan_cfg_get_reo_status_ring_mask(
  1521. soc->wlan_cfg_ctx, intr_ctx_num);
  1522. int rxdma2host_ring_mask = wlan_cfg_get_rxdma2host_ring_mask(
  1523. soc->wlan_cfg_ctx, intr_ctx_num);
  1524. int host2rxdma_ring_mask = wlan_cfg_get_host2rxdma_ring_mask(
  1525. soc->wlan_cfg_ctx, intr_ctx_num);
  1526. int host2rxdma_mon_ring_mask = wlan_cfg_get_host2rxdma_mon_ring_mask(
  1527. soc->wlan_cfg_ctx, intr_ctx_num);
  1528. int rx_near_full_grp_1_mask =
  1529. wlan_cfg_get_rx_near_full_grp_1_mask(soc->wlan_cfg_ctx,
  1530. intr_ctx_num);
  1531. int rx_near_full_grp_2_mask =
  1532. wlan_cfg_get_rx_near_full_grp_2_mask(soc->wlan_cfg_ctx,
  1533. intr_ctx_num);
  1534. int tx_ring_near_full_mask =
  1535. wlan_cfg_get_tx_ring_near_full_mask(soc->wlan_cfg_ctx,
  1536. intr_ctx_num);
  1537. int host2txmon_ring_mask =
  1538. wlan_cfg_get_host2txmon_ring_mask(soc->wlan_cfg_ctx,
  1539. intr_ctx_num);
  1540. unsigned int vector =
  1541. (intr_ctx_num % msi_vector_count) + msi_vector_start;
  1542. int num_irq = 0;
  1543. soc->intr_mode = DP_INTR_MSI;
  1544. if (tx_mask | rx_mask | rx_mon_mask | tx_mon_mask | rx_err_ring_mask |
  1545. rx_wbm_rel_ring_mask | reo_status_ring_mask | rxdma2host_ring_mask |
  1546. host2rxdma_ring_mask | host2rxdma_mon_ring_mask |
  1547. rx_near_full_grp_1_mask | rx_near_full_grp_2_mask |
  1548. tx_ring_near_full_mask | host2txmon_ring_mask)
  1549. irq_id_map[num_irq++] =
  1550. pld_get_msi_irq(soc->osdev->dev, vector);
  1551. *num_irq_r = num_irq;
  1552. }
  1553. static void dp_soc_interrupt_map_calculate(struct dp_soc *soc, int intr_ctx_num,
  1554. int *irq_id_map, int *num_irq)
  1555. {
  1556. int msi_vector_count, ret;
  1557. uint32_t msi_base_data, msi_vector_start;
  1558. if (pld_get_enable_intx(soc->osdev->dev)) {
  1559. return dp_soc_interrupt_map_calculate_wifi3_pci_legacy(soc,
  1560. intr_ctx_num, irq_id_map, num_irq);
  1561. }
  1562. ret = pld_get_user_msi_assignment(soc->osdev->dev, "DP",
  1563. &msi_vector_count,
  1564. &msi_base_data,
  1565. &msi_vector_start);
  1566. if (ret)
  1567. return dp_soc_interrupt_map_calculate_integrated(soc,
  1568. intr_ctx_num, irq_id_map, num_irq);
  1569. else
  1570. dp_soc_interrupt_map_calculate_msi(soc,
  1571. intr_ctx_num, irq_id_map, num_irq,
  1572. msi_vector_count, msi_vector_start);
  1573. }
  1574. #ifdef WLAN_FEATURE_NEAR_FULL_IRQ
  1575. /**
  1576. * dp_soc_near_full_interrupt_attach() - Register handler for DP near fill irq
  1577. * @soc: DP soc handle
  1578. * @num_irq: IRQ number
  1579. * @irq_id_map: IRQ map
  1580. * @intr_id: interrupt context ID
  1581. *
  1582. * Return: 0 for success. nonzero for failure.
  1583. */
  1584. static inline int
  1585. dp_soc_near_full_interrupt_attach(struct dp_soc *soc, int num_irq,
  1586. int irq_id_map[], int intr_id)
  1587. {
  1588. return hif_register_ext_group(soc->hif_handle,
  1589. num_irq, irq_id_map,
  1590. dp_service_near_full_srngs,
  1591. &soc->intr_ctx[intr_id], "dp_nf_intr",
  1592. HIF_EXEC_NAPI_TYPE,
  1593. QCA_NAPI_DEF_SCALE_BIN_SHIFT);
  1594. }
  1595. #else
  1596. static inline int
  1597. dp_soc_near_full_interrupt_attach(struct dp_soc *soc, int num_irq,
  1598. int *irq_id_map, int intr_id)
  1599. {
  1600. return 0;
  1601. }
  1602. #endif
  1603. #ifdef DP_CON_MON_MSI_SKIP_SET
  1604. static inline bool dp_skip_rx_mon_ring_mask_set(struct dp_soc *soc)
  1605. {
  1606. return !!(soc->cdp_soc.ol_ops->get_con_mode() !=
  1607. QDF_GLOBAL_MONITOR_MODE &&
  1608. !wlan_cfg_get_local_pkt_capture(soc->wlan_cfg_ctx));
  1609. }
  1610. #else
  1611. static inline bool dp_skip_rx_mon_ring_mask_set(struct dp_soc *soc)
  1612. {
  1613. return false;
  1614. }
  1615. #endif
  1616. void dp_soc_interrupt_detach(struct cdp_soc_t *txrx_soc)
  1617. {
  1618. struct dp_soc *soc = (struct dp_soc *)txrx_soc;
  1619. int i;
  1620. if (soc->intr_mode == DP_INTR_POLL) {
  1621. qdf_timer_free(&soc->int_timer);
  1622. } else {
  1623. hif_deconfigure_ext_group_interrupts(soc->hif_handle);
  1624. hif_deregister_exec_group(soc->hif_handle, "dp_intr");
  1625. hif_deregister_exec_group(soc->hif_handle, "dp_nf_intr");
  1626. }
  1627. for (i = 0; i < wlan_cfg_get_num_contexts(soc->wlan_cfg_ctx); i++) {
  1628. soc->intr_ctx[i].tx_ring_mask = 0;
  1629. soc->intr_ctx[i].rx_ring_mask = 0;
  1630. soc->intr_ctx[i].rx_mon_ring_mask = 0;
  1631. soc->intr_ctx[i].rx_err_ring_mask = 0;
  1632. soc->intr_ctx[i].rx_wbm_rel_ring_mask = 0;
  1633. soc->intr_ctx[i].reo_status_ring_mask = 0;
  1634. soc->intr_ctx[i].rxdma2host_ring_mask = 0;
  1635. soc->intr_ctx[i].host2rxdma_ring_mask = 0;
  1636. soc->intr_ctx[i].host2rxdma_mon_ring_mask = 0;
  1637. soc->intr_ctx[i].rx_near_full_grp_1_mask = 0;
  1638. soc->intr_ctx[i].rx_near_full_grp_2_mask = 0;
  1639. soc->intr_ctx[i].tx_ring_near_full_mask = 0;
  1640. soc->intr_ctx[i].tx_mon_ring_mask = 0;
  1641. soc->intr_ctx[i].host2txmon_ring_mask = 0;
  1642. soc->intr_ctx[i].umac_reset_intr_mask = 0;
  1643. hif_event_history_deinit(soc->hif_handle, i);
  1644. qdf_lro_deinit(soc->intr_ctx[i].lro_ctx);
  1645. }
  1646. qdf_mem_set(&soc->mon_intr_id_lmac_map,
  1647. sizeof(soc->mon_intr_id_lmac_map),
  1648. DP_MON_INVALID_LMAC_ID);
  1649. }
  1650. QDF_STATUS dp_soc_interrupt_attach(struct cdp_soc_t *txrx_soc)
  1651. {
  1652. struct dp_soc *soc = (struct dp_soc *)txrx_soc;
  1653. int i = 0;
  1654. int num_irq = 0;
  1655. int rx_err_ring_intr_ctxt_id = HIF_MAX_GROUP;
  1656. int lmac_id = 0;
  1657. int napi_scale;
  1658. qdf_mem_set(&soc->mon_intr_id_lmac_map,
  1659. sizeof(soc->mon_intr_id_lmac_map), DP_MON_INVALID_LMAC_ID);
  1660. for (i = 0; i < wlan_cfg_get_num_contexts(soc->wlan_cfg_ctx); i++) {
  1661. int ret = 0;
  1662. /* Map of IRQ ids registered with one interrupt context */
  1663. int irq_id_map[HIF_MAX_GRP_IRQ];
  1664. int tx_mask =
  1665. wlan_cfg_get_tx_ring_mask(soc->wlan_cfg_ctx, i);
  1666. int rx_mask =
  1667. wlan_cfg_get_rx_ring_mask(soc->wlan_cfg_ctx, i);
  1668. int rx_mon_mask =
  1669. dp_soc_get_mon_mask_for_interrupt_mode(soc, i);
  1670. int tx_mon_ring_mask =
  1671. wlan_cfg_get_tx_mon_ring_mask(soc->wlan_cfg_ctx, i);
  1672. int rx_err_ring_mask =
  1673. wlan_cfg_get_rx_err_ring_mask(soc->wlan_cfg_ctx, i);
  1674. int rx_wbm_rel_ring_mask =
  1675. wlan_cfg_get_rx_wbm_rel_ring_mask(soc->wlan_cfg_ctx, i);
  1676. int reo_status_ring_mask =
  1677. wlan_cfg_get_reo_status_ring_mask(soc->wlan_cfg_ctx, i);
  1678. int rxdma2host_ring_mask =
  1679. wlan_cfg_get_rxdma2host_ring_mask(soc->wlan_cfg_ctx, i);
  1680. int host2rxdma_ring_mask =
  1681. wlan_cfg_get_host2rxdma_ring_mask(soc->wlan_cfg_ctx, i);
  1682. int host2rxdma_mon_ring_mask =
  1683. wlan_cfg_get_host2rxdma_mon_ring_mask(
  1684. soc->wlan_cfg_ctx, i);
  1685. int rx_near_full_grp_1_mask =
  1686. wlan_cfg_get_rx_near_full_grp_1_mask(soc->wlan_cfg_ctx,
  1687. i);
  1688. int rx_near_full_grp_2_mask =
  1689. wlan_cfg_get_rx_near_full_grp_2_mask(soc->wlan_cfg_ctx,
  1690. i);
  1691. int tx_ring_near_full_mask =
  1692. wlan_cfg_get_tx_ring_near_full_mask(soc->wlan_cfg_ctx,
  1693. i);
  1694. int host2txmon_ring_mask =
  1695. wlan_cfg_get_host2txmon_ring_mask(soc->wlan_cfg_ctx, i);
  1696. int umac_reset_intr_mask =
  1697. wlan_cfg_get_umac_reset_intr_mask(soc->wlan_cfg_ctx, i);
  1698. if (dp_skip_rx_mon_ring_mask_set(soc))
  1699. rx_mon_mask = 0;
  1700. soc->intr_ctx[i].dp_intr_id = i;
  1701. soc->intr_ctx[i].tx_ring_mask = tx_mask;
  1702. soc->intr_ctx[i].rx_ring_mask = rx_mask;
  1703. soc->intr_ctx[i].rx_mon_ring_mask = rx_mon_mask;
  1704. soc->intr_ctx[i].rx_err_ring_mask = rx_err_ring_mask;
  1705. soc->intr_ctx[i].rxdma2host_ring_mask = rxdma2host_ring_mask;
  1706. soc->intr_ctx[i].host2rxdma_ring_mask = host2rxdma_ring_mask;
  1707. soc->intr_ctx[i].rx_wbm_rel_ring_mask = rx_wbm_rel_ring_mask;
  1708. soc->intr_ctx[i].reo_status_ring_mask = reo_status_ring_mask;
  1709. soc->intr_ctx[i].host2rxdma_mon_ring_mask =
  1710. host2rxdma_mon_ring_mask;
  1711. soc->intr_ctx[i].rx_near_full_grp_1_mask =
  1712. rx_near_full_grp_1_mask;
  1713. soc->intr_ctx[i].rx_near_full_grp_2_mask =
  1714. rx_near_full_grp_2_mask;
  1715. soc->intr_ctx[i].tx_ring_near_full_mask =
  1716. tx_ring_near_full_mask;
  1717. soc->intr_ctx[i].tx_mon_ring_mask = tx_mon_ring_mask;
  1718. soc->intr_ctx[i].host2txmon_ring_mask = host2txmon_ring_mask;
  1719. soc->intr_ctx[i].umac_reset_intr_mask = umac_reset_intr_mask;
  1720. soc->intr_ctx[i].soc = soc;
  1721. num_irq = 0;
  1722. dp_soc_interrupt_map_calculate(soc, i, &irq_id_map[0],
  1723. &num_irq);
  1724. if (rx_near_full_grp_1_mask | rx_near_full_grp_2_mask |
  1725. tx_ring_near_full_mask) {
  1726. dp_soc_near_full_interrupt_attach(soc, num_irq,
  1727. irq_id_map, i);
  1728. } else {
  1729. napi_scale = wlan_cfg_get_napi_scale_factor(
  1730. soc->wlan_cfg_ctx);
  1731. if (!napi_scale)
  1732. napi_scale = QCA_NAPI_DEF_SCALE_BIN_SHIFT;
  1733. ret = hif_register_ext_group(soc->hif_handle,
  1734. num_irq, irq_id_map, dp_service_srngs,
  1735. &soc->intr_ctx[i], "dp_intr",
  1736. HIF_EXEC_NAPI_TYPE, napi_scale);
  1737. }
  1738. dp_debug(" int ctx %u num_irq %u irq_id_map %u %u",
  1739. i, num_irq, irq_id_map[0], irq_id_map[1]);
  1740. if (ret) {
  1741. dp_init_err("%pK: failed, ret = %d", soc, ret);
  1742. dp_soc_interrupt_detach(txrx_soc);
  1743. return QDF_STATUS_E_FAILURE;
  1744. }
  1745. hif_event_history_init(soc->hif_handle, i);
  1746. soc->intr_ctx[i].lro_ctx = qdf_lro_init();
  1747. if (rx_err_ring_mask)
  1748. rx_err_ring_intr_ctxt_id = i;
  1749. if (dp_is_mon_mask_valid(soc, &soc->intr_ctx[i])) {
  1750. soc->mon_intr_id_lmac_map[lmac_id] = i;
  1751. lmac_id++;
  1752. }
  1753. }
  1754. hif_configure_ext_group_interrupts(soc->hif_handle);
  1755. if (rx_err_ring_intr_ctxt_id != HIF_MAX_GROUP)
  1756. hif_config_irq_clear_cpu_affinity(soc->hif_handle,
  1757. rx_err_ring_intr_ctxt_id, 0);
  1758. return QDF_STATUS_SUCCESS;
  1759. }
  1760. #define AVG_MAX_MPDUS_PER_TID 128
  1761. #define AVG_TIDS_PER_CLIENT 2
  1762. #define AVG_FLOWS_PER_TID 2
  1763. #define AVG_MSDUS_PER_FLOW 128
  1764. #define AVG_MSDUS_PER_MPDU 4
  1765. void dp_hw_link_desc_pool_banks_free(struct dp_soc *soc, uint32_t mac_id)
  1766. {
  1767. struct qdf_mem_multi_page_t *pages;
  1768. if (mac_id != WLAN_INVALID_PDEV_ID) {
  1769. pages = dp_monitor_get_link_desc_pages(soc, mac_id);
  1770. } else {
  1771. pages = &soc->link_desc_pages;
  1772. }
  1773. if (!pages) {
  1774. dp_err("can not get link desc pages");
  1775. QDF_ASSERT(0);
  1776. return;
  1777. }
  1778. if (pages->dma_pages) {
  1779. wlan_minidump_remove((void *)
  1780. pages->dma_pages->page_v_addr_start,
  1781. pages->num_pages * pages->page_size,
  1782. soc->ctrl_psoc,
  1783. WLAN_MD_DP_SRNG_WBM_IDLE_LINK,
  1784. "hw_link_desc_bank");
  1785. dp_desc_multi_pages_mem_free(soc, DP_HW_LINK_DESC_TYPE,
  1786. pages, 0, false);
  1787. }
  1788. }
  1789. qdf_export_symbol(dp_hw_link_desc_pool_banks_free);
  1790. QDF_STATUS dp_hw_link_desc_pool_banks_alloc(struct dp_soc *soc, uint32_t mac_id)
  1791. {
  1792. hal_soc_handle_t hal_soc = soc->hal_soc;
  1793. int link_desc_size = hal_get_link_desc_size(soc->hal_soc);
  1794. int link_desc_align = hal_get_link_desc_align(soc->hal_soc);
  1795. uint32_t max_clients = wlan_cfg_get_max_clients(soc->wlan_cfg_ctx);
  1796. uint32_t num_mpdus_per_link_desc = hal_num_mpdus_per_link_desc(hal_soc);
  1797. uint32_t num_msdus_per_link_desc = hal_num_msdus_per_link_desc(hal_soc);
  1798. uint32_t num_mpdu_links_per_queue_desc =
  1799. hal_num_mpdu_links_per_queue_desc(hal_soc);
  1800. uint32_t max_alloc_size = wlan_cfg_max_alloc_size(soc->wlan_cfg_ctx);
  1801. uint32_t *total_link_descs, total_mem_size;
  1802. uint32_t num_mpdu_link_descs, num_mpdu_queue_descs;
  1803. uint32_t num_tx_msdu_link_descs, num_rx_msdu_link_descs;
  1804. uint32_t num_entries;
  1805. struct qdf_mem_multi_page_t *pages;
  1806. struct dp_srng *dp_srng;
  1807. uint8_t minidump_str[MINIDUMP_STR_SIZE];
  1808. /* Only Tx queue descriptors are allocated from common link descriptor
  1809. * pool Rx queue descriptors are not included in this because (REO queue
  1810. * extension descriptors) they are expected to be allocated contiguously
  1811. * with REO queue descriptors
  1812. */
  1813. if (mac_id != WLAN_INVALID_PDEV_ID) {
  1814. pages = dp_monitor_get_link_desc_pages(soc, mac_id);
  1815. /* dp_monitor_get_link_desc_pages returns NULL only
  1816. * if monitor SOC is NULL
  1817. */
  1818. if (!pages) {
  1819. dp_err("can not get link desc pages");
  1820. QDF_ASSERT(0);
  1821. return QDF_STATUS_E_FAULT;
  1822. }
  1823. dp_srng = &soc->rxdma_mon_desc_ring[mac_id];
  1824. num_entries = dp_srng->alloc_size /
  1825. hal_srng_get_entrysize(soc->hal_soc,
  1826. RXDMA_MONITOR_DESC);
  1827. total_link_descs = dp_monitor_get_total_link_descs(soc, mac_id);
  1828. qdf_str_lcopy(minidump_str, "mon_link_desc_bank",
  1829. MINIDUMP_STR_SIZE);
  1830. } else {
  1831. num_mpdu_link_descs = (max_clients * AVG_TIDS_PER_CLIENT *
  1832. AVG_MAX_MPDUS_PER_TID) / num_mpdus_per_link_desc;
  1833. num_mpdu_queue_descs = num_mpdu_link_descs /
  1834. num_mpdu_links_per_queue_desc;
  1835. num_tx_msdu_link_descs = (max_clients * AVG_TIDS_PER_CLIENT *
  1836. AVG_FLOWS_PER_TID * AVG_MSDUS_PER_FLOW) /
  1837. num_msdus_per_link_desc;
  1838. num_rx_msdu_link_descs = (max_clients * AVG_TIDS_PER_CLIENT *
  1839. AVG_MAX_MPDUS_PER_TID * AVG_MSDUS_PER_MPDU) / 6;
  1840. num_entries = num_mpdu_link_descs + num_mpdu_queue_descs +
  1841. num_tx_msdu_link_descs + num_rx_msdu_link_descs;
  1842. pages = &soc->link_desc_pages;
  1843. total_link_descs = &soc->total_link_descs;
  1844. qdf_str_lcopy(minidump_str, "link_desc_bank",
  1845. MINIDUMP_STR_SIZE);
  1846. }
  1847. /* If link descriptor banks are allocated, return from here */
  1848. if (pages->num_pages)
  1849. return QDF_STATUS_SUCCESS;
  1850. /* Round up to power of 2 */
  1851. *total_link_descs = 1;
  1852. while (*total_link_descs < num_entries)
  1853. *total_link_descs <<= 1;
  1854. dp_init_info("%pK: total_link_descs: %u, link_desc_size: %d",
  1855. soc, *total_link_descs, link_desc_size);
  1856. total_mem_size = *total_link_descs * link_desc_size;
  1857. total_mem_size += link_desc_align;
  1858. dp_init_info("%pK: total_mem_size: %d",
  1859. soc, total_mem_size);
  1860. dp_set_max_page_size(pages, max_alloc_size);
  1861. dp_desc_multi_pages_mem_alloc(soc, DP_HW_LINK_DESC_TYPE,
  1862. pages,
  1863. link_desc_size,
  1864. *total_link_descs,
  1865. 0, false);
  1866. if (!pages->num_pages) {
  1867. dp_err("Multi page alloc fail for hw link desc pool");
  1868. return QDF_STATUS_E_FAULT;
  1869. }
  1870. wlan_minidump_log(pages->dma_pages->page_v_addr_start,
  1871. pages->num_pages * pages->page_size,
  1872. soc->ctrl_psoc,
  1873. WLAN_MD_DP_SRNG_WBM_IDLE_LINK,
  1874. "hw_link_desc_bank");
  1875. return QDF_STATUS_SUCCESS;
  1876. }
  1877. void dp_hw_link_desc_ring_free(struct dp_soc *soc)
  1878. {
  1879. uint32_t i;
  1880. uint32_t size = soc->wbm_idle_scatter_buf_size;
  1881. void *vaddr = soc->wbm_idle_link_ring.base_vaddr_unaligned;
  1882. qdf_dma_addr_t paddr;
  1883. if (soc->wbm_idle_scatter_buf_base_vaddr[0]) {
  1884. for (i = 0; i < MAX_IDLE_SCATTER_BUFS; i++) {
  1885. vaddr = soc->wbm_idle_scatter_buf_base_vaddr[i];
  1886. paddr = soc->wbm_idle_scatter_buf_base_paddr[i];
  1887. if (vaddr) {
  1888. qdf_mem_free_consistent(soc->osdev,
  1889. soc->osdev->dev,
  1890. size,
  1891. vaddr,
  1892. paddr,
  1893. 0);
  1894. vaddr = NULL;
  1895. }
  1896. }
  1897. } else {
  1898. wlan_minidump_remove(soc->wbm_idle_link_ring.base_vaddr_unaligned,
  1899. soc->wbm_idle_link_ring.alloc_size,
  1900. soc->ctrl_psoc,
  1901. WLAN_MD_DP_SRNG_WBM_IDLE_LINK,
  1902. "wbm_idle_link_ring");
  1903. dp_srng_free(soc, &soc->wbm_idle_link_ring);
  1904. }
  1905. }
  1906. QDF_STATUS dp_hw_link_desc_ring_alloc(struct dp_soc *soc)
  1907. {
  1908. uint32_t entry_size, i;
  1909. uint32_t total_mem_size;
  1910. qdf_dma_addr_t *baseaddr = NULL;
  1911. struct dp_srng *dp_srng;
  1912. uint32_t ring_type;
  1913. uint32_t max_alloc_size = wlan_cfg_max_alloc_size(soc->wlan_cfg_ctx);
  1914. uint32_t tlds;
  1915. ring_type = WBM_IDLE_LINK;
  1916. dp_srng = &soc->wbm_idle_link_ring;
  1917. tlds = soc->total_link_descs;
  1918. entry_size = hal_srng_get_entrysize(soc->hal_soc, ring_type);
  1919. total_mem_size = entry_size * tlds;
  1920. if (total_mem_size <= max_alloc_size) {
  1921. if (dp_srng_alloc(soc, dp_srng, ring_type, tlds, 0)) {
  1922. dp_init_err("%pK: Link desc idle ring setup failed",
  1923. soc);
  1924. goto fail;
  1925. }
  1926. wlan_minidump_log(soc->wbm_idle_link_ring.base_vaddr_unaligned,
  1927. soc->wbm_idle_link_ring.alloc_size,
  1928. soc->ctrl_psoc,
  1929. WLAN_MD_DP_SRNG_WBM_IDLE_LINK,
  1930. "wbm_idle_link_ring");
  1931. } else {
  1932. uint32_t num_scatter_bufs;
  1933. uint32_t buf_size = 0;
  1934. soc->wbm_idle_scatter_buf_size =
  1935. hal_idle_list_scatter_buf_size(soc->hal_soc);
  1936. hal_idle_scatter_buf_num_entries(
  1937. soc->hal_soc,
  1938. soc->wbm_idle_scatter_buf_size);
  1939. num_scatter_bufs = hal_idle_list_num_scatter_bufs(
  1940. soc->hal_soc, total_mem_size,
  1941. soc->wbm_idle_scatter_buf_size);
  1942. if (num_scatter_bufs > MAX_IDLE_SCATTER_BUFS) {
  1943. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  1944. FL("scatter bufs size out of bounds"));
  1945. goto fail;
  1946. }
  1947. for (i = 0; i < num_scatter_bufs; i++) {
  1948. baseaddr = &soc->wbm_idle_scatter_buf_base_paddr[i];
  1949. buf_size = soc->wbm_idle_scatter_buf_size;
  1950. soc->wbm_idle_scatter_buf_base_vaddr[i] =
  1951. qdf_mem_alloc_consistent(soc->osdev,
  1952. soc->osdev->dev,
  1953. buf_size,
  1954. baseaddr);
  1955. if (!soc->wbm_idle_scatter_buf_base_vaddr[i]) {
  1956. QDF_TRACE(QDF_MODULE_ID_DP,
  1957. QDF_TRACE_LEVEL_ERROR,
  1958. FL("Scatter lst memory alloc fail"));
  1959. goto fail;
  1960. }
  1961. }
  1962. soc->num_scatter_bufs = num_scatter_bufs;
  1963. }
  1964. return QDF_STATUS_SUCCESS;
  1965. fail:
  1966. for (i = 0; i < MAX_IDLE_SCATTER_BUFS; i++) {
  1967. void *vaddr = soc->wbm_idle_scatter_buf_base_vaddr[i];
  1968. qdf_dma_addr_t paddr = soc->wbm_idle_scatter_buf_base_paddr[i];
  1969. if (vaddr) {
  1970. qdf_mem_free_consistent(soc->osdev, soc->osdev->dev,
  1971. soc->wbm_idle_scatter_buf_size,
  1972. vaddr,
  1973. paddr, 0);
  1974. vaddr = NULL;
  1975. }
  1976. }
  1977. return QDF_STATUS_E_NOMEM;
  1978. }
  1979. qdf_export_symbol(dp_hw_link_desc_pool_banks_alloc);
  1980. QDF_STATUS dp_hw_link_desc_ring_init(struct dp_soc *soc)
  1981. {
  1982. struct dp_srng *dp_srng = &soc->wbm_idle_link_ring;
  1983. if (dp_srng->base_vaddr_unaligned) {
  1984. if (dp_srng_init(soc, dp_srng, WBM_IDLE_LINK, 0, 0))
  1985. return QDF_STATUS_E_FAILURE;
  1986. }
  1987. return QDF_STATUS_SUCCESS;
  1988. }
  1989. void dp_hw_link_desc_ring_deinit(struct dp_soc *soc)
  1990. {
  1991. dp_srng_deinit(soc, &soc->wbm_idle_link_ring, WBM_IDLE_LINK, 0);
  1992. }
  1993. void dp_link_desc_ring_replenish(struct dp_soc *soc, uint32_t mac_id)
  1994. {
  1995. uint32_t cookie = 0;
  1996. uint32_t page_idx = 0;
  1997. struct qdf_mem_multi_page_t *pages;
  1998. struct qdf_mem_dma_page_t *dma_pages;
  1999. uint32_t offset = 0;
  2000. uint32_t count = 0;
  2001. uint32_t desc_id = 0;
  2002. void *desc_srng;
  2003. int link_desc_size = hal_get_link_desc_size(soc->hal_soc);
  2004. uint32_t *total_link_descs_addr;
  2005. uint32_t total_link_descs;
  2006. uint32_t scatter_buf_num;
  2007. uint32_t num_entries_per_buf = 0;
  2008. uint32_t rem_entries;
  2009. uint32_t num_descs_per_page;
  2010. uint32_t num_scatter_bufs = 0;
  2011. uint8_t *scatter_buf_ptr;
  2012. void *desc;
  2013. num_scatter_bufs = soc->num_scatter_bufs;
  2014. if (mac_id == WLAN_INVALID_PDEV_ID) {
  2015. pages = &soc->link_desc_pages;
  2016. total_link_descs = soc->total_link_descs;
  2017. desc_srng = soc->wbm_idle_link_ring.hal_srng;
  2018. } else {
  2019. pages = dp_monitor_get_link_desc_pages(soc, mac_id);
  2020. /* dp_monitor_get_link_desc_pages returns NULL only
  2021. * if monitor SOC is NULL
  2022. */
  2023. if (!pages) {
  2024. dp_err("can not get link desc pages");
  2025. QDF_ASSERT(0);
  2026. return;
  2027. }
  2028. total_link_descs_addr =
  2029. dp_monitor_get_total_link_descs(soc, mac_id);
  2030. total_link_descs = *total_link_descs_addr;
  2031. desc_srng = soc->rxdma_mon_desc_ring[mac_id].hal_srng;
  2032. }
  2033. dma_pages = pages->dma_pages;
  2034. do {
  2035. qdf_mem_zero(dma_pages[page_idx].page_v_addr_start,
  2036. pages->page_size);
  2037. page_idx++;
  2038. } while (page_idx < pages->num_pages);
  2039. if (desc_srng) {
  2040. hal_srng_access_start_unlocked(soc->hal_soc, desc_srng);
  2041. page_idx = 0;
  2042. count = 0;
  2043. offset = 0;
  2044. pages = &soc->link_desc_pages;
  2045. while ((desc = hal_srng_src_get_next(soc->hal_soc,
  2046. desc_srng)) &&
  2047. (count < total_link_descs)) {
  2048. page_idx = count / pages->num_element_per_page;
  2049. if (desc_id == pages->num_element_per_page)
  2050. desc_id = 0;
  2051. offset = count % pages->num_element_per_page;
  2052. cookie = LINK_DESC_COOKIE(desc_id, page_idx,
  2053. soc->link_desc_id_start);
  2054. hal_set_link_desc_addr(soc->hal_soc, desc, cookie,
  2055. dma_pages[page_idx].page_p_addr
  2056. + (offset * link_desc_size),
  2057. soc->idle_link_bm_id);
  2058. count++;
  2059. desc_id++;
  2060. }
  2061. hal_srng_access_end_unlocked(soc->hal_soc, desc_srng);
  2062. } else {
  2063. /* Populate idle list scatter buffers with link descriptor
  2064. * pointers
  2065. */
  2066. scatter_buf_num = 0;
  2067. num_entries_per_buf = hal_idle_scatter_buf_num_entries(
  2068. soc->hal_soc,
  2069. soc->wbm_idle_scatter_buf_size);
  2070. scatter_buf_ptr = (uint8_t *)(
  2071. soc->wbm_idle_scatter_buf_base_vaddr[scatter_buf_num]);
  2072. rem_entries = num_entries_per_buf;
  2073. pages = &soc->link_desc_pages;
  2074. page_idx = 0; count = 0;
  2075. offset = 0;
  2076. num_descs_per_page = pages->num_element_per_page;
  2077. while (count < total_link_descs) {
  2078. page_idx = count / num_descs_per_page;
  2079. offset = count % num_descs_per_page;
  2080. if (desc_id == pages->num_element_per_page)
  2081. desc_id = 0;
  2082. cookie = LINK_DESC_COOKIE(desc_id, page_idx,
  2083. soc->link_desc_id_start);
  2084. hal_set_link_desc_addr(soc->hal_soc,
  2085. (void *)scatter_buf_ptr,
  2086. cookie,
  2087. dma_pages[page_idx].page_p_addr +
  2088. (offset * link_desc_size),
  2089. soc->idle_link_bm_id);
  2090. rem_entries--;
  2091. if (rem_entries) {
  2092. scatter_buf_ptr += link_desc_size;
  2093. } else {
  2094. rem_entries = num_entries_per_buf;
  2095. scatter_buf_num++;
  2096. if (scatter_buf_num >= num_scatter_bufs)
  2097. break;
  2098. scatter_buf_ptr = (uint8_t *)
  2099. (soc->wbm_idle_scatter_buf_base_vaddr[
  2100. scatter_buf_num]);
  2101. }
  2102. count++;
  2103. desc_id++;
  2104. }
  2105. /* Setup link descriptor idle list in HW */
  2106. hal_setup_link_idle_list(soc->hal_soc,
  2107. soc->wbm_idle_scatter_buf_base_paddr,
  2108. soc->wbm_idle_scatter_buf_base_vaddr,
  2109. num_scatter_bufs, soc->wbm_idle_scatter_buf_size,
  2110. (uint32_t)(scatter_buf_ptr -
  2111. (uint8_t *)(soc->wbm_idle_scatter_buf_base_vaddr[
  2112. scatter_buf_num-1])), total_link_descs);
  2113. }
  2114. }
  2115. qdf_export_symbol(dp_link_desc_ring_replenish);
  2116. #ifdef IPA_OFFLOAD
  2117. #define USE_1_IPA_RX_REO_RING 1
  2118. #define USE_2_IPA_RX_REO_RINGS 2
  2119. #define REO_DST_RING_SIZE_QCA6290 1023
  2120. #ifndef CONFIG_WIFI_EMULATION_WIFI_3_0
  2121. #define REO_DST_RING_SIZE_QCA8074 1023
  2122. #define REO_DST_RING_SIZE_QCN9000 2048
  2123. #else
  2124. #define REO_DST_RING_SIZE_QCA8074 8
  2125. #define REO_DST_RING_SIZE_QCN9000 8
  2126. #endif /* CONFIG_WIFI_EMULATION_WIFI_3_0 */
  2127. #ifdef IPA_WDI3_TX_TWO_PIPES
  2128. #ifdef DP_MEMORY_OPT
  2129. static int dp_ipa_init_alt_tx_ring(struct dp_soc *soc)
  2130. {
  2131. return dp_init_tx_ring_pair_by_index(soc, IPA_TX_ALT_RING_IDX);
  2132. }
  2133. static void dp_ipa_deinit_alt_tx_ring(struct dp_soc *soc)
  2134. {
  2135. dp_deinit_tx_pair_by_index(soc, IPA_TX_ALT_RING_IDX);
  2136. }
  2137. static int dp_ipa_alloc_alt_tx_ring(struct dp_soc *soc)
  2138. {
  2139. return dp_alloc_tx_ring_pair_by_index(soc, IPA_TX_ALT_RING_IDX);
  2140. }
  2141. static void dp_ipa_free_alt_tx_ring(struct dp_soc *soc)
  2142. {
  2143. dp_free_tx_ring_pair_by_index(soc, IPA_TX_ALT_RING_IDX);
  2144. }
  2145. #else /* !DP_MEMORY_OPT */
  2146. static int dp_ipa_init_alt_tx_ring(struct dp_soc *soc)
  2147. {
  2148. return 0;
  2149. }
  2150. static void dp_ipa_deinit_alt_tx_ring(struct dp_soc *soc)
  2151. {
  2152. }
  2153. static int dp_ipa_alloc_alt_tx_ring(struct dp_soc *soc)
  2154. {
  2155. return 0;
  2156. }
  2157. static void dp_ipa_free_alt_tx_ring(struct dp_soc *soc)
  2158. {
  2159. }
  2160. #endif /* DP_MEMORY_OPT */
  2161. void dp_ipa_hal_tx_init_alt_data_ring(struct dp_soc *soc)
  2162. {
  2163. hal_tx_init_data_ring(soc->hal_soc,
  2164. soc->tcl_data_ring[IPA_TX_ALT_RING_IDX].hal_srng);
  2165. }
  2166. #else /* !IPA_WDI3_TX_TWO_PIPES */
  2167. static int dp_ipa_init_alt_tx_ring(struct dp_soc *soc)
  2168. {
  2169. return 0;
  2170. }
  2171. static void dp_ipa_deinit_alt_tx_ring(struct dp_soc *soc)
  2172. {
  2173. }
  2174. static int dp_ipa_alloc_alt_tx_ring(struct dp_soc *soc)
  2175. {
  2176. return 0;
  2177. }
  2178. static void dp_ipa_free_alt_tx_ring(struct dp_soc *soc)
  2179. {
  2180. }
  2181. void dp_ipa_hal_tx_init_alt_data_ring(struct dp_soc *soc)
  2182. {
  2183. }
  2184. #endif /* IPA_WDI3_TX_TWO_PIPES */
  2185. #else
  2186. #define REO_DST_RING_SIZE_QCA6290 1024
  2187. static int dp_ipa_init_alt_tx_ring(struct dp_soc *soc)
  2188. {
  2189. return 0;
  2190. }
  2191. static void dp_ipa_deinit_alt_tx_ring(struct dp_soc *soc)
  2192. {
  2193. }
  2194. static int dp_ipa_alloc_alt_tx_ring(struct dp_soc *soc)
  2195. {
  2196. return 0;
  2197. }
  2198. static void dp_ipa_free_alt_tx_ring(struct dp_soc *soc)
  2199. {
  2200. }
  2201. void dp_ipa_hal_tx_init_alt_data_ring(struct dp_soc *soc)
  2202. {
  2203. }
  2204. #endif /* IPA_OFFLOAD */
  2205. /**
  2206. * dp_soc_reset_cpu_ring_map() - Reset cpu ring map
  2207. * @soc: Datapath soc handler
  2208. *
  2209. * This api resets the default cpu ring map
  2210. */
  2211. void dp_soc_reset_cpu_ring_map(struct dp_soc *soc)
  2212. {
  2213. uint8_t i;
  2214. int nss_config = wlan_cfg_get_dp_soc_nss_cfg(soc->wlan_cfg_ctx);
  2215. for (i = 0; i < WLAN_CFG_INT_NUM_CONTEXTS; i++) {
  2216. switch (nss_config) {
  2217. case dp_nss_cfg_first_radio:
  2218. /*
  2219. * Setting Tx ring map for one nss offloaded radio
  2220. */
  2221. soc->tx_ring_map[i] = dp_cpu_ring_map[DP_NSS_FIRST_RADIO_OFFLOADED_MAP][i];
  2222. break;
  2223. case dp_nss_cfg_second_radio:
  2224. /*
  2225. * Setting Tx ring for two nss offloaded radios
  2226. */
  2227. soc->tx_ring_map[i] = dp_cpu_ring_map[DP_NSS_SECOND_RADIO_OFFLOADED_MAP][i];
  2228. break;
  2229. case dp_nss_cfg_dbdc:
  2230. /*
  2231. * Setting Tx ring map for 2 nss offloaded radios
  2232. */
  2233. soc->tx_ring_map[i] =
  2234. dp_cpu_ring_map[DP_NSS_DBDC_OFFLOADED_MAP][i];
  2235. break;
  2236. case dp_nss_cfg_dbtc:
  2237. /*
  2238. * Setting Tx ring map for 3 nss offloaded radios
  2239. */
  2240. soc->tx_ring_map[i] =
  2241. dp_cpu_ring_map[DP_NSS_DBTC_OFFLOADED_MAP][i];
  2242. break;
  2243. default:
  2244. dp_err("tx_ring_map failed due to invalid nss cfg");
  2245. break;
  2246. }
  2247. }
  2248. }
  2249. /**
  2250. * dp_soc_disable_unused_mac_intr_mask() - reset interrupt mask for
  2251. * unused WMAC hw rings
  2252. * @soc: DP Soc handle
  2253. * @mac_num: wmac num
  2254. *
  2255. * Return: Return void
  2256. */
  2257. static void dp_soc_disable_unused_mac_intr_mask(struct dp_soc *soc,
  2258. int mac_num)
  2259. {
  2260. uint8_t *grp_mask = NULL;
  2261. int group_number;
  2262. grp_mask = &soc->wlan_cfg_ctx->int_host2rxdma_ring_mask[0];
  2263. group_number = dp_srng_find_ring_in_mask(mac_num, grp_mask);
  2264. wlan_cfg_set_host2rxdma_ring_mask(soc->wlan_cfg_ctx,
  2265. group_number, 0x0);
  2266. grp_mask = &soc->wlan_cfg_ctx->int_rx_mon_ring_mask[0];
  2267. group_number = dp_srng_find_ring_in_mask(mac_num, grp_mask);
  2268. wlan_cfg_set_rx_mon_ring_mask(soc->wlan_cfg_ctx,
  2269. group_number, 0x0);
  2270. grp_mask = &soc->wlan_cfg_ctx->int_rxdma2host_ring_mask[0];
  2271. group_number = dp_srng_find_ring_in_mask(mac_num, grp_mask);
  2272. wlan_cfg_set_rxdma2host_ring_mask(soc->wlan_cfg_ctx,
  2273. group_number, 0x0);
  2274. grp_mask = &soc->wlan_cfg_ctx->int_host2rxdma_mon_ring_mask[0];
  2275. group_number = dp_srng_find_ring_in_mask(mac_num, grp_mask);
  2276. wlan_cfg_set_host2rxdma_mon_ring_mask(soc->wlan_cfg_ctx,
  2277. group_number, 0x0);
  2278. }
  2279. #ifdef IPA_OFFLOAD
  2280. #ifdef IPA_WDI3_VLAN_SUPPORT
  2281. /**
  2282. * dp_soc_reset_ipa_vlan_intr_mask() - reset interrupt mask for IPA offloaded
  2283. * ring for vlan tagged traffic
  2284. * @soc: DP Soc handle
  2285. *
  2286. * Return: Return void
  2287. */
  2288. void dp_soc_reset_ipa_vlan_intr_mask(struct dp_soc *soc)
  2289. {
  2290. uint8_t *grp_mask = NULL;
  2291. int group_number, mask;
  2292. if (!wlan_ipa_is_vlan_enabled())
  2293. return;
  2294. grp_mask = &soc->wlan_cfg_ctx->int_rx_ring_mask[0];
  2295. group_number = dp_srng_find_ring_in_mask(IPA_ALT_REO_DEST_RING_IDX, grp_mask);
  2296. if (group_number < 0) {
  2297. dp_init_debug("%pK: ring not part of any group; ring_type: %d,ring_num %d",
  2298. soc, REO_DST, IPA_ALT_REO_DEST_RING_IDX);
  2299. return;
  2300. }
  2301. mask = wlan_cfg_get_rx_ring_mask(soc->wlan_cfg_ctx, group_number);
  2302. /* reset the interrupt mask for offloaded ring */
  2303. mask &= (~(1 << IPA_ALT_REO_DEST_RING_IDX));
  2304. /*
  2305. * set the interrupt mask to zero for rx offloaded radio.
  2306. */
  2307. wlan_cfg_set_rx_ring_mask(soc->wlan_cfg_ctx, group_number, mask);
  2308. }
  2309. #else
  2310. inline
  2311. void dp_soc_reset_ipa_vlan_intr_mask(struct dp_soc *soc)
  2312. { }
  2313. #endif /* IPA_WDI3_VLAN_SUPPORT */
  2314. #else
  2315. inline
  2316. void dp_soc_reset_ipa_vlan_intr_mask(struct dp_soc *soc)
  2317. { }
  2318. #endif /* IPA_OFFLOAD */
  2319. /**
  2320. * dp_soc_reset_intr_mask() - reset interrupt mask
  2321. * @soc: DP Soc handle
  2322. *
  2323. * Return: Return void
  2324. */
  2325. void dp_soc_reset_intr_mask(struct dp_soc *soc)
  2326. {
  2327. uint8_t j;
  2328. uint8_t *grp_mask = NULL;
  2329. int group_number, mask, num_ring;
  2330. /* number of tx ring */
  2331. num_ring = soc->num_tcl_data_rings;
  2332. /*
  2333. * group mask for tx completion ring.
  2334. */
  2335. grp_mask = &soc->wlan_cfg_ctx->int_tx_ring_mask[0];
  2336. /* loop and reset the mask for only offloaded ring */
  2337. for (j = 0; j < WLAN_CFG_NUM_TCL_DATA_RINGS; j++) {
  2338. /*
  2339. * Group number corresponding to tx offloaded ring.
  2340. */
  2341. group_number = dp_srng_find_ring_in_mask(j, grp_mask);
  2342. if (group_number < 0) {
  2343. dp_init_debug("%pK: ring not part of any group; ring_type: %d,ring_num %d",
  2344. soc, WBM2SW_RELEASE, j);
  2345. continue;
  2346. }
  2347. mask = wlan_cfg_get_tx_ring_mask(soc->wlan_cfg_ctx, group_number);
  2348. if (!dp_soc_ring_if_nss_offloaded(soc, WBM2SW_RELEASE, j) &&
  2349. (!mask)) {
  2350. continue;
  2351. }
  2352. /* reset the tx mask for offloaded ring */
  2353. mask &= (~(1 << j));
  2354. /*
  2355. * reset the interrupt mask for offloaded ring.
  2356. */
  2357. wlan_cfg_set_tx_ring_mask(soc->wlan_cfg_ctx, group_number, mask);
  2358. }
  2359. /* number of rx rings */
  2360. num_ring = soc->num_reo_dest_rings;
  2361. /*
  2362. * group mask for reo destination ring.
  2363. */
  2364. grp_mask = &soc->wlan_cfg_ctx->int_rx_ring_mask[0];
  2365. /* loop and reset the mask for only offloaded ring */
  2366. for (j = 0; j < WLAN_CFG_NUM_REO_DEST_RING; j++) {
  2367. /*
  2368. * Group number corresponding to rx offloaded ring.
  2369. */
  2370. group_number = dp_srng_find_ring_in_mask(j, grp_mask);
  2371. if (group_number < 0) {
  2372. dp_init_debug("%pK: ring not part of any group; ring_type: %d,ring_num %d",
  2373. soc, REO_DST, j);
  2374. continue;
  2375. }
  2376. mask = wlan_cfg_get_rx_ring_mask(soc->wlan_cfg_ctx, group_number);
  2377. if (!dp_soc_ring_if_nss_offloaded(soc, REO_DST, j) &&
  2378. (!mask)) {
  2379. continue;
  2380. }
  2381. /* reset the interrupt mask for offloaded ring */
  2382. mask &= (~(1 << j));
  2383. /*
  2384. * set the interrupt mask to zero for rx offloaded radio.
  2385. */
  2386. wlan_cfg_set_rx_ring_mask(soc->wlan_cfg_ctx, group_number, mask);
  2387. }
  2388. /*
  2389. * group mask for Rx buffer refill ring
  2390. */
  2391. grp_mask = &soc->wlan_cfg_ctx->int_host2rxdma_ring_mask[0];
  2392. /* loop and reset the mask for only offloaded ring */
  2393. for (j = 0; j < MAX_PDEV_CNT; j++) {
  2394. int lmac_id = wlan_cfg_get_hw_mac_idx(soc->wlan_cfg_ctx, j);
  2395. if (!dp_soc_ring_if_nss_offloaded(soc, RXDMA_BUF, j)) {
  2396. continue;
  2397. }
  2398. /*
  2399. * Group number corresponding to rx offloaded ring.
  2400. */
  2401. group_number = dp_srng_find_ring_in_mask(lmac_id, grp_mask);
  2402. if (group_number < 0) {
  2403. dp_init_debug("%pK: ring not part of any group; ring_type: %d,ring_num %d",
  2404. soc, REO_DST, lmac_id);
  2405. continue;
  2406. }
  2407. /* set the interrupt mask for offloaded ring */
  2408. mask = wlan_cfg_get_host2rxdma_ring_mask(soc->wlan_cfg_ctx,
  2409. group_number);
  2410. mask &= (~(1 << lmac_id));
  2411. /*
  2412. * set the interrupt mask to zero for rx offloaded radio.
  2413. */
  2414. wlan_cfg_set_host2rxdma_ring_mask(soc->wlan_cfg_ctx,
  2415. group_number, mask);
  2416. }
  2417. grp_mask = &soc->wlan_cfg_ctx->int_rx_err_ring_mask[0];
  2418. for (j = 0; j < num_ring; j++) {
  2419. if (!dp_soc_ring_if_nss_offloaded(soc, REO_EXCEPTION, j)) {
  2420. continue;
  2421. }
  2422. /*
  2423. * Group number corresponding to rx err ring.
  2424. */
  2425. group_number = dp_srng_find_ring_in_mask(j, grp_mask);
  2426. if (group_number < 0) {
  2427. dp_init_debug("%pK: ring not part of any group; ring_type: %d,ring_num %d",
  2428. soc, REO_EXCEPTION, j);
  2429. continue;
  2430. }
  2431. wlan_cfg_set_rx_err_ring_mask(soc->wlan_cfg_ctx,
  2432. group_number, 0);
  2433. }
  2434. }
  2435. #ifdef IPA_OFFLOAD
  2436. bool dp_reo_remap_config(struct dp_soc *soc, uint32_t *remap0,
  2437. uint32_t *remap1, uint32_t *remap2)
  2438. {
  2439. uint32_t ring[WLAN_CFG_NUM_REO_DEST_RING_MAX] = {
  2440. REO_REMAP_SW1, REO_REMAP_SW2, REO_REMAP_SW3,
  2441. REO_REMAP_SW5, REO_REMAP_SW6, REO_REMAP_SW7};
  2442. switch (soc->arch_id) {
  2443. case CDP_ARCH_TYPE_BE:
  2444. hal_compute_reo_remap_ix2_ix3(soc->hal_soc, ring,
  2445. soc->num_reo_dest_rings -
  2446. USE_2_IPA_RX_REO_RINGS, remap1,
  2447. remap2);
  2448. break;
  2449. case CDP_ARCH_TYPE_LI:
  2450. if (wlan_ipa_is_vlan_enabled()) {
  2451. hal_compute_reo_remap_ix2_ix3(
  2452. soc->hal_soc, ring,
  2453. soc->num_reo_dest_rings -
  2454. USE_2_IPA_RX_REO_RINGS, remap1,
  2455. remap2);
  2456. } else {
  2457. hal_compute_reo_remap_ix2_ix3(
  2458. soc->hal_soc, ring,
  2459. soc->num_reo_dest_rings -
  2460. USE_1_IPA_RX_REO_RING, remap1,
  2461. remap2);
  2462. }
  2463. hal_compute_reo_remap_ix0(soc->hal_soc, remap0);
  2464. break;
  2465. default:
  2466. dp_err("unknown arch_id 0x%x", soc->arch_id);
  2467. QDF_BUG(0);
  2468. }
  2469. dp_debug("remap1 %x remap2 %x", *remap1, *remap2);
  2470. return true;
  2471. }
  2472. #ifdef IPA_WDI3_TX_TWO_PIPES
  2473. static bool dp_ipa_is_alt_tx_ring(int index)
  2474. {
  2475. return index == IPA_TX_ALT_RING_IDX;
  2476. }
  2477. static bool dp_ipa_is_alt_tx_comp_ring(int index)
  2478. {
  2479. return index == IPA_TX_ALT_COMP_RING_IDX;
  2480. }
  2481. #else /* !IPA_WDI3_TX_TWO_PIPES */
  2482. static bool dp_ipa_is_alt_tx_ring(int index)
  2483. {
  2484. return false;
  2485. }
  2486. static bool dp_ipa_is_alt_tx_comp_ring(int index)
  2487. {
  2488. return false;
  2489. }
  2490. #endif /* IPA_WDI3_TX_TWO_PIPES */
  2491. /**
  2492. * dp_ipa_get_tx_ring_size() - Get Tx ring size for IPA
  2493. *
  2494. * @tx_ring_num: Tx ring number
  2495. * @tx_ipa_ring_sz: Return param only updated for IPA.
  2496. * @soc_cfg_ctx: dp soc cfg context
  2497. *
  2498. * Return: None
  2499. */
  2500. static void dp_ipa_get_tx_ring_size(int tx_ring_num, int *tx_ipa_ring_sz,
  2501. struct wlan_cfg_dp_soc_ctxt *soc_cfg_ctx)
  2502. {
  2503. if (!soc_cfg_ctx->ipa_enabled)
  2504. return;
  2505. if (tx_ring_num == IPA_TCL_DATA_RING_IDX)
  2506. *tx_ipa_ring_sz = wlan_cfg_ipa_tx_ring_size(soc_cfg_ctx);
  2507. else if (dp_ipa_is_alt_tx_ring(tx_ring_num))
  2508. *tx_ipa_ring_sz = wlan_cfg_ipa_tx_alt_ring_size(soc_cfg_ctx);
  2509. }
  2510. /**
  2511. * dp_ipa_get_tx_comp_ring_size() - Get Tx comp ring size for IPA
  2512. *
  2513. * @tx_comp_ring_num: Tx comp ring number
  2514. * @tx_comp_ipa_ring_sz: Return param only updated for IPA.
  2515. * @soc_cfg_ctx: dp soc cfg context
  2516. *
  2517. * Return: None
  2518. */
  2519. static void dp_ipa_get_tx_comp_ring_size(int tx_comp_ring_num,
  2520. int *tx_comp_ipa_ring_sz,
  2521. struct wlan_cfg_dp_soc_ctxt *soc_cfg_ctx)
  2522. {
  2523. if (!soc_cfg_ctx->ipa_enabled)
  2524. return;
  2525. if (tx_comp_ring_num == IPA_TCL_DATA_RING_IDX)
  2526. *tx_comp_ipa_ring_sz =
  2527. wlan_cfg_ipa_tx_comp_ring_size(soc_cfg_ctx);
  2528. else if (dp_ipa_is_alt_tx_comp_ring(tx_comp_ring_num))
  2529. *tx_comp_ipa_ring_sz =
  2530. wlan_cfg_ipa_tx_alt_comp_ring_size(soc_cfg_ctx);
  2531. }
  2532. #else
  2533. static uint8_t dp_reo_ring_selection(uint32_t value, uint32_t *ring)
  2534. {
  2535. uint8_t num = 0;
  2536. switch (value) {
  2537. /* should we have all the different possible ring configs */
  2538. case 0xFF:
  2539. num = 8;
  2540. ring[0] = REO_REMAP_SW1;
  2541. ring[1] = REO_REMAP_SW2;
  2542. ring[2] = REO_REMAP_SW3;
  2543. ring[3] = REO_REMAP_SW4;
  2544. ring[4] = REO_REMAP_SW5;
  2545. ring[5] = REO_REMAP_SW6;
  2546. ring[6] = REO_REMAP_SW7;
  2547. ring[7] = REO_REMAP_SW8;
  2548. break;
  2549. case 0x3F:
  2550. num = 6;
  2551. ring[0] = REO_REMAP_SW1;
  2552. ring[1] = REO_REMAP_SW2;
  2553. ring[2] = REO_REMAP_SW3;
  2554. ring[3] = REO_REMAP_SW4;
  2555. ring[4] = REO_REMAP_SW5;
  2556. ring[5] = REO_REMAP_SW6;
  2557. break;
  2558. case 0xF:
  2559. num = 4;
  2560. ring[0] = REO_REMAP_SW1;
  2561. ring[1] = REO_REMAP_SW2;
  2562. ring[2] = REO_REMAP_SW3;
  2563. ring[3] = REO_REMAP_SW4;
  2564. break;
  2565. case 0xE:
  2566. num = 3;
  2567. ring[0] = REO_REMAP_SW2;
  2568. ring[1] = REO_REMAP_SW3;
  2569. ring[2] = REO_REMAP_SW4;
  2570. break;
  2571. case 0xD:
  2572. num = 3;
  2573. ring[0] = REO_REMAP_SW1;
  2574. ring[1] = REO_REMAP_SW3;
  2575. ring[2] = REO_REMAP_SW4;
  2576. break;
  2577. case 0xC:
  2578. num = 2;
  2579. ring[0] = REO_REMAP_SW3;
  2580. ring[1] = REO_REMAP_SW4;
  2581. break;
  2582. case 0xB:
  2583. num = 3;
  2584. ring[0] = REO_REMAP_SW1;
  2585. ring[1] = REO_REMAP_SW2;
  2586. ring[2] = REO_REMAP_SW4;
  2587. break;
  2588. case 0xA:
  2589. num = 2;
  2590. ring[0] = REO_REMAP_SW2;
  2591. ring[1] = REO_REMAP_SW4;
  2592. break;
  2593. case 0x9:
  2594. num = 2;
  2595. ring[0] = REO_REMAP_SW1;
  2596. ring[1] = REO_REMAP_SW4;
  2597. break;
  2598. case 0x8:
  2599. num = 1;
  2600. ring[0] = REO_REMAP_SW4;
  2601. break;
  2602. case 0x7:
  2603. num = 3;
  2604. ring[0] = REO_REMAP_SW1;
  2605. ring[1] = REO_REMAP_SW2;
  2606. ring[2] = REO_REMAP_SW3;
  2607. break;
  2608. case 0x6:
  2609. num = 2;
  2610. ring[0] = REO_REMAP_SW2;
  2611. ring[1] = REO_REMAP_SW3;
  2612. break;
  2613. case 0x5:
  2614. num = 2;
  2615. ring[0] = REO_REMAP_SW1;
  2616. ring[1] = REO_REMAP_SW3;
  2617. break;
  2618. case 0x4:
  2619. num = 1;
  2620. ring[0] = REO_REMAP_SW3;
  2621. break;
  2622. case 0x3:
  2623. num = 2;
  2624. ring[0] = REO_REMAP_SW1;
  2625. ring[1] = REO_REMAP_SW2;
  2626. break;
  2627. case 0x2:
  2628. num = 1;
  2629. ring[0] = REO_REMAP_SW2;
  2630. break;
  2631. case 0x1:
  2632. num = 1;
  2633. ring[0] = REO_REMAP_SW1;
  2634. break;
  2635. default:
  2636. dp_err("unknown reo ring map 0x%x", value);
  2637. QDF_BUG(0);
  2638. }
  2639. return num;
  2640. }
  2641. bool dp_reo_remap_config(struct dp_soc *soc,
  2642. uint32_t *remap0,
  2643. uint32_t *remap1,
  2644. uint32_t *remap2)
  2645. {
  2646. uint8_t offload_radio = wlan_cfg_get_dp_soc_nss_cfg(soc->wlan_cfg_ctx);
  2647. uint32_t reo_config = wlan_cfg_get_reo_rings_mapping(soc->wlan_cfg_ctx);
  2648. uint8_t num;
  2649. uint32_t ring[WLAN_CFG_NUM_REO_DEST_RING_MAX];
  2650. uint32_t value;
  2651. switch (offload_radio) {
  2652. case dp_nss_cfg_default:
  2653. value = reo_config & WLAN_CFG_NUM_REO_RINGS_MAP_MAX;
  2654. num = dp_reo_ring_selection(value, ring);
  2655. hal_compute_reo_remap_ix2_ix3(soc->hal_soc, ring,
  2656. num, remap1, remap2);
  2657. hal_compute_reo_remap_ix0(soc->hal_soc, remap0);
  2658. break;
  2659. case dp_nss_cfg_first_radio:
  2660. value = reo_config & 0xE;
  2661. num = dp_reo_ring_selection(value, ring);
  2662. hal_compute_reo_remap_ix2_ix3(soc->hal_soc, ring,
  2663. num, remap1, remap2);
  2664. break;
  2665. case dp_nss_cfg_second_radio:
  2666. value = reo_config & 0xD;
  2667. num = dp_reo_ring_selection(value, ring);
  2668. hal_compute_reo_remap_ix2_ix3(soc->hal_soc, ring,
  2669. num, remap1, remap2);
  2670. break;
  2671. case dp_nss_cfg_dbdc:
  2672. case dp_nss_cfg_dbtc:
  2673. /* return false if both or all are offloaded to NSS */
  2674. return false;
  2675. }
  2676. dp_debug("remap1 %x remap2 %x offload_radio %u",
  2677. *remap1, *remap2, offload_radio);
  2678. return true;
  2679. }
  2680. static void dp_ipa_get_tx_ring_size(int ring_num, int *tx_ipa_ring_sz,
  2681. struct wlan_cfg_dp_soc_ctxt *soc_cfg_ctx)
  2682. {
  2683. }
  2684. static void dp_ipa_get_tx_comp_ring_size(int tx_comp_ring_num,
  2685. int *tx_comp_ipa_ring_sz,
  2686. struct wlan_cfg_dp_soc_ctxt *soc_cfg_ctx)
  2687. {
  2688. }
  2689. #endif /* IPA_OFFLOAD */
  2690. /**
  2691. * dp_reo_frag_dst_set() - configure reo register to set the
  2692. * fragment destination ring
  2693. * @soc: Datapath soc
  2694. * @frag_dst_ring: output parameter to set fragment destination ring
  2695. *
  2696. * Based on offload_radio below fragment destination rings is selected
  2697. * 0 - TCL
  2698. * 1 - SW1
  2699. * 2 - SW2
  2700. * 3 - SW3
  2701. * 4 - SW4
  2702. * 5 - Release
  2703. * 6 - FW
  2704. * 7 - alternate select
  2705. *
  2706. * Return: void
  2707. */
  2708. void dp_reo_frag_dst_set(struct dp_soc *soc, uint8_t *frag_dst_ring)
  2709. {
  2710. uint8_t offload_radio = wlan_cfg_get_dp_soc_nss_cfg(soc->wlan_cfg_ctx);
  2711. switch (offload_radio) {
  2712. case dp_nss_cfg_default:
  2713. *frag_dst_ring = REO_REMAP_TCL;
  2714. break;
  2715. case dp_nss_cfg_first_radio:
  2716. /*
  2717. * This configuration is valid for single band radio which
  2718. * is also NSS offload.
  2719. */
  2720. case dp_nss_cfg_dbdc:
  2721. case dp_nss_cfg_dbtc:
  2722. *frag_dst_ring = HAL_SRNG_REO_ALTERNATE_SELECT;
  2723. break;
  2724. default:
  2725. dp_init_err("%pK: dp_reo_frag_dst_set invalid offload radio config", soc);
  2726. break;
  2727. }
  2728. }
  2729. #ifdef WLAN_FEATURE_STATS_EXT
  2730. static inline void dp_create_ext_stats_event(struct dp_soc *soc)
  2731. {
  2732. qdf_event_create(&soc->rx_hw_stats_event);
  2733. }
  2734. #else
  2735. static inline void dp_create_ext_stats_event(struct dp_soc *soc)
  2736. {
  2737. }
  2738. #endif
  2739. static void dp_deinit_tx_pair_by_index(struct dp_soc *soc, int index)
  2740. {
  2741. int tcl_ring_num, wbm_ring_num;
  2742. wlan_cfg_get_tcl_wbm_ring_num_for_index(soc->wlan_cfg_ctx,
  2743. index,
  2744. &tcl_ring_num,
  2745. &wbm_ring_num);
  2746. if (tcl_ring_num == -1) {
  2747. dp_err("incorrect tcl ring num for index %u", index);
  2748. return;
  2749. }
  2750. wlan_minidump_remove(soc->tcl_data_ring[index].base_vaddr_unaligned,
  2751. soc->tcl_data_ring[index].alloc_size,
  2752. soc->ctrl_psoc,
  2753. WLAN_MD_DP_SRNG_TCL_DATA,
  2754. "tcl_data_ring");
  2755. dp_info("index %u tcl %u wbm %u", index, tcl_ring_num, wbm_ring_num);
  2756. dp_srng_deinit(soc, &soc->tcl_data_ring[index], TCL_DATA,
  2757. tcl_ring_num);
  2758. if (wbm_ring_num == INVALID_WBM_RING_NUM)
  2759. return;
  2760. wlan_minidump_remove(soc->tx_comp_ring[index].base_vaddr_unaligned,
  2761. soc->tx_comp_ring[index].alloc_size,
  2762. soc->ctrl_psoc,
  2763. WLAN_MD_DP_SRNG_TX_COMP,
  2764. "tcl_comp_ring");
  2765. dp_srng_deinit(soc, &soc->tx_comp_ring[index], WBM2SW_RELEASE,
  2766. wbm_ring_num);
  2767. }
  2768. /**
  2769. * dp_init_tx_ring_pair_by_index() - The function inits tcl data/wbm completion
  2770. * ring pair
  2771. * @soc: DP soc pointer
  2772. * @index: index of soc->tcl_data or soc->tx_comp to initialize
  2773. *
  2774. * Return: QDF_STATUS_SUCCESS on success, error code otherwise.
  2775. */
  2776. static QDF_STATUS dp_init_tx_ring_pair_by_index(struct dp_soc *soc,
  2777. uint8_t index)
  2778. {
  2779. int tcl_ring_num, wbm_ring_num;
  2780. uint8_t bm_id;
  2781. if (index >= MAX_TCL_DATA_RINGS) {
  2782. dp_err("unexpected index!");
  2783. QDF_BUG(0);
  2784. goto fail1;
  2785. }
  2786. wlan_cfg_get_tcl_wbm_ring_num_for_index(soc->wlan_cfg_ctx,
  2787. index,
  2788. &tcl_ring_num,
  2789. &wbm_ring_num);
  2790. if (tcl_ring_num == -1) {
  2791. dp_err("incorrect tcl ring num for index %u", index);
  2792. goto fail1;
  2793. }
  2794. dp_info("index %u tcl %u wbm %u", index, tcl_ring_num, wbm_ring_num);
  2795. if (dp_srng_init(soc, &soc->tcl_data_ring[index], TCL_DATA,
  2796. tcl_ring_num, 0)) {
  2797. dp_err("dp_srng_init failed for tcl_data_ring");
  2798. goto fail1;
  2799. }
  2800. wlan_minidump_log(soc->tcl_data_ring[index].base_vaddr_unaligned,
  2801. soc->tcl_data_ring[index].alloc_size,
  2802. soc->ctrl_psoc,
  2803. WLAN_MD_DP_SRNG_TCL_DATA,
  2804. "tcl_data_ring");
  2805. if (wbm_ring_num == INVALID_WBM_RING_NUM)
  2806. goto set_rbm;
  2807. if (dp_srng_init(soc, &soc->tx_comp_ring[index], WBM2SW_RELEASE,
  2808. wbm_ring_num, 0)) {
  2809. dp_err("dp_srng_init failed for tx_comp_ring");
  2810. goto fail1;
  2811. }
  2812. wlan_minidump_log(soc->tx_comp_ring[index].base_vaddr_unaligned,
  2813. soc->tx_comp_ring[index].alloc_size,
  2814. soc->ctrl_psoc,
  2815. WLAN_MD_DP_SRNG_TX_COMP,
  2816. "tcl_comp_ring");
  2817. set_rbm:
  2818. bm_id = wlan_cfg_get_rbm_id_for_index(soc->wlan_cfg_ctx, tcl_ring_num);
  2819. soc->arch_ops.tx_implicit_rbm_set(soc, tcl_ring_num, bm_id);
  2820. return QDF_STATUS_SUCCESS;
  2821. fail1:
  2822. return QDF_STATUS_E_FAILURE;
  2823. }
  2824. static void dp_free_tx_ring_pair_by_index(struct dp_soc *soc, uint8_t index)
  2825. {
  2826. dp_debug("index %u", index);
  2827. dp_srng_free(soc, &soc->tcl_data_ring[index]);
  2828. dp_srng_free(soc, &soc->tx_comp_ring[index]);
  2829. }
  2830. /**
  2831. * dp_alloc_tx_ring_pair_by_index() - The function allocs tcl data/wbm2sw
  2832. * ring pair for the given "index"
  2833. * @soc: DP soc pointer
  2834. * @index: index of soc->tcl_data or soc->tx_comp to initialize
  2835. *
  2836. * Return: QDF_STATUS_SUCCESS on success, error code otherwise.
  2837. */
  2838. static QDF_STATUS dp_alloc_tx_ring_pair_by_index(struct dp_soc *soc,
  2839. uint8_t index)
  2840. {
  2841. int tx_ring_size;
  2842. int tx_comp_ring_size;
  2843. struct wlan_cfg_dp_soc_ctxt *soc_cfg_ctx = soc->wlan_cfg_ctx;
  2844. int cached = 0;
  2845. if (index >= MAX_TCL_DATA_RINGS) {
  2846. dp_err("unexpected index!");
  2847. QDF_BUG(0);
  2848. goto fail1;
  2849. }
  2850. dp_debug("index %u", index);
  2851. tx_ring_size = wlan_cfg_tx_ring_size(soc_cfg_ctx);
  2852. dp_ipa_get_tx_ring_size(index, &tx_ring_size, soc_cfg_ctx);
  2853. if (dp_srng_alloc(soc, &soc->tcl_data_ring[index], TCL_DATA,
  2854. tx_ring_size, cached)) {
  2855. dp_err("dp_srng_alloc failed for tcl_data_ring");
  2856. goto fail1;
  2857. }
  2858. tx_comp_ring_size = wlan_cfg_tx_comp_ring_size(soc_cfg_ctx);
  2859. dp_ipa_get_tx_comp_ring_size(index, &tx_comp_ring_size, soc_cfg_ctx);
  2860. /* Enable cached TCL desc if NSS offload is disabled */
  2861. if (!wlan_cfg_get_dp_soc_nss_cfg(soc_cfg_ctx))
  2862. cached = WLAN_CFG_DST_RING_CACHED_DESC;
  2863. if (wlan_cfg_get_wbm_ring_num_for_index(soc->wlan_cfg_ctx, index) ==
  2864. INVALID_WBM_RING_NUM)
  2865. return QDF_STATUS_SUCCESS;
  2866. if (dp_srng_alloc(soc, &soc->tx_comp_ring[index], WBM2SW_RELEASE,
  2867. tx_comp_ring_size, cached)) {
  2868. dp_err("dp_srng_alloc failed for tx_comp_ring");
  2869. goto fail1;
  2870. }
  2871. return QDF_STATUS_SUCCESS;
  2872. fail1:
  2873. return QDF_STATUS_E_FAILURE;
  2874. }
  2875. /**
  2876. * dp_dscp_tid_map_setup() - Initialize the dscp-tid maps
  2877. * @pdev: DP_PDEV handle
  2878. *
  2879. * Return: void
  2880. */
  2881. void
  2882. dp_dscp_tid_map_setup(struct dp_pdev *pdev)
  2883. {
  2884. uint8_t map_id;
  2885. struct dp_soc *soc = pdev->soc;
  2886. if (!soc)
  2887. return;
  2888. for (map_id = 0; map_id < DP_MAX_TID_MAPS; map_id++) {
  2889. qdf_mem_copy(pdev->dscp_tid_map[map_id],
  2890. default_dscp_tid_map,
  2891. sizeof(default_dscp_tid_map));
  2892. }
  2893. for (map_id = 0; map_id < soc->num_hw_dscp_tid_map; map_id++) {
  2894. hal_tx_set_dscp_tid_map(soc->hal_soc,
  2895. default_dscp_tid_map,
  2896. map_id);
  2897. }
  2898. }
  2899. /**
  2900. * dp_pcp_tid_map_setup() - Initialize the pcp-tid maps
  2901. * @pdev: DP_PDEV handle
  2902. *
  2903. * Return: void
  2904. */
  2905. void
  2906. dp_pcp_tid_map_setup(struct dp_pdev *pdev)
  2907. {
  2908. struct dp_soc *soc = pdev->soc;
  2909. if (!soc)
  2910. return;
  2911. qdf_mem_copy(soc->pcp_tid_map, default_pcp_tid_map,
  2912. sizeof(default_pcp_tid_map));
  2913. hal_tx_set_pcp_tid_map_default(soc->hal_soc, default_pcp_tid_map);
  2914. }
  2915. #ifndef DP_UMAC_HW_RESET_SUPPORT
  2916. static inline
  2917. #endif
  2918. void dp_reo_desc_freelist_destroy(struct dp_soc *soc)
  2919. {
  2920. struct reo_desc_list_node *desc;
  2921. struct dp_rx_tid *rx_tid;
  2922. qdf_spin_lock_bh(&soc->reo_desc_freelist_lock);
  2923. while (qdf_list_remove_front(&soc->reo_desc_freelist,
  2924. (qdf_list_node_t **)&desc) == QDF_STATUS_SUCCESS) {
  2925. rx_tid = &desc->rx_tid;
  2926. qdf_mem_unmap_nbytes_single(soc->osdev,
  2927. rx_tid->hw_qdesc_paddr,
  2928. QDF_DMA_BIDIRECTIONAL,
  2929. rx_tid->hw_qdesc_alloc_size);
  2930. qdf_mem_free(rx_tid->hw_qdesc_vaddr_unaligned);
  2931. qdf_mem_free(desc);
  2932. }
  2933. qdf_spin_unlock_bh(&soc->reo_desc_freelist_lock);
  2934. qdf_list_destroy(&soc->reo_desc_freelist);
  2935. qdf_spinlock_destroy(&soc->reo_desc_freelist_lock);
  2936. }
  2937. #ifdef WLAN_DP_FEATURE_DEFERRED_REO_QDESC_DESTROY
  2938. /**
  2939. * dp_reo_desc_deferred_freelist_create() - Initialize the resources used
  2940. * for deferred reo desc list
  2941. * @soc: Datapath soc handle
  2942. *
  2943. * Return: void
  2944. */
  2945. static void dp_reo_desc_deferred_freelist_create(struct dp_soc *soc)
  2946. {
  2947. qdf_spinlock_create(&soc->reo_desc_deferred_freelist_lock);
  2948. qdf_list_create(&soc->reo_desc_deferred_freelist,
  2949. REO_DESC_DEFERRED_FREELIST_SIZE);
  2950. soc->reo_desc_deferred_freelist_init = true;
  2951. }
  2952. /**
  2953. * dp_reo_desc_deferred_freelist_destroy() - loop the deferred free list &
  2954. * free the leftover REO QDESCs
  2955. * @soc: Datapath soc handle
  2956. *
  2957. * Return: void
  2958. */
  2959. static void dp_reo_desc_deferred_freelist_destroy(struct dp_soc *soc)
  2960. {
  2961. struct reo_desc_deferred_freelist_node *desc;
  2962. qdf_spin_lock_bh(&soc->reo_desc_deferred_freelist_lock);
  2963. soc->reo_desc_deferred_freelist_init = false;
  2964. while (qdf_list_remove_front(&soc->reo_desc_deferred_freelist,
  2965. (qdf_list_node_t **)&desc) == QDF_STATUS_SUCCESS) {
  2966. qdf_mem_unmap_nbytes_single(soc->osdev,
  2967. desc->hw_qdesc_paddr,
  2968. QDF_DMA_BIDIRECTIONAL,
  2969. desc->hw_qdesc_alloc_size);
  2970. qdf_mem_free(desc->hw_qdesc_vaddr_unaligned);
  2971. qdf_mem_free(desc);
  2972. }
  2973. qdf_spin_unlock_bh(&soc->reo_desc_deferred_freelist_lock);
  2974. qdf_list_destroy(&soc->reo_desc_deferred_freelist);
  2975. qdf_spinlock_destroy(&soc->reo_desc_deferred_freelist_lock);
  2976. }
  2977. #else
  2978. static inline void dp_reo_desc_deferred_freelist_create(struct dp_soc *soc)
  2979. {
  2980. }
  2981. static inline void dp_reo_desc_deferred_freelist_destroy(struct dp_soc *soc)
  2982. {
  2983. }
  2984. #endif /* !WLAN_DP_FEATURE_DEFERRED_REO_QDESC_DESTROY */
  2985. /**
  2986. * dp_soc_reset_txrx_ring_map() - reset tx ring map
  2987. * @soc: DP SOC handle
  2988. *
  2989. */
  2990. static void dp_soc_reset_txrx_ring_map(struct dp_soc *soc)
  2991. {
  2992. uint32_t i;
  2993. for (i = 0; i < WLAN_CFG_INT_NUM_CONTEXTS; i++)
  2994. soc->tx_ring_map[i] = 0;
  2995. }
  2996. /**
  2997. * dp_soc_deinit() - Deinitialize txrx SOC
  2998. * @txrx_soc: Opaque DP SOC handle
  2999. *
  3000. * Return: None
  3001. */
  3002. void dp_soc_deinit(void *txrx_soc)
  3003. {
  3004. struct dp_soc *soc = (struct dp_soc *)txrx_soc;
  3005. struct htt_soc *htt_soc = soc->htt_handle;
  3006. dp_monitor_soc_deinit(soc);
  3007. /* free peer tables & AST tables allocated during peer_map_attach */
  3008. if (soc->peer_map_attach_success) {
  3009. dp_peer_find_detach(soc);
  3010. soc->arch_ops.txrx_peer_map_detach(soc);
  3011. soc->peer_map_attach_success = FALSE;
  3012. }
  3013. qdf_flush_work(&soc->htt_stats.work);
  3014. qdf_disable_work(&soc->htt_stats.work);
  3015. qdf_spinlock_destroy(&soc->htt_stats.lock);
  3016. dp_soc_reset_txrx_ring_map(soc);
  3017. dp_reo_desc_freelist_destroy(soc);
  3018. dp_reo_desc_deferred_freelist_destroy(soc);
  3019. DEINIT_RX_HW_STATS_LOCK(soc);
  3020. qdf_spinlock_destroy(&soc->ast_lock);
  3021. dp_peer_mec_spinlock_destroy(soc);
  3022. qdf_nbuf_queue_free(&soc->htt_stats.msg);
  3023. qdf_nbuf_queue_free(&soc->invalid_buf_queue);
  3024. qdf_spinlock_destroy(&soc->rx.defrag.defrag_lock);
  3025. qdf_spinlock_destroy(&soc->vdev_map_lock);
  3026. dp_reo_cmdlist_destroy(soc);
  3027. qdf_spinlock_destroy(&soc->rx.reo_cmd_lock);
  3028. dp_soc_tx_desc_sw_pools_deinit(soc);
  3029. dp_soc_srng_deinit(soc);
  3030. dp_hw_link_desc_ring_deinit(soc);
  3031. dp_soc_print_inactive_objects(soc);
  3032. qdf_spinlock_destroy(&soc->inactive_peer_list_lock);
  3033. qdf_spinlock_destroy(&soc->inactive_vdev_list_lock);
  3034. htt_soc_htc_dealloc(soc->htt_handle);
  3035. htt_soc_detach(htt_soc);
  3036. /* Free wbm sg list and reset flags in down path */
  3037. dp_rx_wbm_sg_list_deinit(soc);
  3038. wlan_minidump_remove(soc, sizeof(*soc), soc->ctrl_psoc,
  3039. WLAN_MD_DP_SOC, "dp_soc");
  3040. }
  3041. #ifdef QCA_HOST2FW_RXBUF_RING
  3042. void
  3043. dp_htt_setup_rxdma_err_dst_ring(struct dp_soc *soc, int mac_id,
  3044. int lmac_id)
  3045. {
  3046. if (soc->rxdma_err_dst_ring[lmac_id].hal_srng)
  3047. htt_srng_setup(soc->htt_handle, mac_id,
  3048. soc->rxdma_err_dst_ring[lmac_id].hal_srng,
  3049. RXDMA_DST);
  3050. }
  3051. #endif
  3052. void dp_vdev_get_default_reo_hash(struct dp_vdev *vdev,
  3053. enum cdp_host_reo_dest_ring *reo_dest,
  3054. bool *hash_based)
  3055. {
  3056. struct dp_soc *soc;
  3057. struct dp_pdev *pdev;
  3058. pdev = vdev->pdev;
  3059. soc = pdev->soc;
  3060. /*
  3061. * hash based steering is disabled for Radios which are offloaded
  3062. * to NSS
  3063. */
  3064. if (!wlan_cfg_get_dp_pdev_nss_enabled(pdev->wlan_cfg_ctx))
  3065. *hash_based = wlan_cfg_is_rx_hash_enabled(soc->wlan_cfg_ctx);
  3066. /*
  3067. * Below line of code will ensure the proper reo_dest ring is chosen
  3068. * for cases where toeplitz hash cannot be generated (ex: non TCP/UDP)
  3069. */
  3070. *reo_dest = pdev->reo_dest;
  3071. }
  3072. #ifdef IPA_OFFLOAD
  3073. /**
  3074. * dp_is_vdev_subtype_p2p() - Check if the subtype for vdev is P2P
  3075. * @vdev: Virtual device
  3076. *
  3077. * Return: true if the vdev is of subtype P2P
  3078. * false if the vdev is of any other subtype
  3079. */
  3080. static inline bool dp_is_vdev_subtype_p2p(struct dp_vdev *vdev)
  3081. {
  3082. if (vdev->subtype == wlan_op_subtype_p2p_device ||
  3083. vdev->subtype == wlan_op_subtype_p2p_cli ||
  3084. vdev->subtype == wlan_op_subtype_p2p_go)
  3085. return true;
  3086. return false;
  3087. }
  3088. /**
  3089. * dp_peer_setup_get_reo_hash() - get reo dest ring and hash values for a peer
  3090. * @vdev: Datapath VDEV handle
  3091. * @setup_info:
  3092. * @reo_dest: pointer to default reo_dest ring for vdev to be populated
  3093. * @hash_based: pointer to hash value (enabled/disabled) to be populated
  3094. * @lmac_peer_id_msb:
  3095. *
  3096. * If IPA is enabled in ini, for SAP mode, disable hash based
  3097. * steering, use default reo_dst ring for RX. Use config values for other modes.
  3098. *
  3099. * Return: None
  3100. */
  3101. static void dp_peer_setup_get_reo_hash(struct dp_vdev *vdev,
  3102. struct cdp_peer_setup_info *setup_info,
  3103. enum cdp_host_reo_dest_ring *reo_dest,
  3104. bool *hash_based,
  3105. uint8_t *lmac_peer_id_msb)
  3106. {
  3107. struct dp_soc *soc;
  3108. struct dp_pdev *pdev;
  3109. pdev = vdev->pdev;
  3110. soc = pdev->soc;
  3111. dp_vdev_get_default_reo_hash(vdev, reo_dest, hash_based);
  3112. /* For P2P-GO interfaces we do not need to change the REO
  3113. * configuration even if IPA config is enabled
  3114. */
  3115. if (dp_is_vdev_subtype_p2p(vdev))
  3116. return;
  3117. /*
  3118. * If IPA is enabled, disable hash-based flow steering and set
  3119. * reo_dest_ring_4 as the REO ring to receive packets on.
  3120. * IPA is configured to reap reo_dest_ring_4.
  3121. *
  3122. * Note - REO DST indexes are from 0 - 3, while cdp_host_reo_dest_ring
  3123. * value enum value is from 1 - 4.
  3124. * Hence, *reo_dest = IPA_REO_DEST_RING_IDX + 1
  3125. */
  3126. if (wlan_cfg_is_ipa_enabled(soc->wlan_cfg_ctx)) {
  3127. if (dp_ipa_is_mdm_platform()) {
  3128. *reo_dest = IPA_REO_DEST_RING_IDX + 1;
  3129. if (vdev->opmode == wlan_op_mode_ap)
  3130. *hash_based = 0;
  3131. } else {
  3132. dp_debug("opt_dp: default HOST reo ring is set");
  3133. }
  3134. }
  3135. }
  3136. #else
  3137. /**
  3138. * dp_peer_setup_get_reo_hash() - get reo dest ring and hash values for a peer
  3139. * @vdev: Datapath VDEV handle
  3140. * @setup_info:
  3141. * @reo_dest: pointer to default reo_dest ring for vdev to be populated
  3142. * @hash_based: pointer to hash value (enabled/disabled) to be populated
  3143. * @lmac_peer_id_msb:
  3144. *
  3145. * Use system config values for hash based steering.
  3146. * Return: None
  3147. */
  3148. static void dp_peer_setup_get_reo_hash(struct dp_vdev *vdev,
  3149. struct cdp_peer_setup_info *setup_info,
  3150. enum cdp_host_reo_dest_ring *reo_dest,
  3151. bool *hash_based,
  3152. uint8_t *lmac_peer_id_msb)
  3153. {
  3154. struct dp_soc *soc = vdev->pdev->soc;
  3155. soc->arch_ops.peer_get_reo_hash(vdev, setup_info, reo_dest, hash_based,
  3156. lmac_peer_id_msb);
  3157. }
  3158. #endif /* IPA_OFFLOAD */
  3159. /**
  3160. * dp_peer_setup_wifi3() - initialize the peer
  3161. * @soc_hdl: soc handle object
  3162. * @vdev_id: vdev_id of vdev object
  3163. * @peer_mac: Peer's mac address
  3164. * @setup_info: peer setup info for MLO
  3165. *
  3166. * Return: QDF_STATUS
  3167. */
  3168. QDF_STATUS
  3169. dp_peer_setup_wifi3(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  3170. uint8_t *peer_mac,
  3171. struct cdp_peer_setup_info *setup_info)
  3172. {
  3173. struct dp_soc *soc = (struct dp_soc *)soc_hdl;
  3174. struct dp_pdev *pdev;
  3175. bool hash_based = 0;
  3176. enum cdp_host_reo_dest_ring reo_dest;
  3177. QDF_STATUS status = QDF_STATUS_SUCCESS;
  3178. struct dp_vdev *vdev = NULL;
  3179. struct dp_peer *peer =
  3180. dp_peer_find_hash_find(soc, peer_mac, 0, vdev_id,
  3181. DP_MOD_ID_CDP);
  3182. struct dp_peer *mld_peer = NULL;
  3183. enum wlan_op_mode vdev_opmode;
  3184. uint8_t lmac_peer_id_msb = 0;
  3185. if (!peer)
  3186. return QDF_STATUS_E_FAILURE;
  3187. vdev = peer->vdev;
  3188. if (!vdev) {
  3189. status = QDF_STATUS_E_FAILURE;
  3190. goto fail;
  3191. }
  3192. /* save vdev related member in case vdev freed */
  3193. vdev_opmode = vdev->opmode;
  3194. pdev = vdev->pdev;
  3195. dp_peer_setup_get_reo_hash(vdev, setup_info,
  3196. &reo_dest, &hash_based,
  3197. &lmac_peer_id_msb);
  3198. dp_cfg_event_record_peer_setup_evt(soc, DP_CFG_EVENT_PEER_SETUP,
  3199. peer, vdev, vdev->vdev_id,
  3200. setup_info);
  3201. dp_info("pdev: %d vdev :%d opmode:%u peer %pK (" QDF_MAC_ADDR_FMT ") "
  3202. "hash-based-steering:%d default-reo_dest:%u",
  3203. pdev->pdev_id, vdev->vdev_id,
  3204. vdev->opmode, peer,
  3205. QDF_MAC_ADDR_REF(peer->mac_addr.raw), hash_based, reo_dest);
  3206. /*
  3207. * There are corner cases where the AD1 = AD2 = "VAPs address"
  3208. * i.e both the devices have same MAC address. In these
  3209. * cases we want such pkts to be processed in NULL Q handler
  3210. * which is REO2TCL ring. for this reason we should
  3211. * not setup reo_queues and default route for bss_peer.
  3212. */
  3213. if (!IS_MLO_DP_MLD_PEER(peer))
  3214. dp_monitor_peer_tx_init(pdev, peer);
  3215. if (!setup_info)
  3216. if (dp_peer_legacy_setup(soc, peer) !=
  3217. QDF_STATUS_SUCCESS) {
  3218. status = QDF_STATUS_E_RESOURCES;
  3219. goto fail;
  3220. }
  3221. if (peer->bss_peer && vdev->opmode == wlan_op_mode_ap) {
  3222. status = QDF_STATUS_E_FAILURE;
  3223. goto fail;
  3224. }
  3225. if (soc->cdp_soc.ol_ops->peer_set_default_routing) {
  3226. /* TODO: Check the destination ring number to be passed to FW */
  3227. soc->cdp_soc.ol_ops->peer_set_default_routing(
  3228. soc->ctrl_psoc,
  3229. peer->vdev->pdev->pdev_id,
  3230. peer->mac_addr.raw,
  3231. peer->vdev->vdev_id, hash_based, reo_dest,
  3232. lmac_peer_id_msb);
  3233. }
  3234. qdf_atomic_set(&peer->is_default_route_set, 1);
  3235. status = dp_peer_mlo_setup(soc, peer, vdev->vdev_id, setup_info);
  3236. if (QDF_IS_STATUS_ERROR(status)) {
  3237. dp_peer_err("peer mlo setup failed");
  3238. qdf_assert_always(0);
  3239. }
  3240. if (vdev_opmode != wlan_op_mode_monitor) {
  3241. /* In case of MLD peer, switch peer to mld peer and
  3242. * do peer_rx_init.
  3243. */
  3244. if (hal_reo_shared_qaddr_is_enable(soc->hal_soc) &&
  3245. IS_MLO_DP_LINK_PEER(peer)) {
  3246. if (setup_info && setup_info->is_first_link) {
  3247. mld_peer = DP_GET_MLD_PEER_FROM_PEER(peer);
  3248. if (mld_peer)
  3249. dp_peer_rx_init(pdev, mld_peer);
  3250. else
  3251. dp_peer_err("MLD peer null. Primary link peer:%pK", peer);
  3252. }
  3253. } else {
  3254. dp_peer_rx_init(pdev, peer);
  3255. }
  3256. }
  3257. if (!IS_MLO_DP_MLD_PEER(peer))
  3258. dp_peer_ppdu_delayed_ba_init(peer);
  3259. fail:
  3260. dp_peer_unref_delete(peer, DP_MOD_ID_CDP);
  3261. return status;
  3262. }
  3263. /**
  3264. * dp_set_ba_aging_timeout() - set ba aging timeout per AC
  3265. * @txrx_soc: cdp soc handle
  3266. * @ac: Access category
  3267. * @value: timeout value in millisec
  3268. *
  3269. * Return: void
  3270. */
  3271. void dp_set_ba_aging_timeout(struct cdp_soc_t *txrx_soc,
  3272. uint8_t ac, uint32_t value)
  3273. {
  3274. struct dp_soc *soc = (struct dp_soc *)txrx_soc;
  3275. hal_set_ba_aging_timeout(soc->hal_soc, ac, value);
  3276. }
  3277. /**
  3278. * dp_get_ba_aging_timeout() - get ba aging timeout per AC
  3279. * @txrx_soc: cdp soc handle
  3280. * @ac: access category
  3281. * @value: timeout value in millisec
  3282. *
  3283. * Return: void
  3284. */
  3285. void dp_get_ba_aging_timeout(struct cdp_soc_t *txrx_soc,
  3286. uint8_t ac, uint32_t *value)
  3287. {
  3288. struct dp_soc *soc = (struct dp_soc *)txrx_soc;
  3289. hal_get_ba_aging_timeout(soc->hal_soc, ac, value);
  3290. }
  3291. /**
  3292. * dp_set_pdev_reo_dest() - set the reo destination ring for this pdev
  3293. * @txrx_soc: cdp soc handle
  3294. * @pdev_id: id of physical device object
  3295. * @val: reo destination ring index (1 - 4)
  3296. *
  3297. * Return: QDF_STATUS
  3298. */
  3299. QDF_STATUS
  3300. dp_set_pdev_reo_dest(struct cdp_soc_t *txrx_soc, uint8_t pdev_id,
  3301. enum cdp_host_reo_dest_ring val)
  3302. {
  3303. struct dp_pdev *pdev =
  3304. dp_get_pdev_from_soc_pdev_id_wifi3((struct dp_soc *)txrx_soc,
  3305. pdev_id);
  3306. if (pdev) {
  3307. pdev->reo_dest = val;
  3308. return QDF_STATUS_SUCCESS;
  3309. }
  3310. return QDF_STATUS_E_FAILURE;
  3311. }
  3312. /**
  3313. * dp_get_pdev_reo_dest() - get the reo destination for this pdev
  3314. * @txrx_soc: cdp soc handle
  3315. * @pdev_id: id of physical device object
  3316. *
  3317. * Return: reo destination ring index
  3318. */
  3319. enum cdp_host_reo_dest_ring
  3320. dp_get_pdev_reo_dest(struct cdp_soc_t *txrx_soc, uint8_t pdev_id)
  3321. {
  3322. struct dp_pdev *pdev =
  3323. dp_get_pdev_from_soc_pdev_id_wifi3((struct dp_soc *)txrx_soc,
  3324. pdev_id);
  3325. if (pdev)
  3326. return pdev->reo_dest;
  3327. else
  3328. return cdp_host_reo_dest_ring_unknown;
  3329. }
  3330. void dp_rx_bar_stats_cb(struct dp_soc *soc, void *cb_ctxt,
  3331. union hal_reo_status *reo_status)
  3332. {
  3333. struct dp_pdev *pdev = (struct dp_pdev *)cb_ctxt;
  3334. struct hal_reo_queue_status *queue_status = &(reo_status->queue_status);
  3335. if (!dp_check_pdev_exists(soc, pdev)) {
  3336. dp_err_rl("pdev doesn't exist");
  3337. return;
  3338. }
  3339. if (!qdf_atomic_read(&soc->cmn_init_done))
  3340. return;
  3341. if (queue_status->header.status != HAL_REO_CMD_SUCCESS) {
  3342. DP_PRINT_STATS("REO stats failure %d",
  3343. queue_status->header.status);
  3344. qdf_atomic_set(&(pdev->stats_cmd_complete), 1);
  3345. return;
  3346. }
  3347. pdev->stats.rx.bar_recv_cnt += queue_status->bar_rcvd_cnt;
  3348. qdf_atomic_set(&(pdev->stats_cmd_complete), 1);
  3349. }
  3350. /**
  3351. * dp_dump_wbm_idle_hptp() - dump wbm idle ring, hw hp tp info.
  3352. * @soc: dp soc.
  3353. * @pdev: dp pdev.
  3354. *
  3355. * Return: None.
  3356. */
  3357. void
  3358. dp_dump_wbm_idle_hptp(struct dp_soc *soc, struct dp_pdev *pdev)
  3359. {
  3360. uint32_t hw_head;
  3361. uint32_t hw_tail;
  3362. struct dp_srng *srng;
  3363. if (!soc) {
  3364. dp_err("soc is NULL");
  3365. return;
  3366. }
  3367. if (!pdev) {
  3368. dp_err("pdev is NULL");
  3369. return;
  3370. }
  3371. srng = &pdev->soc->wbm_idle_link_ring;
  3372. if (!srng) {
  3373. dp_err("wbm_idle_link_ring srng is NULL");
  3374. return;
  3375. }
  3376. hal_get_hw_hptp(soc->hal_soc, srng->hal_srng, &hw_head,
  3377. &hw_tail, WBM_IDLE_LINK);
  3378. dp_debug("WBM_IDLE_LINK: HW hp: %d, HW tp: %d",
  3379. hw_head, hw_tail);
  3380. }
  3381. #ifdef WLAN_FEATURE_RX_SOFTIRQ_TIME_LIMIT
  3382. static void dp_update_soft_irq_limits(struct dp_soc *soc, uint32_t tx_limit,
  3383. uint32_t rx_limit)
  3384. {
  3385. soc->wlan_cfg_ctx->tx_comp_loop_pkt_limit = tx_limit;
  3386. soc->wlan_cfg_ctx->rx_reap_loop_pkt_limit = rx_limit;
  3387. }
  3388. #else
  3389. static inline
  3390. void dp_update_soft_irq_limits(struct dp_soc *soc, uint32_t tx_limit,
  3391. uint32_t rx_limit)
  3392. {
  3393. }
  3394. #endif /* WLAN_FEATURE_RX_SOFTIRQ_TIME_LIMIT */
  3395. /**
  3396. * dp_display_srng_info() - Dump the srng HP TP info
  3397. * @soc_hdl: CDP Soc handle
  3398. *
  3399. * This function dumps the SW hp/tp values for the important rings.
  3400. * HW hp/tp values are not being dumped, since it can lead to
  3401. * READ NOC error when UMAC is in low power state. MCC does not have
  3402. * device force wake working yet.
  3403. *
  3404. * Return: none
  3405. */
  3406. void dp_display_srng_info(struct cdp_soc_t *soc_hdl)
  3407. {
  3408. struct dp_soc *soc = cdp_soc_t_to_dp_soc(soc_hdl);
  3409. hal_soc_handle_t hal_soc = soc->hal_soc;
  3410. uint32_t hp, tp, i;
  3411. dp_info("SRNG HP-TP data:");
  3412. for (i = 0; i < soc->num_tcl_data_rings; i++) {
  3413. hal_get_sw_hptp(hal_soc, soc->tcl_data_ring[i].hal_srng,
  3414. &tp, &hp);
  3415. dp_info("TCL DATA ring[%d]: hp=0x%x, tp=0x%x", i, hp, tp);
  3416. if (wlan_cfg_get_wbm_ring_num_for_index(soc->wlan_cfg_ctx, i) ==
  3417. INVALID_WBM_RING_NUM)
  3418. continue;
  3419. hal_get_sw_hptp(hal_soc, soc->tx_comp_ring[i].hal_srng,
  3420. &tp, &hp);
  3421. dp_info("TX comp ring[%d]: hp=0x%x, tp=0x%x", i, hp, tp);
  3422. }
  3423. for (i = 0; i < soc->num_reo_dest_rings; i++) {
  3424. hal_get_sw_hptp(hal_soc, soc->reo_dest_ring[i].hal_srng,
  3425. &tp, &hp);
  3426. dp_info("REO DST ring[%d]: hp=0x%x, tp=0x%x", i, hp, tp);
  3427. }
  3428. hal_get_sw_hptp(hal_soc, soc->reo_exception_ring.hal_srng, &tp, &hp);
  3429. dp_info("REO exception ring: hp=0x%x, tp=0x%x", hp, tp);
  3430. hal_get_sw_hptp(hal_soc, soc->rx_rel_ring.hal_srng, &tp, &hp);
  3431. dp_info("WBM RX release ring: hp=0x%x, tp=0x%x", hp, tp);
  3432. hal_get_sw_hptp(hal_soc, soc->wbm_desc_rel_ring.hal_srng, &tp, &hp);
  3433. dp_info("WBM desc release ring: hp=0x%x, tp=0x%x", hp, tp);
  3434. }
  3435. /**
  3436. * dp_set_pdev_pcp_tid_map_wifi3() - update pcp tid map in pdev
  3437. * @psoc: dp soc handle
  3438. * @pdev_id: id of DP_PDEV handle
  3439. * @pcp: pcp value
  3440. * @tid: tid value passed by the user
  3441. *
  3442. * Return: QDF_STATUS_SUCCESS on success
  3443. */
  3444. QDF_STATUS dp_set_pdev_pcp_tid_map_wifi3(ol_txrx_soc_handle psoc,
  3445. uint8_t pdev_id,
  3446. uint8_t pcp, uint8_t tid)
  3447. {
  3448. struct dp_soc *soc = (struct dp_soc *)psoc;
  3449. soc->pcp_tid_map[pcp] = tid;
  3450. hal_tx_update_pcp_tid_map(soc->hal_soc, pcp, tid);
  3451. return QDF_STATUS_SUCCESS;
  3452. }
  3453. /**
  3454. * dp_set_vdev_pcp_tid_map_wifi3() - update pcp tid map in vdev
  3455. * @soc_hdl: DP soc handle
  3456. * @vdev_id: id of DP_VDEV handle
  3457. * @pcp: pcp value
  3458. * @tid: tid value passed by the user
  3459. *
  3460. * Return: QDF_STATUS_SUCCESS on success
  3461. */
  3462. QDF_STATUS dp_set_vdev_pcp_tid_map_wifi3(struct cdp_soc_t *soc_hdl,
  3463. uint8_t vdev_id,
  3464. uint8_t pcp, uint8_t tid)
  3465. {
  3466. struct dp_soc *soc = cdp_soc_t_to_dp_soc(soc_hdl);
  3467. struct dp_vdev *vdev = dp_vdev_get_ref_by_id(soc, vdev_id,
  3468. DP_MOD_ID_CDP);
  3469. if (!vdev)
  3470. return QDF_STATUS_E_FAILURE;
  3471. vdev->pcp_tid_map[pcp] = tid;
  3472. dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_CDP);
  3473. return QDF_STATUS_SUCCESS;
  3474. }
  3475. #if defined(FEATURE_RUNTIME_PM) || defined(DP_POWER_SAVE)
  3476. void dp_drain_txrx(struct cdp_soc_t *soc_handle)
  3477. {
  3478. struct dp_soc *soc = (struct dp_soc *)soc_handle;
  3479. uint32_t cur_tx_limit, cur_rx_limit;
  3480. uint32_t budget = 0xffff;
  3481. uint32_t val;
  3482. int i;
  3483. int cpu = dp_srng_get_cpu();
  3484. cur_tx_limit = soc->wlan_cfg_ctx->tx_comp_loop_pkt_limit;
  3485. cur_rx_limit = soc->wlan_cfg_ctx->rx_reap_loop_pkt_limit;
  3486. /* Temporarily increase soft irq limits when going to drain
  3487. * the UMAC/LMAC SRNGs and restore them after polling.
  3488. * Though the budget is on higher side, the TX/RX reaping loops
  3489. * will not execute longer as both TX and RX would be suspended
  3490. * by the time this API is called.
  3491. */
  3492. dp_update_soft_irq_limits(soc, budget, budget);
  3493. for (i = 0; i < wlan_cfg_get_num_contexts(soc->wlan_cfg_ctx); i++)
  3494. dp_service_srngs(&soc->intr_ctx[i], budget, cpu);
  3495. dp_update_soft_irq_limits(soc, cur_tx_limit, cur_rx_limit);
  3496. /* Do a dummy read at offset 0; this will ensure all
  3497. * pendings writes(HP/TP) are flushed before read returns.
  3498. */
  3499. val = HAL_REG_READ((struct hal_soc *)soc->hal_soc, 0);
  3500. dp_debug("Register value at offset 0: %u", val);
  3501. }
  3502. #endif
  3503. #if defined(DP_POWER_SAVE) || defined(FEATURE_RUNTIME_PM)
  3504. /**
  3505. * dp_flush_ring_hptp() - Update ring shadow
  3506. * register HP/TP address when runtime
  3507. * resume
  3508. * @soc: DP soc context
  3509. * @hal_srng: srng
  3510. *
  3511. * Return: None
  3512. */
  3513. static void dp_flush_ring_hptp(struct dp_soc *soc, hal_ring_handle_t hal_srng)
  3514. {
  3515. if (hal_srng && hal_srng_get_clear_event(hal_srng,
  3516. HAL_SRNG_FLUSH_EVENT)) {
  3517. /* Acquire the lock */
  3518. hal_srng_access_start(soc->hal_soc, hal_srng);
  3519. hal_srng_access_end(soc->hal_soc, hal_srng);
  3520. hal_srng_set_flush_last_ts(hal_srng);
  3521. dp_debug("flushed");
  3522. }
  3523. }
  3524. void dp_update_ring_hptp(struct dp_soc *soc, bool force_flush_tx)
  3525. {
  3526. uint8_t i;
  3527. if (force_flush_tx) {
  3528. for (i = 0; i < soc->num_tcl_data_rings; i++) {
  3529. hal_srng_set_event(soc->tcl_data_ring[i].hal_srng,
  3530. HAL_SRNG_FLUSH_EVENT);
  3531. dp_flush_ring_hptp(soc, soc->tcl_data_ring[i].hal_srng);
  3532. }
  3533. return;
  3534. }
  3535. for (i = 0; i < soc->num_tcl_data_rings; i++)
  3536. dp_flush_ring_hptp(soc, soc->tcl_data_ring[i].hal_srng);
  3537. dp_flush_ring_hptp(soc, soc->reo_cmd_ring.hal_srng);
  3538. }
  3539. #endif
  3540. #ifdef WLAN_FEATURE_STATS_EXT
  3541. /* rx hw stats event wait timeout in ms */
  3542. #define DP_REO_STATUS_STATS_TIMEOUT 100
  3543. /**
  3544. * dp_rx_hw_stats_cb() - request rx hw stats response callback
  3545. * @soc: soc handle
  3546. * @cb_ctxt: callback context
  3547. * @reo_status: reo command response status
  3548. *
  3549. * Return: None
  3550. */
  3551. static void dp_rx_hw_stats_cb(struct dp_soc *soc, void *cb_ctxt,
  3552. union hal_reo_status *reo_status)
  3553. {
  3554. struct dp_req_rx_hw_stats_t *rx_hw_stats = cb_ctxt;
  3555. struct hal_reo_queue_status *queue_status = &reo_status->queue_status;
  3556. bool is_query_timeout;
  3557. qdf_spin_lock_bh(&soc->rx_hw_stats_lock);
  3558. is_query_timeout = rx_hw_stats->is_query_timeout;
  3559. /* free the cb_ctxt if all pending tid stats query is received */
  3560. if (qdf_atomic_dec_and_test(&rx_hw_stats->pending_tid_stats_cnt)) {
  3561. if (!is_query_timeout) {
  3562. qdf_event_set(&soc->rx_hw_stats_event);
  3563. soc->is_last_stats_ctx_init = false;
  3564. }
  3565. qdf_mem_free(rx_hw_stats);
  3566. }
  3567. if (queue_status->header.status != HAL_REO_CMD_SUCCESS) {
  3568. dp_info("REO stats failure %d",
  3569. queue_status->header.status);
  3570. qdf_spin_unlock_bh(&soc->rx_hw_stats_lock);
  3571. return;
  3572. }
  3573. if (!is_query_timeout) {
  3574. soc->ext_stats.rx_mpdu_received +=
  3575. queue_status->mpdu_frms_cnt;
  3576. soc->ext_stats.rx_mpdu_missed +=
  3577. queue_status->hole_cnt;
  3578. }
  3579. qdf_spin_unlock_bh(&soc->rx_hw_stats_lock);
  3580. }
  3581. /**
  3582. * dp_request_rx_hw_stats() - request rx hardware stats
  3583. * @soc_hdl: soc handle
  3584. * @vdev_id: vdev id
  3585. *
  3586. * Return: None
  3587. */
  3588. QDF_STATUS
  3589. dp_request_rx_hw_stats(struct cdp_soc_t *soc_hdl, uint8_t vdev_id)
  3590. {
  3591. struct dp_soc *soc = (struct dp_soc *)soc_hdl;
  3592. struct dp_vdev *vdev = dp_vdev_get_ref_by_id(soc, vdev_id,
  3593. DP_MOD_ID_CDP);
  3594. struct dp_peer *peer = NULL;
  3595. QDF_STATUS status;
  3596. struct dp_req_rx_hw_stats_t *rx_hw_stats;
  3597. int rx_stats_sent_cnt = 0;
  3598. uint32_t last_rx_mpdu_received;
  3599. uint32_t last_rx_mpdu_missed;
  3600. if (!vdev) {
  3601. dp_err("vdev is null for vdev_id: %u", vdev_id);
  3602. status = QDF_STATUS_E_INVAL;
  3603. goto out;
  3604. }
  3605. peer = dp_vdev_bss_peer_ref_n_get(soc, vdev, DP_MOD_ID_CDP);
  3606. if (!peer) {
  3607. dp_err("Peer is NULL");
  3608. status = QDF_STATUS_E_INVAL;
  3609. goto out;
  3610. }
  3611. rx_hw_stats = qdf_mem_malloc(sizeof(*rx_hw_stats));
  3612. if (!rx_hw_stats) {
  3613. dp_err("malloc failed for hw stats structure");
  3614. status = QDF_STATUS_E_INVAL;
  3615. goto out;
  3616. }
  3617. qdf_event_reset(&soc->rx_hw_stats_event);
  3618. qdf_spin_lock_bh(&soc->rx_hw_stats_lock);
  3619. /* save the last soc cumulative stats and reset it to 0 */
  3620. last_rx_mpdu_received = soc->ext_stats.rx_mpdu_received;
  3621. last_rx_mpdu_missed = soc->ext_stats.rx_mpdu_missed;
  3622. soc->ext_stats.rx_mpdu_received = 0;
  3623. soc->ext_stats.rx_mpdu_missed = 0;
  3624. dp_debug("HW stats query start");
  3625. rx_stats_sent_cnt =
  3626. dp_peer_rxtid_stats(peer, dp_rx_hw_stats_cb, rx_hw_stats);
  3627. if (!rx_stats_sent_cnt) {
  3628. dp_err("no tid stats sent successfully");
  3629. qdf_mem_free(rx_hw_stats);
  3630. qdf_spin_unlock_bh(&soc->rx_hw_stats_lock);
  3631. status = QDF_STATUS_E_INVAL;
  3632. goto out;
  3633. }
  3634. qdf_atomic_set(&rx_hw_stats->pending_tid_stats_cnt,
  3635. rx_stats_sent_cnt);
  3636. rx_hw_stats->is_query_timeout = false;
  3637. soc->is_last_stats_ctx_init = true;
  3638. qdf_spin_unlock_bh(&soc->rx_hw_stats_lock);
  3639. status = qdf_wait_single_event(&soc->rx_hw_stats_event,
  3640. DP_REO_STATUS_STATS_TIMEOUT);
  3641. dp_debug("HW stats query end with %d", rx_stats_sent_cnt);
  3642. qdf_spin_lock_bh(&soc->rx_hw_stats_lock);
  3643. if (status != QDF_STATUS_SUCCESS) {
  3644. dp_info("partial rx hw stats event collected with %d",
  3645. qdf_atomic_read(
  3646. &rx_hw_stats->pending_tid_stats_cnt));
  3647. if (soc->is_last_stats_ctx_init)
  3648. rx_hw_stats->is_query_timeout = true;
  3649. /*
  3650. * If query timeout happened, use the last saved stats
  3651. * for this time query.
  3652. */
  3653. soc->ext_stats.rx_mpdu_received = last_rx_mpdu_received;
  3654. soc->ext_stats.rx_mpdu_missed = last_rx_mpdu_missed;
  3655. DP_STATS_INC(soc, rx.rx_hw_stats_timeout, 1);
  3656. }
  3657. qdf_spin_unlock_bh(&soc->rx_hw_stats_lock);
  3658. out:
  3659. if (peer)
  3660. dp_peer_unref_delete(peer, DP_MOD_ID_CDP);
  3661. if (vdev)
  3662. dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_CDP);
  3663. DP_STATS_INC(soc, rx.rx_hw_stats_requested, 1);
  3664. return status;
  3665. }
  3666. /**
  3667. * dp_reset_rx_hw_ext_stats() - Reset rx hardware ext stats
  3668. * @soc_hdl: soc handle
  3669. *
  3670. * Return: None
  3671. */
  3672. void dp_reset_rx_hw_ext_stats(struct cdp_soc_t *soc_hdl)
  3673. {
  3674. struct dp_soc *soc = (struct dp_soc *)soc_hdl;
  3675. soc->ext_stats.rx_mpdu_received = 0;
  3676. soc->ext_stats.rx_mpdu_missed = 0;
  3677. }
  3678. #endif /* WLAN_FEATURE_STATS_EXT */
  3679. uint32_t dp_get_tx_rings_grp_bitmap(struct cdp_soc_t *soc_hdl)
  3680. {
  3681. struct dp_soc *soc = (struct dp_soc *)soc_hdl;
  3682. return soc->wlan_cfg_ctx->tx_rings_grp_bitmap;
  3683. }
  3684. void dp_soc_set_txrx_ring_map(struct dp_soc *soc)
  3685. {
  3686. uint32_t i;
  3687. for (i = 0; i < WLAN_CFG_INT_NUM_CONTEXTS; i++) {
  3688. soc->tx_ring_map[i] = dp_cpu_ring_map[DP_NSS_DEFAULT_MAP][i];
  3689. }
  3690. }
  3691. qdf_export_symbol(dp_soc_set_txrx_ring_map);
  3692. static void dp_soc_cfg_dump(struct dp_soc *soc, uint32_t target_type)
  3693. {
  3694. dp_init_info("DP soc Dump for Target = %d", target_type);
  3695. dp_init_info("ast_override_support = %d, da_war_enabled = %d,",
  3696. soc->ast_override_support, soc->da_war_enabled);
  3697. wlan_cfg_dp_soc_ctx_dump(soc->wlan_cfg_ctx);
  3698. }
  3699. /**
  3700. * dp_soc_cfg_init() - initialize target specific configuration
  3701. * during dp_soc_init
  3702. * @soc: dp soc handle
  3703. */
  3704. static void dp_soc_cfg_init(struct dp_soc *soc)
  3705. {
  3706. uint32_t target_type;
  3707. target_type = hal_get_target_type(soc->hal_soc);
  3708. switch (target_type) {
  3709. case TARGET_TYPE_QCA6290:
  3710. wlan_cfg_set_reo_dst_ring_size(soc->wlan_cfg_ctx,
  3711. REO_DST_RING_SIZE_QCA6290);
  3712. soc->ast_override_support = 1;
  3713. soc->da_war_enabled = false;
  3714. break;
  3715. case TARGET_TYPE_QCA6390:
  3716. case TARGET_TYPE_QCA6490:
  3717. case TARGET_TYPE_QCA6750:
  3718. wlan_cfg_set_reo_dst_ring_size(soc->wlan_cfg_ctx,
  3719. REO_DST_RING_SIZE_QCA6290);
  3720. wlan_cfg_set_raw_mode_war(soc->wlan_cfg_ctx, true);
  3721. soc->ast_override_support = 1;
  3722. if (soc->cdp_soc.ol_ops->get_con_mode &&
  3723. soc->cdp_soc.ol_ops->get_con_mode() ==
  3724. QDF_GLOBAL_MONITOR_MODE) {
  3725. int int_ctx;
  3726. for (int_ctx = 0; int_ctx < WLAN_CFG_INT_NUM_CONTEXTS; int_ctx++) {
  3727. soc->wlan_cfg_ctx->int_rx_ring_mask[int_ctx] = 0;
  3728. soc->wlan_cfg_ctx->int_rxdma2host_ring_mask[int_ctx] = 0;
  3729. }
  3730. }
  3731. soc->wlan_cfg_ctx->rxdma1_enable = 0;
  3732. break;
  3733. case TARGET_TYPE_KIWI:
  3734. case TARGET_TYPE_MANGO:
  3735. case TARGET_TYPE_PEACH:
  3736. soc->ast_override_support = 1;
  3737. soc->per_tid_basize_max_tid = 8;
  3738. if (soc->cdp_soc.ol_ops->get_con_mode &&
  3739. soc->cdp_soc.ol_ops->get_con_mode() ==
  3740. QDF_GLOBAL_MONITOR_MODE) {
  3741. int int_ctx;
  3742. for (int_ctx = 0; int_ctx < WLAN_CFG_INT_NUM_CONTEXTS;
  3743. int_ctx++) {
  3744. soc->wlan_cfg_ctx->int_rx_ring_mask[int_ctx] = 0;
  3745. if (dp_is_monitor_mode_using_poll(soc))
  3746. soc->wlan_cfg_ctx->int_rxdma2host_ring_mask[int_ctx] = 0;
  3747. }
  3748. }
  3749. soc->wlan_cfg_ctx->rxdma1_enable = 0;
  3750. soc->wlan_cfg_ctx->num_rxdma_dst_rings_per_pdev = 1;
  3751. break;
  3752. case TARGET_TYPE_QCA8074:
  3753. wlan_cfg_set_raw_mode_war(soc->wlan_cfg_ctx, true);
  3754. soc->da_war_enabled = true;
  3755. soc->is_rx_fse_full_cache_invalidate_war_enabled = true;
  3756. break;
  3757. case TARGET_TYPE_QCA8074V2:
  3758. case TARGET_TYPE_QCA6018:
  3759. case TARGET_TYPE_QCA9574:
  3760. wlan_cfg_set_raw_mode_war(soc->wlan_cfg_ctx, false);
  3761. soc->ast_override_support = 1;
  3762. soc->per_tid_basize_max_tid = 8;
  3763. soc->num_hw_dscp_tid_map = HAL_MAX_HW_DSCP_TID_V2_MAPS;
  3764. soc->da_war_enabled = false;
  3765. soc->is_rx_fse_full_cache_invalidate_war_enabled = true;
  3766. break;
  3767. case TARGET_TYPE_QCN9000:
  3768. soc->ast_override_support = 1;
  3769. soc->da_war_enabled = false;
  3770. wlan_cfg_set_raw_mode_war(soc->wlan_cfg_ctx, false);
  3771. soc->per_tid_basize_max_tid = 8;
  3772. soc->num_hw_dscp_tid_map = HAL_MAX_HW_DSCP_TID_V2_MAPS;
  3773. soc->lmac_polled_mode = 0;
  3774. soc->wbm_release_desc_rx_sg_support = 1;
  3775. soc->is_rx_fse_full_cache_invalidate_war_enabled = true;
  3776. break;
  3777. case TARGET_TYPE_QCA5018:
  3778. case TARGET_TYPE_QCN6122:
  3779. case TARGET_TYPE_QCN9160:
  3780. soc->ast_override_support = 1;
  3781. soc->da_war_enabled = false;
  3782. wlan_cfg_set_raw_mode_war(soc->wlan_cfg_ctx, false);
  3783. soc->per_tid_basize_max_tid = 8;
  3784. soc->num_hw_dscp_tid_map = HAL_MAX_HW_DSCP_TID_MAPS_11AX;
  3785. soc->disable_mac1_intr = 1;
  3786. soc->disable_mac2_intr = 1;
  3787. soc->wbm_release_desc_rx_sg_support = 1;
  3788. break;
  3789. case TARGET_TYPE_QCN9224:
  3790. soc->ast_override_support = 1;
  3791. soc->da_war_enabled = false;
  3792. wlan_cfg_set_raw_mode_war(soc->wlan_cfg_ctx, false);
  3793. soc->per_tid_basize_max_tid = 8;
  3794. soc->wbm_release_desc_rx_sg_support = 1;
  3795. soc->rxdma2sw_rings_not_supported = 1;
  3796. soc->wbm_sg_last_msdu_war = 1;
  3797. soc->ast_offload_support = AST_OFFLOAD_ENABLE_STATUS;
  3798. soc->mec_fw_offload = FW_MEC_FW_OFFLOAD_ENABLED;
  3799. soc->num_hw_dscp_tid_map = HAL_MAX_HW_DSCP_TID_V2_MAPS;
  3800. wlan_cfg_set_txmon_hw_support(soc->wlan_cfg_ctx, true);
  3801. soc->host_ast_db_enable = cfg_get(soc->ctrl_psoc,
  3802. CFG_DP_HOST_AST_DB_ENABLE);
  3803. soc->features.wds_ext_ast_override_enable = true;
  3804. break;
  3805. case TARGET_TYPE_QCA5332:
  3806. case TARGET_TYPE_QCN6432:
  3807. soc->ast_override_support = 1;
  3808. soc->da_war_enabled = false;
  3809. wlan_cfg_set_raw_mode_war(soc->wlan_cfg_ctx, false);
  3810. soc->per_tid_basize_max_tid = 8;
  3811. soc->wbm_release_desc_rx_sg_support = 1;
  3812. soc->rxdma2sw_rings_not_supported = 1;
  3813. soc->wbm_sg_last_msdu_war = 1;
  3814. soc->ast_offload_support = AST_OFFLOAD_ENABLE_STATUS;
  3815. soc->mec_fw_offload = FW_MEC_FW_OFFLOAD_ENABLED;
  3816. soc->num_hw_dscp_tid_map = HAL_MAX_HW_DSCP_TID_V2_MAPS_5332;
  3817. wlan_cfg_set_txmon_hw_support(soc->wlan_cfg_ctx, true);
  3818. soc->host_ast_db_enable = cfg_get(soc->ctrl_psoc,
  3819. CFG_DP_HOST_AST_DB_ENABLE);
  3820. soc->features.wds_ext_ast_override_enable = true;
  3821. break;
  3822. default:
  3823. qdf_print("%s: Unknown tgt type %d\n", __func__, target_type);
  3824. qdf_assert_always(0);
  3825. break;
  3826. }
  3827. dp_soc_cfg_dump(soc, target_type);
  3828. }
  3829. /**
  3830. * dp_soc_get_ap_mld_mode() - store ap mld mode from ini
  3831. * @soc: Opaque DP SOC handle
  3832. *
  3833. * Return: none
  3834. */
  3835. #if defined(WLAN_FEATURE_11BE_MLO) && defined(WLAN_MLO_MULTI_CHIP)
  3836. static inline void dp_soc_get_ap_mld_mode(struct dp_soc *soc)
  3837. {
  3838. if (soc->cdp_soc.ol_ops->get_dp_cfg_param) {
  3839. soc->mld_mode_ap =
  3840. soc->cdp_soc.ol_ops->get_dp_cfg_param(soc->ctrl_psoc,
  3841. CDP_CFG_MLD_NETDEV_MODE_AP);
  3842. }
  3843. qdf_info("DP mld_mode_ap-%u\n", soc->mld_mode_ap);
  3844. }
  3845. #else
  3846. static inline void dp_soc_get_ap_mld_mode(struct dp_soc *soc)
  3847. {
  3848. (void)soc;
  3849. }
  3850. #endif
  3851. /**
  3852. * dp_soc_init() - Initialize txrx SOC
  3853. * @soc: Opaque DP SOC handle
  3854. * @htc_handle: Opaque HTC handle
  3855. * @hif_handle: Opaque HIF handle
  3856. *
  3857. * Return: DP SOC handle on success, NULL on failure
  3858. */
  3859. void *dp_soc_init(struct dp_soc *soc, HTC_HANDLE htc_handle,
  3860. struct hif_opaque_softc *hif_handle)
  3861. {
  3862. struct htt_soc *htt_soc = (struct htt_soc *)soc->htt_handle;
  3863. bool is_monitor_mode = false;
  3864. uint8_t i;
  3865. int num_dp_msi;
  3866. bool ppeds_attached = false;
  3867. htt_soc = htt_soc_attach(soc, htc_handle);
  3868. if (!htt_soc)
  3869. goto fail1;
  3870. soc->htt_handle = htt_soc;
  3871. if (htt_soc_htc_prealloc(htt_soc) != QDF_STATUS_SUCCESS)
  3872. goto fail2;
  3873. htt_set_htc_handle(htt_soc, htc_handle);
  3874. dp_soc_cfg_init(soc);
  3875. dp_monitor_soc_cfg_init(soc);
  3876. /* Reset/Initialize wbm sg list and flags */
  3877. dp_rx_wbm_sg_list_reset(soc);
  3878. /* Note: Any SRNG ring initialization should happen only after
  3879. * Interrupt mode is set and followed by filling up the
  3880. * interrupt mask. IT SHOULD ALWAYS BE IN THIS ORDER.
  3881. */
  3882. dp_soc_set_interrupt_mode(soc);
  3883. if (soc->cdp_soc.ol_ops->get_con_mode &&
  3884. soc->cdp_soc.ol_ops->get_con_mode() ==
  3885. QDF_GLOBAL_MONITOR_MODE) {
  3886. is_monitor_mode = true;
  3887. soc->curr_rx_pkt_tlv_size = soc->rx_mon_pkt_tlv_size;
  3888. } else {
  3889. soc->curr_rx_pkt_tlv_size = soc->rx_pkt_tlv_size;
  3890. }
  3891. num_dp_msi = dp_get_num_msi_available(soc, soc->intr_mode);
  3892. if (num_dp_msi < 0) {
  3893. dp_init_err("%pK: dp_interrupt assignment failed", soc);
  3894. goto fail3;
  3895. }
  3896. if (soc->arch_ops.ppeds_handle_attached)
  3897. ppeds_attached = soc->arch_ops.ppeds_handle_attached(soc);
  3898. wlan_cfg_fill_interrupt_mask(soc->wlan_cfg_ctx, num_dp_msi,
  3899. soc->intr_mode, is_monitor_mode,
  3900. ppeds_attached);
  3901. /* initialize WBM_IDLE_LINK ring */
  3902. if (dp_hw_link_desc_ring_init(soc)) {
  3903. dp_init_err("%pK: dp_hw_link_desc_ring_init failed", soc);
  3904. goto fail3;
  3905. }
  3906. dp_link_desc_ring_replenish(soc, WLAN_INVALID_PDEV_ID);
  3907. if (dp_soc_srng_init(soc)) {
  3908. dp_init_err("%pK: dp_soc_srng_init failed", soc);
  3909. goto fail4;
  3910. }
  3911. if (htt_soc_initialize(soc->htt_handle, soc->ctrl_psoc,
  3912. htt_get_htc_handle(htt_soc),
  3913. soc->hal_soc, soc->osdev) == NULL)
  3914. goto fail5;
  3915. /* Initialize descriptors in TCL Rings */
  3916. for (i = 0; i < soc->num_tcl_data_rings; i++) {
  3917. hal_tx_init_data_ring(soc->hal_soc,
  3918. soc->tcl_data_ring[i].hal_srng);
  3919. }
  3920. if (dp_soc_tx_desc_sw_pools_init(soc)) {
  3921. dp_init_err("%pK: dp_tx_soc_attach failed", soc);
  3922. goto fail6;
  3923. }
  3924. if (soc->arch_ops.txrx_soc_ppeds_start) {
  3925. if (soc->arch_ops.txrx_soc_ppeds_start(soc)) {
  3926. dp_init_err("%pK: ppeds start failed", soc);
  3927. goto fail7;
  3928. }
  3929. }
  3930. wlan_cfg_set_rx_hash(soc->wlan_cfg_ctx,
  3931. cfg_get(soc->ctrl_psoc, CFG_DP_RX_HASH));
  3932. soc->cce_disable = false;
  3933. soc->max_ast_ageout_count = MAX_AST_AGEOUT_COUNT;
  3934. soc->sta_mode_search_policy = DP_TX_ADDR_SEARCH_ADDR_POLICY;
  3935. qdf_mem_zero(&soc->vdev_id_map, sizeof(soc->vdev_id_map));
  3936. qdf_spinlock_create(&soc->vdev_map_lock);
  3937. qdf_atomic_init(&soc->num_tx_outstanding);
  3938. qdf_atomic_init(&soc->num_tx_exception);
  3939. soc->num_tx_allowed =
  3940. wlan_cfg_get_dp_soc_tx_device_limit(soc->wlan_cfg_ctx);
  3941. soc->num_tx_spl_allowed =
  3942. wlan_cfg_get_dp_soc_tx_spl_device_limit(soc->wlan_cfg_ctx);
  3943. soc->num_reg_tx_allowed = soc->num_tx_allowed - soc->num_tx_spl_allowed;
  3944. if (soc->cdp_soc.ol_ops->get_dp_cfg_param) {
  3945. int ret = soc->cdp_soc.ol_ops->get_dp_cfg_param(soc->ctrl_psoc,
  3946. CDP_CFG_MAX_PEER_ID);
  3947. if (ret != -EINVAL)
  3948. wlan_cfg_set_max_peer_id(soc->wlan_cfg_ctx, ret);
  3949. ret = soc->cdp_soc.ol_ops->get_dp_cfg_param(soc->ctrl_psoc,
  3950. CDP_CFG_CCE_DISABLE);
  3951. if (ret == 1)
  3952. soc->cce_disable = true;
  3953. }
  3954. /*
  3955. * Skip registering hw ring interrupts for WMAC2 on IPQ6018
  3956. * and IPQ5018 WMAC2 is not there in these platforms.
  3957. */
  3958. if (hal_get_target_type(soc->hal_soc) == TARGET_TYPE_QCA6018 ||
  3959. soc->disable_mac2_intr)
  3960. dp_soc_disable_unused_mac_intr_mask(soc, 0x2);
  3961. /*
  3962. * Skip registering hw ring interrupts for WMAC1 on IPQ5018
  3963. * WMAC1 is not there in this platform.
  3964. */
  3965. if (soc->disable_mac1_intr)
  3966. dp_soc_disable_unused_mac_intr_mask(soc, 0x1);
  3967. /* setup the global rx defrag waitlist */
  3968. TAILQ_INIT(&soc->rx.defrag.waitlist);
  3969. soc->rx.defrag.timeout_ms =
  3970. wlan_cfg_get_rx_defrag_min_timeout(soc->wlan_cfg_ctx);
  3971. soc->rx.defrag.next_flush_ms = 0;
  3972. soc->rx.flags.defrag_timeout_check =
  3973. wlan_cfg_get_defrag_timeout_check(soc->wlan_cfg_ctx);
  3974. qdf_spinlock_create(&soc->rx.defrag.defrag_lock);
  3975. dp_monitor_soc_init(soc);
  3976. qdf_atomic_set(&soc->cmn_init_done, 1);
  3977. qdf_nbuf_queue_init(&soc->htt_stats.msg);
  3978. qdf_spinlock_create(&soc->ast_lock);
  3979. dp_peer_mec_spinlock_create(soc);
  3980. qdf_spinlock_create(&soc->reo_desc_freelist_lock);
  3981. qdf_list_create(&soc->reo_desc_freelist, REO_DESC_FREELIST_SIZE);
  3982. INIT_RX_HW_STATS_LOCK(soc);
  3983. qdf_nbuf_queue_init(&soc->invalid_buf_queue);
  3984. /* fill the tx/rx cpu ring map*/
  3985. dp_soc_set_txrx_ring_map(soc);
  3986. TAILQ_INIT(&soc->inactive_peer_list);
  3987. qdf_spinlock_create(&soc->inactive_peer_list_lock);
  3988. TAILQ_INIT(&soc->inactive_vdev_list);
  3989. qdf_spinlock_create(&soc->inactive_vdev_list_lock);
  3990. qdf_spinlock_create(&soc->htt_stats.lock);
  3991. /* initialize work queue for stats processing */
  3992. qdf_create_work(0, &soc->htt_stats.work, htt_t2h_stats_handler, soc);
  3993. dp_reo_desc_deferred_freelist_create(soc);
  3994. dp_info("Mem stats: DMA = %u HEAP = %u SKB = %u",
  3995. qdf_dma_mem_stats_read(),
  3996. qdf_heap_mem_stats_read(),
  3997. qdf_skb_total_mem_stats_read());
  3998. soc->vdev_stats_id_map = 0;
  3999. dp_soc_get_ap_mld_mode(soc);
  4000. return soc;
  4001. fail7:
  4002. dp_soc_tx_desc_sw_pools_deinit(soc);
  4003. fail6:
  4004. htt_soc_htc_dealloc(soc->htt_handle);
  4005. fail5:
  4006. dp_soc_srng_deinit(soc);
  4007. fail4:
  4008. dp_hw_link_desc_ring_deinit(soc);
  4009. fail3:
  4010. htt_htc_pkt_pool_free(htt_soc);
  4011. fail2:
  4012. htt_soc_detach(htt_soc);
  4013. fail1:
  4014. return NULL;
  4015. }
  4016. #ifndef WLAN_DP_DISABLE_TCL_CMD_CRED_SRNG
  4017. static inline QDF_STATUS dp_soc_tcl_cmd_cred_srng_init(struct dp_soc *soc)
  4018. {
  4019. QDF_STATUS status;
  4020. if (soc->init_tcl_cmd_cred_ring) {
  4021. status = dp_srng_init(soc, &soc->tcl_cmd_credit_ring,
  4022. TCL_CMD_CREDIT, 0, 0);
  4023. if (QDF_IS_STATUS_ERROR(status))
  4024. return status;
  4025. wlan_minidump_log(soc->tcl_cmd_credit_ring.base_vaddr_unaligned,
  4026. soc->tcl_cmd_credit_ring.alloc_size,
  4027. soc->ctrl_psoc,
  4028. WLAN_MD_DP_SRNG_TCL_CMD,
  4029. "wbm_desc_rel_ring");
  4030. }
  4031. return QDF_STATUS_SUCCESS;
  4032. }
  4033. static inline void dp_soc_tcl_cmd_cred_srng_deinit(struct dp_soc *soc)
  4034. {
  4035. if (soc->init_tcl_cmd_cred_ring) {
  4036. wlan_minidump_remove(soc->tcl_cmd_credit_ring.base_vaddr_unaligned,
  4037. soc->tcl_cmd_credit_ring.alloc_size,
  4038. soc->ctrl_psoc, WLAN_MD_DP_SRNG_TCL_CMD,
  4039. "wbm_desc_rel_ring");
  4040. dp_srng_deinit(soc, &soc->tcl_cmd_credit_ring,
  4041. TCL_CMD_CREDIT, 0);
  4042. }
  4043. }
  4044. static inline QDF_STATUS dp_soc_tcl_cmd_cred_srng_alloc(struct dp_soc *soc)
  4045. {
  4046. struct wlan_cfg_dp_soc_ctxt *soc_cfg_ctx = soc->wlan_cfg_ctx;
  4047. uint32_t entries;
  4048. QDF_STATUS status;
  4049. entries = wlan_cfg_get_dp_soc_tcl_cmd_credit_ring_size(soc_cfg_ctx);
  4050. if (soc->init_tcl_cmd_cred_ring) {
  4051. status = dp_srng_alloc(soc, &soc->tcl_cmd_credit_ring,
  4052. TCL_CMD_CREDIT, entries, 0);
  4053. if (QDF_IS_STATUS_ERROR(status))
  4054. return status;
  4055. }
  4056. return QDF_STATUS_SUCCESS;
  4057. }
  4058. static inline void dp_soc_tcl_cmd_cred_srng_free(struct dp_soc *soc)
  4059. {
  4060. if (soc->init_tcl_cmd_cred_ring)
  4061. dp_srng_free(soc, &soc->tcl_cmd_credit_ring);
  4062. }
  4063. inline void dp_tx_init_cmd_credit_ring(struct dp_soc *soc)
  4064. {
  4065. if (soc->init_tcl_cmd_cred_ring)
  4066. hal_tx_init_cmd_credit_ring(soc->hal_soc,
  4067. soc->tcl_cmd_credit_ring.hal_srng);
  4068. }
  4069. #else
  4070. static inline QDF_STATUS dp_soc_tcl_cmd_cred_srng_init(struct dp_soc *soc)
  4071. {
  4072. return QDF_STATUS_SUCCESS;
  4073. }
  4074. static inline void dp_soc_tcl_cmd_cred_srng_deinit(struct dp_soc *soc)
  4075. {
  4076. }
  4077. static inline QDF_STATUS dp_soc_tcl_cmd_cred_srng_alloc(struct dp_soc *soc)
  4078. {
  4079. return QDF_STATUS_SUCCESS;
  4080. }
  4081. static inline void dp_soc_tcl_cmd_cred_srng_free(struct dp_soc *soc)
  4082. {
  4083. }
  4084. inline void dp_tx_init_cmd_credit_ring(struct dp_soc *soc)
  4085. {
  4086. }
  4087. #endif
  4088. #ifndef WLAN_DP_DISABLE_TCL_STATUS_SRNG
  4089. static inline QDF_STATUS dp_soc_tcl_status_srng_init(struct dp_soc *soc)
  4090. {
  4091. QDF_STATUS status;
  4092. status = dp_srng_init(soc, &soc->tcl_status_ring, TCL_STATUS, 0, 0);
  4093. if (QDF_IS_STATUS_ERROR(status))
  4094. return status;
  4095. wlan_minidump_log(soc->tcl_status_ring.base_vaddr_unaligned,
  4096. soc->tcl_status_ring.alloc_size,
  4097. soc->ctrl_psoc,
  4098. WLAN_MD_DP_SRNG_TCL_STATUS,
  4099. "wbm_desc_rel_ring");
  4100. return QDF_STATUS_SUCCESS;
  4101. }
  4102. static inline void dp_soc_tcl_status_srng_deinit(struct dp_soc *soc)
  4103. {
  4104. wlan_minidump_remove(soc->tcl_status_ring.base_vaddr_unaligned,
  4105. soc->tcl_status_ring.alloc_size,
  4106. soc->ctrl_psoc, WLAN_MD_DP_SRNG_TCL_STATUS,
  4107. "wbm_desc_rel_ring");
  4108. dp_srng_deinit(soc, &soc->tcl_status_ring, TCL_STATUS, 0);
  4109. }
  4110. static inline QDF_STATUS dp_soc_tcl_status_srng_alloc(struct dp_soc *soc)
  4111. {
  4112. struct wlan_cfg_dp_soc_ctxt *soc_cfg_ctx = soc->wlan_cfg_ctx;
  4113. uint32_t entries;
  4114. QDF_STATUS status = QDF_STATUS_SUCCESS;
  4115. entries = wlan_cfg_get_dp_soc_tcl_status_ring_size(soc_cfg_ctx);
  4116. status = dp_srng_alloc(soc, &soc->tcl_status_ring,
  4117. TCL_STATUS, entries, 0);
  4118. return status;
  4119. }
  4120. static inline void dp_soc_tcl_status_srng_free(struct dp_soc *soc)
  4121. {
  4122. dp_srng_free(soc, &soc->tcl_status_ring);
  4123. }
  4124. #else
  4125. static inline QDF_STATUS dp_soc_tcl_status_srng_init(struct dp_soc *soc)
  4126. {
  4127. return QDF_STATUS_SUCCESS;
  4128. }
  4129. static inline void dp_soc_tcl_status_srng_deinit(struct dp_soc *soc)
  4130. {
  4131. }
  4132. static inline QDF_STATUS dp_soc_tcl_status_srng_alloc(struct dp_soc *soc)
  4133. {
  4134. return QDF_STATUS_SUCCESS;
  4135. }
  4136. static inline void dp_soc_tcl_status_srng_free(struct dp_soc *soc)
  4137. {
  4138. }
  4139. #endif
  4140. /**
  4141. * dp_soc_srng_deinit() - de-initialize soc srng rings
  4142. * @soc: Datapath soc handle
  4143. *
  4144. */
  4145. void dp_soc_srng_deinit(struct dp_soc *soc)
  4146. {
  4147. uint32_t i;
  4148. if (soc->arch_ops.txrx_soc_srng_deinit)
  4149. soc->arch_ops.txrx_soc_srng_deinit(soc);
  4150. /* Free the ring memories */
  4151. /* Common rings */
  4152. wlan_minidump_remove(soc->wbm_desc_rel_ring.base_vaddr_unaligned,
  4153. soc->wbm_desc_rel_ring.alloc_size,
  4154. soc->ctrl_psoc, WLAN_MD_DP_SRNG_WBM_DESC_REL,
  4155. "wbm_desc_rel_ring");
  4156. dp_srng_deinit(soc, &soc->wbm_desc_rel_ring, SW2WBM_RELEASE, 0);
  4157. /* Tx data rings */
  4158. for (i = 0; i < soc->num_tcl_data_rings; i++)
  4159. dp_deinit_tx_pair_by_index(soc, i);
  4160. if (wlan_cfg_is_ipa_enabled(soc->wlan_cfg_ctx)) {
  4161. dp_deinit_tx_pair_by_index(soc, IPA_TCL_DATA_RING_IDX);
  4162. dp_ipa_deinit_alt_tx_ring(soc);
  4163. }
  4164. /* TCL command and status rings */
  4165. dp_soc_tcl_cmd_cred_srng_deinit(soc);
  4166. dp_soc_tcl_status_srng_deinit(soc);
  4167. for (i = 0; i < soc->num_reo_dest_rings; i++) {
  4168. /* TODO: Get number of rings and ring sizes
  4169. * from wlan_cfg
  4170. */
  4171. wlan_minidump_remove(soc->reo_dest_ring[i].base_vaddr_unaligned,
  4172. soc->reo_dest_ring[i].alloc_size,
  4173. soc->ctrl_psoc, WLAN_MD_DP_SRNG_REO_DEST,
  4174. "reo_dest_ring");
  4175. dp_srng_deinit(soc, &soc->reo_dest_ring[i], REO_DST, i);
  4176. }
  4177. /* REO reinjection ring */
  4178. wlan_minidump_remove(soc->reo_reinject_ring.base_vaddr_unaligned,
  4179. soc->reo_reinject_ring.alloc_size,
  4180. soc->ctrl_psoc, WLAN_MD_DP_SRNG_REO_REINJECT,
  4181. "reo_reinject_ring");
  4182. dp_srng_deinit(soc, &soc->reo_reinject_ring, REO_REINJECT, 0);
  4183. /* Rx release ring */
  4184. wlan_minidump_remove(soc->rx_rel_ring.base_vaddr_unaligned,
  4185. soc->rx_rel_ring.alloc_size,
  4186. soc->ctrl_psoc, WLAN_MD_DP_SRNG_RX_REL,
  4187. "reo_release_ring");
  4188. dp_srng_deinit(soc, &soc->rx_rel_ring, WBM2SW_RELEASE, 0);
  4189. /* Rx exception ring */
  4190. /* TODO: Better to store ring_type and ring_num in
  4191. * dp_srng during setup
  4192. */
  4193. wlan_minidump_remove(soc->reo_exception_ring.base_vaddr_unaligned,
  4194. soc->reo_exception_ring.alloc_size,
  4195. soc->ctrl_psoc, WLAN_MD_DP_SRNG_REO_EXCEPTION,
  4196. "reo_exception_ring");
  4197. dp_srng_deinit(soc, &soc->reo_exception_ring, REO_EXCEPTION, 0);
  4198. /* REO command and status rings */
  4199. wlan_minidump_remove(soc->reo_cmd_ring.base_vaddr_unaligned,
  4200. soc->reo_cmd_ring.alloc_size,
  4201. soc->ctrl_psoc, WLAN_MD_DP_SRNG_REO_CMD,
  4202. "reo_cmd_ring");
  4203. dp_srng_deinit(soc, &soc->reo_cmd_ring, REO_CMD, 0);
  4204. wlan_minidump_remove(soc->reo_status_ring.base_vaddr_unaligned,
  4205. soc->reo_status_ring.alloc_size,
  4206. soc->ctrl_psoc, WLAN_MD_DP_SRNG_REO_STATUS,
  4207. "reo_status_ring");
  4208. dp_srng_deinit(soc, &soc->reo_status_ring, REO_STATUS, 0);
  4209. }
  4210. /**
  4211. * dp_soc_srng_init() - Initialize soc level srng rings
  4212. * @soc: Datapath soc handle
  4213. *
  4214. * Return: QDF_STATUS_SUCCESS on success
  4215. * QDF_STATUS_E_FAILURE on failure
  4216. */
  4217. QDF_STATUS dp_soc_srng_init(struct dp_soc *soc)
  4218. {
  4219. struct wlan_cfg_dp_soc_ctxt *soc_cfg_ctx;
  4220. uint8_t i;
  4221. uint8_t wbm2_sw_rx_rel_ring_id;
  4222. soc_cfg_ctx = soc->wlan_cfg_ctx;
  4223. dp_enable_verbose_debug(soc);
  4224. /* WBM descriptor release ring */
  4225. if (dp_srng_init(soc, &soc->wbm_desc_rel_ring, SW2WBM_RELEASE, 0, 0)) {
  4226. dp_init_err("%pK: dp_srng_init failed for wbm_desc_rel_ring", soc);
  4227. goto fail1;
  4228. }
  4229. wlan_minidump_log(soc->wbm_desc_rel_ring.base_vaddr_unaligned,
  4230. soc->wbm_desc_rel_ring.alloc_size,
  4231. soc->ctrl_psoc,
  4232. WLAN_MD_DP_SRNG_WBM_DESC_REL,
  4233. "wbm_desc_rel_ring");
  4234. /* TCL command and status rings */
  4235. if (dp_soc_tcl_cmd_cred_srng_init(soc)) {
  4236. dp_init_err("%pK: dp_srng_init failed for tcl_cmd_ring", soc);
  4237. goto fail1;
  4238. }
  4239. if (dp_soc_tcl_status_srng_init(soc)) {
  4240. dp_init_err("%pK: dp_srng_init failed for tcl_status_ring", soc);
  4241. goto fail1;
  4242. }
  4243. /* REO reinjection ring */
  4244. if (dp_srng_init(soc, &soc->reo_reinject_ring, REO_REINJECT, 0, 0)) {
  4245. dp_init_err("%pK: dp_srng_init failed for reo_reinject_ring", soc);
  4246. goto fail1;
  4247. }
  4248. wlan_minidump_log(soc->reo_reinject_ring.base_vaddr_unaligned,
  4249. soc->reo_reinject_ring.alloc_size,
  4250. soc->ctrl_psoc,
  4251. WLAN_MD_DP_SRNG_REO_REINJECT,
  4252. "reo_reinject_ring");
  4253. wbm2_sw_rx_rel_ring_id = wlan_cfg_get_rx_rel_ring_id(soc_cfg_ctx);
  4254. /* Rx release ring */
  4255. if (dp_srng_init(soc, &soc->rx_rel_ring, WBM2SW_RELEASE,
  4256. wbm2_sw_rx_rel_ring_id, 0)) {
  4257. dp_init_err("%pK: dp_srng_init failed for rx_rel_ring", soc);
  4258. goto fail1;
  4259. }
  4260. wlan_minidump_log(soc->rx_rel_ring.base_vaddr_unaligned,
  4261. soc->rx_rel_ring.alloc_size,
  4262. soc->ctrl_psoc,
  4263. WLAN_MD_DP_SRNG_RX_REL,
  4264. "reo_release_ring");
  4265. /* Rx exception ring */
  4266. if (dp_srng_init(soc, &soc->reo_exception_ring,
  4267. REO_EXCEPTION, 0, MAX_REO_DEST_RINGS)) {
  4268. dp_init_err("%pK: dp_srng_init failed - reo_exception", soc);
  4269. goto fail1;
  4270. }
  4271. wlan_minidump_log(soc->reo_exception_ring.base_vaddr_unaligned,
  4272. soc->reo_exception_ring.alloc_size,
  4273. soc->ctrl_psoc,
  4274. WLAN_MD_DP_SRNG_REO_EXCEPTION,
  4275. "reo_exception_ring");
  4276. /* REO command and status rings */
  4277. if (dp_srng_init(soc, &soc->reo_cmd_ring, REO_CMD, 0, 0)) {
  4278. dp_init_err("%pK: dp_srng_init failed for reo_cmd_ring", soc);
  4279. goto fail1;
  4280. }
  4281. wlan_minidump_log(soc->reo_cmd_ring.base_vaddr_unaligned,
  4282. soc->reo_cmd_ring.alloc_size,
  4283. soc->ctrl_psoc,
  4284. WLAN_MD_DP_SRNG_REO_CMD,
  4285. "reo_cmd_ring");
  4286. hal_reo_init_cmd_ring(soc->hal_soc, soc->reo_cmd_ring.hal_srng);
  4287. TAILQ_INIT(&soc->rx.reo_cmd_list);
  4288. qdf_spinlock_create(&soc->rx.reo_cmd_lock);
  4289. if (dp_srng_init(soc, &soc->reo_status_ring, REO_STATUS, 0, 0)) {
  4290. dp_init_err("%pK: dp_srng_init failed for reo_status_ring", soc);
  4291. goto fail1;
  4292. }
  4293. wlan_minidump_log(soc->reo_status_ring.base_vaddr_unaligned,
  4294. soc->reo_status_ring.alloc_size,
  4295. soc->ctrl_psoc,
  4296. WLAN_MD_DP_SRNG_REO_STATUS,
  4297. "reo_status_ring");
  4298. for (i = 0; i < soc->num_tcl_data_rings; i++) {
  4299. if (dp_init_tx_ring_pair_by_index(soc, i))
  4300. goto fail1;
  4301. }
  4302. if (wlan_cfg_is_ipa_enabled(soc->wlan_cfg_ctx)) {
  4303. if (dp_init_tx_ring_pair_by_index(soc, IPA_TCL_DATA_RING_IDX))
  4304. goto fail1;
  4305. if (dp_ipa_init_alt_tx_ring(soc))
  4306. goto fail1;
  4307. }
  4308. dp_create_ext_stats_event(soc);
  4309. for (i = 0; i < soc->num_reo_dest_rings; i++) {
  4310. /* Initialize REO destination ring */
  4311. if (dp_srng_init(soc, &soc->reo_dest_ring[i], REO_DST, i, 0)) {
  4312. dp_init_err("%pK: dp_srng_init failed for reo_dest_ringn", soc);
  4313. goto fail1;
  4314. }
  4315. wlan_minidump_log(soc->reo_dest_ring[i].base_vaddr_unaligned,
  4316. soc->reo_dest_ring[i].alloc_size,
  4317. soc->ctrl_psoc,
  4318. WLAN_MD_DP_SRNG_REO_DEST,
  4319. "reo_dest_ring");
  4320. }
  4321. if (soc->arch_ops.txrx_soc_srng_init) {
  4322. if (soc->arch_ops.txrx_soc_srng_init(soc)) {
  4323. dp_init_err("%pK: dp_srng_init failed for arch rings",
  4324. soc);
  4325. goto fail1;
  4326. }
  4327. }
  4328. return QDF_STATUS_SUCCESS;
  4329. fail1:
  4330. /*
  4331. * Cleanup will be done as part of soc_detach, which will
  4332. * be called on pdev attach failure
  4333. */
  4334. dp_soc_srng_deinit(soc);
  4335. return QDF_STATUS_E_FAILURE;
  4336. }
  4337. /**
  4338. * dp_soc_srng_free() - free soc level srng rings
  4339. * @soc: Datapath soc handle
  4340. *
  4341. */
  4342. void dp_soc_srng_free(struct dp_soc *soc)
  4343. {
  4344. uint32_t i;
  4345. if (soc->arch_ops.txrx_soc_srng_free)
  4346. soc->arch_ops.txrx_soc_srng_free(soc);
  4347. dp_srng_free(soc, &soc->wbm_desc_rel_ring);
  4348. for (i = 0; i < soc->num_tcl_data_rings; i++)
  4349. dp_free_tx_ring_pair_by_index(soc, i);
  4350. /* Free IPA rings for TCL_TX and TCL_COMPL ring */
  4351. if (wlan_cfg_is_ipa_enabled(soc->wlan_cfg_ctx)) {
  4352. dp_free_tx_ring_pair_by_index(soc, IPA_TCL_DATA_RING_IDX);
  4353. dp_ipa_free_alt_tx_ring(soc);
  4354. }
  4355. dp_soc_tcl_cmd_cred_srng_free(soc);
  4356. dp_soc_tcl_status_srng_free(soc);
  4357. for (i = 0; i < soc->num_reo_dest_rings; i++)
  4358. dp_srng_free(soc, &soc->reo_dest_ring[i]);
  4359. dp_srng_free(soc, &soc->reo_reinject_ring);
  4360. dp_srng_free(soc, &soc->rx_rel_ring);
  4361. dp_srng_free(soc, &soc->reo_exception_ring);
  4362. dp_srng_free(soc, &soc->reo_cmd_ring);
  4363. dp_srng_free(soc, &soc->reo_status_ring);
  4364. }
  4365. /**
  4366. * dp_soc_srng_alloc() - Allocate memory for soc level srng rings
  4367. * @soc: Datapath soc handle
  4368. *
  4369. * Return: QDF_STATUS_SUCCESS on success
  4370. * QDF_STATUS_E_NOMEM on failure
  4371. */
  4372. QDF_STATUS dp_soc_srng_alloc(struct dp_soc *soc)
  4373. {
  4374. uint32_t entries;
  4375. uint32_t i;
  4376. struct wlan_cfg_dp_soc_ctxt *soc_cfg_ctx;
  4377. uint32_t cached = WLAN_CFG_DST_RING_CACHED_DESC;
  4378. uint32_t reo_dst_ring_size;
  4379. soc_cfg_ctx = soc->wlan_cfg_ctx;
  4380. /* sw2wbm link descriptor release ring */
  4381. entries = wlan_cfg_get_dp_soc_wbm_release_ring_size(soc_cfg_ctx);
  4382. if (dp_srng_alloc(soc, &soc->wbm_desc_rel_ring, SW2WBM_RELEASE,
  4383. entries, 0)) {
  4384. dp_init_err("%pK: dp_srng_alloc failed for wbm_desc_rel_ring", soc);
  4385. goto fail1;
  4386. }
  4387. /* TCL command and status rings */
  4388. if (dp_soc_tcl_cmd_cred_srng_alloc(soc)) {
  4389. dp_init_err("%pK: dp_srng_alloc failed for tcl_cmd_ring", soc);
  4390. goto fail1;
  4391. }
  4392. if (dp_soc_tcl_status_srng_alloc(soc)) {
  4393. dp_init_err("%pK: dp_srng_alloc failed for tcl_status_ring", soc);
  4394. goto fail1;
  4395. }
  4396. /* REO reinjection ring */
  4397. entries = wlan_cfg_get_dp_soc_reo_reinject_ring_size(soc_cfg_ctx);
  4398. if (dp_srng_alloc(soc, &soc->reo_reinject_ring, REO_REINJECT,
  4399. entries, 0)) {
  4400. dp_init_err("%pK: dp_srng_alloc failed for reo_reinject_ring", soc);
  4401. goto fail1;
  4402. }
  4403. /* Rx release ring */
  4404. entries = wlan_cfg_get_dp_soc_rx_release_ring_size(soc_cfg_ctx);
  4405. if (dp_srng_alloc(soc, &soc->rx_rel_ring, WBM2SW_RELEASE,
  4406. entries, 0)) {
  4407. dp_init_err("%pK: dp_srng_alloc failed for rx_rel_ring", soc);
  4408. goto fail1;
  4409. }
  4410. /* Rx exception ring */
  4411. entries = wlan_cfg_get_dp_soc_reo_exception_ring_size(soc_cfg_ctx);
  4412. if (dp_srng_alloc(soc, &soc->reo_exception_ring, REO_EXCEPTION,
  4413. entries, 0)) {
  4414. dp_init_err("%pK: dp_srng_alloc failed - reo_exception", soc);
  4415. goto fail1;
  4416. }
  4417. /* REO command and status rings */
  4418. entries = wlan_cfg_get_dp_soc_reo_cmd_ring_size(soc_cfg_ctx);
  4419. if (dp_srng_alloc(soc, &soc->reo_cmd_ring, REO_CMD, entries, 0)) {
  4420. dp_init_err("%pK: dp_srng_alloc failed for reo_cmd_ring", soc);
  4421. goto fail1;
  4422. }
  4423. entries = wlan_cfg_get_dp_soc_reo_status_ring_size(soc_cfg_ctx);
  4424. if (dp_srng_alloc(soc, &soc->reo_status_ring, REO_STATUS,
  4425. entries, 0)) {
  4426. dp_init_err("%pK: dp_srng_alloc failed for reo_status_ring", soc);
  4427. goto fail1;
  4428. }
  4429. reo_dst_ring_size = wlan_cfg_get_reo_dst_ring_size(soc_cfg_ctx);
  4430. /* Disable cached desc if NSS offload is enabled */
  4431. if (wlan_cfg_get_dp_soc_nss_cfg(soc_cfg_ctx))
  4432. cached = 0;
  4433. for (i = 0; i < soc->num_tcl_data_rings; i++) {
  4434. if (dp_alloc_tx_ring_pair_by_index(soc, i))
  4435. goto fail1;
  4436. }
  4437. /* IPA rings for TCL_TX and TX_COMP will be allocated here */
  4438. if (wlan_cfg_is_ipa_enabled(soc->wlan_cfg_ctx)) {
  4439. if (dp_alloc_tx_ring_pair_by_index(soc, IPA_TCL_DATA_RING_IDX))
  4440. goto fail1;
  4441. if (dp_ipa_alloc_alt_tx_ring(soc))
  4442. goto fail1;
  4443. }
  4444. for (i = 0; i < soc->num_reo_dest_rings; i++) {
  4445. /* Setup REO destination ring */
  4446. if (dp_srng_alloc(soc, &soc->reo_dest_ring[i], REO_DST,
  4447. reo_dst_ring_size, cached)) {
  4448. dp_init_err("%pK: dp_srng_alloc failed for reo_dest_ring", soc);
  4449. goto fail1;
  4450. }
  4451. }
  4452. if (soc->arch_ops.txrx_soc_srng_alloc) {
  4453. if (soc->arch_ops.txrx_soc_srng_alloc(soc)) {
  4454. dp_init_err("%pK: dp_srng_alloc failed for arch rings",
  4455. soc);
  4456. goto fail1;
  4457. }
  4458. }
  4459. return QDF_STATUS_SUCCESS;
  4460. fail1:
  4461. dp_soc_srng_free(soc);
  4462. return QDF_STATUS_E_NOMEM;
  4463. }
  4464. /**
  4465. * dp_soc_cfg_attach() - set target specific configuration in
  4466. * dp soc cfg.
  4467. * @soc: dp soc handle
  4468. */
  4469. void dp_soc_cfg_attach(struct dp_soc *soc)
  4470. {
  4471. int target_type;
  4472. int nss_cfg = 0;
  4473. target_type = hal_get_target_type(soc->hal_soc);
  4474. switch (target_type) {
  4475. case TARGET_TYPE_QCA6290:
  4476. wlan_cfg_set_reo_dst_ring_size(soc->wlan_cfg_ctx,
  4477. REO_DST_RING_SIZE_QCA6290);
  4478. break;
  4479. case TARGET_TYPE_QCA6390:
  4480. case TARGET_TYPE_QCA6490:
  4481. case TARGET_TYPE_QCA6750:
  4482. wlan_cfg_set_reo_dst_ring_size(soc->wlan_cfg_ctx,
  4483. REO_DST_RING_SIZE_QCA6290);
  4484. soc->wlan_cfg_ctx->rxdma1_enable = 0;
  4485. break;
  4486. case TARGET_TYPE_KIWI:
  4487. case TARGET_TYPE_MANGO:
  4488. case TARGET_TYPE_PEACH:
  4489. soc->wlan_cfg_ctx->rxdma1_enable = 0;
  4490. break;
  4491. case TARGET_TYPE_QCA8074:
  4492. wlan_cfg_set_tso_desc_attach_defer(soc->wlan_cfg_ctx, 1);
  4493. break;
  4494. case TARGET_TYPE_QCA8074V2:
  4495. case TARGET_TYPE_QCA6018:
  4496. case TARGET_TYPE_QCA9574:
  4497. case TARGET_TYPE_QCN6122:
  4498. case TARGET_TYPE_QCA5018:
  4499. wlan_cfg_set_tso_desc_attach_defer(soc->wlan_cfg_ctx, 1);
  4500. wlan_cfg_set_rxdma1_enable(soc->wlan_cfg_ctx);
  4501. break;
  4502. case TARGET_TYPE_QCN9160:
  4503. wlan_cfg_set_tso_desc_attach_defer(soc->wlan_cfg_ctx, 1);
  4504. soc->wlan_cfg_ctx->rxdma1_enable = 0;
  4505. break;
  4506. case TARGET_TYPE_QCN9000:
  4507. wlan_cfg_set_tso_desc_attach_defer(soc->wlan_cfg_ctx, 1);
  4508. wlan_cfg_set_rxdma1_enable(soc->wlan_cfg_ctx);
  4509. break;
  4510. case TARGET_TYPE_QCN9224:
  4511. case TARGET_TYPE_QCA5332:
  4512. case TARGET_TYPE_QCN6432:
  4513. wlan_cfg_set_tso_desc_attach_defer(soc->wlan_cfg_ctx, 1);
  4514. wlan_cfg_set_rxdma1_enable(soc->wlan_cfg_ctx);
  4515. break;
  4516. default:
  4517. qdf_print("%s: Unknown tgt type %d\n", __func__, target_type);
  4518. qdf_assert_always(0);
  4519. break;
  4520. }
  4521. if (soc->cdp_soc.ol_ops->get_soc_nss_cfg)
  4522. nss_cfg = soc->cdp_soc.ol_ops->get_soc_nss_cfg(soc->ctrl_psoc);
  4523. wlan_cfg_set_dp_soc_nss_cfg(soc->wlan_cfg_ctx, nss_cfg);
  4524. if (wlan_cfg_get_dp_soc_nss_cfg(soc->wlan_cfg_ctx)) {
  4525. wlan_cfg_set_num_tx_desc_pool(soc->wlan_cfg_ctx, 0);
  4526. wlan_cfg_set_num_tx_ext_desc_pool(soc->wlan_cfg_ctx, 0);
  4527. wlan_cfg_set_num_tx_desc(soc->wlan_cfg_ctx, 0);
  4528. wlan_cfg_set_num_tx_ext_desc(soc->wlan_cfg_ctx, 0);
  4529. soc->init_tcl_cmd_cred_ring = false;
  4530. soc->num_tcl_data_rings =
  4531. wlan_cfg_num_nss_tcl_data_rings(soc->wlan_cfg_ctx);
  4532. soc->num_reo_dest_rings =
  4533. wlan_cfg_num_nss_reo_dest_rings(soc->wlan_cfg_ctx);
  4534. } else {
  4535. soc->init_tcl_cmd_cred_ring = true;
  4536. soc->num_tx_comp_rings =
  4537. wlan_cfg_num_tx_comp_rings(soc->wlan_cfg_ctx);
  4538. soc->num_tcl_data_rings =
  4539. wlan_cfg_num_tcl_data_rings(soc->wlan_cfg_ctx);
  4540. soc->num_reo_dest_rings =
  4541. wlan_cfg_num_reo_dest_rings(soc->wlan_cfg_ctx);
  4542. }
  4543. }
  4544. void dp_pdev_set_default_reo(struct dp_pdev *pdev)
  4545. {
  4546. struct dp_soc *soc = pdev->soc;
  4547. switch (pdev->pdev_id) {
  4548. case 0:
  4549. pdev->reo_dest =
  4550. wlan_cfg_radio0_default_reo_get(soc->wlan_cfg_ctx);
  4551. break;
  4552. case 1:
  4553. pdev->reo_dest =
  4554. wlan_cfg_radio1_default_reo_get(soc->wlan_cfg_ctx);
  4555. break;
  4556. case 2:
  4557. pdev->reo_dest =
  4558. wlan_cfg_radio2_default_reo_get(soc->wlan_cfg_ctx);
  4559. break;
  4560. default:
  4561. dp_init_err("%pK: Invalid pdev_id %d for reo selection",
  4562. soc, pdev->pdev_id);
  4563. break;
  4564. }
  4565. }