dp_htt.c 148 KB

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