dp_htt.c 156 KB

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