dp_htt.c 156 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567
  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 <htt.h>
  20. #include <hal_hw_headers.h>
  21. #include <hal_api.h>
  22. #include "dp_peer.h"
  23. #include "dp_types.h"
  24. #include "dp_internal.h"
  25. #include "dp_ipa.h"
  26. #include "dp_rx.h"
  27. #include "htt_stats.h"
  28. #include "htt_ppdu_stats.h"
  29. #include "dp_htt.h"
  30. #ifdef WIFI_MONITOR_SUPPORT
  31. #include <dp_mon.h>
  32. #endif
  33. #include "qdf_mem.h" /* qdf_mem_malloc,free */
  34. #include "cdp_txrx_cmn_struct.h"
  35. #ifdef IPA_OPT_WIFI_DP
  36. #include "cdp_txrx_ipa.h"
  37. #endif
  38. #ifdef FEATURE_PERPKT_INFO
  39. #include "dp_ratetable.h"
  40. #endif
  41. #include <qdf_module.h>
  42. #ifdef CONFIG_SAWF_DEF_QUEUES
  43. #include <dp_sawf_htt.h>
  44. #endif
  45. #include <wbuff.h>
  46. #define HTT_TLV_HDR_LEN HTT_T2H_EXT_STATS_CONF_TLV_HDR_SIZE
  47. #define HTT_HTC_PKT_POOL_INIT_SIZE 64
  48. #define HTT_MSG_BUF_SIZE(msg_bytes) \
  49. ((msg_bytes) + HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING)
  50. #define HTT_PID_BIT_MASK 0x3
  51. #define DP_EXT_MSG_LENGTH 2048
  52. #define HTT_HEADER_LEN 16
  53. #define HTT_MGMT_CTRL_TLV_HDR_RESERVERD_LEN 16
  54. #define HTT_SHIFT_UPPER_TIMESTAMP 32
  55. #define HTT_MASK_UPPER_TIMESTAMP 0xFFFFFFFF00000000
  56. #define HTT_BKP_STATS_MAX_QUEUE_DEPTH 16
  57. struct dp_htt_htc_pkt *
  58. htt_htc_pkt_alloc(struct htt_soc *soc)
  59. {
  60. struct dp_htt_htc_pkt_union *pkt = NULL;
  61. HTT_TX_MUTEX_ACQUIRE(&soc->htt_tx_mutex);
  62. if (soc->htt_htc_pkt_freelist) {
  63. pkt = soc->htt_htc_pkt_freelist;
  64. soc->htt_htc_pkt_freelist = soc->htt_htc_pkt_freelist->u.next;
  65. }
  66. HTT_TX_MUTEX_RELEASE(&soc->htt_tx_mutex);
  67. if (!pkt)
  68. pkt = qdf_mem_malloc(sizeof(*pkt));
  69. if (!pkt)
  70. return NULL;
  71. htc_packet_set_magic_cookie(&(pkt->u.pkt.htc_pkt), 0);
  72. return &pkt->u.pkt; /* not actually a dereference */
  73. }
  74. qdf_export_symbol(htt_htc_pkt_alloc);
  75. void
  76. htt_htc_pkt_free(struct htt_soc *soc, struct dp_htt_htc_pkt *pkt)
  77. {
  78. struct dp_htt_htc_pkt_union *u_pkt =
  79. (struct dp_htt_htc_pkt_union *)pkt;
  80. HTT_TX_MUTEX_ACQUIRE(&soc->htt_tx_mutex);
  81. htc_packet_set_magic_cookie(&(u_pkt->u.pkt.htc_pkt), 0);
  82. u_pkt->u.next = soc->htt_htc_pkt_freelist;
  83. soc->htt_htc_pkt_freelist = u_pkt;
  84. HTT_TX_MUTEX_RELEASE(&soc->htt_tx_mutex);
  85. }
  86. qdf_export_symbol(htt_htc_pkt_free);
  87. void
  88. htt_htc_pkt_pool_free(struct htt_soc *soc)
  89. {
  90. struct dp_htt_htc_pkt_union *pkt, *next;
  91. pkt = soc->htt_htc_pkt_freelist;
  92. while (pkt) {
  93. next = pkt->u.next;
  94. qdf_mem_free(pkt);
  95. pkt = next;
  96. }
  97. soc->htt_htc_pkt_freelist = NULL;
  98. }
  99. #ifndef ENABLE_CE4_COMP_DISABLE_HTT_HTC_MISC_LIST
  100. /**
  101. * htt_htc_misc_pkt_list_trim() - trim misc list
  102. * @soc: HTT SOC handle
  103. * @level: max no. of pkts in list
  104. */
  105. static void
  106. htt_htc_misc_pkt_list_trim(struct htt_soc *soc, int level)
  107. {
  108. struct dp_htt_htc_pkt_union *pkt, *next, *prev = NULL;
  109. int i = 0;
  110. qdf_nbuf_t netbuf;
  111. HTT_TX_MUTEX_ACQUIRE(&soc->htt_tx_mutex);
  112. pkt = soc->htt_htc_pkt_misclist;
  113. while (pkt) {
  114. next = pkt->u.next;
  115. /* trim the out grown list*/
  116. if (++i > level) {
  117. netbuf =
  118. (qdf_nbuf_t)(pkt->u.pkt.htc_pkt.pNetBufContext);
  119. qdf_nbuf_unmap(soc->osdev, netbuf, QDF_DMA_TO_DEVICE);
  120. qdf_nbuf_free(netbuf);
  121. qdf_mem_free(pkt);
  122. pkt = NULL;
  123. if (prev)
  124. prev->u.next = NULL;
  125. }
  126. prev = pkt;
  127. pkt = next;
  128. }
  129. HTT_TX_MUTEX_RELEASE(&soc->htt_tx_mutex);
  130. }
  131. void
  132. htt_htc_misc_pkt_list_add(struct htt_soc *soc, struct dp_htt_htc_pkt *pkt)
  133. {
  134. struct dp_htt_htc_pkt_union *u_pkt =
  135. (struct dp_htt_htc_pkt_union *)pkt;
  136. int misclist_trim_level = htc_get_tx_queue_depth(soc->htc_soc,
  137. pkt->htc_pkt.Endpoint)
  138. + DP_HTT_HTC_PKT_MISCLIST_SIZE;
  139. HTT_TX_MUTEX_ACQUIRE(&soc->htt_tx_mutex);
  140. if (soc->htt_htc_pkt_misclist) {
  141. u_pkt->u.next = soc->htt_htc_pkt_misclist;
  142. soc->htt_htc_pkt_misclist = u_pkt;
  143. } else {
  144. soc->htt_htc_pkt_misclist = u_pkt;
  145. }
  146. HTT_TX_MUTEX_RELEASE(&soc->htt_tx_mutex);
  147. /* only ce pipe size + tx_queue_depth could possibly be in use
  148. * free older packets in the misclist
  149. */
  150. htt_htc_misc_pkt_list_trim(soc, misclist_trim_level);
  151. }
  152. qdf_export_symbol(htt_htc_misc_pkt_list_add);
  153. #endif /* ENABLE_CE4_COMP_DISABLE_HTT_HTC_MISC_LIST */
  154. /**
  155. * htt_htc_misc_pkt_pool_free() - free pkts in misc list
  156. * @soc: HTT SOC handle
  157. */
  158. static void
  159. htt_htc_misc_pkt_pool_free(struct htt_soc *soc)
  160. {
  161. struct dp_htt_htc_pkt_union *pkt, *next;
  162. qdf_nbuf_t netbuf;
  163. HTT_TX_MUTEX_ACQUIRE(&soc->htt_tx_mutex);
  164. pkt = soc->htt_htc_pkt_misclist;
  165. while (pkt) {
  166. next = pkt->u.next;
  167. if (htc_packet_get_magic_cookie(&(pkt->u.pkt.htc_pkt)) !=
  168. HTC_PACKET_MAGIC_COOKIE) {
  169. pkt = next;
  170. soc->stats.skip_count++;
  171. continue;
  172. }
  173. netbuf = (qdf_nbuf_t) (pkt->u.pkt.htc_pkt.pNetBufContext);
  174. qdf_nbuf_unmap(soc->osdev, netbuf, QDF_DMA_TO_DEVICE);
  175. soc->stats.htc_pkt_free++;
  176. dp_htt_info("%pK: Pkt free count %d",
  177. soc->dp_soc, soc->stats.htc_pkt_free);
  178. qdf_nbuf_free(netbuf);
  179. qdf_mem_free(pkt);
  180. pkt = next;
  181. }
  182. soc->htt_htc_pkt_misclist = NULL;
  183. HTT_TX_MUTEX_RELEASE(&soc->htt_tx_mutex);
  184. dp_info("HTC Packets, fail count = %d, skip count = %d",
  185. soc->stats.fail_count, soc->stats.skip_count);
  186. }
  187. /**
  188. * htt_t2h_mac_addr_deswizzle() - Swap MAC addr bytes if FW endianness differ
  189. * @tgt_mac_addr: Target MAC
  190. * @buffer: Output buffer
  191. */
  192. static u_int8_t *
  193. htt_t2h_mac_addr_deswizzle(u_int8_t *tgt_mac_addr, u_int8_t *buffer)
  194. {
  195. #ifdef BIG_ENDIAN_HOST
  196. /*
  197. * The host endianness is opposite of the target endianness.
  198. * To make u_int32_t elements come out correctly, the target->host
  199. * upload has swizzled the bytes in each u_int32_t element of the
  200. * message.
  201. * For byte-array message fields like the MAC address, this
  202. * upload swizzling puts the bytes in the wrong order, and needs
  203. * to be undone.
  204. */
  205. buffer[0] = tgt_mac_addr[3];
  206. buffer[1] = tgt_mac_addr[2];
  207. buffer[2] = tgt_mac_addr[1];
  208. buffer[3] = tgt_mac_addr[0];
  209. buffer[4] = tgt_mac_addr[7];
  210. buffer[5] = tgt_mac_addr[6];
  211. return buffer;
  212. #else
  213. /*
  214. * The host endianness matches the target endianness -
  215. * we can use the mac addr directly from the message buffer.
  216. */
  217. return tgt_mac_addr;
  218. #endif
  219. }
  220. /**
  221. * dp_htt_h2t_send_complete_free_netbuf() - Free completed buffer
  222. * @soc: SOC handle
  223. * @status: Completion status
  224. * @netbuf: HTT buffer
  225. */
  226. static void
  227. dp_htt_h2t_send_complete_free_netbuf(
  228. void *soc, A_STATUS status, qdf_nbuf_t netbuf)
  229. {
  230. qdf_nbuf_free(netbuf);
  231. }
  232. #ifdef ENABLE_CE4_COMP_DISABLE_HTT_HTC_MISC_LIST
  233. void
  234. dp_htt_h2t_send_complete(void *context, HTC_PACKET *htc_pkt)
  235. {
  236. struct htt_soc *soc = (struct htt_soc *) context;
  237. struct dp_htt_htc_pkt *htt_pkt;
  238. qdf_nbuf_t netbuf;
  239. htt_pkt = container_of(htc_pkt, struct dp_htt_htc_pkt, htc_pkt);
  240. /* process (free or keep) the netbuf that held the message */
  241. netbuf = (qdf_nbuf_t) htc_pkt->pNetBufContext;
  242. /*
  243. * adf sendcomplete is required for windows only
  244. */
  245. /* qdf_nbuf_set_sendcompleteflag(netbuf, TRUE); */
  246. /* free the htt_htc_pkt / HTC_PACKET object */
  247. qdf_nbuf_free(netbuf);
  248. htt_htc_pkt_free(soc, htt_pkt);
  249. }
  250. #else /* ENABLE_CE4_COMP_DISABLE_HTT_HTC_MISC_LIST */
  251. void
  252. dp_htt_h2t_send_complete(void *context, HTC_PACKET *htc_pkt)
  253. {
  254. void (*send_complete_part2)(
  255. void *soc, QDF_STATUS status, qdf_nbuf_t msdu);
  256. struct htt_soc *soc = (struct htt_soc *) context;
  257. struct dp_htt_htc_pkt *htt_pkt;
  258. qdf_nbuf_t netbuf;
  259. send_complete_part2 = htc_pkt->pPktContext;
  260. htt_pkt = container_of(htc_pkt, struct dp_htt_htc_pkt, htc_pkt);
  261. /* process (free or keep) the netbuf that held the message */
  262. netbuf = (qdf_nbuf_t) htc_pkt->pNetBufContext;
  263. /*
  264. * adf sendcomplete is required for windows only
  265. */
  266. /* qdf_nbuf_set_sendcompleteflag(netbuf, TRUE); */
  267. if (send_complete_part2){
  268. send_complete_part2(
  269. htt_pkt->soc_ctxt, htc_pkt->Status, netbuf);
  270. }
  271. /* free the htt_htc_pkt / HTC_PACKET object */
  272. htt_htc_pkt_free(soc, htt_pkt);
  273. }
  274. #endif /* ENABLE_CE4_COMP_DISABLE_HTT_HTC_MISC_LIST */
  275. /**
  276. * dp_htt_h2t_add_tcl_metadata_ver_v1() - Add tcl_metadata version V1
  277. * @soc: HTT SOC handle
  278. * @msg: Pointer to nbuf
  279. *
  280. * Return: 0 on success; error code on failure
  281. */
  282. static int dp_htt_h2t_add_tcl_metadata_ver_v1(struct htt_soc *soc,
  283. qdf_nbuf_t *msg)
  284. {
  285. uint32_t *msg_word;
  286. *msg = qdf_nbuf_alloc(
  287. soc->osdev,
  288. HTT_MSG_BUF_SIZE(HTT_VER_REQ_BYTES),
  289. /* reserve room for the HTC header */
  290. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  291. if (!*msg)
  292. return QDF_STATUS_E_NOMEM;
  293. /*
  294. * Set the length of the message.
  295. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  296. * separately during the below call to qdf_nbuf_push_head.
  297. * The contribution from the HTC header is added separately inside HTC.
  298. */
  299. if (!qdf_nbuf_put_tail(*msg, HTT_VER_REQ_BYTES)) {
  300. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  301. "%s: Failed to expand head for HTT_H2T_MSG_TYPE_VERSION_REQ msg",
  302. __func__);
  303. return QDF_STATUS_E_FAILURE;
  304. }
  305. /* fill in the message contents */
  306. msg_word = (u_int32_t *)qdf_nbuf_data(*msg);
  307. /* rewind beyond alignment pad to get to the HTC header reserved area */
  308. qdf_nbuf_push_head(*msg, HTC_HDR_ALIGNMENT_PADDING);
  309. *msg_word = 0;
  310. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_VERSION_REQ);
  311. return QDF_STATUS_SUCCESS;
  312. }
  313. #ifdef QCA_DP_TX_FW_METADATA_V2
  314. /**
  315. * dp_htt_h2t_add_tcl_metadata_ver_v2() - Add tcl_metadata version V2
  316. * @soc: HTT SOC handle
  317. * @msg: Pointer to nbuf
  318. *
  319. * Return: 0 on success; error code on failure
  320. */
  321. static int dp_htt_h2t_add_tcl_metadata_ver_v2(struct htt_soc *soc,
  322. qdf_nbuf_t *msg)
  323. {
  324. uint32_t *msg_word;
  325. *msg = qdf_nbuf_alloc(
  326. soc->osdev,
  327. HTT_MSG_BUF_SIZE(HTT_VER_REQ_BYTES + HTT_TCL_METADATA_VER_SZ),
  328. /* reserve room for the HTC header */
  329. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  330. if (!*msg)
  331. return QDF_STATUS_E_NOMEM;
  332. /*
  333. * Set the length of the message.
  334. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  335. * separately during the below call to qdf_nbuf_push_head.
  336. * The contribution from the HTC header is added separately inside HTC.
  337. */
  338. if (!qdf_nbuf_put_tail(*msg,
  339. HTT_VER_REQ_BYTES + HTT_TCL_METADATA_VER_SZ)) {
  340. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  341. "%s: Failed to expand head for HTT_H2T_MSG_TYPE_VERSION_REQ msg",
  342. __func__);
  343. return QDF_STATUS_E_FAILURE;
  344. }
  345. /* fill in the message contents */
  346. msg_word = (u_int32_t *)qdf_nbuf_data(*msg);
  347. /* rewind beyond alignment pad to get to the HTC header reserved area */
  348. qdf_nbuf_push_head(*msg, HTC_HDR_ALIGNMENT_PADDING);
  349. *msg_word = 0;
  350. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_VERSION_REQ);
  351. /* word 1 */
  352. msg_word++;
  353. *msg_word = 0;
  354. HTT_OPTION_TLV_TAG_SET(*msg_word, HTT_OPTION_TLV_TAG_TCL_METADATA_VER);
  355. HTT_OPTION_TLV_LENGTH_SET(*msg_word, HTT_TCL_METADATA_VER_SZ);
  356. HTT_OPTION_TLV_TCL_METADATA_VER_SET(*msg_word,
  357. HTT_OPTION_TLV_TCL_METADATA_V21);
  358. return QDF_STATUS_SUCCESS;
  359. }
  360. /**
  361. * dp_htt_h2t_add_tcl_metadata_ver() - Add tcl_metadata version
  362. * @soc: HTT SOC handle
  363. * @msg: Pointer to nbuf
  364. *
  365. * Return: 0 on success; error code on failure
  366. */
  367. static int dp_htt_h2t_add_tcl_metadata_ver(struct htt_soc *soc, qdf_nbuf_t *msg)
  368. {
  369. /* Use tcl_metadata_v1 when NSS offload is enabled */
  370. if (wlan_cfg_get_dp_soc_nss_cfg(soc->dp_soc->wlan_cfg_ctx) ||
  371. soc->dp_soc->cdp_soc.ol_ops->get_con_mode() == QDF_GLOBAL_FTM_MODE)
  372. return dp_htt_h2t_add_tcl_metadata_ver_v1(soc, msg);
  373. else
  374. return dp_htt_h2t_add_tcl_metadata_ver_v2(soc, msg);
  375. }
  376. #else
  377. static int dp_htt_h2t_add_tcl_metadata_ver(struct htt_soc *soc, qdf_nbuf_t *msg)
  378. {
  379. return dp_htt_h2t_add_tcl_metadata_ver_v1(soc, msg);
  380. }
  381. #endif
  382. /**
  383. * htt_h2t_ver_req_msg() - Send HTT version request message to target
  384. * @soc: HTT SOC handle
  385. *
  386. * Return: 0 on success; error code on failure
  387. */
  388. static int htt_h2t_ver_req_msg(struct htt_soc *soc)
  389. {
  390. struct dp_htt_htc_pkt *pkt;
  391. qdf_nbuf_t msg = NULL;
  392. QDF_STATUS status;
  393. status = dp_htt_h2t_add_tcl_metadata_ver(soc, &msg);
  394. if (status != QDF_STATUS_SUCCESS)
  395. return status;
  396. pkt = htt_htc_pkt_alloc(soc);
  397. if (!pkt) {
  398. qdf_nbuf_free(msg);
  399. return QDF_STATUS_E_FAILURE;
  400. }
  401. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  402. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  403. dp_htt_h2t_send_complete_free_netbuf, qdf_nbuf_data(msg),
  404. qdf_nbuf_len(msg), soc->htc_endpoint,
  405. HTC_TX_PACKET_TAG_RTPM_PUT_RC);
  406. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  407. status = DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_VERSION_REQ,
  408. NULL);
  409. if (status != QDF_STATUS_SUCCESS) {
  410. qdf_nbuf_free(msg);
  411. htt_htc_pkt_free(soc, pkt);
  412. }
  413. return status;
  414. }
  415. #ifdef IPA_OPT_WIFI_DP
  416. QDF_STATUS htt_h2t_rx_cce_super_rule_setup(struct htt_soc *soc, void *param)
  417. {
  418. struct wifi_dp_flt_setup *flt_params =
  419. (struct wifi_dp_flt_setup *)param;
  420. struct dp_htt_htc_pkt *pkt;
  421. qdf_nbuf_t msg;
  422. uint32_t *msg_word;
  423. uint8_t *htt_logger_bufp;
  424. uint16_t ver = 0;
  425. uint8_t i, valid = 0;
  426. uint8_t num_filters = flt_params->num_filters;
  427. uint8_t pdev_id = flt_params->pdev_id;
  428. uint8_t op = flt_params->op;
  429. uint16_t ipv4 = qdf_ntohs(QDF_NBUF_TRAC_IPV4_ETH_TYPE);
  430. uint16_t ipv6 = qdf_ntohs(QDF_NBUF_TRAC_IPV6_ETH_TYPE);
  431. QDF_STATUS status;
  432. if (num_filters > RX_CCE_SUPER_RULE_SETUP_NUM) {
  433. dp_htt_err("Wrong filter count %d", num_filters);
  434. return QDF_STATUS_FILT_REQ_ERROR;
  435. }
  436. msg = qdf_nbuf_alloc(soc->osdev,
  437. HTT_MSG_BUF_SIZE(HTT_RX_CCE_SUPER_RULE_SETUP_SZ),
  438. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4,
  439. true);
  440. if (!msg) {
  441. dp_htt_err("Fail to allocate SUPER_RULE_SETUP msg ");
  442. return QDF_STATUS_E_FAILURE;
  443. }
  444. qdf_nbuf_put_tail(msg, HTT_RX_CCE_SUPER_RULE_SETUP_SZ);
  445. msg_word = (uint32_t *)qdf_nbuf_data(msg);
  446. memset(msg_word, 0, HTT_RX_CCE_SUPER_RULE_SETUP_SZ);
  447. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  448. htt_logger_bufp = (uint8_t *)msg_word;
  449. *msg_word = 0;
  450. HTT_H2T_MSG_TYPE_SET(*msg_word,
  451. HTT_H2T_MSG_TYPE_RX_CCE_SUPER_RULE_SETUP);
  452. HTT_RX_CCE_SUPER_RULE_SETUP_PDEV_ID_SET(*msg_word, pdev_id);
  453. HTT_RX_CCE_SUPER_RULE_SETUP_OPERATION_SET(*msg_word, op);
  454. /* Set cce_super_rule_params */
  455. for (i = 0; i < RX_CCE_SUPER_RULE_SETUP_NUM; i++) {
  456. valid = flt_params->flt_addr_params[i].valid;
  457. ver = flt_params->flt_addr_params[i].l3_type;
  458. msg_word++;
  459. if (ver == ipv4) {
  460. HTT_RX_CCE_SUPER_RULE_SETUP_IPV4_ADDR_ARRAY_SET(
  461. msg_word,
  462. flt_params->flt_addr_params[i].src_ipv4_addr);
  463. } else if (ver == ipv6) {
  464. HTT_RX_CCE_SUPER_RULE_SETUP_IPV6_ADDR_ARRAY_SET(
  465. msg_word,
  466. flt_params->flt_addr_params[i].src_ipv6_addr);
  467. } else {
  468. dp_htt_debug("Filter %d not in use.", i);
  469. }
  470. /* move uint32_t *msg_word by IPV6 addr size */
  471. msg_word += (QDF_IPV6_ADDR_SIZE / 4);
  472. if (ver == ipv4) {
  473. HTT_RX_CCE_SUPER_RULE_SETUP_IPV4_ADDR_ARRAY_SET(
  474. msg_word,
  475. flt_params->flt_addr_params[i].dst_ipv4_addr);
  476. } else if (ver == ipv6) {
  477. HTT_RX_CCE_SUPER_RULE_SETUP_IPV6_ADDR_ARRAY_SET(
  478. msg_word,
  479. flt_params->flt_addr_params[i].dst_ipv6_addr);
  480. } else {
  481. dp_htt_debug("Filter %d not in use.", i);
  482. }
  483. /* move uint32_t *msg_word by IPV6 addr size */
  484. msg_word += (QDF_IPV6_ADDR_SIZE / 4);
  485. HTT_RX_CCE_SUPER_RULE_SETUP_L3_TYPE_SET(*msg_word, ver);
  486. HTT_RX_CCE_SUPER_RULE_SETUP_L4_TYPE_SET(
  487. *msg_word,
  488. flt_params->flt_addr_params[i].l4_type);
  489. HTT_RX_CCE_SUPER_RULE_SETUP_IS_VALID_SET(*msg_word, valid);
  490. msg_word++;
  491. HTT_RX_CCE_SUPER_RULE_SETUP_L4_SRC_PORT_SET(
  492. *msg_word,
  493. flt_params->flt_addr_params[i].src_port);
  494. HTT_RX_CCE_SUPER_RULE_SETUP_L4_DST_PORT_SET(
  495. *msg_word,
  496. flt_params->flt_addr_params[i].dst_port);
  497. dp_info("opt_dp:: pdev: %u ver %u, flt_num %u, op %u",
  498. pdev_id, ver, i, op);
  499. dp_info("valid %u", valid);
  500. }
  501. pkt = htt_htc_pkt_alloc(soc);
  502. if (!pkt) {
  503. dp_htt_err("Fail to allocate dp_htt_htc_pkt buffer");
  504. qdf_assert(0);
  505. qdf_nbuf_free(msg);
  506. return QDF_STATUS_E_NOMEM;
  507. }
  508. pkt->soc_ctxt = NULL; /*not used during send-done callback */
  509. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  510. dp_htt_h2t_send_complete_free_netbuf,
  511. qdf_nbuf_data(msg), qdf_nbuf_len(msg),
  512. soc->htc_endpoint,
  513. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  514. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  515. status = DP_HTT_SEND_HTC_PKT(soc, pkt,
  516. HTT_H2T_MSG_TYPE_RX_CCE_SUPER_RULE_SETUP,
  517. htt_logger_bufp);
  518. if (status != QDF_STATUS_SUCCESS) {
  519. qdf_nbuf_free(msg);
  520. htt_htc_pkt_free(soc, pkt);
  521. }
  522. return status;
  523. }
  524. #endif /* IPA_OPT_WIFI_DP */
  525. int htt_srng_setup(struct htt_soc *soc, int mac_id,
  526. hal_ring_handle_t hal_ring_hdl,
  527. int hal_ring_type)
  528. {
  529. struct dp_htt_htc_pkt *pkt;
  530. qdf_nbuf_t htt_msg;
  531. uint32_t *msg_word;
  532. struct hal_srng_params srng_params;
  533. qdf_dma_addr_t hp_addr, tp_addr;
  534. uint32_t ring_entry_size =
  535. hal_srng_get_entrysize(soc->hal_soc, hal_ring_type);
  536. int htt_ring_type, htt_ring_id;
  537. uint8_t *htt_logger_bufp;
  538. int target_pdev_id;
  539. int lmac_id = dp_get_lmac_id_for_pdev_id(soc->dp_soc, 0, mac_id);
  540. QDF_STATUS status;
  541. /* Sizes should be set in 4-byte words */
  542. ring_entry_size = ring_entry_size >> 2;
  543. htt_msg = qdf_nbuf_alloc(soc->osdev,
  544. HTT_MSG_BUF_SIZE(HTT_SRING_SETUP_SZ),
  545. /* reserve room for the HTC header */
  546. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  547. if (!htt_msg) {
  548. dp_err("htt_msg alloc failed ring type %d", hal_ring_type);
  549. goto fail0;
  550. }
  551. hal_get_srng_params(soc->hal_soc, hal_ring_hdl, &srng_params);
  552. hp_addr = hal_srng_get_hp_addr(soc->hal_soc, hal_ring_hdl);
  553. tp_addr = hal_srng_get_tp_addr(soc->hal_soc, hal_ring_hdl);
  554. switch (hal_ring_type) {
  555. case RXDMA_BUF:
  556. #ifdef QCA_HOST2FW_RXBUF_RING
  557. if (srng_params.ring_id ==
  558. (HAL_SRNG_WMAC1_SW2RXDMA0_BUF0 +
  559. (lmac_id * HAL_MAX_RINGS_PER_LMAC))) {
  560. htt_ring_id = HTT_HOST1_TO_FW_RXBUF_RING;
  561. htt_ring_type = HTT_SW_TO_SW_RING;
  562. #ifdef IPA_OFFLOAD
  563. } else if (srng_params.ring_id ==
  564. (HAL_SRNG_WMAC1_SW2RXDMA0_BUF1 +
  565. (lmac_id * HAL_MAX_RINGS_PER_LMAC))) {
  566. htt_ring_id = HTT_HOST2_TO_FW_RXBUF_RING;
  567. htt_ring_type = HTT_SW_TO_SW_RING;
  568. #ifdef IPA_WDI3_VLAN_SUPPORT
  569. } else if (srng_params.ring_id ==
  570. (HAL_SRNG_WMAC1_SW2RXDMA0_BUF2 +
  571. (lmac_id * HAL_MAX_RINGS_PER_LMAC))) {
  572. htt_ring_id = HTT_HOST3_TO_FW_RXBUF_RING;
  573. htt_ring_type = HTT_SW_TO_SW_RING;
  574. #endif
  575. #endif
  576. #else
  577. if (srng_params.ring_id ==
  578. (HAL_SRNG_WMAC1_SW2RXDMA0_BUF0 +
  579. (lmac_id * HAL_MAX_RINGS_PER_LMAC))) {
  580. htt_ring_id = HTT_RXDMA_HOST_BUF_RING;
  581. htt_ring_type = HTT_SW_TO_HW_RING;
  582. #endif
  583. } else if (srng_params.ring_id ==
  584. (HAL_SRNG_WMAC1_SW2RXDMA1_BUF +
  585. (lmac_id * HAL_MAX_RINGS_PER_LMAC))) {
  586. htt_ring_id = HTT_RXDMA_HOST_BUF_RING;
  587. htt_ring_type = HTT_SW_TO_HW_RING;
  588. #ifdef FEATURE_DIRECT_LINK
  589. } else if (srng_params.ring_id ==
  590. (HAL_SRNG_WMAC1_RX_DIRECT_LINK_SW_REFILL_RING +
  591. (lmac_id * HAL_MAX_RINGS_PER_LMAC))) {
  592. htt_ring_id = HTT_LPASS_TO_FW_RXBUF_RING;
  593. htt_ring_type = HTT_SW_TO_SW_RING;
  594. #endif
  595. } else {
  596. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  597. "%s: Ring %d currently not supported",
  598. __func__, srng_params.ring_id);
  599. goto fail1;
  600. }
  601. break;
  602. case RXDMA_MONITOR_BUF:
  603. htt_ring_id = dp_htt_get_mon_htt_ring_id(soc->dp_soc,
  604. RXDMA_MONITOR_BUF);
  605. htt_ring_type = HTT_SW_TO_HW_RING;
  606. break;
  607. case RXDMA_MONITOR_STATUS:
  608. htt_ring_id = HTT_RXDMA_MONITOR_STATUS_RING;
  609. htt_ring_type = HTT_SW_TO_HW_RING;
  610. break;
  611. case RXDMA_MONITOR_DST:
  612. htt_ring_id = dp_htt_get_mon_htt_ring_id(soc->dp_soc,
  613. RXDMA_MONITOR_DST);
  614. htt_ring_type = HTT_HW_TO_SW_RING;
  615. break;
  616. case RXDMA_MONITOR_DESC:
  617. htt_ring_id = HTT_RXDMA_MONITOR_DESC_RING;
  618. htt_ring_type = HTT_SW_TO_HW_RING;
  619. break;
  620. case RXDMA_DST:
  621. htt_ring_id = HTT_RXDMA_NON_MONITOR_DEST_RING;
  622. htt_ring_type = HTT_HW_TO_SW_RING;
  623. break;
  624. case TX_MONITOR_BUF:
  625. htt_ring_id = HTT_TX_MON_HOST2MON_BUF_RING;
  626. htt_ring_type = HTT_SW_TO_HW_RING;
  627. break;
  628. case TX_MONITOR_DST:
  629. htt_ring_id = HTT_TX_MON_MON2HOST_DEST_RING;
  630. htt_ring_type = HTT_HW_TO_SW_RING;
  631. break;
  632. case SW2RXDMA_LINK_RELEASE:
  633. htt_ring_id = HTT_RXDMA_MONITOR_DESC_RING;
  634. htt_ring_type = HTT_SW_TO_HW_RING;
  635. break;
  636. default:
  637. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  638. "%s: Ring currently not supported", __func__);
  639. goto fail1;
  640. }
  641. dp_info("ring_type %d ring_id %d htt_ring_id %d hp_addr 0x%llx tp_addr 0x%llx",
  642. hal_ring_type, srng_params.ring_id, htt_ring_id,
  643. (uint64_t)hp_addr,
  644. (uint64_t)tp_addr);
  645. /*
  646. * Set the length of the message.
  647. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  648. * separately during the below call to qdf_nbuf_push_head.
  649. * The contribution from the HTC header is added separately inside HTC.
  650. */
  651. if (qdf_nbuf_put_tail(htt_msg, HTT_SRING_SETUP_SZ) == NULL) {
  652. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  653. "%s: Failed to expand head for SRING_SETUP msg",
  654. __func__);
  655. return QDF_STATUS_E_FAILURE;
  656. }
  657. msg_word = (uint32_t *)qdf_nbuf_data(htt_msg);
  658. /* rewind beyond alignment pad to get to the HTC header reserved area */
  659. qdf_nbuf_push_head(htt_msg, HTC_HDR_ALIGNMENT_PADDING);
  660. /* word 0 */
  661. *msg_word = 0;
  662. htt_logger_bufp = (uint8_t *)msg_word;
  663. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_SRING_SETUP);
  664. target_pdev_id =
  665. dp_get_target_pdev_id_for_host_pdev_id(soc->dp_soc, mac_id);
  666. if ((htt_ring_type == HTT_SW_TO_HW_RING) ||
  667. (htt_ring_type == HTT_HW_TO_SW_RING))
  668. HTT_SRING_SETUP_PDEV_ID_SET(*msg_word, target_pdev_id);
  669. else
  670. HTT_SRING_SETUP_PDEV_ID_SET(*msg_word, mac_id);
  671. dp_info("mac_id %d", mac_id);
  672. HTT_SRING_SETUP_RING_TYPE_SET(*msg_word, htt_ring_type);
  673. /* TODO: Discuss with FW on changing this to unique ID and using
  674. * htt_ring_type to send the type of ring
  675. */
  676. HTT_SRING_SETUP_RING_ID_SET(*msg_word, htt_ring_id);
  677. /* word 1 */
  678. msg_word++;
  679. *msg_word = 0;
  680. HTT_SRING_SETUP_RING_BASE_ADDR_LO_SET(*msg_word,
  681. srng_params.ring_base_paddr & 0xffffffff);
  682. /* word 2 */
  683. msg_word++;
  684. *msg_word = 0;
  685. HTT_SRING_SETUP_RING_BASE_ADDR_HI_SET(*msg_word,
  686. (uint64_t)srng_params.ring_base_paddr >> 32);
  687. /* word 3 */
  688. msg_word++;
  689. *msg_word = 0;
  690. HTT_SRING_SETUP_ENTRY_SIZE_SET(*msg_word, ring_entry_size);
  691. HTT_SRING_SETUP_RING_SIZE_SET(*msg_word,
  692. (ring_entry_size * srng_params.num_entries));
  693. dp_info("entry_size %d", ring_entry_size);
  694. dp_info("num_entries %d", srng_params.num_entries);
  695. dp_info("ring_size %d", (ring_entry_size * srng_params.num_entries));
  696. if (htt_ring_type == HTT_SW_TO_HW_RING)
  697. HTT_SRING_SETUP_RING_MISC_CFG_FLAG_LOOPCOUNT_DISABLE_SET(
  698. *msg_word, 1);
  699. HTT_SRING_SETUP_RING_MISC_CFG_FLAG_MSI_SWAP_SET(*msg_word,
  700. !!(srng_params.flags & HAL_SRNG_MSI_SWAP));
  701. HTT_SRING_SETUP_RING_MISC_CFG_FLAG_TLV_SWAP_SET(*msg_word,
  702. !!(srng_params.flags & HAL_SRNG_DATA_TLV_SWAP));
  703. HTT_SRING_SETUP_RING_MISC_CFG_FLAG_HOST_FW_SWAP_SET(*msg_word,
  704. !!(srng_params.flags & HAL_SRNG_RING_PTR_SWAP));
  705. /* word 4 */
  706. msg_word++;
  707. *msg_word = 0;
  708. HTT_SRING_SETUP_HEAD_OFFSET32_REMOTE_BASE_ADDR_LO_SET(*msg_word,
  709. hp_addr & 0xffffffff);
  710. /* word 5 */
  711. msg_word++;
  712. *msg_word = 0;
  713. HTT_SRING_SETUP_HEAD_OFFSET32_REMOTE_BASE_ADDR_HI_SET(*msg_word,
  714. (uint64_t)hp_addr >> 32);
  715. /* word 6 */
  716. msg_word++;
  717. *msg_word = 0;
  718. HTT_SRING_SETUP_TAIL_OFFSET32_REMOTE_BASE_ADDR_LO_SET(*msg_word,
  719. tp_addr & 0xffffffff);
  720. /* word 7 */
  721. msg_word++;
  722. *msg_word = 0;
  723. HTT_SRING_SETUP_TAIL_OFFSET32_REMOTE_BASE_ADDR_HI_SET(*msg_word,
  724. (uint64_t)tp_addr >> 32);
  725. /* word 8 */
  726. msg_word++;
  727. *msg_word = 0;
  728. HTT_SRING_SETUP_RING_MSI_ADDR_LO_SET(*msg_word,
  729. srng_params.msi_addr & 0xffffffff);
  730. /* word 9 */
  731. msg_word++;
  732. *msg_word = 0;
  733. HTT_SRING_SETUP_RING_MSI_ADDR_HI_SET(*msg_word,
  734. (uint64_t)(srng_params.msi_addr) >> 32);
  735. /* word 10 */
  736. msg_word++;
  737. *msg_word = 0;
  738. HTT_SRING_SETUP_RING_MSI_DATA_SET(*msg_word,
  739. qdf_cpu_to_le32(srng_params.msi_data));
  740. /* word 11 */
  741. msg_word++;
  742. *msg_word = 0;
  743. HTT_SRING_SETUP_INTR_BATCH_COUNTER_TH_SET(*msg_word,
  744. srng_params.intr_batch_cntr_thres_entries *
  745. ring_entry_size);
  746. HTT_SRING_SETUP_INTR_TIMER_TH_SET(*msg_word,
  747. srng_params.intr_timer_thres_us >> 3);
  748. /* word 12 */
  749. msg_word++;
  750. *msg_word = 0;
  751. if (srng_params.flags & HAL_SRNG_LOW_THRES_INTR_ENABLE) {
  752. /* TODO: Setting low threshold to 1/8th of ring size - see
  753. * if this needs to be configurable
  754. */
  755. HTT_SRING_SETUP_INTR_LOW_TH_SET(*msg_word,
  756. srng_params.low_threshold);
  757. }
  758. /* "response_required" field should be set if a HTT response message is
  759. * required after setting up the ring.
  760. */
  761. pkt = htt_htc_pkt_alloc(soc);
  762. if (!pkt) {
  763. dp_err("pkt alloc failed, ring_type %d ring_id %d htt_ring_id %d",
  764. hal_ring_type, srng_params.ring_id, htt_ring_id);
  765. goto fail1;
  766. }
  767. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  768. SET_HTC_PACKET_INFO_TX(
  769. &pkt->htc_pkt,
  770. dp_htt_h2t_send_complete_free_netbuf,
  771. qdf_nbuf_data(htt_msg),
  772. qdf_nbuf_len(htt_msg),
  773. soc->htc_endpoint,
  774. HTC_TX_PACKET_TAG_RUNTIME_PUT); /* tag for no FW response msg */
  775. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, htt_msg);
  776. status = DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_SRING_SETUP,
  777. htt_logger_bufp);
  778. if (status != QDF_STATUS_SUCCESS) {
  779. qdf_nbuf_free(htt_msg);
  780. htt_htc_pkt_free(soc, pkt);
  781. }
  782. return status;
  783. fail1:
  784. qdf_nbuf_free(htt_msg);
  785. fail0:
  786. return QDF_STATUS_E_FAILURE;
  787. }
  788. qdf_export_symbol(htt_srng_setup);
  789. #ifdef QCA_SUPPORT_FULL_MON
  790. /**
  791. * htt_h2t_full_mon_cfg() - Send full monitor configuration msg to FW
  792. *
  793. * @htt_soc: HTT Soc handle
  794. * @pdev_id: Radio id
  795. * @config: enabled/disable configuration
  796. *
  797. * Return: Success when HTT message is sent, error on failure
  798. */
  799. int htt_h2t_full_mon_cfg(struct htt_soc *htt_soc,
  800. uint8_t pdev_id,
  801. enum dp_full_mon_config config)
  802. {
  803. struct htt_soc *soc = (struct htt_soc *)htt_soc;
  804. struct dp_htt_htc_pkt *pkt;
  805. qdf_nbuf_t htt_msg;
  806. uint32_t *msg_word;
  807. uint8_t *htt_logger_bufp;
  808. htt_msg = qdf_nbuf_alloc(soc->osdev,
  809. HTT_MSG_BUF_SIZE(
  810. HTT_RX_FULL_MONITOR_MODE_SETUP_SZ),
  811. /* reserve room for the HTC header */
  812. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING,
  813. 4,
  814. TRUE);
  815. if (!htt_msg)
  816. return QDF_STATUS_E_FAILURE;
  817. /*
  818. * Set the length of the message.
  819. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  820. * separately during the below call to qdf_nbuf_push_head.
  821. * The contribution from the HTC header is added separately inside HTC.
  822. */
  823. if (!qdf_nbuf_put_tail(htt_msg, HTT_RX_FULL_MONITOR_MODE_SETUP_SZ)) {
  824. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  825. "%s: Failed to expand head for RX Ring Cfg msg",
  826. __func__);
  827. goto fail1;
  828. }
  829. msg_word = (uint32_t *)qdf_nbuf_data(htt_msg);
  830. /* rewind beyond alignment pad to get to the HTC header reserved area */
  831. qdf_nbuf_push_head(htt_msg, HTC_HDR_ALIGNMENT_PADDING);
  832. /* word 0 */
  833. *msg_word = 0;
  834. htt_logger_bufp = (uint8_t *)msg_word;
  835. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RX_FULL_MONITOR_MODE);
  836. HTT_RX_FULL_MONITOR_MODE_OPERATION_PDEV_ID_SET(
  837. *msg_word, DP_SW2HW_MACID(pdev_id));
  838. msg_word++;
  839. *msg_word = 0;
  840. /* word 1 */
  841. if (config == DP_FULL_MON_ENABLE) {
  842. HTT_RX_FULL_MONITOR_MODE_ENABLE_SET(*msg_word, true);
  843. HTT_RX_FULL_MONITOR_MODE_ZERO_MPDU_SET(*msg_word, true);
  844. HTT_RX_FULL_MONITOR_MODE_NON_ZERO_MPDU_SET(*msg_word, true);
  845. HTT_RX_FULL_MONITOR_MODE_RELEASE_RINGS_SET(*msg_word, 0x2);
  846. } else if (config == DP_FULL_MON_DISABLE) {
  847. /* As per MAC team's suggestion, While disabling full monitor
  848. * mode, Set 'en' bit to true in full monitor mode register.
  849. */
  850. HTT_RX_FULL_MONITOR_MODE_ENABLE_SET(*msg_word, true);
  851. HTT_RX_FULL_MONITOR_MODE_ZERO_MPDU_SET(*msg_word, false);
  852. HTT_RX_FULL_MONITOR_MODE_NON_ZERO_MPDU_SET(*msg_word, false);
  853. HTT_RX_FULL_MONITOR_MODE_RELEASE_RINGS_SET(*msg_word, 0x2);
  854. }
  855. pkt = htt_htc_pkt_alloc(soc);
  856. if (!pkt) {
  857. qdf_err("HTC packet allocation failed");
  858. goto fail1;
  859. }
  860. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  861. SET_HTC_PACKET_INFO_TX(
  862. &pkt->htc_pkt,
  863. dp_htt_h2t_send_complete_free_netbuf,
  864. qdf_nbuf_data(htt_msg),
  865. qdf_nbuf_len(htt_msg),
  866. soc->htc_endpoint,
  867. HTC_TX_PACKET_TAG_RUNTIME_PUT); /* tag for no FW response msg */
  868. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, htt_msg);
  869. qdf_debug("config: %d", config);
  870. DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_RX_FULL_MONITOR_MODE,
  871. htt_logger_bufp);
  872. return QDF_STATUS_SUCCESS;
  873. fail1:
  874. qdf_nbuf_free(htt_msg);
  875. return QDF_STATUS_E_FAILURE;
  876. }
  877. qdf_export_symbol(htt_h2t_full_mon_cfg);
  878. #else
  879. int htt_h2t_full_mon_cfg(struct htt_soc *htt_soc,
  880. uint8_t pdev_id,
  881. enum dp_full_mon_config config)
  882. {
  883. return 0;
  884. }
  885. qdf_export_symbol(htt_h2t_full_mon_cfg);
  886. #endif
  887. #ifdef QCA_UNDECODED_METADATA_SUPPORT
  888. static inline void
  889. dp_mon_rx_enable_phy_errors(uint32_t *msg_word,
  890. struct htt_rx_ring_tlv_filter *htt_tlv_filter)
  891. {
  892. if (htt_tlv_filter->phy_err_filter_valid) {
  893. HTT_RX_RING_SELECTION_CFG_FP_PHY_ERR_SET
  894. (*msg_word, htt_tlv_filter->fp_phy_err);
  895. HTT_RX_RING_SELECTION_CFG_FP_PHY_ERR_BUF_SRC_SET
  896. (*msg_word, htt_tlv_filter->fp_phy_err_buf_src);
  897. HTT_RX_RING_SELECTION_CFG_FP_PHY_ERR_BUF_DEST_SET
  898. (*msg_word, htt_tlv_filter->fp_phy_err_buf_dest);
  899. /* word 12*/
  900. msg_word++;
  901. *msg_word = 0;
  902. HTT_RX_RING_SELECTION_CFG_PHY_ERR_MASK_SET
  903. (*msg_word, htt_tlv_filter->phy_err_mask);
  904. /* word 13*/
  905. msg_word++;
  906. *msg_word = 0;
  907. HTT_RX_RING_SELECTION_CFG_PHY_ERR_MASK_CONT_SET
  908. (*msg_word, htt_tlv_filter->phy_err_mask_cont);
  909. }
  910. }
  911. #else
  912. static inline void
  913. dp_mon_rx_enable_phy_errors(uint32_t *msg_word,
  914. struct htt_rx_ring_tlv_filter *htt_tlv_filter)
  915. {
  916. }
  917. #endif
  918. int htt_h2t_rx_ring_cfg(struct htt_soc *htt_soc, int pdev_id,
  919. hal_ring_handle_t hal_ring_hdl,
  920. int hal_ring_type, int ring_buf_size,
  921. struct htt_rx_ring_tlv_filter *htt_tlv_filter)
  922. {
  923. struct htt_soc *soc = (struct htt_soc *)htt_soc;
  924. struct dp_htt_htc_pkt *pkt;
  925. qdf_nbuf_t htt_msg;
  926. uint32_t *msg_word;
  927. uint32_t *msg_word_data;
  928. struct hal_srng_params srng_params;
  929. uint32_t htt_ring_type, htt_ring_id;
  930. uint32_t tlv_filter;
  931. uint8_t *htt_logger_bufp;
  932. struct wlan_cfg_dp_soc_ctxt *wlan_cfg_ctx = soc->dp_soc->wlan_cfg_ctx;
  933. uint32_t mon_drop_th = wlan_cfg_get_mon_drop_thresh(wlan_cfg_ctx);
  934. int target_pdev_id;
  935. QDF_STATUS status;
  936. htt_msg = qdf_nbuf_alloc(soc->osdev,
  937. HTT_MSG_BUF_SIZE(HTT_RX_RING_SELECTION_CFG_SZ),
  938. /* reserve room for the HTC header */
  939. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  940. if (!htt_msg) {
  941. dp_err("htt_msg alloc failed ring type %d", hal_ring_type);
  942. goto fail0;
  943. }
  944. hal_get_srng_params(soc->hal_soc, hal_ring_hdl, &srng_params);
  945. switch (hal_ring_type) {
  946. case RXDMA_BUF:
  947. htt_ring_id = HTT_RXDMA_HOST_BUF_RING;
  948. htt_ring_type = HTT_SW_TO_HW_RING;
  949. break;
  950. case RXDMA_MONITOR_BUF:
  951. htt_ring_id = dp_htt_get_mon_htt_ring_id(soc->dp_soc,
  952. RXDMA_MONITOR_BUF);
  953. htt_ring_type = HTT_SW_TO_HW_RING;
  954. break;
  955. case RXDMA_MONITOR_STATUS:
  956. htt_ring_id = HTT_RXDMA_MONITOR_STATUS_RING;
  957. htt_ring_type = HTT_SW_TO_HW_RING;
  958. break;
  959. case RXDMA_MONITOR_DST:
  960. htt_ring_id = dp_htt_get_mon_htt_ring_id(soc->dp_soc,
  961. RXDMA_MONITOR_DST);
  962. htt_ring_type = HTT_HW_TO_SW_RING;
  963. break;
  964. case RXDMA_MONITOR_DESC:
  965. htt_ring_id = HTT_RXDMA_MONITOR_DESC_RING;
  966. htt_ring_type = HTT_SW_TO_HW_RING;
  967. break;
  968. case RXDMA_DST:
  969. htt_ring_id = HTT_RXDMA_NON_MONITOR_DEST_RING;
  970. htt_ring_type = HTT_HW_TO_SW_RING;
  971. break;
  972. default:
  973. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  974. "%s: Ring currently not supported", __func__);
  975. goto fail1;
  976. }
  977. dp_info("ring_type %d ring_id %d htt_ring_id %d",
  978. hal_ring_type, srng_params.ring_id, htt_ring_id);
  979. /*
  980. * Set the length of the message.
  981. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  982. * separately during the below call to qdf_nbuf_push_head.
  983. * The contribution from the HTC header is added separately inside HTC.
  984. */
  985. if (qdf_nbuf_put_tail(htt_msg, HTT_RX_RING_SELECTION_CFG_SZ) == NULL) {
  986. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  987. "%s: Failed to expand head for RX Ring Cfg msg",
  988. __func__);
  989. goto fail1; /* failure */
  990. }
  991. msg_word = (uint32_t *)qdf_nbuf_data(htt_msg);
  992. /* rewind beyond alignment pad to get to the HTC header reserved area */
  993. qdf_nbuf_push_head(htt_msg, HTC_HDR_ALIGNMENT_PADDING);
  994. /* word 0 */
  995. htt_logger_bufp = (uint8_t *)msg_word;
  996. *msg_word = 0;
  997. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RX_RING_SELECTION_CFG);
  998. /* applicable only for post Li */
  999. dp_rx_mon_enable(soc->dp_soc, msg_word, htt_tlv_filter);
  1000. /*
  1001. * pdev_id is indexed from 0 whereas mac_id is indexed from 1
  1002. * SW_TO_SW and SW_TO_HW rings are unaffected by this
  1003. */
  1004. target_pdev_id =
  1005. dp_get_target_pdev_id_for_host_pdev_id(soc->dp_soc, pdev_id);
  1006. if (htt_ring_type == HTT_SW_TO_SW_RING ||
  1007. htt_ring_type == HTT_SW_TO_HW_RING ||
  1008. htt_ring_type == HTT_HW_TO_SW_RING)
  1009. HTT_RX_RING_SELECTION_CFG_PDEV_ID_SET(*msg_word,
  1010. target_pdev_id);
  1011. /* TODO: Discuss with FW on changing this to unique ID and using
  1012. * htt_ring_type to send the type of ring
  1013. */
  1014. HTT_RX_RING_SELECTION_CFG_RING_ID_SET(*msg_word, htt_ring_id);
  1015. HTT_RX_RING_SELECTION_CFG_STATUS_TLV_SET(*msg_word,
  1016. !!(srng_params.flags & HAL_SRNG_MSI_SWAP));
  1017. HTT_RX_RING_SELECTION_CFG_RX_OFFSETS_VALID_SET(*msg_word,
  1018. htt_tlv_filter->offset_valid);
  1019. if (mon_drop_th > 0)
  1020. HTT_RX_RING_SELECTION_CFG_DROP_THRESHOLD_VALID_SET(*msg_word,
  1021. 1);
  1022. else
  1023. HTT_RX_RING_SELECTION_CFG_DROP_THRESHOLD_VALID_SET(*msg_word,
  1024. 0);
  1025. /* word 1 */
  1026. msg_word++;
  1027. *msg_word = 0;
  1028. HTT_RX_RING_SELECTION_CFG_RING_BUFFER_SIZE_SET(*msg_word,
  1029. ring_buf_size);
  1030. dp_mon_rx_packet_length_set(soc->dp_soc, msg_word, htt_tlv_filter);
  1031. dp_mon_rx_hdr_length_set(soc->dp_soc, msg_word, htt_tlv_filter);
  1032. dp_mon_rx_mac_filter_set(soc->dp_soc, msg_word, htt_tlv_filter);
  1033. /* word 2 */
  1034. msg_word++;
  1035. *msg_word = 0;
  1036. if (htt_tlv_filter->enable_fp) {
  1037. /* TYPE: MGMT */
  1038. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1039. FP, MGMT, 0000,
  1040. (htt_tlv_filter->fp_mgmt_filter &
  1041. FILTER_MGMT_ASSOC_REQ) ? 1 : 0);
  1042. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1043. FP, MGMT, 0001,
  1044. (htt_tlv_filter->fp_mgmt_filter &
  1045. FILTER_MGMT_ASSOC_RES) ? 1 : 0);
  1046. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1047. FP, MGMT, 0010,
  1048. (htt_tlv_filter->fp_mgmt_filter &
  1049. FILTER_MGMT_REASSOC_REQ) ? 1 : 0);
  1050. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1051. FP, MGMT, 0011,
  1052. (htt_tlv_filter->fp_mgmt_filter &
  1053. FILTER_MGMT_REASSOC_RES) ? 1 : 0);
  1054. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1055. FP, MGMT, 0100,
  1056. (htt_tlv_filter->fp_mgmt_filter &
  1057. FILTER_MGMT_PROBE_REQ) ? 1 : 0);
  1058. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1059. FP, MGMT, 0101,
  1060. (htt_tlv_filter->fp_mgmt_filter &
  1061. FILTER_MGMT_PROBE_RES) ? 1 : 0);
  1062. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1063. FP, MGMT, 0110,
  1064. (htt_tlv_filter->fp_mgmt_filter &
  1065. FILTER_MGMT_TIM_ADVT) ? 1 : 0);
  1066. /* reserved */
  1067. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0, FP,
  1068. MGMT, 0111,
  1069. (htt_tlv_filter->fp_mgmt_filter &
  1070. FILTER_MGMT_RESERVED_7) ? 1 : 0);
  1071. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1072. FP, MGMT, 1000,
  1073. (htt_tlv_filter->fp_mgmt_filter &
  1074. FILTER_MGMT_BEACON) ? 1 : 0);
  1075. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1076. FP, MGMT, 1001,
  1077. (htt_tlv_filter->fp_mgmt_filter &
  1078. FILTER_MGMT_ATIM) ? 1 : 0);
  1079. }
  1080. if (htt_tlv_filter->enable_md) {
  1081. /* TYPE: MGMT */
  1082. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1083. MD, MGMT, 0000,
  1084. (htt_tlv_filter->md_mgmt_filter &
  1085. FILTER_MGMT_ASSOC_REQ) ? 1 : 0);
  1086. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1087. MD, MGMT, 0001,
  1088. (htt_tlv_filter->md_mgmt_filter &
  1089. FILTER_MGMT_ASSOC_RES) ? 1 : 0);
  1090. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1091. MD, MGMT, 0010,
  1092. (htt_tlv_filter->md_mgmt_filter &
  1093. FILTER_MGMT_REASSOC_REQ) ? 1 : 0);
  1094. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1095. MD, MGMT, 0011,
  1096. (htt_tlv_filter->md_mgmt_filter &
  1097. FILTER_MGMT_REASSOC_RES) ? 1 : 0);
  1098. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1099. MD, MGMT, 0100,
  1100. (htt_tlv_filter->md_mgmt_filter &
  1101. FILTER_MGMT_PROBE_REQ) ? 1 : 0);
  1102. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1103. MD, MGMT, 0101,
  1104. (htt_tlv_filter->md_mgmt_filter &
  1105. FILTER_MGMT_PROBE_RES) ? 1 : 0);
  1106. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1107. MD, MGMT, 0110,
  1108. (htt_tlv_filter->md_mgmt_filter &
  1109. FILTER_MGMT_TIM_ADVT) ? 1 : 0);
  1110. /* reserved */
  1111. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0, MD,
  1112. MGMT, 0111,
  1113. (htt_tlv_filter->md_mgmt_filter &
  1114. FILTER_MGMT_RESERVED_7) ? 1 : 0);
  1115. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1116. MD, MGMT, 1000,
  1117. (htt_tlv_filter->md_mgmt_filter &
  1118. FILTER_MGMT_BEACON) ? 1 : 0);
  1119. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1120. MD, MGMT, 1001,
  1121. (htt_tlv_filter->md_mgmt_filter &
  1122. FILTER_MGMT_ATIM) ? 1 : 0);
  1123. }
  1124. if (htt_tlv_filter->enable_mo) {
  1125. /* TYPE: MGMT */
  1126. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1127. MO, MGMT, 0000,
  1128. (htt_tlv_filter->mo_mgmt_filter &
  1129. FILTER_MGMT_ASSOC_REQ) ? 1 : 0);
  1130. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1131. MO, MGMT, 0001,
  1132. (htt_tlv_filter->mo_mgmt_filter &
  1133. FILTER_MGMT_ASSOC_RES) ? 1 : 0);
  1134. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1135. MO, MGMT, 0010,
  1136. (htt_tlv_filter->mo_mgmt_filter &
  1137. FILTER_MGMT_REASSOC_REQ) ? 1 : 0);
  1138. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1139. MO, MGMT, 0011,
  1140. (htt_tlv_filter->mo_mgmt_filter &
  1141. FILTER_MGMT_REASSOC_RES) ? 1 : 0);
  1142. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1143. MO, MGMT, 0100,
  1144. (htt_tlv_filter->mo_mgmt_filter &
  1145. FILTER_MGMT_PROBE_REQ) ? 1 : 0);
  1146. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1147. MO, MGMT, 0101,
  1148. (htt_tlv_filter->mo_mgmt_filter &
  1149. FILTER_MGMT_PROBE_RES) ? 1 : 0);
  1150. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1151. MO, MGMT, 0110,
  1152. (htt_tlv_filter->mo_mgmt_filter &
  1153. FILTER_MGMT_TIM_ADVT) ? 1 : 0);
  1154. /* reserved */
  1155. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0, MO,
  1156. MGMT, 0111,
  1157. (htt_tlv_filter->mo_mgmt_filter &
  1158. FILTER_MGMT_RESERVED_7) ? 1 : 0);
  1159. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1160. MO, MGMT, 1000,
  1161. (htt_tlv_filter->mo_mgmt_filter &
  1162. FILTER_MGMT_BEACON) ? 1 : 0);
  1163. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1164. MO, MGMT, 1001,
  1165. (htt_tlv_filter->mo_mgmt_filter &
  1166. FILTER_MGMT_ATIM) ? 1 : 0);
  1167. }
  1168. /* word 3 */
  1169. msg_word++;
  1170. *msg_word = 0;
  1171. if (htt_tlv_filter->enable_fp) {
  1172. /* TYPE: MGMT */
  1173. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1174. FP, MGMT, 1010,
  1175. (htt_tlv_filter->fp_mgmt_filter &
  1176. FILTER_MGMT_DISASSOC) ? 1 : 0);
  1177. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1178. FP, MGMT, 1011,
  1179. (htt_tlv_filter->fp_mgmt_filter &
  1180. FILTER_MGMT_AUTH) ? 1 : 0);
  1181. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1182. FP, MGMT, 1100,
  1183. (htt_tlv_filter->fp_mgmt_filter &
  1184. FILTER_MGMT_DEAUTH) ? 1 : 0);
  1185. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1186. FP, MGMT, 1101,
  1187. (htt_tlv_filter->fp_mgmt_filter &
  1188. FILTER_MGMT_ACTION) ? 1 : 0);
  1189. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1190. FP, MGMT, 1110,
  1191. (htt_tlv_filter->fp_mgmt_filter &
  1192. FILTER_MGMT_ACT_NO_ACK) ? 1 : 0);
  1193. /* reserved*/
  1194. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1, FP,
  1195. MGMT, 1111,
  1196. (htt_tlv_filter->fp_mgmt_filter &
  1197. FILTER_MGMT_RESERVED_15) ? 1 : 0);
  1198. }
  1199. if (htt_tlv_filter->enable_md) {
  1200. /* TYPE: MGMT */
  1201. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1202. MD, MGMT, 1010,
  1203. (htt_tlv_filter->md_mgmt_filter &
  1204. FILTER_MGMT_DISASSOC) ? 1 : 0);
  1205. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1206. MD, MGMT, 1011,
  1207. (htt_tlv_filter->md_mgmt_filter &
  1208. FILTER_MGMT_AUTH) ? 1 : 0);
  1209. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1210. MD, MGMT, 1100,
  1211. (htt_tlv_filter->md_mgmt_filter &
  1212. FILTER_MGMT_DEAUTH) ? 1 : 0);
  1213. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1214. MD, MGMT, 1101,
  1215. (htt_tlv_filter->md_mgmt_filter &
  1216. FILTER_MGMT_ACTION) ? 1 : 0);
  1217. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1218. MD, MGMT, 1110,
  1219. (htt_tlv_filter->md_mgmt_filter &
  1220. FILTER_MGMT_ACT_NO_ACK) ? 1 : 0);
  1221. }
  1222. if (htt_tlv_filter->enable_mo) {
  1223. /* TYPE: MGMT */
  1224. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1225. MO, MGMT, 1010,
  1226. (htt_tlv_filter->mo_mgmt_filter &
  1227. FILTER_MGMT_DISASSOC) ? 1 : 0);
  1228. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1229. MO, MGMT, 1011,
  1230. (htt_tlv_filter->mo_mgmt_filter &
  1231. FILTER_MGMT_AUTH) ? 1 : 0);
  1232. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1233. MO, MGMT, 1100,
  1234. (htt_tlv_filter->mo_mgmt_filter &
  1235. FILTER_MGMT_DEAUTH) ? 1 : 0);
  1236. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1237. MO, MGMT, 1101,
  1238. (htt_tlv_filter->mo_mgmt_filter &
  1239. FILTER_MGMT_ACTION) ? 1 : 0);
  1240. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1241. MO, MGMT, 1110,
  1242. (htt_tlv_filter->mo_mgmt_filter &
  1243. FILTER_MGMT_ACT_NO_ACK) ? 1 : 0);
  1244. /* reserved*/
  1245. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1, MO,
  1246. MGMT, 1111,
  1247. (htt_tlv_filter->mo_mgmt_filter &
  1248. FILTER_MGMT_RESERVED_15) ? 1 : 0);
  1249. }
  1250. /* word 4 */
  1251. msg_word++;
  1252. *msg_word = 0;
  1253. if (htt_tlv_filter->enable_fp) {
  1254. /* TYPE: CTRL */
  1255. /* reserved */
  1256. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1257. CTRL, 0000,
  1258. (htt_tlv_filter->fp_ctrl_filter &
  1259. FILTER_CTRL_RESERVED_1) ? 1 : 0);
  1260. /* reserved */
  1261. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1262. CTRL, 0001,
  1263. (htt_tlv_filter->fp_ctrl_filter &
  1264. FILTER_CTRL_RESERVED_2) ? 1 : 0);
  1265. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1266. CTRL, 0010,
  1267. (htt_tlv_filter->fp_ctrl_filter &
  1268. FILTER_CTRL_TRIGGER) ? 1 : 0);
  1269. /* reserved */
  1270. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1271. CTRL, 0011,
  1272. (htt_tlv_filter->fp_ctrl_filter &
  1273. FILTER_CTRL_RESERVED_4) ? 1 : 0);
  1274. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1275. CTRL, 0100,
  1276. (htt_tlv_filter->fp_ctrl_filter &
  1277. FILTER_CTRL_BF_REP_POLL) ? 1 : 0);
  1278. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1279. CTRL, 0101,
  1280. (htt_tlv_filter->fp_ctrl_filter &
  1281. FILTER_CTRL_VHT_NDP) ? 1 : 0);
  1282. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1283. CTRL, 0110,
  1284. (htt_tlv_filter->fp_ctrl_filter &
  1285. FILTER_CTRL_FRAME_EXT) ? 1 : 0);
  1286. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1287. CTRL, 0111,
  1288. (htt_tlv_filter->fp_ctrl_filter &
  1289. FILTER_CTRL_CTRLWRAP) ? 1 : 0);
  1290. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1291. CTRL, 1000,
  1292. (htt_tlv_filter->fp_ctrl_filter &
  1293. FILTER_CTRL_BA_REQ) ? 1 : 0);
  1294. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1295. CTRL, 1001,
  1296. (htt_tlv_filter->fp_ctrl_filter &
  1297. FILTER_CTRL_BA) ? 1 : 0);
  1298. }
  1299. if (htt_tlv_filter->enable_md) {
  1300. /* TYPE: CTRL */
  1301. /* reserved */
  1302. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1303. CTRL, 0000,
  1304. (htt_tlv_filter->md_ctrl_filter &
  1305. FILTER_CTRL_RESERVED_1) ? 1 : 0);
  1306. /* reserved */
  1307. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1308. CTRL, 0001,
  1309. (htt_tlv_filter->md_ctrl_filter &
  1310. FILTER_CTRL_RESERVED_2) ? 1 : 0);
  1311. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1312. CTRL, 0010,
  1313. (htt_tlv_filter->md_ctrl_filter &
  1314. FILTER_CTRL_TRIGGER) ? 1 : 0);
  1315. /* reserved */
  1316. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1317. CTRL, 0011,
  1318. (htt_tlv_filter->md_ctrl_filter &
  1319. FILTER_CTRL_RESERVED_4) ? 1 : 0);
  1320. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1321. CTRL, 0100,
  1322. (htt_tlv_filter->md_ctrl_filter &
  1323. FILTER_CTRL_BF_REP_POLL) ? 1 : 0);
  1324. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1325. CTRL, 0101,
  1326. (htt_tlv_filter->md_ctrl_filter &
  1327. FILTER_CTRL_VHT_NDP) ? 1 : 0);
  1328. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1329. CTRL, 0110,
  1330. (htt_tlv_filter->md_ctrl_filter &
  1331. FILTER_CTRL_FRAME_EXT) ? 1 : 0);
  1332. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1333. CTRL, 0111,
  1334. (htt_tlv_filter->md_ctrl_filter &
  1335. FILTER_CTRL_CTRLWRAP) ? 1 : 0);
  1336. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1337. CTRL, 1000,
  1338. (htt_tlv_filter->md_ctrl_filter &
  1339. FILTER_CTRL_BA_REQ) ? 1 : 0);
  1340. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1341. CTRL, 1001,
  1342. (htt_tlv_filter->md_ctrl_filter &
  1343. FILTER_CTRL_BA) ? 1 : 0);
  1344. }
  1345. if (htt_tlv_filter->enable_mo) {
  1346. /* TYPE: CTRL */
  1347. /* reserved */
  1348. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1349. CTRL, 0000,
  1350. (htt_tlv_filter->mo_ctrl_filter &
  1351. FILTER_CTRL_RESERVED_1) ? 1 : 0);
  1352. /* reserved */
  1353. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1354. CTRL, 0001,
  1355. (htt_tlv_filter->mo_ctrl_filter &
  1356. FILTER_CTRL_RESERVED_2) ? 1 : 0);
  1357. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1358. CTRL, 0010,
  1359. (htt_tlv_filter->mo_ctrl_filter &
  1360. FILTER_CTRL_TRIGGER) ? 1 : 0);
  1361. /* reserved */
  1362. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1363. CTRL, 0011,
  1364. (htt_tlv_filter->mo_ctrl_filter &
  1365. FILTER_CTRL_RESERVED_4) ? 1 : 0);
  1366. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1367. CTRL, 0100,
  1368. (htt_tlv_filter->mo_ctrl_filter &
  1369. FILTER_CTRL_BF_REP_POLL) ? 1 : 0);
  1370. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1371. CTRL, 0101,
  1372. (htt_tlv_filter->mo_ctrl_filter &
  1373. FILTER_CTRL_VHT_NDP) ? 1 : 0);
  1374. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1375. CTRL, 0110,
  1376. (htt_tlv_filter->mo_ctrl_filter &
  1377. FILTER_CTRL_FRAME_EXT) ? 1 : 0);
  1378. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1379. CTRL, 0111,
  1380. (htt_tlv_filter->mo_ctrl_filter &
  1381. FILTER_CTRL_CTRLWRAP) ? 1 : 0);
  1382. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1383. CTRL, 1000,
  1384. (htt_tlv_filter->mo_ctrl_filter &
  1385. FILTER_CTRL_BA_REQ) ? 1 : 0);
  1386. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1387. CTRL, 1001,
  1388. (htt_tlv_filter->mo_ctrl_filter &
  1389. FILTER_CTRL_BA) ? 1 : 0);
  1390. }
  1391. /* word 5 */
  1392. msg_word++;
  1393. *msg_word = 0;
  1394. if (htt_tlv_filter->enable_fp) {
  1395. /* TYPE: CTRL */
  1396. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1397. CTRL, 1010,
  1398. (htt_tlv_filter->fp_ctrl_filter &
  1399. FILTER_CTRL_PSPOLL) ? 1 : 0);
  1400. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1401. CTRL, 1011,
  1402. (htt_tlv_filter->fp_ctrl_filter &
  1403. FILTER_CTRL_RTS) ? 1 : 0);
  1404. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1405. CTRL, 1100,
  1406. (htt_tlv_filter->fp_ctrl_filter &
  1407. FILTER_CTRL_CTS) ? 1 : 0);
  1408. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1409. CTRL, 1101,
  1410. (htt_tlv_filter->fp_ctrl_filter &
  1411. FILTER_CTRL_ACK) ? 1 : 0);
  1412. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1413. CTRL, 1110,
  1414. (htt_tlv_filter->fp_ctrl_filter &
  1415. FILTER_CTRL_CFEND) ? 1 : 0);
  1416. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1417. CTRL, 1111,
  1418. (htt_tlv_filter->fp_ctrl_filter &
  1419. FILTER_CTRL_CFEND_CFACK) ? 1 : 0);
  1420. /* TYPE: DATA */
  1421. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1422. DATA, MCAST,
  1423. (htt_tlv_filter->fp_data_filter &
  1424. FILTER_DATA_MCAST) ? 1 : 0);
  1425. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1426. DATA, UCAST,
  1427. (htt_tlv_filter->fp_data_filter &
  1428. FILTER_DATA_UCAST) ? 1 : 0);
  1429. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1430. DATA, NULL,
  1431. (htt_tlv_filter->fp_data_filter &
  1432. FILTER_DATA_NULL) ? 1 : 0);
  1433. }
  1434. if (htt_tlv_filter->enable_md) {
  1435. /* TYPE: CTRL */
  1436. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1437. CTRL, 1010,
  1438. (htt_tlv_filter->md_ctrl_filter &
  1439. FILTER_CTRL_PSPOLL) ? 1 : 0);
  1440. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1441. CTRL, 1011,
  1442. (htt_tlv_filter->md_ctrl_filter &
  1443. FILTER_CTRL_RTS) ? 1 : 0);
  1444. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1445. CTRL, 1100,
  1446. (htt_tlv_filter->md_ctrl_filter &
  1447. FILTER_CTRL_CTS) ? 1 : 0);
  1448. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1449. CTRL, 1101,
  1450. (htt_tlv_filter->md_ctrl_filter &
  1451. FILTER_CTRL_ACK) ? 1 : 0);
  1452. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1453. CTRL, 1110,
  1454. (htt_tlv_filter->md_ctrl_filter &
  1455. FILTER_CTRL_CFEND) ? 1 : 0);
  1456. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1457. CTRL, 1111,
  1458. (htt_tlv_filter->md_ctrl_filter &
  1459. FILTER_CTRL_CFEND_CFACK) ? 1 : 0);
  1460. /* TYPE: DATA */
  1461. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1462. DATA, MCAST,
  1463. (htt_tlv_filter->md_data_filter &
  1464. FILTER_DATA_MCAST) ? 1 : 0);
  1465. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1466. DATA, UCAST,
  1467. (htt_tlv_filter->md_data_filter &
  1468. FILTER_DATA_UCAST) ? 1 : 0);
  1469. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1470. DATA, NULL,
  1471. (htt_tlv_filter->md_data_filter &
  1472. FILTER_DATA_NULL) ? 1 : 0);
  1473. }
  1474. if (htt_tlv_filter->enable_mo) {
  1475. /* TYPE: CTRL */
  1476. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1477. CTRL, 1010,
  1478. (htt_tlv_filter->mo_ctrl_filter &
  1479. FILTER_CTRL_PSPOLL) ? 1 : 0);
  1480. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1481. CTRL, 1011,
  1482. (htt_tlv_filter->mo_ctrl_filter &
  1483. FILTER_CTRL_RTS) ? 1 : 0);
  1484. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1485. CTRL, 1100,
  1486. (htt_tlv_filter->mo_ctrl_filter &
  1487. FILTER_CTRL_CTS) ? 1 : 0);
  1488. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1489. CTRL, 1101,
  1490. (htt_tlv_filter->mo_ctrl_filter &
  1491. FILTER_CTRL_ACK) ? 1 : 0);
  1492. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1493. CTRL, 1110,
  1494. (htt_tlv_filter->mo_ctrl_filter &
  1495. FILTER_CTRL_CFEND) ? 1 : 0);
  1496. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1497. CTRL, 1111,
  1498. (htt_tlv_filter->mo_ctrl_filter &
  1499. FILTER_CTRL_CFEND_CFACK) ? 1 : 0);
  1500. /* TYPE: DATA */
  1501. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1502. DATA, MCAST,
  1503. (htt_tlv_filter->mo_data_filter &
  1504. FILTER_DATA_MCAST) ? 1 : 0);
  1505. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1506. DATA, UCAST,
  1507. (htt_tlv_filter->mo_data_filter &
  1508. FILTER_DATA_UCAST) ? 1 : 0);
  1509. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1510. DATA, NULL,
  1511. (htt_tlv_filter->mo_data_filter &
  1512. FILTER_DATA_NULL) ? 1 : 0);
  1513. }
  1514. /* word 6 */
  1515. msg_word++;
  1516. *msg_word = 0;
  1517. tlv_filter = 0;
  1518. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, MPDU_START,
  1519. htt_tlv_filter->mpdu_start);
  1520. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, MSDU_START,
  1521. htt_tlv_filter->msdu_start);
  1522. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, PACKET,
  1523. htt_tlv_filter->packet);
  1524. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, MSDU_END,
  1525. htt_tlv_filter->msdu_end);
  1526. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, MPDU_END,
  1527. htt_tlv_filter->mpdu_end);
  1528. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, PACKET_HEADER,
  1529. htt_tlv_filter->packet_header);
  1530. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, ATTENTION,
  1531. htt_tlv_filter->attention);
  1532. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, PPDU_START,
  1533. htt_tlv_filter->ppdu_start);
  1534. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, PPDU_END,
  1535. htt_tlv_filter->ppdu_end);
  1536. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, PPDU_END_USER_STATS,
  1537. htt_tlv_filter->ppdu_end_user_stats);
  1538. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter,
  1539. PPDU_END_USER_STATS_EXT,
  1540. htt_tlv_filter->ppdu_end_user_stats_ext);
  1541. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, PPDU_END_STATUS_DONE,
  1542. htt_tlv_filter->ppdu_end_status_done);
  1543. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, PPDU_START_USER_INFO,
  1544. htt_tlv_filter->ppdu_start_user_info);
  1545. /* RESERVED bit maps to header_per_msdu in htt_tlv_filter*/
  1546. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, RESERVED,
  1547. htt_tlv_filter->header_per_msdu);
  1548. HTT_RX_RING_SELECTION_CFG_TLV_FILTER_IN_FLAG_SET(*msg_word, tlv_filter);
  1549. msg_word_data = (uint32_t *)qdf_nbuf_data(htt_msg);
  1550. dp_info("config_data: [0x%x][0x%x][0x%x][0x%x][0x%x][0x%x][0x%x]",
  1551. msg_word_data[0], msg_word_data[1], msg_word_data[2],
  1552. msg_word_data[3], msg_word_data[4], msg_word_data[5],
  1553. msg_word_data[6]);
  1554. /* word 7 */
  1555. msg_word++;
  1556. *msg_word = 0;
  1557. if (htt_tlv_filter->offset_valid) {
  1558. HTT_RX_RING_SELECTION_CFG_RX_PACKET_OFFSET_SET(*msg_word,
  1559. htt_tlv_filter->rx_packet_offset);
  1560. HTT_RX_RING_SELECTION_CFG_RX_HEADER_OFFSET_SET(*msg_word,
  1561. htt_tlv_filter->rx_header_offset);
  1562. /* word 8 */
  1563. msg_word++;
  1564. *msg_word = 0;
  1565. HTT_RX_RING_SELECTION_CFG_RX_MPDU_END_OFFSET_SET(*msg_word,
  1566. htt_tlv_filter->rx_mpdu_end_offset);
  1567. HTT_RX_RING_SELECTION_CFG_RX_MPDU_START_OFFSET_SET(*msg_word,
  1568. htt_tlv_filter->rx_mpdu_start_offset);
  1569. /* word 9 */
  1570. msg_word++;
  1571. *msg_word = 0;
  1572. HTT_RX_RING_SELECTION_CFG_RX_MSDU_END_OFFSET_SET(*msg_word,
  1573. htt_tlv_filter->rx_msdu_end_offset);
  1574. HTT_RX_RING_SELECTION_CFG_RX_MSDU_START_OFFSET_SET(*msg_word,
  1575. htt_tlv_filter->rx_msdu_start_offset);
  1576. /* word 10 */
  1577. msg_word++;
  1578. *msg_word = 0;
  1579. HTT_RX_RING_SELECTION_CFG_RX_ATTENTION_OFFSET_SET(*msg_word,
  1580. htt_tlv_filter->rx_attn_offset);
  1581. /* word 11 */
  1582. msg_word++;
  1583. *msg_word = 0;
  1584. } else {
  1585. /* word 11 */
  1586. msg_word += 4;
  1587. *msg_word = 0;
  1588. }
  1589. soc->dp_soc->arch_ops.dp_rx_word_mask_subscribe(
  1590. soc->dp_soc,
  1591. msg_word,
  1592. (void *)htt_tlv_filter);
  1593. dp_mon_rx_wmask_subscribe(soc->dp_soc, msg_word, htt_tlv_filter);
  1594. if (mon_drop_th > 0)
  1595. HTT_RX_RING_SELECTION_CFG_RX_DROP_THRESHOLD_SET(*msg_word,
  1596. mon_drop_th);
  1597. dp_mon_rx_enable_mpdu_logging(soc->dp_soc, msg_word, htt_tlv_filter);
  1598. dp_mon_rx_enable_phy_errors(msg_word, htt_tlv_filter);
  1599. /* word 14*/
  1600. msg_word += 3;
  1601. /* word 15*/
  1602. msg_word++;
  1603. /* word 16*/
  1604. msg_word++;
  1605. *msg_word = 0;
  1606. dp_mon_rx_enable_pkt_tlv_offset(soc->dp_soc, msg_word, htt_tlv_filter);
  1607. /* word 20 and 21*/
  1608. msg_word += 4;
  1609. *msg_word = 0;
  1610. dp_mon_rx_enable_fpmo(soc->dp_soc, msg_word, htt_tlv_filter);
  1611. /* "response_required" field should be set if a HTT response message is
  1612. * required after setting up the ring.
  1613. */
  1614. pkt = htt_htc_pkt_alloc(soc);
  1615. if (!pkt) {
  1616. dp_err("pkt alloc failed, ring_type %d ring_id %d htt_ring_id %d",
  1617. hal_ring_type, srng_params.ring_id, htt_ring_id);
  1618. goto fail1;
  1619. }
  1620. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  1621. SET_HTC_PACKET_INFO_TX(
  1622. &pkt->htc_pkt,
  1623. dp_htt_h2t_send_complete_free_netbuf,
  1624. qdf_nbuf_data(htt_msg),
  1625. qdf_nbuf_len(htt_msg),
  1626. soc->htc_endpoint,
  1627. HTC_TX_PACKET_TAG_RUNTIME_PUT); /* tag for no FW response msg */
  1628. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, htt_msg);
  1629. status = DP_HTT_SEND_HTC_PKT(soc, pkt,
  1630. HTT_H2T_MSG_TYPE_RX_RING_SELECTION_CFG,
  1631. htt_logger_bufp);
  1632. if (status != QDF_STATUS_SUCCESS) {
  1633. qdf_nbuf_free(htt_msg);
  1634. htt_htc_pkt_free(soc, pkt);
  1635. }
  1636. return status;
  1637. fail1:
  1638. qdf_nbuf_free(htt_msg);
  1639. fail0:
  1640. return QDF_STATUS_E_FAILURE;
  1641. }
  1642. qdf_export_symbol(htt_h2t_rx_ring_cfg);
  1643. #if defined(HTT_STATS_ENABLE)
  1644. static inline QDF_STATUS dp_send_htt_stat_resp(struct htt_stats_context *htt_stats,
  1645. struct dp_soc *soc, qdf_nbuf_t htt_msg)
  1646. {
  1647. uint32_t pdev_id;
  1648. uint32_t *msg_word = NULL;
  1649. uint32_t msg_remain_len = 0;
  1650. msg_word = (uint32_t *) qdf_nbuf_data(htt_msg);
  1651. /*COOKIE MSB*/
  1652. pdev_id = *(msg_word + 2) & HTT_PID_BIT_MASK;
  1653. /* stats message length + 16 size of HTT header*/
  1654. msg_remain_len = qdf_min(htt_stats->msg_len + 16,
  1655. (uint32_t)DP_EXT_MSG_LENGTH);
  1656. dp_wdi_event_handler(WDI_EVENT_HTT_STATS, soc,
  1657. msg_word, msg_remain_len,
  1658. WDI_NO_VAL, pdev_id);
  1659. if (htt_stats->msg_len >= DP_EXT_MSG_LENGTH) {
  1660. htt_stats->msg_len -= DP_EXT_MSG_LENGTH;
  1661. }
  1662. /* Need to be freed here as WDI handler will
  1663. * make a copy of pkt to send data to application
  1664. */
  1665. qdf_nbuf_free(htt_msg);
  1666. return QDF_STATUS_SUCCESS;
  1667. }
  1668. #else
  1669. static inline QDF_STATUS
  1670. dp_send_htt_stat_resp(struct htt_stats_context *htt_stats,
  1671. struct dp_soc *soc, qdf_nbuf_t htt_msg)
  1672. {
  1673. return QDF_STATUS_E_NOSUPPORT;
  1674. }
  1675. #endif
  1676. #ifdef HTT_STATS_DEBUGFS_SUPPORT
  1677. /* dp_send_htt_stats_dbgfs_msg() - Function to send htt data to upper layer.
  1678. * @pdev: dp pdev handle
  1679. * @msg_word: HTT msg
  1680. * @msg_len: Length of HTT msg sent
  1681. *
  1682. * Return: none
  1683. */
  1684. static inline void
  1685. dp_htt_stats_dbgfs_send_msg(struct dp_pdev *pdev, uint32_t *msg_word,
  1686. uint32_t msg_len)
  1687. {
  1688. struct htt_dbgfs_cfg dbgfs_cfg;
  1689. int done = 0;
  1690. /* send 5th word of HTT msg to upper layer */
  1691. dbgfs_cfg.msg_word = (msg_word + 4);
  1692. dbgfs_cfg.m = pdev->dbgfs_cfg->m;
  1693. /* stats message length + 16 size of HTT header*/
  1694. msg_len = qdf_min(msg_len + HTT_HEADER_LEN, (uint32_t)DP_EXT_MSG_LENGTH);
  1695. if (pdev->dbgfs_cfg->htt_stats_dbgfs_msg_process)
  1696. pdev->dbgfs_cfg->htt_stats_dbgfs_msg_process(&dbgfs_cfg,
  1697. (msg_len - HTT_HEADER_LEN));
  1698. /* Get TLV Done bit from 4th msg word */
  1699. done = HTT_T2H_EXT_STATS_CONF_TLV_DONE_GET(*(msg_word + 3));
  1700. if (done) {
  1701. if (qdf_event_set(&pdev->dbgfs_cfg->htt_stats_dbgfs_event))
  1702. dp_htt_err("%pK: Failed to set event for debugfs htt stats"
  1703. , pdev->soc);
  1704. }
  1705. }
  1706. #else
  1707. static inline void
  1708. dp_htt_stats_dbgfs_send_msg(struct dp_pdev *pdev, uint32_t *msg_word,
  1709. uint32_t msg_len)
  1710. {
  1711. }
  1712. #endif /* HTT_STATS_DEBUGFS_SUPPORT */
  1713. #ifdef WLAN_SYSFS_DP_STATS
  1714. /* dp_htt_stats_sysfs_update_config() - Function to send htt data to upper layer.
  1715. * @pdev: dp pdev handle
  1716. *
  1717. * This function sets the process id and printing mode within the sysfs config
  1718. * struct. which enables DP_PRINT statements within this process to write to the
  1719. * console buffer provided by the user space.
  1720. *
  1721. * Return: None
  1722. */
  1723. static inline void
  1724. dp_htt_stats_sysfs_update_config(struct dp_pdev *pdev)
  1725. {
  1726. struct dp_soc *soc = pdev->soc;
  1727. if (!soc) {
  1728. dp_htt_err("soc is null");
  1729. return;
  1730. }
  1731. if (!soc->sysfs_config) {
  1732. dp_htt_err("soc->sysfs_config is NULL");
  1733. return;
  1734. }
  1735. /* set sysfs config parameters */
  1736. soc->sysfs_config->process_id = qdf_get_current_pid();
  1737. soc->sysfs_config->printing_mode = PRINTING_MODE_ENABLED;
  1738. }
  1739. /**
  1740. * dp_htt_stats_sysfs_set_event() - Set sysfs stats event.
  1741. * @soc: soc handle.
  1742. * @msg_word: Pointer to htt msg word.
  1743. *
  1744. * Return: void
  1745. */
  1746. static inline void
  1747. dp_htt_stats_sysfs_set_event(struct dp_soc *soc, uint32_t *msg_word)
  1748. {
  1749. int done = 0;
  1750. done = HTT_T2H_EXT_STATS_CONF_TLV_DONE_GET(*(msg_word + 3));
  1751. if (done) {
  1752. if (qdf_event_set(&soc->sysfs_config->sysfs_txrx_fw_request_done))
  1753. dp_htt_err("%pK:event compl Fail to set event ",
  1754. soc);
  1755. }
  1756. }
  1757. #else /* WLAN_SYSFS_DP_STATS */
  1758. static inline void
  1759. dp_htt_stats_sysfs_update_config(struct dp_pdev *pdev)
  1760. {
  1761. }
  1762. static inline void
  1763. dp_htt_stats_sysfs_set_event(struct dp_soc *dp_soc, uint32_t *msg_word)
  1764. {
  1765. }
  1766. #endif /* WLAN_SYSFS_DP_STATS */
  1767. /* dp_htt_set_pdev_obss_stats() - Function to set pdev obss stats.
  1768. * @pdev: dp pdev handle
  1769. * @tag_type: HTT TLV tag type
  1770. * @tag_buf: TLV buffer pointer
  1771. *
  1772. * Return: None
  1773. */
  1774. static inline void
  1775. dp_htt_set_pdev_obss_stats(struct dp_pdev *pdev, uint32_t tag_type,
  1776. uint32_t *tag_buf)
  1777. {
  1778. if (tag_type != HTT_STATS_PDEV_OBSS_PD_TAG) {
  1779. dp_err("Tag mismatch");
  1780. return;
  1781. }
  1782. qdf_mem_copy(&pdev->stats.htt_tx_pdev_stats.obss_pd_stats_tlv,
  1783. tag_buf, sizeof(struct cdp_pdev_obss_pd_stats_tlv));
  1784. qdf_event_set(&pdev->fw_obss_stats_event);
  1785. }
  1786. /**
  1787. * dp_process_htt_stat_msg(): Process the list of buffers of HTT EXT stats
  1788. * @htt_stats: htt stats info
  1789. * @soc: dp_soc
  1790. *
  1791. * The FW sends the HTT EXT STATS as a stream of T2H messages. Each T2H message
  1792. * contains sub messages which are identified by a TLV header.
  1793. * In this function we will process the stream of T2H messages and read all the
  1794. * TLV contained in the message.
  1795. *
  1796. * The following cases have been taken care of
  1797. * Case 1: When the tlv_remain_length <= msg_remain_length of HTT MSG buffer
  1798. * In this case the buffer will contain multiple tlvs.
  1799. * Case 2: When the tlv_remain_length > msg_remain_length of HTT MSG buffer.
  1800. * Only one tlv will be contained in the HTT message and this tag
  1801. * will extend onto the next buffer.
  1802. * Case 3: When the buffer is the continuation of the previous message
  1803. * Case 4: tlv length is 0. which will indicate the end of message
  1804. *
  1805. * Return: void
  1806. */
  1807. static inline void dp_process_htt_stat_msg(struct htt_stats_context *htt_stats,
  1808. struct dp_soc *soc)
  1809. {
  1810. htt_tlv_tag_t tlv_type = 0xff;
  1811. qdf_nbuf_t htt_msg = NULL;
  1812. uint32_t *msg_word;
  1813. uint8_t *tlv_buf_head = NULL;
  1814. uint8_t *tlv_buf_tail = NULL;
  1815. uint32_t msg_remain_len = 0;
  1816. uint32_t tlv_remain_len = 0;
  1817. uint32_t *tlv_start;
  1818. int cookie_val = 0;
  1819. int cookie_msb = 0;
  1820. int pdev_id;
  1821. bool copy_stats = false;
  1822. struct dp_pdev *pdev;
  1823. /* Process node in the HTT message queue */
  1824. while ((htt_msg = qdf_nbuf_queue_remove(&htt_stats->msg))
  1825. != NULL) {
  1826. msg_word = (uint32_t *) qdf_nbuf_data(htt_msg);
  1827. cookie_val = *(msg_word + 1);
  1828. htt_stats->msg_len = HTT_T2H_EXT_STATS_CONF_TLV_LENGTH_GET(
  1829. *(msg_word +
  1830. HTT_T2H_EXT_STATS_TLV_START_OFFSET));
  1831. if (cookie_val) {
  1832. if (dp_send_htt_stat_resp(htt_stats, soc, htt_msg)
  1833. == QDF_STATUS_SUCCESS) {
  1834. continue;
  1835. }
  1836. }
  1837. cookie_msb = *(msg_word + 2);
  1838. pdev_id = *(msg_word + 2) & HTT_PID_BIT_MASK;
  1839. pdev = soc->pdev_list[pdev_id];
  1840. if (!cookie_val && (cookie_msb & DBG_STATS_COOKIE_HTT_DBGFS)) {
  1841. dp_htt_stats_dbgfs_send_msg(pdev, msg_word,
  1842. htt_stats->msg_len);
  1843. qdf_nbuf_free(htt_msg);
  1844. continue;
  1845. }
  1846. if (!cookie_val && (cookie_msb & DBG_SYSFS_STATS_COOKIE))
  1847. dp_htt_stats_sysfs_update_config(pdev);
  1848. if (cookie_msb & DBG_STATS_COOKIE_DP_STATS)
  1849. copy_stats = true;
  1850. /* read 5th word */
  1851. msg_word = msg_word + 4;
  1852. msg_remain_len = qdf_min(htt_stats->msg_len,
  1853. (uint32_t) DP_EXT_MSG_LENGTH);
  1854. /* Keep processing the node till node length is 0 */
  1855. while (msg_remain_len) {
  1856. /*
  1857. * if message is not a continuation of previous message
  1858. * read the tlv type and tlv length
  1859. */
  1860. if (!tlv_buf_head) {
  1861. tlv_type = HTT_STATS_TLV_TAG_GET(
  1862. *msg_word);
  1863. tlv_remain_len = HTT_STATS_TLV_LENGTH_GET(
  1864. *msg_word);
  1865. }
  1866. if (tlv_remain_len == 0) {
  1867. msg_remain_len = 0;
  1868. if (tlv_buf_head) {
  1869. qdf_mem_free(tlv_buf_head);
  1870. tlv_buf_head = NULL;
  1871. tlv_buf_tail = NULL;
  1872. }
  1873. goto error;
  1874. }
  1875. if (!tlv_buf_head)
  1876. tlv_remain_len += HTT_TLV_HDR_LEN;
  1877. if ((tlv_remain_len <= msg_remain_len)) {
  1878. /* Case 3 */
  1879. if (tlv_buf_head) {
  1880. qdf_mem_copy(tlv_buf_tail,
  1881. (uint8_t *)msg_word,
  1882. tlv_remain_len);
  1883. tlv_start = (uint32_t *)tlv_buf_head;
  1884. } else {
  1885. /* Case 1 */
  1886. tlv_start = msg_word;
  1887. }
  1888. if (copy_stats)
  1889. dp_htt_stats_copy_tag(pdev,
  1890. tlv_type,
  1891. tlv_start);
  1892. else
  1893. dp_htt_stats_print_tag(pdev,
  1894. tlv_type,
  1895. tlv_start);
  1896. if (tlv_type == HTT_STATS_PEER_DETAILS_TAG ||
  1897. tlv_type == HTT_STATS_PEER_STATS_CMN_TAG)
  1898. dp_peer_update_inactive_time(pdev,
  1899. tlv_type,
  1900. tlv_start);
  1901. if (cookie_msb & DBG_STATS_COOKIE_HTT_OBSS)
  1902. dp_htt_set_pdev_obss_stats(pdev,
  1903. tlv_type,
  1904. tlv_start);
  1905. msg_remain_len -= tlv_remain_len;
  1906. msg_word = (uint32_t *)
  1907. (((uint8_t *)msg_word) +
  1908. tlv_remain_len);
  1909. tlv_remain_len = 0;
  1910. if (tlv_buf_head) {
  1911. qdf_mem_free(tlv_buf_head);
  1912. tlv_buf_head = NULL;
  1913. tlv_buf_tail = NULL;
  1914. }
  1915. } else { /* tlv_remain_len > msg_remain_len */
  1916. /* Case 2 & 3 */
  1917. if (!tlv_buf_head) {
  1918. tlv_buf_head = qdf_mem_malloc(
  1919. tlv_remain_len);
  1920. if (!tlv_buf_head) {
  1921. QDF_TRACE(QDF_MODULE_ID_TXRX,
  1922. QDF_TRACE_LEVEL_ERROR,
  1923. "Alloc failed");
  1924. goto error;
  1925. }
  1926. tlv_buf_tail = tlv_buf_head;
  1927. }
  1928. qdf_mem_copy(tlv_buf_tail, (uint8_t *)msg_word,
  1929. msg_remain_len);
  1930. tlv_remain_len -= msg_remain_len;
  1931. tlv_buf_tail += msg_remain_len;
  1932. }
  1933. }
  1934. if (htt_stats->msg_len >= DP_EXT_MSG_LENGTH) {
  1935. htt_stats->msg_len -= DP_EXT_MSG_LENGTH;
  1936. }
  1937. /* indicate event completion in case the event is done */
  1938. if (!cookie_val && (cookie_msb & DBG_SYSFS_STATS_COOKIE))
  1939. dp_htt_stats_sysfs_set_event(soc, msg_word);
  1940. qdf_nbuf_free(htt_msg);
  1941. }
  1942. return;
  1943. error:
  1944. qdf_nbuf_free(htt_msg);
  1945. while ((htt_msg = qdf_nbuf_queue_remove(&htt_stats->msg))
  1946. != NULL)
  1947. qdf_nbuf_free(htt_msg);
  1948. }
  1949. void htt_t2h_stats_handler(void *context)
  1950. {
  1951. struct dp_soc *soc = (struct dp_soc *)context;
  1952. struct htt_stats_context htt_stats;
  1953. uint32_t *msg_word;
  1954. qdf_nbuf_t htt_msg = NULL;
  1955. uint8_t done;
  1956. uint32_t rem_stats;
  1957. if (!soc) {
  1958. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  1959. "soc is NULL");
  1960. return;
  1961. }
  1962. if (!qdf_atomic_read(&soc->cmn_init_done)) {
  1963. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  1964. "soc: 0x%pK, init_done: %d", soc,
  1965. qdf_atomic_read(&soc->cmn_init_done));
  1966. return;
  1967. }
  1968. qdf_mem_zero(&htt_stats, sizeof(htt_stats));
  1969. qdf_nbuf_queue_init(&htt_stats.msg);
  1970. /* pull one completed stats from soc->htt_stats_msg and process */
  1971. qdf_spin_lock_bh(&soc->htt_stats.lock);
  1972. if (!soc->htt_stats.num_stats) {
  1973. qdf_spin_unlock_bh(&soc->htt_stats.lock);
  1974. return;
  1975. }
  1976. while ((htt_msg = qdf_nbuf_queue_remove(&soc->htt_stats.msg)) != NULL) {
  1977. msg_word = (uint32_t *) qdf_nbuf_data(htt_msg);
  1978. msg_word = msg_word + HTT_T2H_EXT_STATS_TLV_START_OFFSET;
  1979. done = HTT_T2H_EXT_STATS_CONF_TLV_DONE_GET(*msg_word);
  1980. qdf_nbuf_queue_add(&htt_stats.msg, htt_msg);
  1981. /*
  1982. * Done bit signifies that this is the last T2H buffer in the
  1983. * stream of HTT EXT STATS message
  1984. */
  1985. if (done)
  1986. break;
  1987. }
  1988. rem_stats = --soc->htt_stats.num_stats;
  1989. qdf_spin_unlock_bh(&soc->htt_stats.lock);
  1990. /* If there are more stats to process, schedule stats work again.
  1991. * Scheduling prior to processing ht_stats to queue with early
  1992. * index
  1993. */
  1994. if (rem_stats)
  1995. qdf_sched_work(0, &soc->htt_stats.work);
  1996. dp_process_htt_stat_msg(&htt_stats, soc);
  1997. }
  1998. /**
  1999. * dp_txrx_fw_stats_handler() - Function to process HTT EXT stats
  2000. * @soc: DP SOC handle
  2001. * @htt_t2h_msg: HTT message nbuf
  2002. *
  2003. * return:void
  2004. */
  2005. static inline void dp_txrx_fw_stats_handler(struct dp_soc *soc,
  2006. qdf_nbuf_t htt_t2h_msg)
  2007. {
  2008. uint8_t done;
  2009. qdf_nbuf_t msg_copy;
  2010. uint32_t *msg_word;
  2011. msg_word = (uint32_t *)qdf_nbuf_data(htt_t2h_msg);
  2012. msg_word = msg_word + 3;
  2013. done = HTT_T2H_EXT_STATS_CONF_TLV_DONE_GET(*msg_word);
  2014. /*
  2015. * HTT EXT stats response comes as stream of TLVs which span over
  2016. * multiple T2H messages.
  2017. * The first message will carry length of the response.
  2018. * For rest of the messages length will be zero.
  2019. *
  2020. * Clone the T2H message buffer and store it in a list to process
  2021. * it later.
  2022. *
  2023. * The original T2H message buffers gets freed in the T2H HTT event
  2024. * handler
  2025. */
  2026. msg_copy = qdf_nbuf_clone(htt_t2h_msg);
  2027. if (!msg_copy) {
  2028. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO,
  2029. "T2H message clone failed for HTT EXT STATS");
  2030. goto error;
  2031. }
  2032. qdf_spin_lock_bh(&soc->htt_stats.lock);
  2033. qdf_nbuf_queue_add(&soc->htt_stats.msg, msg_copy);
  2034. /*
  2035. * Done bit signifies that this is the last T2H buffer in the stream of
  2036. * HTT EXT STATS message
  2037. */
  2038. if (done) {
  2039. soc->htt_stats.num_stats++;
  2040. qdf_sched_work(0, &soc->htt_stats.work);
  2041. }
  2042. qdf_spin_unlock_bh(&soc->htt_stats.lock);
  2043. return;
  2044. error:
  2045. qdf_spin_lock_bh(&soc->htt_stats.lock);
  2046. while ((msg_copy = qdf_nbuf_queue_remove(&soc->htt_stats.msg))
  2047. != NULL) {
  2048. qdf_nbuf_free(msg_copy);
  2049. }
  2050. soc->htt_stats.num_stats = 0;
  2051. qdf_spin_unlock_bh(&soc->htt_stats.lock);
  2052. return;
  2053. }
  2054. int htt_soc_attach_target(struct htt_soc *htt_soc)
  2055. {
  2056. struct htt_soc *soc = (struct htt_soc *)htt_soc;
  2057. return htt_h2t_ver_req_msg(soc);
  2058. }
  2059. void htt_set_htc_handle(struct htt_soc *htt_soc, HTC_HANDLE htc_soc)
  2060. {
  2061. htt_soc->htc_soc = htc_soc;
  2062. }
  2063. HTC_HANDLE htt_get_htc_handle(struct htt_soc *htt_soc)
  2064. {
  2065. return htt_soc->htc_soc;
  2066. }
  2067. struct htt_soc *htt_soc_attach(struct dp_soc *soc, HTC_HANDLE htc_handle)
  2068. {
  2069. int i;
  2070. int j;
  2071. int umac_alloc_size = HTT_SW_UMAC_RING_IDX_MAX *
  2072. sizeof(struct bp_handler);
  2073. int lmac_alloc_size = HTT_SW_LMAC_RING_IDX_MAX *
  2074. sizeof(struct bp_handler);
  2075. struct htt_soc *htt_soc = NULL;
  2076. htt_soc = qdf_mem_malloc(sizeof(*htt_soc));
  2077. if (!htt_soc) {
  2078. dp_err("HTT attach failed");
  2079. return NULL;
  2080. }
  2081. for (i = 0; i < MAX_PDEV_CNT; i++) {
  2082. htt_soc->pdevid_tt[i].umac_path =
  2083. qdf_mem_malloc(umac_alloc_size);
  2084. if (!htt_soc->pdevid_tt[i].umac_path)
  2085. break;
  2086. for (j = 0; j < HTT_SW_UMAC_RING_IDX_MAX; j++)
  2087. htt_soc->pdevid_tt[i].umac_path[j].bp_start_tt = -1;
  2088. htt_soc->pdevid_tt[i].lmac_path =
  2089. qdf_mem_malloc(lmac_alloc_size);
  2090. if (!htt_soc->pdevid_tt[i].lmac_path) {
  2091. qdf_mem_free(htt_soc->pdevid_tt[i].umac_path);
  2092. break;
  2093. }
  2094. for (j = 0; j < HTT_SW_LMAC_RING_IDX_MAX ; j++)
  2095. htt_soc->pdevid_tt[i].lmac_path[j].bp_start_tt = -1;
  2096. }
  2097. if (i != MAX_PDEV_CNT) {
  2098. for (j = 0; j < i; j++) {
  2099. qdf_mem_free(htt_soc->pdevid_tt[j].umac_path);
  2100. qdf_mem_free(htt_soc->pdevid_tt[j].lmac_path);
  2101. }
  2102. qdf_mem_free(htt_soc);
  2103. return NULL;
  2104. }
  2105. htt_soc->dp_soc = soc;
  2106. htt_soc->htc_soc = htc_handle;
  2107. HTT_TX_MUTEX_INIT(&htt_soc->htt_tx_mutex);
  2108. return htt_soc;
  2109. }
  2110. #if defined(WDI_EVENT_ENABLE) && \
  2111. !defined(REMOVE_PKT_LOG)
  2112. /**
  2113. * dp_pktlog_msg_handler() - Pktlog msg handler
  2114. * @soc: HTT SOC handle
  2115. * @msg_word: Pointer to payload
  2116. *
  2117. * Return: None
  2118. */
  2119. static void
  2120. dp_pktlog_msg_handler(struct htt_soc *soc,
  2121. uint32_t *msg_word)
  2122. {
  2123. uint8_t pdev_id;
  2124. uint8_t target_pdev_id;
  2125. uint32_t *pl_hdr;
  2126. target_pdev_id = HTT_T2H_PKTLOG_PDEV_ID_GET(*msg_word);
  2127. pdev_id = dp_get_host_pdev_id_for_target_pdev_id(soc->dp_soc,
  2128. target_pdev_id);
  2129. pl_hdr = (msg_word + 1);
  2130. dp_wdi_event_handler(WDI_EVENT_OFFLOAD_ALL, soc->dp_soc,
  2131. pl_hdr, HTT_INVALID_PEER, WDI_NO_VAL,
  2132. pdev_id);
  2133. }
  2134. #else
  2135. static void
  2136. dp_pktlog_msg_handler(struct htt_soc *soc,
  2137. uint32_t *msg_word)
  2138. {
  2139. }
  2140. #endif
  2141. #ifdef QCA_SUPPORT_PRIMARY_LINK_MIGRATE
  2142. QDF_STATUS
  2143. dp_h2t_ptqm_migration_msg_send(struct dp_soc *dp_soc, uint16_t vdev_id,
  2144. uint8_t pdev_id,
  2145. uint8_t chip_id, uint16_t peer_id,
  2146. uint16_t ml_peer_id, uint16_t src_info,
  2147. QDF_STATUS status)
  2148. {
  2149. struct htt_soc *soc = dp_soc->htt_handle;
  2150. struct dp_htt_htc_pkt *pkt;
  2151. uint8_t *htt_logger_bufp;
  2152. qdf_nbuf_t msg;
  2153. uint32_t *msg_word;
  2154. QDF_STATUS ret = QDF_STATUS_SUCCESS;
  2155. bool src_info_valid = false;
  2156. msg = qdf_nbuf_alloc(
  2157. soc->osdev,
  2158. HTT_MSG_BUF_SIZE(sizeof(htt_h2t_primary_link_peer_migrate_resp_t)),
  2159. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  2160. if (!msg)
  2161. return QDF_STATUS_E_NOMEM;
  2162. /*
  2163. * Set the length of the message.
  2164. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  2165. * separately during the below call to qdf_nbuf_push_head.
  2166. * The contribution from the HTC header is added separately inside HTC.
  2167. */
  2168. if (qdf_nbuf_put_tail(msg, sizeof(htt_h2t_primary_link_peer_migrate_resp_t))
  2169. == NULL) {
  2170. dp_htt_err("Failed to expand head for"
  2171. "HTT_H2T_MSG_TYPE_PRIMARY_LINK_PEER_MIGRATE_RESP");
  2172. qdf_nbuf_free(msg);
  2173. return QDF_STATUS_E_FAILURE;
  2174. }
  2175. msg_word = (uint32_t *)qdf_nbuf_data(msg);
  2176. memset(msg_word, 0, sizeof(htt_h2t_primary_link_peer_migrate_resp_t));
  2177. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  2178. htt_logger_bufp = (uint8_t *)msg_word;
  2179. *msg_word = 0;
  2180. HTT_H2T_MSG_TYPE_SET(*msg_word,
  2181. HTT_H2T_MSG_TYPE_PRIMARY_LINK_PEER_MIGRATE_RESP);
  2182. HTT_H2T_PRIMARY_LINK_PEER_MIGRATE_PDEV_ID_SET(*msg_word, pdev_id);
  2183. HTT_H2T_PRIMARY_LINK_PEER_MIGRATE_CHIP_ID_SET(*msg_word, chip_id);
  2184. HTT_H2T_PRIMARY_LINK_PEER_MIGRATE_VDEV_ID_SET(*msg_word, vdev_id);
  2185. /* word 1 */
  2186. msg_word++;
  2187. *msg_word = 0;
  2188. HTT_H2T_PRIMARY_LINK_PEER_MIGRATE_SW_LINK_PEER_ID_SET(*msg_word,
  2189. peer_id);
  2190. HTT_H2T_PRIMARY_LINK_PEER_MIGRATE_ML_PEER_ID_SET(*msg_word,
  2191. ml_peer_id);
  2192. /* word 1 */
  2193. msg_word++;
  2194. *msg_word = 0;
  2195. if (src_info != 0)
  2196. src_info_valid = true;
  2197. HTT_H2T_PRIMARY_LINK_PEER_MIGRATE_SRC_INFO_VALID_SET(*msg_word,
  2198. src_info_valid);
  2199. HTT_H2T_PRIMARY_LINK_PEER_MIGRATE_SRC_INFO_SET(*msg_word,
  2200. src_info);
  2201. HTT_H2T_PRIMARY_LINK_PEER_MIGRATE_STATUS_SET(*msg_word,
  2202. status);
  2203. pkt = htt_htc_pkt_alloc(soc);
  2204. if (!pkt) {
  2205. dp_htt_err("Fail to allocate dp_htt_htc_pkt buffer");
  2206. qdf_nbuf_free(msg);
  2207. return QDF_STATUS_E_NOMEM;
  2208. }
  2209. pkt->soc_ctxt = NULL;
  2210. /* macro to set packet parameters for TX */
  2211. SET_HTC_PACKET_INFO_TX(
  2212. &pkt->htc_pkt,
  2213. dp_htt_h2t_send_complete_free_netbuf,
  2214. qdf_nbuf_data(msg),
  2215. qdf_nbuf_len(msg),
  2216. soc->htc_endpoint,
  2217. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  2218. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  2219. ret = DP_HTT_SEND_HTC_PKT(
  2220. soc, pkt,
  2221. HTT_H2T_MSG_TYPE_PRIMARY_LINK_PEER_MIGRATE_RESP,
  2222. htt_logger_bufp);
  2223. if (ret != QDF_STATUS_SUCCESS) {
  2224. qdf_nbuf_free(msg);
  2225. htt_htc_pkt_free(soc, pkt);
  2226. }
  2227. return ret;
  2228. }
  2229. #endif
  2230. #ifdef QCA_VDEV_STATS_HW_OFFLOAD_SUPPORT
  2231. /**
  2232. * dp_vdev_txrx_hw_stats_handler - Handle vdev stats received from FW
  2233. * @soc: htt soc handle
  2234. * @msg_word: buffer containing stats
  2235. *
  2236. * Return: void
  2237. */
  2238. static void dp_vdev_txrx_hw_stats_handler(struct htt_soc *soc,
  2239. uint32_t *msg_word)
  2240. {
  2241. struct dp_soc *dpsoc = (struct dp_soc *)soc->dp_soc;
  2242. uint8_t pdev_id;
  2243. uint8_t vdev_id;
  2244. uint8_t target_pdev_id;
  2245. uint16_t payload_size;
  2246. struct dp_pdev *pdev;
  2247. struct dp_vdev *vdev;
  2248. uint8_t *tlv_buf;
  2249. uint32_t *tlv_buf_temp;
  2250. uint32_t *tag_buf;
  2251. htt_tlv_tag_t tlv_type;
  2252. uint16_t tlv_length;
  2253. uint64_t pkt_count = 0;
  2254. uint64_t byte_count = 0;
  2255. uint64_t soc_drop_cnt = 0;
  2256. struct cdp_pkt_info tx_comp = { 0 };
  2257. struct cdp_pkt_info tx_failed = { 0 };
  2258. target_pdev_id =
  2259. HTT_T2H_VDEVS_TXRX_STATS_PERIODIC_IND_PDEV_ID_GET(*msg_word);
  2260. pdev_id = dp_get_host_pdev_id_for_target_pdev_id(dpsoc,
  2261. target_pdev_id);
  2262. if (pdev_id >= MAX_PDEV_CNT)
  2263. return;
  2264. pdev = dpsoc->pdev_list[pdev_id];
  2265. if (!pdev) {
  2266. dp_err("PDEV is NULL for pdev_id:%d", pdev_id);
  2267. return;
  2268. }
  2269. payload_size =
  2270. HTT_T2H_VDEVS_TXRX_STATS_PERIODIC_IND_PAYLOAD_SIZE_GET(*msg_word);
  2271. qdf_trace_hex_dump(QDF_MODULE_ID_DP_HTT, QDF_TRACE_LEVEL_INFO,
  2272. (void *)msg_word, payload_size + 16);
  2273. /* Adjust msg_word to point to the first TLV in buffer */
  2274. msg_word = msg_word + 4;
  2275. /* Parse the received buffer till payload size reaches 0 */
  2276. while (payload_size > 0) {
  2277. tlv_buf = (uint8_t *)msg_word;
  2278. tlv_buf_temp = msg_word;
  2279. tlv_type = HTT_STATS_TLV_TAG_GET(*msg_word);
  2280. tlv_length = HTT_STATS_TLV_LENGTH_GET(*msg_word);
  2281. /* Add header size to tlv length*/
  2282. tlv_length += 4;
  2283. switch (tlv_type) {
  2284. case HTT_STATS_SOC_TXRX_STATS_COMMON_TAG:
  2285. {
  2286. tag_buf = tlv_buf_temp +
  2287. HTT_VDEV_STATS_GET_INDEX(SOC_DROP_CNT);
  2288. soc_drop_cnt = HTT_VDEV_GET_STATS_U64(tag_buf);
  2289. DP_STATS_UPD(dpsoc, tx.tqm_drop_no_peer, soc_drop_cnt);
  2290. break;
  2291. }
  2292. case HTT_STATS_VDEV_TXRX_STATS_HW_STATS_TAG:
  2293. {
  2294. tag_buf = tlv_buf_temp +
  2295. HTT_VDEV_STATS_GET_INDEX(VDEV_ID);
  2296. vdev_id = (uint8_t)(*tag_buf);
  2297. vdev = dp_vdev_get_ref_by_id(dpsoc, vdev_id,
  2298. DP_MOD_ID_HTT);
  2299. if (!vdev)
  2300. goto invalid_vdev;
  2301. /* Extract received packet count from buffer */
  2302. tag_buf = tlv_buf_temp +
  2303. HTT_VDEV_STATS_GET_INDEX(RX_PKT_CNT);
  2304. pkt_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2305. DP_STATS_UPD(vdev, rx_i.reo_rcvd_pkt.num, pkt_count);
  2306. /* Extract received packet byte count from buffer */
  2307. tag_buf = tlv_buf_temp +
  2308. HTT_VDEV_STATS_GET_INDEX(RX_BYTE_CNT);
  2309. byte_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2310. DP_STATS_UPD(vdev, rx_i.reo_rcvd_pkt.bytes, byte_count);
  2311. /* Extract tx success packet count from buffer */
  2312. tag_buf = tlv_buf_temp +
  2313. HTT_VDEV_STATS_GET_INDEX(TX_SUCCESS_PKT_CNT);
  2314. pkt_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2315. tx_comp.num = pkt_count;
  2316. /* Extract tx success packet byte count from buffer */
  2317. tag_buf = tlv_buf_temp +
  2318. HTT_VDEV_STATS_GET_INDEX(TX_SUCCESS_BYTE_CNT);
  2319. byte_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2320. tx_comp.bytes = byte_count;
  2321. /* Extract tx retry packet count from buffer */
  2322. tag_buf = tlv_buf_temp +
  2323. HTT_VDEV_STATS_GET_INDEX(TX_RETRY_PKT_CNT);
  2324. pkt_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2325. tx_comp.num += pkt_count;
  2326. tx_failed.num = pkt_count;
  2327. /* Extract tx retry packet byte count from buffer */
  2328. tag_buf = tlv_buf_temp +
  2329. HTT_VDEV_STATS_GET_INDEX(TX_RETRY_BYTE_CNT);
  2330. byte_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2331. tx_comp.bytes += byte_count;
  2332. tx_failed.bytes = byte_count;
  2333. /* Extract tx drop packet count from buffer */
  2334. tag_buf = tlv_buf_temp +
  2335. HTT_VDEV_STATS_GET_INDEX(TX_DROP_PKT_CNT);
  2336. pkt_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2337. tx_comp.num += pkt_count;
  2338. tx_failed.num += pkt_count;
  2339. /* Extract tx drop packet byte count from buffer */
  2340. tag_buf = tlv_buf_temp +
  2341. HTT_VDEV_STATS_GET_INDEX(TX_DROP_BYTE_CNT);
  2342. byte_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2343. tx_comp.bytes += byte_count;
  2344. tx_failed.bytes += byte_count;
  2345. /* Extract tx age-out packet count from buffer */
  2346. tag_buf = tlv_buf_temp +
  2347. HTT_VDEV_STATS_GET_INDEX(TX_AGE_OUT_PKT_CNT);
  2348. pkt_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2349. tx_comp.num += pkt_count;
  2350. tx_failed.num += pkt_count;
  2351. /* Extract tx age-out packet byte count from buffer */
  2352. tag_buf = tlv_buf_temp +
  2353. HTT_VDEV_STATS_GET_INDEX(TX_AGE_OUT_BYTE_CNT);
  2354. byte_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2355. tx_comp.bytes += byte_count;
  2356. tx_failed.bytes += byte_count;
  2357. /* Extract tqm bypass packet count from buffer */
  2358. tag_buf = tlv_buf_temp +
  2359. HTT_VDEV_STATS_GET_INDEX(TX_TQM_BYPASS_PKT_CNT);
  2360. pkt_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2361. tx_comp.num += pkt_count;
  2362. /* Extract tx bypass packet byte count from buffer */
  2363. tag_buf = tlv_buf_temp +
  2364. HTT_VDEV_STATS_GET_INDEX(TX_TQM_BYPASS_BYTE_CNT);
  2365. byte_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2366. tx_comp.bytes += byte_count;
  2367. DP_STATS_UPD(vdev, tx.comp_pkt.num, tx_comp.num);
  2368. DP_STATS_UPD(vdev, tx.comp_pkt.bytes, tx_comp.bytes);
  2369. DP_STATS_UPD(vdev, tx.tx_failed, tx_failed.num);
  2370. dp_vdev_unref_delete(dpsoc, vdev, DP_MOD_ID_HTT);
  2371. break;
  2372. }
  2373. default:
  2374. qdf_assert(0);
  2375. }
  2376. invalid_vdev:
  2377. msg_word = (uint32_t *)((uint8_t *)tlv_buf + tlv_length);
  2378. payload_size -= tlv_length;
  2379. }
  2380. }
  2381. #else
  2382. static void dp_vdev_txrx_hw_stats_handler(struct htt_soc *soc,
  2383. uint32_t *msg_word)
  2384. {}
  2385. #endif
  2386. #ifdef CONFIG_SAWF_DEF_QUEUES
  2387. static void dp_sawf_def_queues_update_map_report_conf(struct htt_soc *soc,
  2388. uint32_t *msg_word,
  2389. qdf_nbuf_t htt_t2h_msg)
  2390. {
  2391. dp_htt_sawf_def_queues_map_report_conf(soc, msg_word, htt_t2h_msg);
  2392. }
  2393. #else
  2394. static void dp_sawf_def_queues_update_map_report_conf(struct htt_soc *soc,
  2395. uint32_t *msg_word,
  2396. qdf_nbuf_t htt_t2h_msg)
  2397. {}
  2398. #endif
  2399. #ifdef CONFIG_SAWF
  2400. /**
  2401. * dp_sawf_msduq_map() - Msdu queue creation information received
  2402. * from target
  2403. * @soc: soc handle.
  2404. * @msg_word: Pointer to htt msg word.
  2405. * @htt_t2h_msg: HTT message nbuf
  2406. *
  2407. * Return: void
  2408. */
  2409. static void dp_sawf_msduq_map(struct htt_soc *soc, uint32_t *msg_word,
  2410. qdf_nbuf_t htt_t2h_msg)
  2411. {
  2412. dp_htt_sawf_msduq_map(soc, msg_word, htt_t2h_msg);
  2413. }
  2414. /**
  2415. * dp_sawf_dynamic_ast_update() - Dynamic AST index update for SAWF peer
  2416. * from target
  2417. * @soc: soc handle.
  2418. * @msg_word: Pointer to htt msg word.
  2419. * @htt_t2h_msg: HTT message nbuf
  2420. *
  2421. * Return: void
  2422. */
  2423. static void dp_sawf_dynamic_ast_update(struct htt_soc *soc, uint32_t *msg_word,
  2424. qdf_nbuf_t htt_t2h_msg)
  2425. {
  2426. dp_htt_sawf_dynamic_ast_update(soc, msg_word, htt_t2h_msg);
  2427. }
  2428. /**
  2429. * dp_sawf_mpdu_stats_handler() - HTT message handler for MPDU stats
  2430. * @soc: soc handle.
  2431. * @htt_t2h_msg: HTT message nbuf
  2432. *
  2433. * Return: void
  2434. */
  2435. static void dp_sawf_mpdu_stats_handler(struct htt_soc *soc,
  2436. qdf_nbuf_t htt_t2h_msg)
  2437. {
  2438. dp_sawf_htt_mpdu_stats_handler(soc, htt_t2h_msg);
  2439. }
  2440. #else
  2441. static void dp_sawf_msduq_map(struct htt_soc *soc, uint32_t *msg_word,
  2442. qdf_nbuf_t htt_t2h_msg)
  2443. {}
  2444. static void dp_sawf_mpdu_stats_handler(struct htt_soc *soc,
  2445. qdf_nbuf_t htt_t2h_msg)
  2446. {}
  2447. static void dp_sawf_dynamic_ast_update(struct htt_soc *soc, uint32_t *msg_word,
  2448. qdf_nbuf_t htt_t2h_msg)
  2449. {}
  2450. #endif
  2451. /**
  2452. * time_allow_print() - time allow print
  2453. * @htt_bp_handler: backpressure handler
  2454. * @ring_id: ring_id (index)
  2455. * @th_time: threshold time
  2456. *
  2457. * Return: 1 for successfully saving timestamp in array
  2458. * and 0 for timestamp falling within 2 seconds after last one
  2459. */
  2460. static bool time_allow_print(struct bp_handler *htt_bp_handler,
  2461. u_int8_t ring_id, u_int32_t th_time)
  2462. {
  2463. unsigned long tstamp;
  2464. struct bp_handler *path = &htt_bp_handler[ring_id];
  2465. tstamp = qdf_get_system_timestamp();
  2466. if (!path)
  2467. return 0; //unable to print backpressure messages
  2468. if (path->bp_start_tt == -1) {
  2469. path->bp_start_tt = tstamp;
  2470. path->bp_duration = 0;
  2471. path->bp_last_tt = tstamp;
  2472. path->bp_counter = 1;
  2473. return 1;
  2474. }
  2475. path->bp_duration = tstamp - path->bp_start_tt;
  2476. path->bp_last_tt = tstamp;
  2477. path->bp_counter++;
  2478. if (path->bp_duration >= th_time) {
  2479. path->bp_start_tt = -1;
  2480. return 1;
  2481. }
  2482. return 0;
  2483. }
  2484. static void dp_htt_alert_print(enum htt_t2h_msg_type msg_type,
  2485. struct dp_pdev *pdev, u_int8_t ring_id,
  2486. u_int16_t hp_idx, u_int16_t tp_idx,
  2487. u_int32_t bkp_time,
  2488. struct bp_handler *htt_bp_handler,
  2489. char *ring_stype)
  2490. {
  2491. dp_alert("seq_num %u msg_type: %d pdev_id: %d ring_type: %s ",
  2492. pdev->bkp_stats.seq_num, msg_type, pdev->pdev_id, ring_stype);
  2493. dp_alert("ring_id: %d hp_idx: %d tp_idx: %d bkpressure_time_ms: %d ",
  2494. ring_id, hp_idx, tp_idx, bkp_time);
  2495. dp_alert("last_bp_event: %ld, total_bp_duration: %ld, bp_counter: %ld",
  2496. htt_bp_handler[ring_id].bp_last_tt,
  2497. htt_bp_handler[ring_id].bp_duration,
  2498. htt_bp_handler[ring_id].bp_counter);
  2499. }
  2500. /**
  2501. * dp_get_srng_ring_state_from_hal(): Get hal level ring stats
  2502. * @soc: DP_SOC handle
  2503. * @pdev: DP pdev handle
  2504. * @srng: DP_SRNG handle
  2505. * @ring_type: srng src/dst ring
  2506. * @state: ring state
  2507. * @pdev: pdev
  2508. * @srng: DP_SRNG handle
  2509. * @ring_type: srng src/dst ring
  2510. * @state: ring_state
  2511. *
  2512. * Return: void
  2513. */
  2514. static QDF_STATUS
  2515. dp_get_srng_ring_state_from_hal(struct dp_soc *soc,
  2516. struct dp_pdev *pdev,
  2517. struct dp_srng *srng,
  2518. enum hal_ring_type ring_type,
  2519. struct dp_srng_ring_state *state)
  2520. {
  2521. struct hal_soc *hal_soc;
  2522. if (!soc || !srng || !srng->hal_srng || !state)
  2523. return QDF_STATUS_E_INVAL;
  2524. hal_soc = (struct hal_soc *)soc->hal_soc;
  2525. hal_get_sw_hptp(soc->hal_soc, srng->hal_srng, &state->sw_tail,
  2526. &state->sw_head);
  2527. hal_get_hw_hptp(soc->hal_soc, srng->hal_srng, &state->hw_head,
  2528. &state->hw_tail, ring_type);
  2529. state->ring_type = ring_type;
  2530. return QDF_STATUS_SUCCESS;
  2531. }
  2532. #ifdef QCA_MONITOR_PKT_SUPPORT
  2533. static void
  2534. dp_queue_mon_ring_stats(struct dp_pdev *pdev,
  2535. int lmac_id, uint32_t *num_srng,
  2536. struct dp_soc_srngs_state *soc_srngs_state)
  2537. {
  2538. QDF_STATUS status;
  2539. if (pdev->soc->wlan_cfg_ctx->rxdma1_enable) {
  2540. status = dp_get_srng_ring_state_from_hal
  2541. (pdev->soc, pdev,
  2542. &pdev->soc->rxdma_mon_buf_ring[lmac_id],
  2543. RXDMA_MONITOR_BUF,
  2544. &soc_srngs_state->ring_state[*num_srng]);
  2545. if (status == QDF_STATUS_SUCCESS)
  2546. qdf_assert_always(++(*num_srng) < DP_MAX_SRNGS);
  2547. status = dp_get_srng_ring_state_from_hal
  2548. (pdev->soc, pdev,
  2549. &pdev->soc->rxdma_mon_dst_ring[lmac_id],
  2550. RXDMA_MONITOR_DST,
  2551. &soc_srngs_state->ring_state[*num_srng]);
  2552. if (status == QDF_STATUS_SUCCESS)
  2553. qdf_assert_always(++(*num_srng) < DP_MAX_SRNGS);
  2554. status = dp_get_srng_ring_state_from_hal
  2555. (pdev->soc, pdev,
  2556. &pdev->soc->rxdma_mon_desc_ring[lmac_id],
  2557. RXDMA_MONITOR_DESC,
  2558. &soc_srngs_state->ring_state[*num_srng]);
  2559. if (status == QDF_STATUS_SUCCESS)
  2560. qdf_assert_always(++(*num_srng) < DP_MAX_SRNGS);
  2561. }
  2562. }
  2563. #else
  2564. static void
  2565. dp_queue_mon_ring_stats(struct dp_pdev *pdev,
  2566. int lmac_id, uint32_t *num_srng,
  2567. struct dp_soc_srngs_state *soc_srngs_state)
  2568. {
  2569. }
  2570. #endif
  2571. #ifndef WLAN_DP_DISABLE_TCL_CMD_CRED_SRNG
  2572. static inline QDF_STATUS
  2573. dp_get_tcl_cmd_cred_ring_state_from_hal(struct dp_pdev *pdev,
  2574. struct dp_srng_ring_state *ring_state)
  2575. {
  2576. return dp_get_srng_ring_state_from_hal(pdev->soc, pdev,
  2577. &pdev->soc->tcl_cmd_credit_ring,
  2578. TCL_CMD_CREDIT, ring_state);
  2579. }
  2580. #else
  2581. static inline QDF_STATUS
  2582. dp_get_tcl_cmd_cred_ring_state_from_hal(struct dp_pdev *pdev,
  2583. struct dp_srng_ring_state *ring_state)
  2584. {
  2585. return QDF_STATUS_SUCCESS;
  2586. }
  2587. #endif
  2588. #ifndef WLAN_DP_DISABLE_TCL_STATUS_SRNG
  2589. static inline QDF_STATUS
  2590. dp_get_tcl_status_ring_state_from_hal(struct dp_pdev *pdev,
  2591. struct dp_srng_ring_state *ring_state)
  2592. {
  2593. return dp_get_srng_ring_state_from_hal(pdev->soc, pdev,
  2594. &pdev->soc->tcl_status_ring,
  2595. TCL_STATUS, ring_state);
  2596. }
  2597. #else
  2598. static inline QDF_STATUS
  2599. dp_get_tcl_status_ring_state_from_hal(struct dp_pdev *pdev,
  2600. struct dp_srng_ring_state *ring_state)
  2601. {
  2602. return QDF_STATUS_SUCCESS;
  2603. }
  2604. #endif
  2605. /**
  2606. * dp_queue_ring_stats() - Print pdev hal level ring stats
  2607. * dp_queue_ring_stats(): Print pdev hal level ring stats
  2608. * @pdev: DP_pdev handle
  2609. *
  2610. * Return: void
  2611. */
  2612. static void dp_queue_ring_stats(struct dp_pdev *pdev)
  2613. {
  2614. uint32_t i;
  2615. int mac_id;
  2616. int lmac_id;
  2617. uint32_t j = 0;
  2618. struct dp_soc *soc = pdev->soc;
  2619. struct dp_soc_srngs_state * soc_srngs_state = NULL;
  2620. struct dp_soc_srngs_state *drop_srngs_state = NULL;
  2621. QDF_STATUS status;
  2622. soc_srngs_state = qdf_mem_malloc(sizeof(struct dp_soc_srngs_state));
  2623. if (!soc_srngs_state) {
  2624. dp_htt_alert("Memory alloc failed for back pressure event");
  2625. return;
  2626. }
  2627. status = dp_get_srng_ring_state_from_hal
  2628. (pdev->soc, pdev,
  2629. &pdev->soc->reo_exception_ring,
  2630. REO_EXCEPTION,
  2631. &soc_srngs_state->ring_state[j]);
  2632. if (status == QDF_STATUS_SUCCESS)
  2633. qdf_assert_always(++j < DP_MAX_SRNGS);
  2634. status = dp_get_srng_ring_state_from_hal
  2635. (pdev->soc, pdev,
  2636. &pdev->soc->reo_reinject_ring,
  2637. REO_REINJECT,
  2638. &soc_srngs_state->ring_state[j]);
  2639. if (status == QDF_STATUS_SUCCESS)
  2640. qdf_assert_always(++j < DP_MAX_SRNGS);
  2641. status = dp_get_srng_ring_state_from_hal
  2642. (pdev->soc, pdev,
  2643. &pdev->soc->reo_cmd_ring,
  2644. REO_CMD,
  2645. &soc_srngs_state->ring_state[j]);
  2646. if (status == QDF_STATUS_SUCCESS)
  2647. qdf_assert_always(++j < DP_MAX_SRNGS);
  2648. status = dp_get_srng_ring_state_from_hal
  2649. (pdev->soc, pdev,
  2650. &pdev->soc->reo_status_ring,
  2651. REO_STATUS,
  2652. &soc_srngs_state->ring_state[j]);
  2653. if (status == QDF_STATUS_SUCCESS)
  2654. qdf_assert_always(++j < DP_MAX_SRNGS);
  2655. status = dp_get_srng_ring_state_from_hal
  2656. (pdev->soc, pdev,
  2657. &pdev->soc->rx_rel_ring,
  2658. WBM2SW_RELEASE,
  2659. &soc_srngs_state->ring_state[j]);
  2660. if (status == QDF_STATUS_SUCCESS)
  2661. qdf_assert_always(++j < DP_MAX_SRNGS);
  2662. status = dp_get_tcl_cmd_cred_ring_state_from_hal
  2663. (pdev, &soc_srngs_state->ring_state[j]);
  2664. if (status == QDF_STATUS_SUCCESS)
  2665. qdf_assert_always(++j < DP_MAX_SRNGS);
  2666. status = dp_get_tcl_status_ring_state_from_hal
  2667. (pdev, &soc_srngs_state->ring_state[j]);
  2668. if (status == QDF_STATUS_SUCCESS)
  2669. qdf_assert_always(++j < DP_MAX_SRNGS);
  2670. status = dp_get_srng_ring_state_from_hal
  2671. (pdev->soc, pdev,
  2672. &pdev->soc->wbm_desc_rel_ring,
  2673. SW2WBM_RELEASE,
  2674. &soc_srngs_state->ring_state[j]);
  2675. if (status == QDF_STATUS_SUCCESS)
  2676. qdf_assert_always(++j < DP_MAX_SRNGS);
  2677. for (i = 0; i < MAX_REO_DEST_RINGS; i++) {
  2678. status = dp_get_srng_ring_state_from_hal
  2679. (pdev->soc, pdev,
  2680. &pdev->soc->reo_dest_ring[i],
  2681. REO_DST,
  2682. &soc_srngs_state->ring_state[j]);
  2683. if (status == QDF_STATUS_SUCCESS)
  2684. qdf_assert_always(++j < DP_MAX_SRNGS);
  2685. }
  2686. for (i = 0; i < pdev->soc->num_tcl_data_rings; i++) {
  2687. status = dp_get_srng_ring_state_from_hal
  2688. (pdev->soc, pdev,
  2689. &pdev->soc->tcl_data_ring[i],
  2690. TCL_DATA,
  2691. &soc_srngs_state->ring_state[j]);
  2692. if (status == QDF_STATUS_SUCCESS)
  2693. qdf_assert_always(++j < DP_MAX_SRNGS);
  2694. }
  2695. for (i = 0; i < MAX_TCL_DATA_RINGS; i++) {
  2696. status = dp_get_srng_ring_state_from_hal
  2697. (pdev->soc, pdev,
  2698. &pdev->soc->tx_comp_ring[i],
  2699. WBM2SW_RELEASE,
  2700. &soc_srngs_state->ring_state[j]);
  2701. if (status == QDF_STATUS_SUCCESS)
  2702. qdf_assert_always(++j < DP_MAX_SRNGS);
  2703. }
  2704. lmac_id = dp_get_lmac_id_for_pdev_id(pdev->soc, 0, pdev->pdev_id);
  2705. status = dp_get_srng_ring_state_from_hal
  2706. (pdev->soc, pdev,
  2707. &pdev->soc->rx_refill_buf_ring
  2708. [lmac_id],
  2709. RXDMA_BUF,
  2710. &soc_srngs_state->ring_state[j]);
  2711. if (status == QDF_STATUS_SUCCESS)
  2712. qdf_assert_always(++j < DP_MAX_SRNGS);
  2713. status = dp_get_srng_ring_state_from_hal
  2714. (pdev->soc, pdev,
  2715. &pdev->rx_refill_buf_ring2,
  2716. RXDMA_BUF,
  2717. &soc_srngs_state->ring_state[j]);
  2718. if (status == QDF_STATUS_SUCCESS)
  2719. qdf_assert_always(++j < DP_MAX_SRNGS);
  2720. for (i = 0; i < MAX_RX_MAC_RINGS; i++) {
  2721. dp_get_srng_ring_state_from_hal
  2722. (pdev->soc, pdev,
  2723. &pdev->rx_mac_buf_ring[i],
  2724. RXDMA_BUF,
  2725. &soc_srngs_state->ring_state[j]);
  2726. if (status == QDF_STATUS_SUCCESS)
  2727. qdf_assert_always(++j < DP_MAX_SRNGS);
  2728. }
  2729. for (mac_id = 0;
  2730. mac_id < soc->wlan_cfg_ctx->num_rxdma_status_rings_per_pdev;
  2731. mac_id++) {
  2732. lmac_id = dp_get_lmac_id_for_pdev_id(pdev->soc,
  2733. mac_id, pdev->pdev_id);
  2734. dp_queue_mon_ring_stats(pdev, lmac_id, &j,
  2735. soc_srngs_state);
  2736. status = dp_get_srng_ring_state_from_hal
  2737. (pdev->soc, pdev,
  2738. &pdev->soc->rxdma_mon_status_ring[lmac_id],
  2739. RXDMA_MONITOR_STATUS,
  2740. &soc_srngs_state->ring_state[j]);
  2741. if (status == QDF_STATUS_SUCCESS)
  2742. qdf_assert_always(++j < DP_MAX_SRNGS);
  2743. }
  2744. for (i = 0; i < soc->wlan_cfg_ctx->num_rxdma_dst_rings_per_pdev; i++) {
  2745. lmac_id = dp_get_lmac_id_for_pdev_id(pdev->soc,
  2746. i, pdev->pdev_id);
  2747. status = dp_get_srng_ring_state_from_hal
  2748. (pdev->soc, pdev,
  2749. &pdev->soc->rxdma_err_dst_ring
  2750. [lmac_id],
  2751. RXDMA_DST,
  2752. &soc_srngs_state->ring_state[j]);
  2753. if (status == QDF_STATUS_SUCCESS)
  2754. qdf_assert_always(++j < DP_MAX_SRNGS);
  2755. }
  2756. soc_srngs_state->max_ring_id = j;
  2757. qdf_spin_lock_bh(&pdev->bkp_stats.list_lock);
  2758. soc_srngs_state->seq_num = pdev->bkp_stats.seq_num;
  2759. if (pdev->bkp_stats.queue_depth >= HTT_BKP_STATS_MAX_QUEUE_DEPTH) {
  2760. drop_srngs_state = TAILQ_FIRST(&pdev->bkp_stats.list);
  2761. qdf_assert_always(drop_srngs_state);
  2762. TAILQ_REMOVE(&pdev->bkp_stats.list, drop_srngs_state,
  2763. list_elem);
  2764. qdf_mem_free(drop_srngs_state);
  2765. pdev->bkp_stats.queue_depth--;
  2766. }
  2767. pdev->bkp_stats.queue_depth++;
  2768. TAILQ_INSERT_TAIL(&pdev->bkp_stats.list, soc_srngs_state,
  2769. list_elem);
  2770. pdev->bkp_stats.seq_num++;
  2771. qdf_spin_unlock_bh(&pdev->bkp_stats.list_lock);
  2772. qdf_queue_work(0, pdev->bkp_stats.work_queue,
  2773. &pdev->bkp_stats.work);
  2774. }
  2775. /**
  2776. * dp_htt_bkp_event_alert() - htt backpressure event alert
  2777. * @msg_word: htt packet context
  2778. * @soc: HTT SOC handle
  2779. *
  2780. * Return: after attempting to print stats
  2781. */
  2782. static void dp_htt_bkp_event_alert(u_int32_t *msg_word, struct htt_soc *soc)
  2783. {
  2784. u_int8_t ring_type;
  2785. u_int8_t pdev_id;
  2786. uint8_t target_pdev_id;
  2787. u_int8_t ring_id;
  2788. u_int16_t hp_idx;
  2789. u_int16_t tp_idx;
  2790. u_int32_t bkp_time;
  2791. u_int32_t th_time;
  2792. enum htt_t2h_msg_type msg_type;
  2793. struct dp_soc *dpsoc;
  2794. struct dp_pdev *pdev;
  2795. struct dp_htt_timestamp *radio_tt;
  2796. struct wlan_cfg_dp_soc_ctxt *soc_cfg_ctx;
  2797. if (!soc)
  2798. return;
  2799. dpsoc = (struct dp_soc *)soc->dp_soc;
  2800. soc_cfg_ctx = dpsoc->wlan_cfg_ctx;
  2801. msg_type = HTT_T2H_MSG_TYPE_GET(*msg_word);
  2802. ring_type = HTT_T2H_RX_BKPRESSURE_RING_TYPE_GET(*msg_word);
  2803. target_pdev_id = HTT_T2H_RX_BKPRESSURE_PDEV_ID_GET(*msg_word);
  2804. pdev_id = dp_get_host_pdev_id_for_target_pdev_id(soc->dp_soc,
  2805. target_pdev_id);
  2806. if (pdev_id >= MAX_PDEV_CNT) {
  2807. dp_htt_debug("%pK: pdev id %d is invalid", soc, pdev_id);
  2808. return;
  2809. }
  2810. th_time = wlan_cfg_time_control_bp(soc_cfg_ctx);
  2811. pdev = (struct dp_pdev *)dpsoc->pdev_list[pdev_id];
  2812. ring_id = HTT_T2H_RX_BKPRESSURE_RINGID_GET(*msg_word);
  2813. hp_idx = HTT_T2H_RX_BKPRESSURE_HEAD_IDX_GET(*(msg_word + 1));
  2814. tp_idx = HTT_T2H_RX_BKPRESSURE_TAIL_IDX_GET(*(msg_word + 1));
  2815. bkp_time = HTT_T2H_RX_BKPRESSURE_TIME_MS_GET(*(msg_word + 2));
  2816. radio_tt = &soc->pdevid_tt[pdev_id];
  2817. switch (ring_type) {
  2818. case HTT_SW_RING_TYPE_UMAC:
  2819. if (!time_allow_print(radio_tt->umac_path, ring_id, th_time))
  2820. return;
  2821. dp_htt_alert_print(msg_type, pdev, ring_id, hp_idx, tp_idx,
  2822. bkp_time, radio_tt->umac_path,
  2823. "HTT_SW_RING_TYPE_UMAC");
  2824. break;
  2825. case HTT_SW_RING_TYPE_LMAC:
  2826. if (!time_allow_print(radio_tt->lmac_path, ring_id, th_time))
  2827. return;
  2828. dp_htt_alert_print(msg_type, pdev, ring_id, hp_idx, tp_idx,
  2829. bkp_time, radio_tt->lmac_path,
  2830. "HTT_SW_RING_TYPE_LMAC");
  2831. break;
  2832. default:
  2833. dp_alert("Invalid ring type: %d", ring_type);
  2834. break;
  2835. }
  2836. dp_queue_ring_stats(pdev);
  2837. }
  2838. #ifdef WLAN_FEATURE_PKT_CAPTURE_V2
  2839. /**
  2840. * dp_offload_ind_handler() - offload msg handler
  2841. * @soc: HTT SOC handle
  2842. * @msg_word: Pointer to payload
  2843. *
  2844. * Return: None
  2845. */
  2846. static void
  2847. dp_offload_ind_handler(struct htt_soc *soc, uint32_t *msg_word)
  2848. {
  2849. u_int8_t pdev_id;
  2850. u_int8_t target_pdev_id;
  2851. target_pdev_id = HTT_T2H_PPDU_STATS_PDEV_ID_GET(*msg_word);
  2852. pdev_id = dp_get_host_pdev_id_for_target_pdev_id(soc->dp_soc,
  2853. target_pdev_id);
  2854. dp_wdi_event_handler(WDI_EVENT_PKT_CAPTURE_OFFLOAD_TX_DATA, soc->dp_soc,
  2855. msg_word, HTT_INVALID_VDEV, WDI_NO_VAL,
  2856. pdev_id);
  2857. }
  2858. #else
  2859. static void
  2860. dp_offload_ind_handler(struct htt_soc *soc, uint32_t *msg_word)
  2861. {
  2862. }
  2863. #endif
  2864. #ifdef WLAN_FEATURE_11BE_MLO
  2865. #ifdef WLAN_MLO_MULTI_CHIP
  2866. static inline void dp_update_mlo_ts_offset(struct dp_soc *soc,
  2867. uint32_t ts_lo, uint32_t ts_hi)
  2868. {
  2869. uint64_t mlo_offset;
  2870. mlo_offset = ((uint64_t)(ts_hi) << 32 | ts_lo);
  2871. soc->cdp_soc.ops->mlo_ops->mlo_update_mlo_ts_offset
  2872. ((struct cdp_soc_t *)soc, mlo_offset);
  2873. }
  2874. static inline
  2875. void dp_update_mlo_delta_tsf2(struct dp_soc *soc, struct dp_pdev *pdev)
  2876. {
  2877. uint64_t delta_tsf2 = 0;
  2878. hal_get_tsf2_offset(soc->hal_soc, pdev->lmac_id, &delta_tsf2);
  2879. soc->cdp_soc.ops->mlo_ops->mlo_update_delta_tsf2
  2880. ((struct cdp_soc_t *)soc, pdev->pdev_id, delta_tsf2);
  2881. }
  2882. #else
  2883. static inline void dp_update_mlo_ts_offset(struct dp_soc *soc,
  2884. uint32_t ts_lo, uint32_t ts_hi)
  2885. {}
  2886. static inline
  2887. void dp_update_mlo_delta_tsf2(struct dp_soc *soc, struct dp_pdev *pdev)
  2888. {}
  2889. #endif
  2890. static void dp_htt_mlo_peer_map_handler(struct htt_soc *soc,
  2891. uint32_t *msg_word)
  2892. {
  2893. uint8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  2894. uint8_t *mlo_peer_mac_addr;
  2895. uint16_t mlo_peer_id;
  2896. uint8_t num_links;
  2897. struct dp_mlo_flow_override_info mlo_flow_info[DP_MLO_FLOW_INFO_MAX];
  2898. struct dp_mlo_link_info mlo_link_info[DP_MAX_MLO_LINKS];
  2899. MLO_PEER_MAP_TLV_TAG_ID tlv_type = 0xff;
  2900. uint16_t tlv_len = 0;
  2901. int i = 0;
  2902. mlo_peer_id = HTT_RX_MLO_PEER_MAP_MLO_PEER_ID_GET(*msg_word);
  2903. num_links =
  2904. HTT_RX_MLO_PEER_MAP_NUM_LOGICAL_LINKS_GET(*msg_word);
  2905. mlo_peer_mac_addr =
  2906. htt_t2h_mac_addr_deswizzle((u_int8_t *)(msg_word + 1),
  2907. &mac_addr_deswizzle_buf[0]);
  2908. mlo_flow_info[0].ast_idx =
  2909. HTT_RX_MLO_PEER_MAP_PRIMARY_AST_INDEX_GET(*(msg_word + 3));
  2910. mlo_flow_info[0].ast_idx_valid =
  2911. HTT_RX_MLO_PEER_MAP_AST_INDEX_VALID_FLAG_GET(*(msg_word + 3));
  2912. mlo_flow_info[0].chip_id =
  2913. HTT_RX_MLO_PEER_MAP_CHIP_ID_AST_INDEX_GET(*(msg_word + 3));
  2914. mlo_flow_info[0].tidmask =
  2915. HTT_RX_MLO_PEER_MAP_TIDMASK_AST_INDEX_GET(*(msg_word + 3));
  2916. mlo_flow_info[0].cache_set_num =
  2917. HTT_RX_MLO_PEER_MAP_CACHE_SET_NUM_AST_INDEX_GET(*(msg_word + 3));
  2918. mlo_flow_info[1].ast_idx =
  2919. HTT_RX_MLO_PEER_MAP_PRIMARY_AST_INDEX_GET(*(msg_word + 3));
  2920. mlo_flow_info[1].ast_idx_valid =
  2921. HTT_RX_MLO_PEER_MAP_AST_INDEX_VALID_FLAG_GET(*(msg_word + 3));
  2922. mlo_flow_info[1].chip_id =
  2923. HTT_RX_MLO_PEER_MAP_CHIP_ID_AST_INDEX_GET(*(msg_word + 3));
  2924. mlo_flow_info[1].tidmask =
  2925. HTT_RX_MLO_PEER_MAP_TIDMASK_AST_INDEX_GET(*(msg_word + 3));
  2926. mlo_flow_info[1].cache_set_num =
  2927. HTT_RX_MLO_PEER_MAP_CACHE_SET_NUM_AST_INDEX_GET(*(msg_word + 3));
  2928. mlo_flow_info[2].ast_idx =
  2929. HTT_RX_MLO_PEER_MAP_PRIMARY_AST_INDEX_GET(*(msg_word + 3));
  2930. mlo_flow_info[2].ast_idx_valid =
  2931. HTT_RX_MLO_PEER_MAP_AST_INDEX_VALID_FLAG_GET(*(msg_word + 3));
  2932. mlo_flow_info[2].chip_id =
  2933. HTT_RX_MLO_PEER_MAP_CHIP_ID_AST_INDEX_GET(*(msg_word + 3));
  2934. mlo_flow_info[2].tidmask =
  2935. HTT_RX_MLO_PEER_MAP_TIDMASK_AST_INDEX_GET(*(msg_word + 3));
  2936. mlo_flow_info[2].cache_set_num =
  2937. HTT_RX_MLO_PEER_MAP_CACHE_SET_NUM_AST_INDEX_GET(*(msg_word + 3));
  2938. msg_word = msg_word + 8;
  2939. while (msg_word && (i < DP_MAX_MLO_LINKS)) {
  2940. mlo_link_info[i].peer_chip_id = 0xFF;
  2941. mlo_link_info[i].vdev_id = 0xFF;
  2942. tlv_type = HTT_RX_MLO_PEER_MAP_TLV_TAG_GET(*msg_word);
  2943. tlv_len = HTT_RX_MLO_PEER_MAP_TLV_LENGTH_GET(*msg_word);
  2944. if (tlv_len == 0) {
  2945. dp_err("TLV Length is 0");
  2946. break;
  2947. }
  2948. if (tlv_type == MLO_PEER_MAP_TLV_STRUCT_SOC_VDEV_PEER_IDS) {
  2949. mlo_link_info[i].peer_chip_id =
  2950. HTT_RX_MLO_PEER_MAP_CHIP_ID_GET(
  2951. *(msg_word + 1));
  2952. mlo_link_info[i].vdev_id =
  2953. HTT_RX_MLO_PEER_MAP_VDEV_ID_GET(
  2954. *(msg_word + 1));
  2955. }
  2956. /* Add header size to tlv length */
  2957. tlv_len = tlv_len + HTT_TLV_HDR_LEN;
  2958. msg_word = (uint32_t *)(((uint8_t *)msg_word) + tlv_len);
  2959. i++;
  2960. }
  2961. dp_rx_mlo_peer_map_handler(soc->dp_soc, mlo_peer_id,
  2962. mlo_peer_mac_addr,
  2963. mlo_flow_info, mlo_link_info);
  2964. }
  2965. #ifdef QCA_SUPPORT_PRIMARY_LINK_MIGRATE
  2966. static void dp_htt_t2h_primary_link_migration(struct htt_soc *soc,
  2967. uint32_t *msg_word)
  2968. {
  2969. u_int16_t peer_id;
  2970. u_int16_t ml_peer_id;
  2971. u_int16_t vdev_id;
  2972. u_int8_t pdev_id;
  2973. u_int8_t chip_id;
  2974. vdev_id = HTT_T2H_PRIMARY_LINK_PEER_MIGRATE_VDEV_ID_GET(
  2975. *msg_word);
  2976. pdev_id = HTT_T2H_PRIMARY_LINK_PEER_MIGRATE_PDEV_ID_GET(
  2977. *msg_word);
  2978. chip_id = HTT_T2H_PRIMARY_LINK_PEER_MIGRATE_CHIP_ID_GET(
  2979. *msg_word);
  2980. ml_peer_id = HTT_T2H_PRIMARY_LINK_PEER_MIGRATE_ML_PEER_ID_GET(
  2981. *(msg_word + 1));
  2982. peer_id = HTT_T2H_PRIMARY_LINK_PEER_MIGRATE_SW_LINK_PEER_ID_GET(
  2983. *(msg_word + 1));
  2984. dp_htt_info("HTT_T2H_MSG_TYPE_PRIMARY_PEER_MIGRATE_IND msg"
  2985. "for peer id %d vdev id %d", peer_id, vdev_id);
  2986. dp_htt_reo_migration(soc->dp_soc, peer_id, ml_peer_id,
  2987. vdev_id, pdev_id, chip_id);
  2988. }
  2989. #else
  2990. static void dp_htt_t2h_primary_link_migration(struct htt_soc *soc,
  2991. uint32_t *msg_word)
  2992. {
  2993. }
  2994. #endif
  2995. static void dp_htt_mlo_peer_unmap_handler(struct htt_soc *soc,
  2996. uint32_t *msg_word)
  2997. {
  2998. uint16_t mlo_peer_id;
  2999. mlo_peer_id = HTT_RX_MLO_PEER_UNMAP_MLO_PEER_ID_GET(*msg_word);
  3000. dp_rx_mlo_peer_unmap_handler(soc->dp_soc, mlo_peer_id);
  3001. }
  3002. static void
  3003. dp_rx_mlo_timestamp_ind_handler(struct dp_soc *soc,
  3004. uint32_t *msg_word)
  3005. {
  3006. uint8_t pdev_id;
  3007. uint8_t target_pdev_id;
  3008. struct dp_pdev *pdev;
  3009. if (!soc)
  3010. return;
  3011. target_pdev_id = HTT_T2H_MLO_TIMESTAMP_OFFSET_PDEV_ID_GET(*msg_word);
  3012. pdev_id = dp_get_host_pdev_id_for_target_pdev_id(soc,
  3013. target_pdev_id);
  3014. if (pdev_id >= MAX_PDEV_CNT) {
  3015. dp_htt_debug("%pK: pdev id %d is invalid", soc, pdev_id);
  3016. return;
  3017. }
  3018. pdev = (struct dp_pdev *)soc->pdev_list[pdev_id];
  3019. if (!pdev) {
  3020. dp_err("Invalid pdev");
  3021. return;
  3022. }
  3023. dp_wdi_event_handler(WDI_EVENT_MLO_TSTMP, soc,
  3024. msg_word, HTT_INVALID_PEER, WDI_NO_VAL,
  3025. pdev_id);
  3026. qdf_spin_lock_bh(&soc->htt_stats.lock);
  3027. pdev->timestamp.msg_type =
  3028. HTT_T2H_MLO_TIMESTAMP_OFFSET_MSG_TYPE_GET(*msg_word);
  3029. pdev->timestamp.pdev_id = pdev_id;
  3030. pdev->timestamp.chip_id =
  3031. HTT_T2H_MLO_TIMESTAMP_OFFSET_CHIP_ID_GET(*msg_word);
  3032. pdev->timestamp.mac_clk_freq =
  3033. HTT_T2H_MLO_TIMESTAMP_OFFSET_MAC_CLK_FREQ_MHZ_GET(*msg_word);
  3034. pdev->timestamp.sync_tstmp_lo_us = *(msg_word + 1);
  3035. pdev->timestamp.sync_tstmp_hi_us = *(msg_word + 2);
  3036. pdev->timestamp.mlo_offset_lo_us = *(msg_word + 3);
  3037. pdev->timestamp.mlo_offset_hi_us = *(msg_word + 4);
  3038. pdev->timestamp.mlo_offset_clks = *(msg_word + 5);
  3039. pdev->timestamp.mlo_comp_us =
  3040. HTT_T2H_MLO_TIMESTAMP_OFFSET_MLO_TIMESTAMP_COMP_US_GET(
  3041. *(msg_word + 6));
  3042. pdev->timestamp.mlo_comp_clks =
  3043. HTT_T2H_MLO_TIMESTAMP_OFFSET_MLO_TIMESTAMP_COMP_CLKS_GET(
  3044. *(msg_word + 6));
  3045. pdev->timestamp.mlo_comp_timer =
  3046. HTT_T2H_MLO_TIMESTAMP_OFFSET_MLO_TIMESTAMP_COMP_PERIOD_US_GET(
  3047. *(msg_word + 7));
  3048. dp_htt_debug("tsf_lo=%d tsf_hi=%d, mlo_ofst_lo=%d, mlo_ofst_hi=%d",
  3049. pdev->timestamp.sync_tstmp_lo_us,
  3050. pdev->timestamp.sync_tstmp_hi_us,
  3051. pdev->timestamp.mlo_offset_lo_us,
  3052. pdev->timestamp.mlo_offset_hi_us);
  3053. qdf_spin_unlock_bh(&soc->htt_stats.lock);
  3054. dp_update_mlo_ts_offset(soc,
  3055. pdev->timestamp.mlo_offset_lo_us,
  3056. pdev->timestamp.mlo_offset_hi_us);
  3057. dp_update_mlo_delta_tsf2(soc, pdev);
  3058. }
  3059. #else
  3060. static void dp_htt_mlo_peer_map_handler(struct htt_soc *soc,
  3061. uint32_t *msg_word)
  3062. {
  3063. qdf_assert_always(0);
  3064. }
  3065. static void dp_htt_mlo_peer_unmap_handler(struct htt_soc *soc,
  3066. uint32_t *msg_word)
  3067. {
  3068. qdf_assert_always(0);
  3069. }
  3070. static void
  3071. dp_rx_mlo_timestamp_ind_handler(void *soc_handle,
  3072. uint32_t *msg_word)
  3073. {
  3074. qdf_assert_always(0);
  3075. }
  3076. static void dp_htt_t2h_primary_link_migration(struct htt_soc *soc,
  3077. uint32_t *msg_word)
  3078. {
  3079. }
  3080. #endif
  3081. /**
  3082. * dp_htt_rx_addba_handler() - RX Addba HTT msg handler
  3083. * @soc: DP Soc handler
  3084. * @peer_id: ID of peer
  3085. * @tid: TID number
  3086. * @win_sz: BA window size
  3087. *
  3088. * Return: None
  3089. */
  3090. static void
  3091. dp_htt_rx_addba_handler(struct dp_soc *soc, uint16_t peer_id,
  3092. uint8_t tid, uint16_t win_sz)
  3093. {
  3094. uint16_t status;
  3095. struct dp_peer *peer;
  3096. peer = dp_peer_get_ref_by_id(soc, peer_id, DP_MOD_ID_HTT);
  3097. if (!peer) {
  3098. dp_err("Peer not found peer id %d", peer_id);
  3099. return;
  3100. }
  3101. status = dp_addba_requestprocess_wifi3((struct cdp_soc_t *)soc,
  3102. peer->mac_addr.raw,
  3103. peer->vdev->vdev_id, 0,
  3104. tid, 0, win_sz, 0xffff);
  3105. dp_addba_resp_tx_completion_wifi3(
  3106. (struct cdp_soc_t *)soc,
  3107. peer->mac_addr.raw, peer->vdev->vdev_id,
  3108. tid,
  3109. status);
  3110. dp_peer_unref_delete(peer, DP_MOD_ID_HTT);
  3111. dp_info("PeerID %d BAW %d TID %d stat %d",
  3112. peer_id, win_sz, tid, status);
  3113. }
  3114. /**
  3115. * dp_htt_ppdu_id_fmt_handler() - PPDU ID Format handler
  3116. * @soc: HTT SOC handle
  3117. * @msg_word: Pointer to payload
  3118. *
  3119. * Return: None
  3120. */
  3121. static void
  3122. dp_htt_ppdu_id_fmt_handler(struct dp_soc *soc, uint32_t *msg_word)
  3123. {
  3124. uint8_t msg_type, valid, bits, offset;
  3125. msg_type = HTT_T2H_MSG_TYPE_GET(*msg_word);
  3126. msg_word += HTT_PPDU_ID_FMT_IND_LINK_ID_OFFSET;
  3127. valid = HTT_PPDU_ID_FMT_IND_VALID_GET_BITS31_16(*msg_word);
  3128. bits = HTT_PPDU_ID_FMT_IND_BITS_GET_BITS31_16(*msg_word);
  3129. offset = HTT_PPDU_ID_FMT_IND_OFFSET_GET_BITS31_16(*msg_word);
  3130. dp_info("link_id: valid %u bits %u offset %u", valid, bits, offset);
  3131. if (valid) {
  3132. soc->link_id_offset = offset;
  3133. soc->link_id_bits = bits;
  3134. }
  3135. }
  3136. #ifdef IPA_OPT_WIFI_DP
  3137. static void dp_ipa_rx_cce_super_rule_setup_done_handler(struct htt_soc *soc,
  3138. uint32_t *msg_word)
  3139. {
  3140. uint8_t pdev_id = 0;
  3141. uint8_t resp_type = 0;
  3142. uint8_t is_rules_enough = 0;
  3143. uint8_t num_rules_avail = 0;
  3144. int filter0_result = 0, filter1_result = 0;
  3145. bool is_success = false;
  3146. pdev_id = HTT_RX_CCE_SUPER_RULE_SETUP_DONE_PDEV_ID_GET(*msg_word);
  3147. resp_type = HTT_RX_CCE_SUPER_RULE_SETUP_DONE_RESPONSE_TYPE_GET(
  3148. *msg_word);
  3149. dp_info("opt_dp:: cce_super_rule_rsp pdev_id: %d resp_type: %d",
  3150. pdev_id, resp_type);
  3151. switch (resp_type) {
  3152. case HTT_RX_CCE_SUPER_RULE_SETUP_REQ_RESPONSE:
  3153. {
  3154. is_rules_enough =
  3155. HTT_RX_CCE_SUPER_RULE_SETUP_DONE_IS_RULE_ENOUGH_GET(
  3156. *msg_word);
  3157. num_rules_avail =
  3158. HTT_RX_CCE_SUPER_RULE_SETUP_DONE_AVAIL_RULE_NUM_GET(
  3159. *msg_word);
  3160. if (is_rules_enough == 1) {
  3161. is_success = true;
  3162. soc->stats.reserve_fail_cnt = 0;
  3163. } else {
  3164. is_success = false;
  3165. soc->stats.reserve_fail_cnt++;
  3166. if (soc->stats.reserve_fail_cnt >
  3167. MAX_RESERVE_FAIL_ATTEMPT) {
  3168. /*
  3169. * IPA will retry only after an hour by default
  3170. * after MAX_RESERVE_FAIL_ATTEMPT
  3171. */
  3172. soc->stats.abort_count++;
  3173. soc->stats.reserve_fail_cnt = 0;
  3174. dp_info(
  3175. "opt_dp: Filter reserve failed max attempts");
  3176. }
  3177. dp_info("opt_dp:: Filter reserve failed. Rules avail %d",
  3178. num_rules_avail);
  3179. }
  3180. dp_ipa_wdi_opt_dpath_notify_flt_rsvd(is_success);
  3181. break;
  3182. }
  3183. case HTT_RX_CCE_SUPER_RULE_INSTALL_RESPONSE:
  3184. {
  3185. filter0_result =
  3186. HTT_RX_CCE_SUPER_RULE_SETUP_DONE_CFG_RESULT_0_GET(
  3187. *msg_word);
  3188. filter1_result =
  3189. HTT_RX_CCE_SUPER_RULE_SETUP_DONE_CFG_RESULT_1_GET(
  3190. *msg_word);
  3191. dp_ipa_wdi_opt_dpath_notify_flt_add_rem_cb(filter0_result,
  3192. filter1_result);
  3193. break;
  3194. }
  3195. case HTT_RX_CCE_SUPER_RULE_RELEASE_RESPONSE:
  3196. {
  3197. filter0_result =
  3198. HTT_RX_CCE_SUPER_RULE_SETUP_DONE_CFG_RESULT_0_GET(
  3199. *msg_word);
  3200. filter1_result =
  3201. HTT_RX_CCE_SUPER_RULE_SETUP_DONE_CFG_RESULT_1_GET(
  3202. *msg_word);
  3203. dp_ipa_wdi_opt_dpath_notify_flt_rlsd(filter0_result,
  3204. filter1_result);
  3205. break;
  3206. }
  3207. default:
  3208. dp_info("opt_dp:: Wrong Super rule setup response");
  3209. };
  3210. dp_info("opt_dp:: cce super rule resp type: %d, is_rules_enough: %d",
  3211. resp_type, is_rules_enough);
  3212. dp_info("num_rules_avail: %d, rslt0: %d, rslt1: %d",
  3213. num_rules_avail, filter0_result, filter1_result);
  3214. }
  3215. #else
  3216. static void dp_ipa_rx_cce_super_rule_setup_done_handler(struct htt_soc *soc,
  3217. uint32_t *msg_word)
  3218. {
  3219. }
  3220. #endif
  3221. #if defined(WLAN_FEATURE_11BE_MLO) && defined(DP_MLO_LINK_STATS_SUPPORT)
  3222. static inline void
  3223. dp_htt_peer_ext_evt(struct htt_soc *soc, uint32_t *msg_word)
  3224. {
  3225. struct dp_peer_ext_evt_info info;
  3226. uint8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  3227. info.peer_id = HTT_RX_PEER_EXTENDED_PEER_ID_GET(*msg_word);
  3228. info.vdev_id = HTT_RX_PEER_EXTENDED_VDEV_ID_GET(*msg_word);
  3229. info.link_id =
  3230. HTT_RX_PEER_EXTENDED_LOGICAL_LINK_ID_GET(*(msg_word + 2));
  3231. info.link_id_valid =
  3232. HTT_RX_PEER_EXTENDED_LOGICAL_LINK_ID_VALID_GET(*(msg_word + 2));
  3233. info.peer_mac_addr =
  3234. htt_t2h_mac_addr_deswizzle((u_int8_t *)(msg_word + 1),
  3235. &mac_addr_deswizzle_buf[0]);
  3236. dp_htt_info("peer id %u, vdev id %u, link id %u, valid %u,peer_mac " QDF_MAC_ADDR_FMT,
  3237. info.peer_id, info.vdev_id, info.link_id,
  3238. info.link_id_valid, QDF_MAC_ADDR_REF(info.peer_mac_addr));
  3239. dp_rx_peer_ext_evt(soc->dp_soc, &info);
  3240. }
  3241. #else
  3242. static inline void
  3243. dp_htt_peer_ext_evt(struct htt_soc *soc, uint32_t *msg_word)
  3244. {
  3245. }
  3246. #endif
  3247. #ifdef WLAN_FEATURE_CE_RX_BUFFER_REUSE
  3248. static void dp_htt_rx_nbuf_free(qdf_nbuf_t nbuf)
  3249. {
  3250. nbuf = wbuff_buff_put(nbuf);
  3251. if (nbuf)
  3252. qdf_nbuf_free(nbuf);
  3253. }
  3254. #else
  3255. static inline void dp_htt_rx_nbuf_free(qdf_nbuf_t nbuf)
  3256. {
  3257. return qdf_nbuf_free(nbuf);
  3258. }
  3259. #endif
  3260. void dp_htt_t2h_msg_handler(void *context, HTC_PACKET *pkt)
  3261. {
  3262. struct htt_soc *soc = (struct htt_soc *) context;
  3263. qdf_nbuf_t htt_t2h_msg = (qdf_nbuf_t) pkt->pPktContext;
  3264. u_int32_t *msg_word;
  3265. enum htt_t2h_msg_type msg_type;
  3266. bool free_buf = true;
  3267. /* check for successful message reception */
  3268. if (pkt->Status != QDF_STATUS_SUCCESS) {
  3269. if (pkt->Status != QDF_STATUS_E_CANCELED)
  3270. soc->stats.htc_err_cnt++;
  3271. dp_htt_rx_nbuf_free(htt_t2h_msg);
  3272. return;
  3273. }
  3274. /* TODO: Check if we should pop the HTC/HTT header alignment padding */
  3275. msg_word = (u_int32_t *) qdf_nbuf_data(htt_t2h_msg);
  3276. msg_type = HTT_T2H_MSG_TYPE_GET(*msg_word);
  3277. htt_event_record(soc->htt_logger_handle,
  3278. msg_type, (uint8_t *)msg_word);
  3279. switch (msg_type) {
  3280. case HTT_T2H_MSG_TYPE_BKPRESSURE_EVENT_IND:
  3281. {
  3282. dp_htt_bkp_event_alert(msg_word, soc);
  3283. break;
  3284. }
  3285. case HTT_T2H_MSG_TYPE_PEER_MAP:
  3286. {
  3287. u_int8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  3288. u_int8_t *peer_mac_addr;
  3289. u_int16_t peer_id;
  3290. u_int16_t hw_peer_id;
  3291. u_int8_t vdev_id;
  3292. u_int8_t is_wds;
  3293. struct dp_soc *dpsoc = (struct dp_soc *)soc->dp_soc;
  3294. peer_id = HTT_RX_PEER_MAP_PEER_ID_GET(*msg_word);
  3295. hw_peer_id =
  3296. HTT_RX_PEER_MAP_HW_PEER_ID_GET(*(msg_word+2));
  3297. vdev_id = HTT_RX_PEER_MAP_VDEV_ID_GET(*msg_word);
  3298. peer_mac_addr = htt_t2h_mac_addr_deswizzle(
  3299. (u_int8_t *) (msg_word+1),
  3300. &mac_addr_deswizzle_buf[0]);
  3301. QDF_TRACE(QDF_MODULE_ID_TXRX,
  3302. QDF_TRACE_LEVEL_DEBUG,
  3303. "HTT_T2H_MSG_TYPE_PEER_MAP msg for peer id %d vdev id %d n",
  3304. peer_id, vdev_id);
  3305. /*
  3306. * check if peer already exists for this peer_id, if so
  3307. * this peer map event is in response for a wds peer add
  3308. * wmi command sent during wds source port learning.
  3309. * in this case just add the ast entry to the existing
  3310. * peer ast_list.
  3311. */
  3312. is_wds = !!(dpsoc->peer_id_to_obj_map[peer_id]);
  3313. dp_rx_peer_map_handler(soc->dp_soc, peer_id, hw_peer_id,
  3314. vdev_id, peer_mac_addr, 0,
  3315. is_wds);
  3316. break;
  3317. }
  3318. case HTT_T2H_MSG_TYPE_PEER_UNMAP:
  3319. {
  3320. u_int16_t peer_id;
  3321. u_int8_t vdev_id;
  3322. u_int8_t mac_addr[QDF_MAC_ADDR_SIZE] = {0};
  3323. peer_id = HTT_RX_PEER_UNMAP_PEER_ID_GET(*msg_word);
  3324. vdev_id = HTT_RX_PEER_UNMAP_VDEV_ID_GET(*msg_word);
  3325. dp_rx_peer_unmap_handler(soc->dp_soc, peer_id,
  3326. vdev_id, mac_addr, 0,
  3327. DP_PEER_WDS_COUNT_INVALID);
  3328. break;
  3329. }
  3330. case HTT_T2H_MSG_TYPE_SEC_IND:
  3331. {
  3332. u_int16_t peer_id;
  3333. enum cdp_sec_type sec_type;
  3334. int is_unicast;
  3335. peer_id = HTT_SEC_IND_PEER_ID_GET(*msg_word);
  3336. sec_type = HTT_SEC_IND_SEC_TYPE_GET(*msg_word);
  3337. is_unicast = HTT_SEC_IND_UNICAST_GET(*msg_word);
  3338. /* point to the first part of the Michael key */
  3339. msg_word++;
  3340. dp_rx_sec_ind_handler(
  3341. soc->dp_soc, peer_id, sec_type, is_unicast,
  3342. msg_word, msg_word + 2);
  3343. break;
  3344. }
  3345. case HTT_T2H_MSG_TYPE_PPDU_STATS_IND:
  3346. {
  3347. free_buf =
  3348. dp_monitor_ppdu_stats_ind_handler(soc,
  3349. msg_word,
  3350. htt_t2h_msg);
  3351. break;
  3352. }
  3353. case HTT_T2H_MSG_TYPE_PKTLOG:
  3354. {
  3355. dp_pktlog_msg_handler(soc, msg_word);
  3356. break;
  3357. }
  3358. case HTT_T2H_MSG_TYPE_VERSION_CONF:
  3359. {
  3360. /*
  3361. * HTC maintains runtime pm count for H2T messages that
  3362. * have a response msg from FW. This count ensures that
  3363. * in the case FW does not sent out the response or host
  3364. * did not process this indication runtime_put happens
  3365. * properly in the cleanup path.
  3366. */
  3367. if (htc_dec_return_htt_runtime_cnt(soc->htc_soc) >= 0)
  3368. htc_pm_runtime_put(soc->htc_soc);
  3369. else
  3370. soc->stats.htt_ver_req_put_skip++;
  3371. soc->tgt_ver.major = HTT_VER_CONF_MAJOR_GET(*msg_word);
  3372. soc->tgt_ver.minor = HTT_VER_CONF_MINOR_GET(*msg_word);
  3373. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_LOW,
  3374. "target uses HTT version %d.%d; host uses %d.%d",
  3375. soc->tgt_ver.major, soc->tgt_ver.minor,
  3376. HTT_CURRENT_VERSION_MAJOR,
  3377. HTT_CURRENT_VERSION_MINOR);
  3378. if (soc->tgt_ver.major != HTT_CURRENT_VERSION_MAJOR) {
  3379. QDF_TRACE(QDF_MODULE_ID_TXRX,
  3380. QDF_TRACE_LEVEL_WARN,
  3381. "*** Incompatible host/target HTT versions!");
  3382. }
  3383. /* abort if the target is incompatible with the host */
  3384. qdf_assert(soc->tgt_ver.major ==
  3385. HTT_CURRENT_VERSION_MAJOR);
  3386. if (soc->tgt_ver.minor != HTT_CURRENT_VERSION_MINOR) {
  3387. QDF_TRACE(QDF_MODULE_ID_TXRX,
  3388. QDF_TRACE_LEVEL_INFO_LOW,
  3389. "*** Warning: host/target HTT versions"
  3390. " are different, though compatible!");
  3391. }
  3392. break;
  3393. }
  3394. case HTT_T2H_MSG_TYPE_RX_ADDBA:
  3395. {
  3396. uint16_t peer_id;
  3397. uint8_t tid;
  3398. uint16_t win_sz;
  3399. /*
  3400. * Update REO Queue Desc with new values
  3401. */
  3402. peer_id = HTT_RX_ADDBA_PEER_ID_GET(*msg_word);
  3403. tid = HTT_RX_ADDBA_TID_GET(*msg_word);
  3404. win_sz = HTT_RX_ADDBA_WIN_SIZE_GET(*msg_word);
  3405. /*
  3406. * Window size needs to be incremented by 1
  3407. * since fw needs to represent a value of 256
  3408. * using just 8 bits
  3409. */
  3410. dp_htt_rx_addba_handler(soc->dp_soc, peer_id,
  3411. tid, win_sz + 1);
  3412. break;
  3413. }
  3414. case HTT_T2H_MSG_TYPE_RX_ADDBA_EXTN:
  3415. {
  3416. uint16_t peer_id;
  3417. uint8_t tid;
  3418. uint16_t win_sz;
  3419. peer_id = HTT_RX_ADDBA_EXTN_PEER_ID_GET(*msg_word);
  3420. tid = HTT_RX_ADDBA_EXTN_TID_GET(*msg_word);
  3421. msg_word++;
  3422. win_sz = HTT_RX_ADDBA_EXTN_WIN_SIZE_GET(*msg_word);
  3423. dp_htt_rx_addba_handler(soc->dp_soc, peer_id,
  3424. tid, win_sz);
  3425. break;
  3426. }
  3427. case HTT_T2H_PPDU_ID_FMT_IND:
  3428. {
  3429. dp_htt_ppdu_id_fmt_handler(soc->dp_soc, msg_word);
  3430. break;
  3431. }
  3432. case HTT_T2H_MSG_TYPE_EXT_STATS_CONF:
  3433. {
  3434. dp_txrx_fw_stats_handler(soc->dp_soc, htt_t2h_msg);
  3435. break;
  3436. }
  3437. case HTT_T2H_MSG_TYPE_PEER_MAP_V2:
  3438. {
  3439. u_int8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  3440. u_int8_t *peer_mac_addr;
  3441. u_int16_t peer_id;
  3442. u_int16_t hw_peer_id;
  3443. u_int8_t vdev_id;
  3444. bool is_wds;
  3445. u_int16_t ast_hash;
  3446. struct dp_ast_flow_override_info ast_flow_info = {0};
  3447. peer_id = HTT_RX_PEER_MAP_V2_SW_PEER_ID_GET(*msg_word);
  3448. hw_peer_id =
  3449. HTT_RX_PEER_MAP_V2_HW_PEER_ID_GET(*(msg_word + 2));
  3450. vdev_id = HTT_RX_PEER_MAP_V2_VDEV_ID_GET(*msg_word);
  3451. peer_mac_addr =
  3452. htt_t2h_mac_addr_deswizzle((u_int8_t *)(msg_word + 1),
  3453. &mac_addr_deswizzle_buf[0]);
  3454. is_wds =
  3455. HTT_RX_PEER_MAP_V2_NEXT_HOP_GET(*(msg_word + 3));
  3456. ast_hash =
  3457. HTT_RX_PEER_MAP_V2_AST_HASH_VALUE_GET(*(msg_word + 3));
  3458. /*
  3459. * Update 4 ast_index per peer, ast valid mask
  3460. * and TID flow valid mask.
  3461. * AST valid mask is 3 bit field corresponds to
  3462. * ast_index[3:1]. ast_index 0 is always valid.
  3463. */
  3464. ast_flow_info.ast_valid_mask =
  3465. HTT_RX_PEER_MAP_V2_AST_VALID_MASK_GET(*(msg_word + 3));
  3466. ast_flow_info.ast_idx[0] = hw_peer_id;
  3467. ast_flow_info.ast_flow_mask[0] =
  3468. HTT_RX_PEER_MAP_V2_AST_0_FLOW_MASK_GET(*(msg_word + 4));
  3469. ast_flow_info.ast_idx[1] =
  3470. HTT_RX_PEER_MAP_V2_AST_INDEX_1_GET(*(msg_word + 4));
  3471. ast_flow_info.ast_flow_mask[1] =
  3472. HTT_RX_PEER_MAP_V2_AST_1_FLOW_MASK_GET(*(msg_word + 4));
  3473. ast_flow_info.ast_idx[2] =
  3474. HTT_RX_PEER_MAP_V2_AST_INDEX_2_GET(*(msg_word + 5));
  3475. ast_flow_info.ast_flow_mask[2] =
  3476. HTT_RX_PEER_MAP_V2_AST_2_FLOW_MASK_GET(*(msg_word + 4));
  3477. ast_flow_info.ast_idx[3] =
  3478. HTT_RX_PEER_MAP_V2_AST_INDEX_3_GET(*(msg_word + 6));
  3479. ast_flow_info.ast_flow_mask[3] =
  3480. HTT_RX_PEER_MAP_V2_AST_3_FLOW_MASK_GET(*(msg_word + 4));
  3481. /*
  3482. * TID valid mask is applicable only
  3483. * for HI and LOW priority flows.
  3484. * tid_valid_mas is 8 bit field corresponds
  3485. * to TID[7:0]
  3486. */
  3487. ast_flow_info.tid_valid_low_pri_mask =
  3488. HTT_RX_PEER_MAP_V2_TID_VALID_LOW_PRI_GET(*(msg_word + 5));
  3489. ast_flow_info.tid_valid_hi_pri_mask =
  3490. HTT_RX_PEER_MAP_V2_TID_VALID_HI_PRI_GET(*(msg_word + 5));
  3491. QDF_TRACE(QDF_MODULE_ID_TXRX,
  3492. QDF_TRACE_LEVEL_DEBUG,
  3493. "HTT_T2H_MSG_TYPE_PEER_MAP msg for peer id %d vdev id %d n",
  3494. peer_id, vdev_id);
  3495. QDF_TRACE(QDF_MODULE_ID_TXRX,
  3496. QDF_TRACE_LEVEL_INFO,
  3497. "ast_idx[0] %d ast_idx[1] %d ast_idx[2] %d ast_idx[3] %d n",
  3498. ast_flow_info.ast_idx[0],
  3499. ast_flow_info.ast_idx[1],
  3500. ast_flow_info.ast_idx[2],
  3501. ast_flow_info.ast_idx[3]);
  3502. dp_rx_peer_map_handler(soc->dp_soc, peer_id,
  3503. hw_peer_id, vdev_id,
  3504. peer_mac_addr, ast_hash,
  3505. is_wds);
  3506. /*
  3507. * Update ast indexes for flow override support
  3508. * Applicable only for non wds peers
  3509. */
  3510. if (!soc->dp_soc->ast_offload_support)
  3511. dp_peer_ast_index_flow_queue_map_create(
  3512. soc->dp_soc, is_wds,
  3513. peer_id, peer_mac_addr,
  3514. &ast_flow_info);
  3515. break;
  3516. }
  3517. case HTT_T2H_MSG_TYPE_PEER_UNMAP_V2:
  3518. {
  3519. u_int8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  3520. u_int8_t *mac_addr;
  3521. u_int16_t peer_id;
  3522. u_int8_t vdev_id;
  3523. u_int8_t is_wds;
  3524. u_int32_t free_wds_count;
  3525. peer_id =
  3526. HTT_RX_PEER_UNMAP_V2_SW_PEER_ID_GET(*msg_word);
  3527. vdev_id = HTT_RX_PEER_UNMAP_V2_VDEV_ID_GET(*msg_word);
  3528. mac_addr =
  3529. htt_t2h_mac_addr_deswizzle((u_int8_t *)(msg_word + 1),
  3530. &mac_addr_deswizzle_buf[0]);
  3531. is_wds =
  3532. HTT_RX_PEER_UNMAP_V2_NEXT_HOP_GET(*(msg_word + 2));
  3533. free_wds_count =
  3534. HTT_RX_PEER_UNMAP_V2_PEER_WDS_FREE_COUNT_GET(*(msg_word + 4));
  3535. QDF_TRACE(QDF_MODULE_ID_TXRX,
  3536. QDF_TRACE_LEVEL_INFO,
  3537. "HTT_T2H_MSG_TYPE_PEER_UNMAP msg for peer id %d vdev id %d n",
  3538. peer_id, vdev_id);
  3539. dp_rx_peer_unmap_handler(soc->dp_soc, peer_id,
  3540. vdev_id, mac_addr,
  3541. is_wds, free_wds_count);
  3542. break;
  3543. }
  3544. case HTT_T2H_MSG_TYPE_RX_DELBA:
  3545. {
  3546. uint16_t peer_id;
  3547. uint8_t tid;
  3548. uint8_t win_sz;
  3549. QDF_STATUS status;
  3550. peer_id = HTT_RX_DELBA_PEER_ID_GET(*msg_word);
  3551. tid = HTT_RX_DELBA_TID_GET(*msg_word);
  3552. win_sz = HTT_RX_DELBA_WIN_SIZE_GET(*msg_word);
  3553. status = dp_rx_delba_ind_handler(
  3554. soc->dp_soc,
  3555. peer_id, tid, win_sz);
  3556. QDF_TRACE(QDF_MODULE_ID_TXRX,
  3557. QDF_TRACE_LEVEL_INFO,
  3558. FL("DELBA PeerID %d BAW %d TID %d stat %d"),
  3559. peer_id, win_sz, tid, status);
  3560. break;
  3561. }
  3562. case HTT_T2H_MSG_TYPE_RX_DELBA_EXTN:
  3563. {
  3564. uint16_t peer_id;
  3565. uint8_t tid;
  3566. uint16_t win_sz;
  3567. QDF_STATUS status;
  3568. peer_id = HTT_RX_DELBA_EXTN_PEER_ID_GET(*msg_word);
  3569. tid = HTT_RX_DELBA_EXTN_TID_GET(*msg_word);
  3570. msg_word++;
  3571. win_sz = HTT_RX_DELBA_EXTN_WIN_SIZE_GET(*msg_word);
  3572. status = dp_rx_delba_ind_handler(soc->dp_soc,
  3573. peer_id, tid,
  3574. win_sz);
  3575. dp_info("DELBA PeerID %d BAW %d TID %d stat %d",
  3576. peer_id, win_sz, tid, status);
  3577. break;
  3578. }
  3579. case HTT_T2H_MSG_TYPE_FSE_CMEM_BASE_SEND:
  3580. {
  3581. uint16_t num_entries;
  3582. uint32_t cmem_ba_lo;
  3583. uint32_t cmem_ba_hi;
  3584. num_entries = HTT_CMEM_BASE_SEND_NUM_ENTRIES_GET(*msg_word);
  3585. cmem_ba_lo = *(msg_word + 1);
  3586. cmem_ba_hi = *(msg_word + 2);
  3587. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO,
  3588. FL("CMEM FSE num_entries %u CMEM BA LO %x HI %x"),
  3589. num_entries, cmem_ba_lo, cmem_ba_hi);
  3590. dp_rx_fst_update_cmem_params(soc->dp_soc, num_entries,
  3591. cmem_ba_lo, cmem_ba_hi);
  3592. break;
  3593. }
  3594. case HTT_T2H_MSG_TYPE_TX_OFFLOAD_DELIVER_IND:
  3595. {
  3596. dp_offload_ind_handler(soc, msg_word);
  3597. break;
  3598. }
  3599. case HTT_T2H_MSG_TYPE_PEER_MAP_V3:
  3600. {
  3601. u_int8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  3602. u_int8_t *peer_mac_addr;
  3603. u_int16_t peer_id;
  3604. u_int16_t hw_peer_id;
  3605. u_int8_t vdev_id;
  3606. uint8_t is_wds;
  3607. u_int16_t ast_hash = 0;
  3608. peer_id = HTT_RX_PEER_MAP_V3_SW_PEER_ID_GET(*msg_word);
  3609. vdev_id = HTT_RX_PEER_MAP_V3_VDEV_ID_GET(*msg_word);
  3610. peer_mac_addr =
  3611. htt_t2h_mac_addr_deswizzle((u_int8_t *)(msg_word + 1),
  3612. &mac_addr_deswizzle_buf[0]);
  3613. hw_peer_id = HTT_RX_PEER_MAP_V3_HW_PEER_ID_GET(*(msg_word + 3));
  3614. ast_hash = HTT_RX_PEER_MAP_V3_CACHE_SET_NUM_GET(*(msg_word + 3));
  3615. is_wds = HTT_RX_PEER_MAP_V3_NEXT_HOP_GET(*(msg_word + 4));
  3616. dp_htt_info("HTT_T2H_MSG_TYPE_PEER_MAP_V3 msg for peer id %d vdev id %d n",
  3617. peer_id, vdev_id);
  3618. dp_rx_peer_map_handler(soc->dp_soc, peer_id,
  3619. hw_peer_id, vdev_id,
  3620. peer_mac_addr, ast_hash,
  3621. is_wds);
  3622. break;
  3623. }
  3624. case HTT_T2H_MSG_TYPE_PRIMARY_LINK_PEER_MIGRATE_IND:
  3625. {
  3626. dp_htt_t2h_primary_link_migration(soc, msg_word);
  3627. break;
  3628. }
  3629. case HTT_T2H_MSG_TYPE_MLO_RX_PEER_MAP:
  3630. {
  3631. dp_htt_mlo_peer_map_handler(soc, msg_word);
  3632. break;
  3633. }
  3634. case HTT_T2H_MSG_TYPE_MLO_RX_PEER_UNMAP:
  3635. {
  3636. dp_htt_mlo_peer_unmap_handler(soc, msg_word);
  3637. break;
  3638. }
  3639. case HTT_T2H_MSG_TYPE_MLO_TIMESTAMP_OFFSET_IND:
  3640. {
  3641. dp_rx_mlo_timestamp_ind_handler(soc->dp_soc, msg_word);
  3642. break;
  3643. }
  3644. case HTT_T2H_MSG_TYPE_VDEVS_TXRX_STATS_PERIODIC_IND:
  3645. {
  3646. dp_vdev_txrx_hw_stats_handler(soc, msg_word);
  3647. break;
  3648. }
  3649. case HTT_T2H_SAWF_DEF_QUEUES_MAP_REPORT_CONF:
  3650. {
  3651. dp_sawf_def_queues_update_map_report_conf(soc, msg_word,
  3652. htt_t2h_msg);
  3653. break;
  3654. }
  3655. case HTT_T2H_SAWF_MSDUQ_INFO_IND:
  3656. {
  3657. dp_sawf_msduq_map(soc, msg_word, htt_t2h_msg);
  3658. break;
  3659. }
  3660. case HTT_T2H_MSG_TYPE_PEER_AST_OVERRIDE_INDEX_IND:
  3661. {
  3662. dp_sawf_dynamic_ast_update(soc, msg_word, htt_t2h_msg);
  3663. break;
  3664. }
  3665. case HTT_T2H_MSG_TYPE_STREAMING_STATS_IND:
  3666. {
  3667. dp_sawf_mpdu_stats_handler(soc, htt_t2h_msg);
  3668. break;
  3669. }
  3670. case HTT_T2H_MSG_TYPE_RX_CCE_SUPER_RULE_SETUP_DONE:
  3671. {
  3672. dp_ipa_rx_cce_super_rule_setup_done_handler(soc, msg_word);
  3673. break;
  3674. }
  3675. case HTT_T2H_MSG_TYPE_PEER_EXTENDED_EVENT:
  3676. {
  3677. dp_htt_peer_ext_evt(soc, msg_word);
  3678. break;
  3679. }
  3680. default:
  3681. break;
  3682. };
  3683. /* Free the indication buffer */
  3684. if (free_buf)
  3685. dp_htt_rx_nbuf_free(htt_t2h_msg);
  3686. }
  3687. enum htc_send_full_action
  3688. dp_htt_h2t_full(void *context, HTC_PACKET *pkt)
  3689. {
  3690. return HTC_SEND_FULL_KEEP;
  3691. }
  3692. QDF_STATUS
  3693. dp_htt_hif_t2h_hp_callback (void *context, qdf_nbuf_t nbuf, uint8_t pipe_id)
  3694. {
  3695. QDF_STATUS rc = QDF_STATUS_SUCCESS;
  3696. HTC_PACKET htc_pkt;
  3697. qdf_assert_always(pipe_id == DP_HTT_T2H_HP_PIPE);
  3698. qdf_mem_zero(&htc_pkt, sizeof(htc_pkt));
  3699. htc_pkt.Status = QDF_STATUS_SUCCESS;
  3700. htc_pkt.pPktContext = (void *)nbuf;
  3701. dp_htt_t2h_msg_handler(context, &htc_pkt);
  3702. return rc;
  3703. }
  3704. /**
  3705. * htt_htc_soc_attach() - Register SOC level HTT instance with HTC
  3706. * @soc: HTT SOC handle
  3707. *
  3708. * Return: QDF_STATUS
  3709. */
  3710. static QDF_STATUS
  3711. htt_htc_soc_attach(struct htt_soc *soc)
  3712. {
  3713. struct htc_service_connect_req connect;
  3714. struct htc_service_connect_resp response;
  3715. QDF_STATUS status;
  3716. struct dp_soc *dpsoc = soc->dp_soc;
  3717. qdf_mem_zero(&connect, sizeof(connect));
  3718. qdf_mem_zero(&response, sizeof(response));
  3719. connect.pMetaData = NULL;
  3720. connect.MetaDataLength = 0;
  3721. connect.EpCallbacks.pContext = soc;
  3722. connect.EpCallbacks.EpTxComplete = dp_htt_h2t_send_complete;
  3723. connect.EpCallbacks.EpTxCompleteMultiple = NULL;
  3724. connect.EpCallbacks.EpRecv = dp_htt_t2h_msg_handler;
  3725. /* rx buffers currently are provided by HIF, not by EpRecvRefill */
  3726. connect.EpCallbacks.EpRecvRefill = NULL;
  3727. /* N/A, fill is done by HIF */
  3728. connect.EpCallbacks.RecvRefillWaterMark = 1;
  3729. connect.EpCallbacks.EpSendFull = dp_htt_h2t_full;
  3730. /*
  3731. * Specify how deep to let a queue get before htc_send_pkt will
  3732. * call the EpSendFull function due to excessive send queue depth.
  3733. */
  3734. connect.MaxSendQueueDepth = DP_HTT_MAX_SEND_QUEUE_DEPTH;
  3735. /* disable flow control for HTT data message service */
  3736. connect.ConnectionFlags |= HTC_CONNECT_FLAGS_DISABLE_CREDIT_FLOW_CTRL;
  3737. /* connect to control service */
  3738. connect.service_id = HTT_DATA_MSG_SVC;
  3739. status = htc_connect_service(soc->htc_soc, &connect, &response);
  3740. if (status != QDF_STATUS_SUCCESS)
  3741. return status;
  3742. soc->htc_endpoint = response.Endpoint;
  3743. hif_save_htc_htt_config_endpoint(dpsoc->hif_handle, soc->htc_endpoint);
  3744. htt_interface_logging_init(&soc->htt_logger_handle, soc->ctrl_psoc);
  3745. dp_hif_update_pipe_callback(soc->dp_soc, (void *)soc,
  3746. dp_htt_hif_t2h_hp_callback, DP_HTT_T2H_HP_PIPE);
  3747. return QDF_STATUS_SUCCESS; /* success */
  3748. }
  3749. void *
  3750. htt_soc_initialize(struct htt_soc *htt_soc,
  3751. struct cdp_ctrl_objmgr_psoc *ctrl_psoc,
  3752. HTC_HANDLE htc_soc,
  3753. hal_soc_handle_t hal_soc_hdl, qdf_device_t osdev)
  3754. {
  3755. struct htt_soc *soc = (struct htt_soc *)htt_soc;
  3756. soc->osdev = osdev;
  3757. soc->ctrl_psoc = ctrl_psoc;
  3758. soc->htc_soc = htc_soc;
  3759. soc->hal_soc = hal_soc_hdl;
  3760. if (htt_htc_soc_attach(soc))
  3761. goto fail2;
  3762. return soc;
  3763. fail2:
  3764. return NULL;
  3765. }
  3766. void htt_soc_htc_dealloc(struct htt_soc *htt_handle)
  3767. {
  3768. htt_interface_logging_deinit(htt_handle->htt_logger_handle);
  3769. htt_htc_misc_pkt_pool_free(htt_handle);
  3770. htt_htc_pkt_pool_free(htt_handle);
  3771. }
  3772. QDF_STATUS htt_soc_htc_prealloc(struct htt_soc *soc)
  3773. {
  3774. int i;
  3775. soc->htt_htc_pkt_freelist = NULL;
  3776. /* pre-allocate some HTC_PACKET objects */
  3777. for (i = 0; i < HTT_HTC_PKT_POOL_INIT_SIZE; i++) {
  3778. struct dp_htt_htc_pkt_union *pkt;
  3779. pkt = qdf_mem_malloc(sizeof(*pkt));
  3780. if (!pkt)
  3781. return QDF_STATUS_E_NOMEM;
  3782. htt_htc_pkt_free(soc, &pkt->u.pkt);
  3783. }
  3784. return QDF_STATUS_SUCCESS;
  3785. }
  3786. void htt_soc_detach(struct htt_soc *htt_hdl)
  3787. {
  3788. int i;
  3789. struct htt_soc *htt_handle = (struct htt_soc *)htt_hdl;
  3790. for (i = 0; i < MAX_PDEV_CNT; i++) {
  3791. qdf_mem_free(htt_handle->pdevid_tt[i].umac_path);
  3792. qdf_mem_free(htt_handle->pdevid_tt[i].lmac_path);
  3793. }
  3794. HTT_TX_MUTEX_DESTROY(&htt_handle->htt_tx_mutex);
  3795. qdf_mem_free(htt_handle);
  3796. }
  3797. /**
  3798. * dp_h2t_ext_stats_msg_send(): function to construct HTT message to pass to FW
  3799. * @pdev: DP PDEV handle
  3800. * @stats_type_upload_mask: stats type requested by user
  3801. * @config_param_0: extra configuration parameters
  3802. * @config_param_1: extra configuration parameters
  3803. * @config_param_2: extra configuration parameters
  3804. * @config_param_3: extra configuration parameters
  3805. * @cookie_val: cookie value
  3806. * @cookie_msb: msb of debug status cookie
  3807. * @mac_id: mac number
  3808. *
  3809. * return: QDF STATUS
  3810. */
  3811. QDF_STATUS dp_h2t_ext_stats_msg_send(struct dp_pdev *pdev,
  3812. uint32_t stats_type_upload_mask, uint32_t config_param_0,
  3813. uint32_t config_param_1, uint32_t config_param_2,
  3814. uint32_t config_param_3, int cookie_val, int cookie_msb,
  3815. uint8_t mac_id)
  3816. {
  3817. struct htt_soc *soc = pdev->soc->htt_handle;
  3818. struct dp_htt_htc_pkt *pkt;
  3819. qdf_nbuf_t msg;
  3820. uint32_t *msg_word;
  3821. uint8_t pdev_mask = 0;
  3822. uint8_t *htt_logger_bufp;
  3823. int mac_for_pdev;
  3824. int target_pdev_id;
  3825. QDF_STATUS status;
  3826. msg = qdf_nbuf_alloc(
  3827. soc->osdev,
  3828. HTT_MSG_BUF_SIZE(HTT_H2T_EXT_STATS_REQ_MSG_SZ),
  3829. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  3830. if (!msg)
  3831. return QDF_STATUS_E_NOMEM;
  3832. /*TODO:Add support for SOC stats
  3833. * Bit 0: SOC Stats
  3834. * Bit 1: Pdev stats for pdev id 0
  3835. * Bit 2: Pdev stats for pdev id 1
  3836. * Bit 3: Pdev stats for pdev id 2
  3837. */
  3838. mac_for_pdev = dp_get_mac_id_for_pdev(mac_id, pdev->pdev_id);
  3839. target_pdev_id =
  3840. dp_get_target_pdev_id_for_host_pdev_id(pdev->soc, mac_for_pdev);
  3841. pdev_mask = 1 << target_pdev_id;
  3842. /*
  3843. * Set the length of the message.
  3844. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  3845. * separately during the below call to qdf_nbuf_push_head.
  3846. * The contribution from the HTC header is added separately inside HTC.
  3847. */
  3848. if (qdf_nbuf_put_tail(msg, HTT_H2T_EXT_STATS_REQ_MSG_SZ) == NULL) {
  3849. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  3850. "Failed to expand head for HTT_EXT_STATS");
  3851. qdf_nbuf_free(msg);
  3852. return QDF_STATUS_E_FAILURE;
  3853. }
  3854. msg_word = (uint32_t *) qdf_nbuf_data(msg);
  3855. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  3856. htt_logger_bufp = (uint8_t *)msg_word;
  3857. *msg_word = 0;
  3858. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_EXT_STATS_REQ);
  3859. HTT_H2T_EXT_STATS_REQ_PDEV_MASK_SET(*msg_word, pdev_mask);
  3860. HTT_H2T_EXT_STATS_REQ_STATS_TYPE_SET(*msg_word, stats_type_upload_mask);
  3861. /* word 1 */
  3862. msg_word++;
  3863. *msg_word = 0;
  3864. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_0);
  3865. /* word 2 */
  3866. msg_word++;
  3867. *msg_word = 0;
  3868. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_1);
  3869. /* word 3 */
  3870. msg_word++;
  3871. *msg_word = 0;
  3872. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_2);
  3873. /* word 4 */
  3874. msg_word++;
  3875. *msg_word = 0;
  3876. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_3);
  3877. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, 0);
  3878. /* word 5 */
  3879. msg_word++;
  3880. /* word 6 */
  3881. msg_word++;
  3882. *msg_word = 0;
  3883. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, cookie_val);
  3884. /* word 7 */
  3885. msg_word++;
  3886. *msg_word = 0;
  3887. /* Currently Using last 2 bits for pdev_id
  3888. * For future reference, reserving 3 bits in cookie_msb for pdev_id
  3889. */
  3890. cookie_msb = (cookie_msb | pdev->pdev_id);
  3891. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, cookie_msb);
  3892. pkt = htt_htc_pkt_alloc(soc);
  3893. if (!pkt) {
  3894. qdf_nbuf_free(msg);
  3895. return QDF_STATUS_E_NOMEM;
  3896. }
  3897. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  3898. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  3899. dp_htt_h2t_send_complete_free_netbuf,
  3900. qdf_nbuf_data(msg), qdf_nbuf_len(msg),
  3901. soc->htc_endpoint,
  3902. /* tag for FW response msg not guaranteed */
  3903. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  3904. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  3905. status = DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_EXT_STATS_REQ,
  3906. htt_logger_bufp);
  3907. if (status != QDF_STATUS_SUCCESS) {
  3908. qdf_nbuf_free(msg);
  3909. htt_htc_pkt_free(soc, pkt);
  3910. }
  3911. return status;
  3912. }
  3913. #ifdef QCA_VDEV_STATS_HW_OFFLOAD_SUPPORT
  3914. #define HTT_VDEV_TXRX_STATS_RESET_BITMASK_L32_MASK 0xFFFFFFFF
  3915. #define HTT_VDEV_TXRX_STATS_RESET_BITMASK_U32_MASK 0xFFFFFFFF00000000
  3916. #define HTT_VDEV_TXRX_STATS_RESET_BITMASK_U32_SHIFT 32
  3917. QDF_STATUS dp_h2t_hw_vdev_stats_config_send(struct dp_soc *dpsoc,
  3918. uint8_t pdev_id, bool enable,
  3919. bool reset, uint64_t reset_bitmask)
  3920. {
  3921. struct htt_soc *soc = dpsoc->htt_handle;
  3922. struct dp_htt_htc_pkt *pkt;
  3923. qdf_nbuf_t msg;
  3924. uint32_t *msg_word;
  3925. uint8_t *htt_logger_bufp;
  3926. QDF_STATUS status;
  3927. int duration;
  3928. uint32_t bitmask;
  3929. int target_pdev_id;
  3930. msg = qdf_nbuf_alloc(
  3931. soc->osdev,
  3932. HTT_MSG_BUF_SIZE(sizeof(struct htt_h2t_vdevs_txrx_stats_cfg)),
  3933. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, true);
  3934. if (!msg) {
  3935. dp_htt_err("%pK: Fail to allocate "
  3936. "HTT_H2T_HW_VDEV_TXRX_STATS_CFG_MSG_SZ msg buffer", dpsoc);
  3937. return QDF_STATUS_E_NOMEM;
  3938. }
  3939. if (pdev_id != INVALID_PDEV_ID)
  3940. target_pdev_id = DP_SW2HW_MACID(pdev_id);
  3941. else
  3942. target_pdev_id = 0;
  3943. duration =
  3944. wlan_cfg_get_vdev_stats_hw_offload_timer(dpsoc->wlan_cfg_ctx);
  3945. /*
  3946. * Set the length of the message.
  3947. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  3948. * separately during the below call to qdf_nbuf_push_head.
  3949. * The contribution from the HTC header is added separately inside HTC.
  3950. */
  3951. if (!qdf_nbuf_put_tail(msg,
  3952. sizeof(struct htt_h2t_vdevs_txrx_stats_cfg))) {
  3953. dp_htt_err("%pK: Failed to expand head for HTT_HW_VDEV_STATS"
  3954. , dpsoc);
  3955. qdf_nbuf_free(msg);
  3956. return QDF_STATUS_E_FAILURE;
  3957. }
  3958. msg_word = (uint32_t *)qdf_nbuf_data(msg);
  3959. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  3960. htt_logger_bufp = (uint8_t *)msg_word;
  3961. *msg_word = 0;
  3962. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_VDEVS_TXRX_STATS_CFG);
  3963. HTT_RX_VDEVS_TXRX_STATS_PDEV_ID_SET(*msg_word, target_pdev_id);
  3964. HTT_RX_VDEVS_TXRX_STATS_ENABLE_SET(*msg_word, enable);
  3965. HTT_RX_VDEVS_TXRX_STATS_PERIODIC_INTERVAL_SET(*msg_word,
  3966. (duration >> 3));
  3967. HTT_RX_VDEVS_TXRX_STATS_RESET_STATS_BITS_SET(*msg_word, reset);
  3968. msg_word++;
  3969. *msg_word = 0;
  3970. bitmask = (reset_bitmask & HTT_VDEV_TXRX_STATS_RESET_BITMASK_L32_MASK);
  3971. *msg_word = bitmask;
  3972. msg_word++;
  3973. *msg_word = 0;
  3974. bitmask =
  3975. ((reset_bitmask & HTT_VDEV_TXRX_STATS_RESET_BITMASK_U32_MASK) >>
  3976. HTT_VDEV_TXRX_STATS_RESET_BITMASK_U32_SHIFT);
  3977. *msg_word = bitmask;
  3978. pkt = htt_htc_pkt_alloc(soc);
  3979. if (!pkt) {
  3980. dp_htt_err("%pK: Fail to allocate dp_htt_htc_pkt buffer",
  3981. dpsoc);
  3982. qdf_assert(0);
  3983. qdf_nbuf_free(msg);
  3984. return QDF_STATUS_E_NOMEM;
  3985. }
  3986. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  3987. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  3988. dp_htt_h2t_send_complete_free_netbuf,
  3989. qdf_nbuf_data(msg), qdf_nbuf_len(msg),
  3990. soc->htc_endpoint,
  3991. /* tag for no FW response msg */
  3992. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  3993. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  3994. status = DP_HTT_SEND_HTC_PKT(soc, pkt,
  3995. HTT_H2T_MSG_TYPE_VDEVS_TXRX_STATS_CFG,
  3996. htt_logger_bufp);
  3997. if (status != QDF_STATUS_SUCCESS) {
  3998. qdf_nbuf_free(msg);
  3999. htt_htc_pkt_free(soc, pkt);
  4000. }
  4001. return status;
  4002. }
  4003. #else
  4004. QDF_STATUS dp_h2t_hw_vdev_stats_config_send(struct dp_soc *dpsoc,
  4005. uint8_t pdev_id, bool enable,
  4006. bool reset, uint64_t reset_bitmask)
  4007. {
  4008. return QDF_STATUS_SUCCESS;
  4009. }
  4010. #endif
  4011. /**
  4012. * dp_h2t_3tuple_config_send(): function to construct 3 tuple configuration
  4013. * HTT message to pass to FW
  4014. * @pdev: DP PDEV handle
  4015. * @tuple_mask: tuple configuration to report 3 tuple hash value in either
  4016. * toeplitz_2_or_4 or flow_id_toeplitz in MSDU START TLV.
  4017. * @mac_id: mac id
  4018. *
  4019. * tuple_mask[1:0]:
  4020. * 00 - Do not report 3 tuple hash value
  4021. * 10 - Report 3 tuple hash value in toeplitz_2_or_4
  4022. * 01 - Report 3 tuple hash value in flow_id_toeplitz
  4023. * 11 - Report 3 tuple hash value in both toeplitz_2_or_4 & flow_id_toeplitz
  4024. *
  4025. * return: QDF STATUS
  4026. */
  4027. QDF_STATUS dp_h2t_3tuple_config_send(struct dp_pdev *pdev,
  4028. uint32_t tuple_mask, uint8_t mac_id)
  4029. {
  4030. struct htt_soc *soc = pdev->soc->htt_handle;
  4031. struct dp_htt_htc_pkt *pkt;
  4032. qdf_nbuf_t msg;
  4033. uint32_t *msg_word;
  4034. uint8_t *htt_logger_bufp;
  4035. int mac_for_pdev;
  4036. int target_pdev_id;
  4037. msg = qdf_nbuf_alloc(
  4038. soc->osdev,
  4039. HTT_MSG_BUF_SIZE(HTT_3_TUPLE_HASH_CFG_REQ_BYTES),
  4040. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  4041. if (!msg)
  4042. return QDF_STATUS_E_NOMEM;
  4043. mac_for_pdev = dp_get_mac_id_for_pdev(mac_id, pdev->pdev_id);
  4044. target_pdev_id =
  4045. dp_get_target_pdev_id_for_host_pdev_id(pdev->soc, mac_for_pdev);
  4046. /*
  4047. * Set the length of the message.
  4048. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4049. * separately during the below call to qdf_nbuf_push_head.
  4050. * The contribution from the HTC header is added separately inside HTC.
  4051. */
  4052. if (!qdf_nbuf_put_tail(msg, HTT_3_TUPLE_HASH_CFG_REQ_BYTES)) {
  4053. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  4054. "Failed to expand head for HTT_3TUPLE_CONFIG");
  4055. qdf_nbuf_free(msg);
  4056. return QDF_STATUS_E_FAILURE;
  4057. }
  4058. dp_htt_info("%pK: config_param_sent 0x%x for target_pdev %d\n -------------",
  4059. pdev->soc, tuple_mask, target_pdev_id);
  4060. msg_word = (uint32_t *)qdf_nbuf_data(msg);
  4061. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4062. htt_logger_bufp = (uint8_t *)msg_word;
  4063. *msg_word = 0;
  4064. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_3_TUPLE_HASH_CFG);
  4065. HTT_RX_3_TUPLE_HASH_PDEV_ID_SET(*msg_word, target_pdev_id);
  4066. msg_word++;
  4067. *msg_word = 0;
  4068. HTT_H2T_FLOW_ID_TOEPLITZ_FIELD_CONFIG_SET(*msg_word, tuple_mask);
  4069. HTT_H2T_TOEPLITZ_2_OR_4_FIELD_CONFIG_SET(*msg_word, tuple_mask);
  4070. pkt = htt_htc_pkt_alloc(soc);
  4071. if (!pkt) {
  4072. qdf_nbuf_free(msg);
  4073. return QDF_STATUS_E_NOMEM;
  4074. }
  4075. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4076. SET_HTC_PACKET_INFO_TX(
  4077. &pkt->htc_pkt,
  4078. dp_htt_h2t_send_complete_free_netbuf,
  4079. qdf_nbuf_data(msg),
  4080. qdf_nbuf_len(msg),
  4081. soc->htc_endpoint,
  4082. /* tag for no FW response msg */
  4083. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4084. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4085. DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_3_TUPLE_HASH_CFG,
  4086. htt_logger_bufp);
  4087. return QDF_STATUS_SUCCESS;
  4088. }
  4089. /* This macro will revert once proper HTT header will define for
  4090. * HTT_H2T_MSG_TYPE_PPDU_STATS_CFG in htt.h file
  4091. * */
  4092. #if defined(WDI_EVENT_ENABLE)
  4093. QDF_STATUS dp_h2t_cfg_stats_msg_send(struct dp_pdev *pdev,
  4094. uint32_t stats_type_upload_mask, uint8_t mac_id)
  4095. {
  4096. struct htt_soc *soc = pdev->soc->htt_handle;
  4097. struct dp_htt_htc_pkt *pkt;
  4098. qdf_nbuf_t msg;
  4099. uint32_t *msg_word;
  4100. uint8_t pdev_mask;
  4101. QDF_STATUS status;
  4102. msg = qdf_nbuf_alloc(
  4103. soc->osdev,
  4104. HTT_MSG_BUF_SIZE(HTT_H2T_PPDU_STATS_CFG_MSG_SZ),
  4105. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, true);
  4106. if (!msg) {
  4107. dp_htt_err("%pK: Fail to allocate HTT_H2T_PPDU_STATS_CFG_MSG_SZ msg buffer"
  4108. , pdev->soc);
  4109. qdf_assert(0);
  4110. return QDF_STATUS_E_NOMEM;
  4111. }
  4112. /*TODO:Add support for SOC stats
  4113. * Bit 0: SOC Stats
  4114. * Bit 1: Pdev stats for pdev id 0
  4115. * Bit 2: Pdev stats for pdev id 1
  4116. * Bit 3: Pdev stats for pdev id 2
  4117. */
  4118. pdev_mask = 1 << dp_get_target_pdev_id_for_host_pdev_id(pdev->soc,
  4119. mac_id);
  4120. /*
  4121. * Set the length of the message.
  4122. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4123. * separately during the below call to qdf_nbuf_push_head.
  4124. * The contribution from the HTC header is added separately inside HTC.
  4125. */
  4126. if (qdf_nbuf_put_tail(msg, HTT_H2T_PPDU_STATS_CFG_MSG_SZ) == NULL) {
  4127. dp_htt_err("%pK: Failed to expand head for HTT_CFG_STATS"
  4128. , pdev->soc);
  4129. qdf_nbuf_free(msg);
  4130. return QDF_STATUS_E_FAILURE;
  4131. }
  4132. msg_word = (uint32_t *) qdf_nbuf_data(msg);
  4133. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4134. *msg_word = 0;
  4135. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_PPDU_STATS_CFG);
  4136. HTT_H2T_PPDU_STATS_CFG_PDEV_MASK_SET(*msg_word, pdev_mask);
  4137. HTT_H2T_PPDU_STATS_CFG_TLV_BITMASK_SET(*msg_word,
  4138. stats_type_upload_mask);
  4139. pkt = htt_htc_pkt_alloc(soc);
  4140. if (!pkt) {
  4141. dp_htt_err("%pK: Fail to allocate dp_htt_htc_pkt buffer", pdev->soc);
  4142. qdf_assert(0);
  4143. qdf_nbuf_free(msg);
  4144. return QDF_STATUS_E_NOMEM;
  4145. }
  4146. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4147. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  4148. dp_htt_h2t_send_complete_free_netbuf,
  4149. qdf_nbuf_data(msg), qdf_nbuf_len(msg),
  4150. soc->htc_endpoint,
  4151. /* tag for no FW response msg */
  4152. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4153. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4154. status = DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_PPDU_STATS_CFG,
  4155. (uint8_t *)msg_word);
  4156. if (status != QDF_STATUS_SUCCESS) {
  4157. qdf_nbuf_free(msg);
  4158. htt_htc_pkt_free(soc, pkt);
  4159. }
  4160. return status;
  4161. }
  4162. qdf_export_symbol(dp_h2t_cfg_stats_msg_send);
  4163. #endif
  4164. void
  4165. dp_peer_update_inactive_time(struct dp_pdev *pdev, uint32_t tag_type,
  4166. uint32_t *tag_buf)
  4167. {
  4168. struct dp_peer *peer = NULL;
  4169. switch (tag_type) {
  4170. case HTT_STATS_PEER_DETAILS_TAG:
  4171. {
  4172. htt_peer_details_tlv *dp_stats_buf =
  4173. (htt_peer_details_tlv *)tag_buf;
  4174. pdev->fw_stats_peer_id = dp_stats_buf->sw_peer_id;
  4175. }
  4176. break;
  4177. case HTT_STATS_PEER_STATS_CMN_TAG:
  4178. {
  4179. htt_peer_stats_cmn_tlv *dp_stats_buf =
  4180. (htt_peer_stats_cmn_tlv *)tag_buf;
  4181. peer = dp_peer_get_ref_by_id(pdev->soc, pdev->fw_stats_peer_id,
  4182. DP_MOD_ID_HTT);
  4183. if (peer && !peer->bss_peer) {
  4184. peer->stats.tx.inactive_time =
  4185. dp_stats_buf->inactive_time;
  4186. qdf_event_set(&pdev->fw_peer_stats_event);
  4187. }
  4188. if (peer)
  4189. dp_peer_unref_delete(peer, DP_MOD_ID_HTT);
  4190. }
  4191. break;
  4192. default:
  4193. qdf_err("Invalid tag_type: %u", tag_type);
  4194. }
  4195. }
  4196. QDF_STATUS
  4197. dp_htt_rx_flow_fst_setup(struct dp_pdev *pdev,
  4198. struct dp_htt_rx_flow_fst_setup *fse_setup_info)
  4199. {
  4200. struct htt_soc *soc = pdev->soc->htt_handle;
  4201. struct dp_htt_htc_pkt *pkt;
  4202. qdf_nbuf_t msg;
  4203. u_int32_t *msg_word;
  4204. struct htt_h2t_msg_rx_fse_setup_t *fse_setup;
  4205. uint8_t *htt_logger_bufp;
  4206. u_int32_t *key;
  4207. QDF_STATUS status;
  4208. msg = qdf_nbuf_alloc(
  4209. soc->osdev,
  4210. HTT_MSG_BUF_SIZE(sizeof(struct htt_h2t_msg_rx_fse_setup_t)),
  4211. /* reserve room for the HTC header */
  4212. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  4213. if (!msg)
  4214. return QDF_STATUS_E_NOMEM;
  4215. /*
  4216. * Set the length of the message.
  4217. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4218. * separately during the below call to qdf_nbuf_push_head.
  4219. * The contribution from the HTC header is added separately inside HTC.
  4220. */
  4221. if (!qdf_nbuf_put_tail(msg,
  4222. sizeof(struct htt_h2t_msg_rx_fse_setup_t))) {
  4223. qdf_err("Failed to expand head for HTT RX_FSE_SETUP msg");
  4224. return QDF_STATUS_E_FAILURE;
  4225. }
  4226. /* fill in the message contents */
  4227. msg_word = (u_int32_t *)qdf_nbuf_data(msg);
  4228. memset(msg_word, 0, sizeof(struct htt_h2t_msg_rx_fse_setup_t));
  4229. /* rewind beyond alignment pad to get to the HTC header reserved area */
  4230. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4231. htt_logger_bufp = (uint8_t *)msg_word;
  4232. *msg_word = 0;
  4233. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RX_FSE_SETUP_CFG);
  4234. fse_setup = (struct htt_h2t_msg_rx_fse_setup_t *)msg_word;
  4235. HTT_RX_FSE_SETUP_PDEV_ID_SET(*msg_word, fse_setup_info->pdev_id);
  4236. msg_word++;
  4237. HTT_RX_FSE_SETUP_NUM_REC_SET(*msg_word, fse_setup_info->max_entries);
  4238. HTT_RX_FSE_SETUP_MAX_SEARCH_SET(*msg_word, fse_setup_info->max_search);
  4239. HTT_RX_FSE_SETUP_IP_DA_SA_PREFIX_SET(*msg_word,
  4240. fse_setup_info->ip_da_sa_prefix);
  4241. msg_word++;
  4242. HTT_RX_FSE_SETUP_BASE_ADDR_LO_SET(*msg_word,
  4243. fse_setup_info->base_addr_lo);
  4244. msg_word++;
  4245. HTT_RX_FSE_SETUP_BASE_ADDR_HI_SET(*msg_word,
  4246. fse_setup_info->base_addr_hi);
  4247. key = (u_int32_t *)fse_setup_info->hash_key;
  4248. fse_setup->toeplitz31_0 = *key++;
  4249. fse_setup->toeplitz63_32 = *key++;
  4250. fse_setup->toeplitz95_64 = *key++;
  4251. fse_setup->toeplitz127_96 = *key++;
  4252. fse_setup->toeplitz159_128 = *key++;
  4253. fse_setup->toeplitz191_160 = *key++;
  4254. fse_setup->toeplitz223_192 = *key++;
  4255. fse_setup->toeplitz255_224 = *key++;
  4256. fse_setup->toeplitz287_256 = *key++;
  4257. fse_setup->toeplitz314_288 = *key;
  4258. msg_word++;
  4259. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz31_0);
  4260. msg_word++;
  4261. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz63_32);
  4262. msg_word++;
  4263. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz95_64);
  4264. msg_word++;
  4265. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz127_96);
  4266. msg_word++;
  4267. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz159_128);
  4268. msg_word++;
  4269. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz191_160);
  4270. msg_word++;
  4271. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz223_192);
  4272. msg_word++;
  4273. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz255_224);
  4274. msg_word++;
  4275. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz287_256);
  4276. msg_word++;
  4277. HTT_RX_FSE_SETUP_HASH_314_288_SET(*msg_word,
  4278. fse_setup->toeplitz314_288);
  4279. pkt = htt_htc_pkt_alloc(soc);
  4280. if (!pkt) {
  4281. qdf_err("Fail to allocate dp_htt_htc_pkt buffer");
  4282. qdf_assert(0);
  4283. qdf_nbuf_free(msg);
  4284. return QDF_STATUS_E_RESOURCES; /* failure */
  4285. }
  4286. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4287. SET_HTC_PACKET_INFO_TX(
  4288. &pkt->htc_pkt,
  4289. dp_htt_h2t_send_complete_free_netbuf,
  4290. qdf_nbuf_data(msg),
  4291. qdf_nbuf_len(msg),
  4292. soc->htc_endpoint,
  4293. /* tag for no FW response msg */
  4294. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4295. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4296. status = DP_HTT_SEND_HTC_PKT(soc, pkt,
  4297. HTT_H2T_MSG_TYPE_RX_FSE_SETUP_CFG,
  4298. htt_logger_bufp);
  4299. if (status == QDF_STATUS_SUCCESS) {
  4300. dp_info("HTT_H2T RX_FSE_SETUP sent to FW for pdev = %u",
  4301. fse_setup_info->pdev_id);
  4302. QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_ANY, QDF_TRACE_LEVEL_DEBUG,
  4303. (void *)fse_setup_info->hash_key,
  4304. fse_setup_info->hash_key_len);
  4305. } else {
  4306. qdf_nbuf_free(msg);
  4307. htt_htc_pkt_free(soc, pkt);
  4308. }
  4309. return status;
  4310. }
  4311. QDF_STATUS
  4312. dp_htt_rx_flow_fse_operation(struct dp_pdev *pdev,
  4313. struct dp_htt_rx_flow_fst_operation *fse_op_info)
  4314. {
  4315. struct htt_soc *soc = pdev->soc->htt_handle;
  4316. struct dp_htt_htc_pkt *pkt;
  4317. qdf_nbuf_t msg;
  4318. u_int32_t *msg_word;
  4319. struct htt_h2t_msg_rx_fse_operation_t *fse_operation;
  4320. uint8_t *htt_logger_bufp;
  4321. QDF_STATUS status;
  4322. msg = qdf_nbuf_alloc(
  4323. soc->osdev,
  4324. HTT_MSG_BUF_SIZE(sizeof(struct htt_h2t_msg_rx_fse_operation_t)),
  4325. /* reserve room for the HTC header */
  4326. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  4327. if (!msg)
  4328. return QDF_STATUS_E_NOMEM;
  4329. /*
  4330. * Set the length of the message.
  4331. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4332. * separately during the below call to qdf_nbuf_push_head.
  4333. * The contribution from the HTC header is added separately inside HTC.
  4334. */
  4335. if (!qdf_nbuf_put_tail(msg,
  4336. sizeof(struct htt_h2t_msg_rx_fse_operation_t))) {
  4337. qdf_err("Failed to expand head for HTT_RX_FSE_OPERATION msg");
  4338. qdf_nbuf_free(msg);
  4339. return QDF_STATUS_E_FAILURE;
  4340. }
  4341. /* fill in the message contents */
  4342. msg_word = (u_int32_t *)qdf_nbuf_data(msg);
  4343. memset(msg_word, 0, sizeof(struct htt_h2t_msg_rx_fse_operation_t));
  4344. /* rewind beyond alignment pad to get to the HTC header reserved area */
  4345. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4346. htt_logger_bufp = (uint8_t *)msg_word;
  4347. *msg_word = 0;
  4348. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RX_FSE_OPERATION_CFG);
  4349. fse_operation = (struct htt_h2t_msg_rx_fse_operation_t *)msg_word;
  4350. HTT_RX_FSE_OPERATION_PDEV_ID_SET(*msg_word, fse_op_info->pdev_id);
  4351. msg_word++;
  4352. HTT_RX_FSE_IPSEC_VALID_SET(*msg_word, false);
  4353. if (fse_op_info->op_code == DP_HTT_FST_CACHE_INVALIDATE_ENTRY) {
  4354. HTT_RX_FSE_OPERATION_SET(*msg_word,
  4355. HTT_RX_FSE_CACHE_INVALIDATE_ENTRY);
  4356. msg_word++;
  4357. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4358. *msg_word,
  4359. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_31_0));
  4360. msg_word++;
  4361. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4362. *msg_word,
  4363. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_63_32));
  4364. msg_word++;
  4365. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4366. *msg_word,
  4367. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_95_64));
  4368. msg_word++;
  4369. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4370. *msg_word,
  4371. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_127_96));
  4372. msg_word++;
  4373. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4374. *msg_word,
  4375. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.dest_ip_31_0));
  4376. msg_word++;
  4377. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4378. *msg_word,
  4379. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.dest_ip_63_32));
  4380. msg_word++;
  4381. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4382. *msg_word,
  4383. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.dest_ip_95_64));
  4384. msg_word++;
  4385. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4386. *msg_word,
  4387. qdf_htonl(
  4388. fse_op_info->rx_flow->flow_tuple_info.dest_ip_127_96));
  4389. msg_word++;
  4390. HTT_RX_FSE_SOURCEPORT_SET(
  4391. *msg_word,
  4392. fse_op_info->rx_flow->flow_tuple_info.src_port);
  4393. HTT_RX_FSE_DESTPORT_SET(
  4394. *msg_word,
  4395. fse_op_info->rx_flow->flow_tuple_info.dest_port);
  4396. msg_word++;
  4397. HTT_RX_FSE_L4_PROTO_SET(
  4398. *msg_word,
  4399. fse_op_info->rx_flow->flow_tuple_info.l4_protocol);
  4400. } else if (fse_op_info->op_code == DP_HTT_FST_CACHE_INVALIDATE_FULL) {
  4401. HTT_RX_FSE_OPERATION_SET(*msg_word,
  4402. HTT_RX_FSE_CACHE_INVALIDATE_FULL);
  4403. } else if (fse_op_info->op_code == DP_HTT_FST_DISABLE) {
  4404. HTT_RX_FSE_OPERATION_SET(*msg_word, HTT_RX_FSE_DISABLE);
  4405. } else if (fse_op_info->op_code == DP_HTT_FST_ENABLE) {
  4406. HTT_RX_FSE_OPERATION_SET(*msg_word, HTT_RX_FSE_ENABLE);
  4407. }
  4408. pkt = htt_htc_pkt_alloc(soc);
  4409. if (!pkt) {
  4410. qdf_err("Fail to allocate dp_htt_htc_pkt buffer");
  4411. qdf_assert(0);
  4412. qdf_nbuf_free(msg);
  4413. return QDF_STATUS_E_RESOURCES; /* failure */
  4414. }
  4415. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4416. SET_HTC_PACKET_INFO_TX(
  4417. &pkt->htc_pkt,
  4418. dp_htt_h2t_send_complete_free_netbuf,
  4419. qdf_nbuf_data(msg),
  4420. qdf_nbuf_len(msg),
  4421. soc->htc_endpoint,
  4422. /* tag for no FW response msg */
  4423. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4424. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4425. status = DP_HTT_SEND_HTC_PKT(soc, pkt,
  4426. HTT_H2T_MSG_TYPE_RX_FSE_OPERATION_CFG,
  4427. htt_logger_bufp);
  4428. if (status == QDF_STATUS_SUCCESS) {
  4429. dp_info("HTT_H2T RX_FSE_OPERATION_CFG sent to FW for pdev = %u",
  4430. fse_op_info->pdev_id);
  4431. } else {
  4432. qdf_nbuf_free(msg);
  4433. htt_htc_pkt_free(soc, pkt);
  4434. }
  4435. return status;
  4436. }
  4437. /**
  4438. * dp_htt_rx_fisa_config(): Send HTT msg to configure FISA
  4439. * @pdev: DP pdev handle
  4440. * @fisa_config: Fisa config struct
  4441. *
  4442. * Return: Success when HTT message is sent, error on failure
  4443. */
  4444. QDF_STATUS
  4445. dp_htt_rx_fisa_config(struct dp_pdev *pdev,
  4446. struct dp_htt_rx_fisa_cfg *fisa_config)
  4447. {
  4448. struct htt_soc *soc = pdev->soc->htt_handle;
  4449. struct dp_htt_htc_pkt *pkt;
  4450. qdf_nbuf_t msg;
  4451. u_int32_t *msg_word;
  4452. struct htt_h2t_msg_type_fisa_config_t *htt_fisa_config;
  4453. uint8_t *htt_logger_bufp;
  4454. uint32_t len;
  4455. QDF_STATUS status;
  4456. len = HTT_MSG_BUF_SIZE(sizeof(struct htt_h2t_msg_type_fisa_config_t));
  4457. msg = qdf_nbuf_alloc(soc->osdev,
  4458. len,
  4459. /* reserve room for the HTC header */
  4460. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING,
  4461. 4,
  4462. TRUE);
  4463. if (!msg)
  4464. return QDF_STATUS_E_NOMEM;
  4465. /*
  4466. * Set the length of the message.
  4467. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4468. * separately during the below call to qdf_nbuf_push_head.
  4469. * The contribution from the HTC header is added separately inside HTC.
  4470. */
  4471. if (!qdf_nbuf_put_tail(msg,
  4472. sizeof(struct htt_h2t_msg_type_fisa_config_t))) {
  4473. qdf_err("Failed to expand head for HTT_RX_FSE_OPERATION msg");
  4474. qdf_nbuf_free(msg);
  4475. return QDF_STATUS_E_FAILURE;
  4476. }
  4477. /* fill in the message contents */
  4478. msg_word = (u_int32_t *)qdf_nbuf_data(msg);
  4479. memset(msg_word, 0, sizeof(struct htt_h2t_msg_type_fisa_config_t));
  4480. /* rewind beyond alignment pad to get to the HTC header reserved area */
  4481. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4482. htt_logger_bufp = (uint8_t *)msg_word;
  4483. *msg_word = 0;
  4484. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RX_FISA_CFG);
  4485. htt_fisa_config = (struct htt_h2t_msg_type_fisa_config_t *)msg_word;
  4486. HTT_RX_FSE_OPERATION_PDEV_ID_SET(*msg_word, htt_fisa_config->pdev_id);
  4487. msg_word++;
  4488. HTT_RX_FISA_CONFIG_FISA_V2_ENABLE_SET(*msg_word, 1);
  4489. HTT_RX_FISA_CONFIG_FISA_V2_AGGR_LIMIT_SET(*msg_word,
  4490. (fisa_config->max_aggr_supported ? fisa_config->max_aggr_supported : 0xf));
  4491. msg_word++;
  4492. htt_fisa_config->fisa_timeout_threshold = fisa_config->fisa_timeout;
  4493. pkt = htt_htc_pkt_alloc(soc);
  4494. if (!pkt) {
  4495. qdf_err("Fail to allocate dp_htt_htc_pkt buffer");
  4496. qdf_assert(0);
  4497. qdf_nbuf_free(msg);
  4498. return QDF_STATUS_E_RESOURCES; /* failure */
  4499. }
  4500. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4501. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  4502. dp_htt_h2t_send_complete_free_netbuf,
  4503. qdf_nbuf_data(msg),
  4504. qdf_nbuf_len(msg),
  4505. soc->htc_endpoint,
  4506. /* tag for no FW response msg */
  4507. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4508. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4509. status = DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_RX_FISA_CFG,
  4510. htt_logger_bufp);
  4511. if (status == QDF_STATUS_SUCCESS) {
  4512. dp_info("HTT_H2T_MSG_TYPE_RX_FISA_CFG sent to FW for pdev = %u",
  4513. fisa_config->pdev_id);
  4514. } else {
  4515. qdf_nbuf_free(msg);
  4516. htt_htc_pkt_free(soc, pkt);
  4517. }
  4518. return status;
  4519. }
  4520. #ifdef WLAN_SUPPORT_PPEDS
  4521. /**
  4522. * dp_htt_rxdma_rxole_ppe_cfg_set() - Send RxOLE and RxDMA PPE config
  4523. * @soc: Data path SoC handle
  4524. * @cfg: RxDMA and RxOLE PPE config
  4525. *
  4526. * Return: Success when HTT message is sent, error on failure
  4527. */
  4528. QDF_STATUS
  4529. dp_htt_rxdma_rxole_ppe_cfg_set(struct dp_soc *soc,
  4530. struct dp_htt_rxdma_rxole_ppe_config *cfg)
  4531. {
  4532. struct htt_soc *htt_handle = soc->htt_handle;
  4533. uint32_t len;
  4534. qdf_nbuf_t msg;
  4535. u_int32_t *msg_word;
  4536. QDF_STATUS status;
  4537. uint8_t *htt_logger_bufp;
  4538. struct dp_htt_htc_pkt *pkt;
  4539. len = HTT_MSG_BUF_SIZE(
  4540. sizeof(struct htt_h2t_msg_type_rxdma_rxole_ppe_cfg_t));
  4541. msg = qdf_nbuf_alloc(soc->osdev,
  4542. len,
  4543. /* reserve room for the HTC header */
  4544. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING,
  4545. 4,
  4546. TRUE);
  4547. if (!msg)
  4548. return QDF_STATUS_E_NOMEM;
  4549. /*
  4550. * Set the length of the message.
  4551. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4552. * separately during the below call to qdf_nbuf_push_head.
  4553. * The contribution from the HTC header is added separately inside HTC.
  4554. */
  4555. if (!qdf_nbuf_put_tail(
  4556. msg, sizeof(struct htt_h2t_msg_type_rxdma_rxole_ppe_cfg_t))) {
  4557. qdf_err("Failed to expand head for HTT_H2T_MSG_TYPE_RXDMA_RXOLE_PPE_CFG msg");
  4558. qdf_nbuf_free(msg);
  4559. return QDF_STATUS_E_FAILURE;
  4560. }
  4561. /* fill in the message contents */
  4562. msg_word = (u_int32_t *)qdf_nbuf_data(msg);
  4563. memset(msg_word, 0,
  4564. sizeof(struct htt_h2t_msg_type_rxdma_rxole_ppe_cfg_t));
  4565. /* Rewind beyond alignment pad to get to the HTC header reserved area */
  4566. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4567. htt_logger_bufp = (uint8_t *)msg_word;
  4568. *msg_word = 0;
  4569. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RXDMA_RXOLE_PPE_CFG);
  4570. HTT_PPE_CFG_OVERRIDE_SET(*msg_word, cfg->override);
  4571. HTT_PPE_CFG_REO_DEST_IND_SET(
  4572. *msg_word, cfg->reo_destination_indication);
  4573. HTT_PPE_CFG_MULTI_BUF_MSDU_OVERRIDE_EN_SET(
  4574. *msg_word, cfg->multi_buffer_msdu_override_en);
  4575. HTT_PPE_CFG_INTRA_BSS_OVERRIDE_EN_SET(
  4576. *msg_word, cfg->intra_bss_override);
  4577. HTT_PPE_CFG_DECAP_RAW_OVERRIDE_EN_SET(
  4578. *msg_word, cfg->decap_raw_override);
  4579. HTT_PPE_CFG_DECAP_NWIFI_OVERRIDE_EN_SET(
  4580. *msg_word, cfg->decap_nwifi_override);
  4581. HTT_PPE_CFG_IP_FRAG_OVERRIDE_EN_SET(
  4582. *msg_word, cfg->ip_frag_override);
  4583. pkt = htt_htc_pkt_alloc(htt_handle);
  4584. if (!pkt) {
  4585. qdf_err("Fail to allocate dp_htt_htc_pkt buffer");
  4586. qdf_assert(0);
  4587. qdf_nbuf_free(msg);
  4588. return QDF_STATUS_E_RESOURCES; /* failure */
  4589. }
  4590. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4591. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  4592. dp_htt_h2t_send_complete_free_netbuf,
  4593. qdf_nbuf_data(msg),
  4594. qdf_nbuf_len(msg),
  4595. htt_handle->htc_endpoint,
  4596. /* tag for no FW response msg */
  4597. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4598. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4599. status = DP_HTT_SEND_HTC_PKT(htt_handle, pkt,
  4600. HTT_H2T_MSG_TYPE_RXDMA_RXOLE_PPE_CFG,
  4601. htt_logger_bufp);
  4602. if (status != QDF_STATUS_SUCCESS) {
  4603. qdf_nbuf_free(msg);
  4604. htt_htc_pkt_free(htt_handle, pkt);
  4605. return status;
  4606. }
  4607. dp_info("HTT_H2T_MSG_TYPE_RXDMA_RXOLE_PPE_CFG sent");
  4608. return status;
  4609. }
  4610. #endif /* WLAN_SUPPORT_PPEDS */
  4611. /**
  4612. * dp_bk_pressure_stats_handler(): worker function to print back pressure
  4613. * stats
  4614. *
  4615. * @context : argument to work function
  4616. */
  4617. static void dp_bk_pressure_stats_handler(void *context)
  4618. {
  4619. struct dp_pdev *pdev = (struct dp_pdev *)context;
  4620. struct dp_soc_srngs_state *soc_srngs_state = NULL;
  4621. const char *ring_name;
  4622. int i;
  4623. struct dp_srng_ring_state *ring_state;
  4624. bool empty_flag;
  4625. qdf_spin_lock_bh(&pdev->bkp_stats.list_lock);
  4626. /* Extract only first entry for printing in one work event */
  4627. if (pdev->bkp_stats.queue_depth &&
  4628. !TAILQ_EMPTY(&pdev->bkp_stats.list)) {
  4629. soc_srngs_state = TAILQ_FIRST(&pdev->bkp_stats.list);
  4630. TAILQ_REMOVE(&pdev->bkp_stats.list, soc_srngs_state,
  4631. list_elem);
  4632. pdev->bkp_stats.queue_depth--;
  4633. }
  4634. empty_flag = TAILQ_EMPTY(&pdev->bkp_stats.list);
  4635. qdf_spin_unlock_bh(&pdev->bkp_stats.list_lock);
  4636. if (soc_srngs_state) {
  4637. DP_PRINT_STATS("### BKP stats for seq_num %u START ###",
  4638. soc_srngs_state->seq_num);
  4639. for (i = 0; i < soc_srngs_state->max_ring_id; i++) {
  4640. ring_state = &soc_srngs_state->ring_state[i];
  4641. ring_name = dp_srng_get_str_from_hal_ring_type
  4642. (ring_state->ring_type);
  4643. DP_PRINT_STATS("%s: SW:Head pointer = %d Tail Pointer = %d\n",
  4644. ring_name,
  4645. ring_state->sw_head,
  4646. ring_state->sw_tail);
  4647. DP_PRINT_STATS("%s: HW:Head pointer = %d Tail Pointer = %d\n",
  4648. ring_name,
  4649. ring_state->hw_head,
  4650. ring_state->hw_tail);
  4651. }
  4652. DP_PRINT_STATS("### BKP stats for seq_num %u COMPLETE ###",
  4653. soc_srngs_state->seq_num);
  4654. qdf_mem_free(soc_srngs_state);
  4655. }
  4656. dp_print_napi_stats(pdev->soc);
  4657. /* Schedule work again if queue is not empty */
  4658. if (!empty_flag)
  4659. qdf_queue_work(0, pdev->bkp_stats.work_queue,
  4660. &pdev->bkp_stats.work);
  4661. }
  4662. void dp_pdev_bkp_stats_detach(struct dp_pdev *pdev)
  4663. {
  4664. struct dp_soc_srngs_state *ring_state, *ring_state_next;
  4665. if (!pdev->bkp_stats.work_queue)
  4666. return;
  4667. qdf_flush_workqueue(0, pdev->bkp_stats.work_queue);
  4668. qdf_destroy_workqueue(0, pdev->bkp_stats.work_queue);
  4669. qdf_flush_work(&pdev->bkp_stats.work);
  4670. qdf_disable_work(&pdev->bkp_stats.work);
  4671. qdf_spin_lock_bh(&pdev->bkp_stats.list_lock);
  4672. TAILQ_FOREACH_SAFE(ring_state, &pdev->bkp_stats.list,
  4673. list_elem, ring_state_next) {
  4674. TAILQ_REMOVE(&pdev->bkp_stats.list, ring_state,
  4675. list_elem);
  4676. qdf_mem_free(ring_state);
  4677. }
  4678. qdf_spin_unlock_bh(&pdev->bkp_stats.list_lock);
  4679. qdf_spinlock_destroy(&pdev->bkp_stats.list_lock);
  4680. }
  4681. QDF_STATUS dp_pdev_bkp_stats_attach(struct dp_pdev *pdev)
  4682. {
  4683. TAILQ_INIT(&pdev->bkp_stats.list);
  4684. pdev->bkp_stats.seq_num = 0;
  4685. pdev->bkp_stats.queue_depth = 0;
  4686. qdf_create_work(0, &pdev->bkp_stats.work,
  4687. dp_bk_pressure_stats_handler, pdev);
  4688. pdev->bkp_stats.work_queue =
  4689. qdf_alloc_unbound_workqueue("dp_bkp_work_queue");
  4690. if (!pdev->bkp_stats.work_queue)
  4691. goto fail;
  4692. qdf_spinlock_create(&pdev->bkp_stats.list_lock);
  4693. return QDF_STATUS_SUCCESS;
  4694. fail:
  4695. dp_htt_alert("BKP stats attach failed");
  4696. qdf_flush_work(&pdev->bkp_stats.work);
  4697. qdf_disable_work(&pdev->bkp_stats.work);
  4698. return QDF_STATUS_E_FAILURE;
  4699. }
  4700. #ifdef DP_UMAC_HW_RESET_SUPPORT
  4701. QDF_STATUS dp_htt_umac_reset_send_setup_cmd(
  4702. struct dp_soc *soc,
  4703. const struct dp_htt_umac_reset_setup_cmd_params *setup_params)
  4704. {
  4705. struct htt_soc *htt_handle = soc->htt_handle;
  4706. uint32_t len;
  4707. qdf_nbuf_t msg;
  4708. u_int32_t *msg_word;
  4709. QDF_STATUS status;
  4710. uint8_t *htt_logger_bufp;
  4711. struct dp_htt_htc_pkt *pkt;
  4712. len = HTT_MSG_BUF_SIZE(
  4713. HTT_H2T_UMAC_HANG_RECOVERY_PREREQUISITE_SETUP_BYTES);
  4714. msg = qdf_nbuf_alloc(soc->osdev,
  4715. len,
  4716. /* reserve room for the HTC header */
  4717. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING,
  4718. 4,
  4719. TRUE);
  4720. if (!msg)
  4721. return QDF_STATUS_E_NOMEM;
  4722. /*
  4723. * Set the length of the message.
  4724. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4725. * separately during the below call to qdf_nbuf_push_head.
  4726. * The contribution from the HTC header is added separately inside HTC.
  4727. */
  4728. if (!qdf_nbuf_put_tail(
  4729. msg, HTT_H2T_UMAC_HANG_RECOVERY_PREREQUISITE_SETUP_BYTES)) {
  4730. dp_htt_err("Failed to expand head");
  4731. qdf_nbuf_free(msg);
  4732. return QDF_STATUS_E_FAILURE;
  4733. }
  4734. /* fill in the message contents */
  4735. msg_word = (uint32_t *)qdf_nbuf_data(msg);
  4736. /* Rewind beyond alignment pad to get to the HTC header reserved area */
  4737. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4738. htt_logger_bufp = (uint8_t *)msg_word;
  4739. qdf_mem_zero(msg_word,
  4740. HTT_H2T_UMAC_HANG_RECOVERY_PREREQUISITE_SETUP_BYTES);
  4741. HTT_H2T_MSG_TYPE_SET(
  4742. *msg_word,
  4743. HTT_H2T_MSG_TYPE_UMAC_HANG_RECOVERY_PREREQUISITE_SETUP);
  4744. HTT_H2T_UMAC_HANG_RECOVERY_PREREQUISITE_SETUP_T2H_MSG_METHOD_SET(
  4745. *msg_word, htt_umac_hang_recovery_msg_t2h_msi_and_h2t_polling);
  4746. HTT_H2T_UMAC_HANG_RECOVERY_PREREQUISITE_SETUP_H2T_MSG_METHOD_SET(
  4747. *msg_word, htt_umac_hang_recovery_msg_t2h_msi_and_h2t_polling);
  4748. msg_word++;
  4749. *msg_word = setup_params->msi_data;
  4750. msg_word++;
  4751. *msg_word = sizeof(htt_umac_hang_recovery_msg_shmem_t);
  4752. msg_word++;
  4753. *msg_word = setup_params->shmem_addr_low;
  4754. msg_word++;
  4755. *msg_word = setup_params->shmem_addr_high;
  4756. pkt = htt_htc_pkt_alloc(htt_handle);
  4757. if (!pkt) {
  4758. qdf_err("Fail to allocate dp_htt_htc_pkt buffer");
  4759. qdf_assert(0);
  4760. qdf_nbuf_free(msg);
  4761. return QDF_STATUS_E_NOMEM;
  4762. }
  4763. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4764. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  4765. dp_htt_h2t_send_complete_free_netbuf,
  4766. qdf_nbuf_data(msg),
  4767. qdf_nbuf_len(msg),
  4768. htt_handle->htc_endpoint,
  4769. /* tag for no FW response msg */
  4770. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4771. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4772. status = DP_HTT_SEND_HTC_PKT(
  4773. htt_handle, pkt,
  4774. HTT_H2T_MSG_TYPE_UMAC_HANG_RECOVERY_PREREQUISITE_SETUP,
  4775. htt_logger_bufp);
  4776. if (QDF_IS_STATUS_ERROR(status)) {
  4777. qdf_nbuf_free(msg);
  4778. htt_htc_pkt_free(htt_handle, pkt);
  4779. return status;
  4780. }
  4781. dp_info("HTT_H2T_MSG_TYPE_UMAC_HANG_RECOVERY_PREREQUISITE_SETUP sent");
  4782. return status;
  4783. }
  4784. QDF_STATUS dp_htt_umac_reset_send_start_pre_reset_cmd(
  4785. struct dp_soc *soc, bool is_initiator, bool is_umac_hang)
  4786. {
  4787. struct htt_soc *htt_handle = soc->htt_handle;
  4788. uint32_t len;
  4789. qdf_nbuf_t msg;
  4790. u_int32_t *msg_word;
  4791. QDF_STATUS status;
  4792. uint8_t *htt_logger_bufp;
  4793. struct dp_htt_htc_pkt *pkt;
  4794. len = HTT_MSG_BUF_SIZE(
  4795. HTT_H2T_UMAC_HANG_RECOVERY_START_PRE_RESET_BYTES);
  4796. msg = qdf_nbuf_alloc(soc->osdev,
  4797. len,
  4798. /* reserve room for the HTC header */
  4799. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING,
  4800. 4,
  4801. TRUE);
  4802. if (!msg)
  4803. return QDF_STATUS_E_NOMEM;
  4804. /*
  4805. * Set the length of the message.
  4806. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4807. * separately during the below call to qdf_nbuf_push_head.
  4808. * The contribution from the HTC header is added separately inside HTC.
  4809. */
  4810. if (!qdf_nbuf_put_tail(
  4811. msg, HTT_H2T_UMAC_HANG_RECOVERY_START_PRE_RESET_BYTES)) {
  4812. dp_htt_err("Failed to expand head");
  4813. qdf_nbuf_free(msg);
  4814. return QDF_STATUS_E_FAILURE;
  4815. }
  4816. /* fill in the message contents */
  4817. msg_word = (uint32_t *)qdf_nbuf_data(msg);
  4818. /* Rewind beyond alignment pad to get to the HTC header reserved area */
  4819. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4820. htt_logger_bufp = (uint8_t *)msg_word;
  4821. qdf_mem_zero(msg_word,
  4822. HTT_H2T_UMAC_HANG_RECOVERY_START_PRE_RESET_BYTES);
  4823. HTT_H2T_MSG_TYPE_SET(
  4824. *msg_word,
  4825. HTT_H2T_MSG_TYPE_UMAC_HANG_RECOVERY_SOC_START_PRE_RESET);
  4826. HTT_H2T_UMAC_HANG_RECOVERY_START_PRE_RESET_IS_INITIATOR_SET(
  4827. *msg_word, is_initiator);
  4828. HTT_H2T_UMAC_HANG_RECOVERY_START_PRE_RESET_IS_UMAC_HANG_SET(
  4829. *msg_word, is_umac_hang);
  4830. pkt = htt_htc_pkt_alloc(htt_handle);
  4831. if (!pkt) {
  4832. qdf_err("Fail to allocate dp_htt_htc_pkt buffer");
  4833. qdf_assert(0);
  4834. qdf_nbuf_free(msg);
  4835. return QDF_STATUS_E_NOMEM;
  4836. }
  4837. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4838. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  4839. dp_htt_h2t_send_complete_free_netbuf,
  4840. qdf_nbuf_data(msg),
  4841. qdf_nbuf_len(msg),
  4842. htt_handle->htc_endpoint,
  4843. /* tag for no FW response msg */
  4844. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4845. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4846. status = DP_HTT_SEND_HTC_PKT(
  4847. htt_handle, pkt,
  4848. HTT_H2T_MSG_TYPE_UMAC_HANG_RECOVERY_SOC_START_PRE_RESET,
  4849. htt_logger_bufp);
  4850. if (QDF_IS_STATUS_ERROR(status)) {
  4851. qdf_nbuf_free(msg);
  4852. htt_htc_pkt_free(htt_handle, pkt);
  4853. return status;
  4854. }
  4855. dp_info("HTT_H2T_MSG_TYPE_UMAC_HANG_RECOVERY_SOC_START_PRE_RESET sent");
  4856. return status;
  4857. }
  4858. #endif