dp_htt.c 152 KB

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