dp_htt.c 156 KB

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