dp_htt.c 135 KB

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