dp_htt.c 132 KB

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