dp_rings_main.c 145 KB

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