dp_htt.c 132 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651
  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(soc->ctrl_psoc,
  1887. pdev->pdev_id, freq);
  1888. }
  1889. ppdu_desc->phy_mode = HTT_PPDU_STATS_COMMON_TLV_PHY_MODE_GET(*tag_buf);
  1890. }
  1891. /*
  1892. * dp_process_ppdu_stats_user_common_tlv: Process ppdu_stats_user_common
  1893. * @tag_buf: buffer containing the tlv htt_ppdu_stats_user_common_tlv
  1894. * @ppdu_info: per ppdu tlv structure
  1895. *
  1896. * return:void
  1897. */
  1898. static void dp_process_ppdu_stats_user_common_tlv(
  1899. struct dp_pdev *pdev, uint32_t *tag_buf,
  1900. struct ppdu_info *ppdu_info)
  1901. {
  1902. uint16_t peer_id;
  1903. struct cdp_tx_completion_ppdu *ppdu_desc;
  1904. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  1905. uint8_t curr_user_index = 0;
  1906. ppdu_desc =
  1907. (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  1908. tag_buf++;
  1909. peer_id = HTT_PPDU_STATS_USER_RATE_TLV_SW_PEER_ID_GET(*tag_buf);
  1910. curr_user_index =
  1911. dp_get_ppdu_info_user_index(pdev,
  1912. peer_id, ppdu_info);
  1913. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  1914. if (peer_id == DP_SCAN_PEER_ID) {
  1915. ppdu_desc->vdev_id =
  1916. HTT_PPDU_STATS_USER_COMMON_TLV_VAP_ID_GET(*tag_buf);
  1917. } else {
  1918. if (!dp_peer_find_by_id_valid(pdev->soc, peer_id))
  1919. return;
  1920. }
  1921. ppdu_user_desc->peer_id = peer_id;
  1922. tag_buf++;
  1923. if (HTT_PPDU_STATS_USER_COMMON_TLV_DELAYED_BA_GET(*tag_buf)) {
  1924. ppdu_user_desc->delayed_ba = 1;
  1925. ppdu_desc->delayed_ba = 1;
  1926. }
  1927. if (HTT_PPDU_STATS_USER_COMMON_TLV_MCAST_GET(*tag_buf)) {
  1928. ppdu_user_desc->is_mcast = true;
  1929. ppdu_user_desc->mpdu_tried_mcast =
  1930. HTT_PPDU_STATS_USER_COMMON_TLV_MPDUS_TRIED_GET(*tag_buf);
  1931. ppdu_user_desc->num_mpdu = ppdu_user_desc->mpdu_tried_mcast;
  1932. } else {
  1933. ppdu_user_desc->mpdu_tried_ucast =
  1934. HTT_PPDU_STATS_USER_COMMON_TLV_MPDUS_TRIED_GET(*tag_buf);
  1935. }
  1936. tag_buf++;
  1937. ppdu_user_desc->qos_ctrl =
  1938. HTT_PPDU_STATS_USER_COMMON_TLV_QOS_CTRL_GET(*tag_buf);
  1939. ppdu_user_desc->frame_ctrl =
  1940. HTT_PPDU_STATS_USER_COMMON_TLV_FRAME_CTRL_GET(*tag_buf);
  1941. ppdu_desc->frame_ctrl = ppdu_user_desc->frame_ctrl;
  1942. if (ppdu_user_desc->delayed_ba)
  1943. ppdu_user_desc->mpdu_success = 0;
  1944. tag_buf += 3;
  1945. if (HTT_PPDU_STATS_IS_OPAQUE_VALID_GET(*tag_buf)) {
  1946. ppdu_user_desc->ppdu_cookie =
  1947. HTT_PPDU_STATS_HOST_OPAQUE_COOKIE_GET(*tag_buf);
  1948. ppdu_user_desc->is_ppdu_cookie_valid = 1;
  1949. }
  1950. }
  1951. /**
  1952. * dp_process_ppdu_stats_user_rate_tlv() - Process htt_ppdu_stats_user_rate_tlv
  1953. * @pdev: DP pdev handle
  1954. * @tag_buf: T2H message buffer carrying the user rate TLV
  1955. * @ppdu_info: per ppdu tlv structure
  1956. *
  1957. * return:void
  1958. */
  1959. static void dp_process_ppdu_stats_user_rate_tlv(struct dp_pdev *pdev,
  1960. uint32_t *tag_buf,
  1961. struct ppdu_info *ppdu_info)
  1962. {
  1963. uint16_t peer_id;
  1964. struct dp_peer *peer;
  1965. struct cdp_tx_completion_ppdu *ppdu_desc;
  1966. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  1967. uint8_t curr_user_index = 0;
  1968. struct dp_vdev *vdev;
  1969. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  1970. tag_buf++;
  1971. peer_id = HTT_PPDU_STATS_USER_RATE_TLV_SW_PEER_ID_GET(*tag_buf);
  1972. curr_user_index =
  1973. dp_get_ppdu_info_user_index(pdev,
  1974. peer_id, ppdu_info);
  1975. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  1976. if (peer_id == DP_SCAN_PEER_ID) {
  1977. vdev =
  1978. dp_get_vdev_from_soc_vdev_id_wifi3(pdev->soc,
  1979. ppdu_desc->vdev_id);
  1980. if (!vdev)
  1981. return;
  1982. qdf_mem_copy(ppdu_user_desc->mac_addr, vdev->mac_addr.raw,
  1983. QDF_MAC_ADDR_SIZE);
  1984. } else {
  1985. peer = dp_peer_find_by_id(pdev->soc, peer_id);
  1986. if (!peer)
  1987. return;
  1988. qdf_mem_copy(ppdu_user_desc->mac_addr,
  1989. peer->mac_addr.raw, QDF_MAC_ADDR_SIZE);
  1990. dp_peer_unref_del_find_by_id(peer);
  1991. }
  1992. ppdu_user_desc->peer_id = peer_id;
  1993. ppdu_user_desc->tid =
  1994. HTT_PPDU_STATS_USER_RATE_TLV_TID_NUM_GET(*tag_buf);
  1995. tag_buf += 1;
  1996. ppdu_user_desc->user_pos =
  1997. HTT_PPDU_STATS_USER_RATE_TLV_USER_POS_GET(*tag_buf);
  1998. ppdu_user_desc->mu_group_id =
  1999. HTT_PPDU_STATS_USER_RATE_TLV_MU_GROUPID_GET(*tag_buf);
  2000. tag_buf += 1;
  2001. ppdu_user_desc->ru_start =
  2002. HTT_PPDU_STATS_USER_RATE_TLV_RU_START_GET(*tag_buf);
  2003. ppdu_user_desc->ru_tones =
  2004. (HTT_PPDU_STATS_USER_RATE_TLV_RU_END_GET(*tag_buf) -
  2005. HTT_PPDU_STATS_USER_RATE_TLV_RU_START_GET(*tag_buf)) + 1;
  2006. tag_buf += 2;
  2007. ppdu_user_desc->ppdu_type =
  2008. HTT_PPDU_STATS_USER_RATE_TLV_PPDU_TYPE_GET(*tag_buf);
  2009. tag_buf++;
  2010. ppdu_user_desc->tx_rate = *tag_buf;
  2011. ppdu_user_desc->ltf_size =
  2012. HTT_PPDU_STATS_USER_RATE_TLV_LTF_SIZE_GET(*tag_buf);
  2013. ppdu_user_desc->stbc =
  2014. HTT_PPDU_STATS_USER_RATE_TLV_STBC_GET(*tag_buf);
  2015. ppdu_user_desc->he_re =
  2016. HTT_PPDU_STATS_USER_RATE_TLV_HE_RE_GET(*tag_buf);
  2017. ppdu_user_desc->txbf =
  2018. HTT_PPDU_STATS_USER_RATE_TLV_TXBF_GET(*tag_buf);
  2019. ppdu_user_desc->bw =
  2020. HTT_PPDU_STATS_USER_RATE_TLV_BW_GET(*tag_buf) - 2;
  2021. ppdu_user_desc->nss = HTT_PPDU_STATS_USER_RATE_TLV_NSS_GET(*tag_buf);
  2022. ppdu_user_desc->mcs = HTT_PPDU_STATS_USER_RATE_TLV_MCS_GET(*tag_buf);
  2023. ppdu_user_desc->preamble =
  2024. HTT_PPDU_STATS_USER_RATE_TLV_PREAMBLE_GET(*tag_buf);
  2025. ppdu_user_desc->gi = HTT_PPDU_STATS_USER_RATE_TLV_GI_GET(*tag_buf);
  2026. ppdu_user_desc->dcm = HTT_PPDU_STATS_USER_RATE_TLV_DCM_GET(*tag_buf);
  2027. ppdu_user_desc->ldpc = HTT_PPDU_STATS_USER_RATE_TLV_LDPC_GET(*tag_buf);
  2028. }
  2029. /*
  2030. * dp_process_ppdu_stats_enq_mpdu_bitmap_64_tlv: Process
  2031. * htt_ppdu_stats_enq_mpdu_bitmap_64_tlv
  2032. * pdev: DP PDEV handle
  2033. * @tag_buf: buffer containing the tlv htt_ppdu_stats_enq_mpdu_bitmap_64_tlv
  2034. * @ppdu_info: per ppdu tlv structure
  2035. *
  2036. * return:void
  2037. */
  2038. static void dp_process_ppdu_stats_enq_mpdu_bitmap_64_tlv(
  2039. struct dp_pdev *pdev, uint32_t *tag_buf,
  2040. struct ppdu_info *ppdu_info)
  2041. {
  2042. htt_ppdu_stats_enq_mpdu_bitmap_64_tlv *dp_stats_buf =
  2043. (htt_ppdu_stats_enq_mpdu_bitmap_64_tlv *)tag_buf;
  2044. struct cdp_tx_completion_ppdu *ppdu_desc;
  2045. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2046. uint8_t curr_user_index = 0;
  2047. uint16_t peer_id;
  2048. uint32_t size = CDP_BA_64_BIT_MAP_SIZE_DWORDS;
  2049. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2050. tag_buf++;
  2051. peer_id =
  2052. HTT_PPDU_STATS_ENQ_MPDU_BITMAP_TLV_SW_PEER_ID_GET(*tag_buf);
  2053. if (!dp_peer_find_by_id_valid(pdev->soc, peer_id))
  2054. return;
  2055. curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id, ppdu_info);
  2056. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  2057. ppdu_user_desc->peer_id = peer_id;
  2058. ppdu_user_desc->start_seq = dp_stats_buf->start_seq;
  2059. qdf_mem_copy(&ppdu_user_desc->enq_bitmap, &dp_stats_buf->enq_bitmap,
  2060. sizeof(uint32_t) * CDP_BA_64_BIT_MAP_SIZE_DWORDS);
  2061. dp_process_ppdu_stats_update_failed_bitmap(pdev,
  2062. (void *)ppdu_user_desc,
  2063. ppdu_info->ppdu_id,
  2064. size);
  2065. }
  2066. /*
  2067. * dp_process_ppdu_stats_enq_mpdu_bitmap_256_tlv: Process
  2068. * htt_ppdu_stats_enq_mpdu_bitmap_256_tlv
  2069. * soc: DP SOC handle
  2070. * @tag_buf: buffer containing the tlv htt_ppdu_stats_enq_mpdu_bitmap_256_tlv
  2071. * @ppdu_info: per ppdu tlv structure
  2072. *
  2073. * return:void
  2074. */
  2075. static void dp_process_ppdu_stats_enq_mpdu_bitmap_256_tlv(
  2076. struct dp_pdev *pdev, uint32_t *tag_buf,
  2077. struct ppdu_info *ppdu_info)
  2078. {
  2079. htt_ppdu_stats_enq_mpdu_bitmap_256_tlv *dp_stats_buf =
  2080. (htt_ppdu_stats_enq_mpdu_bitmap_256_tlv *)tag_buf;
  2081. struct cdp_tx_completion_ppdu *ppdu_desc;
  2082. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2083. uint8_t curr_user_index = 0;
  2084. uint16_t peer_id;
  2085. uint32_t size = CDP_BA_256_BIT_MAP_SIZE_DWORDS;
  2086. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2087. tag_buf++;
  2088. peer_id =
  2089. HTT_PPDU_STATS_ENQ_MPDU_BITMAP_TLV_SW_PEER_ID_GET(*tag_buf);
  2090. if (!dp_peer_find_by_id_valid(pdev->soc, peer_id))
  2091. return;
  2092. curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id, ppdu_info);
  2093. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  2094. ppdu_user_desc->peer_id = peer_id;
  2095. ppdu_user_desc->start_seq = dp_stats_buf->start_seq;
  2096. qdf_mem_copy(&ppdu_user_desc->enq_bitmap, &dp_stats_buf->enq_bitmap,
  2097. sizeof(uint32_t) * CDP_BA_256_BIT_MAP_SIZE_DWORDS);
  2098. dp_process_ppdu_stats_update_failed_bitmap(pdev,
  2099. (void *)ppdu_user_desc,
  2100. ppdu_info->ppdu_id,
  2101. size);
  2102. }
  2103. /*
  2104. * dp_process_ppdu_stats_user_cmpltn_common_tlv: Process
  2105. * htt_ppdu_stats_user_cmpltn_common_tlv
  2106. * soc: DP SOC handle
  2107. * @tag_buf: buffer containing the tlv htt_ppdu_stats_user_cmpltn_common_tlv
  2108. * @ppdu_info: per ppdu tlv structure
  2109. *
  2110. * return:void
  2111. */
  2112. static void dp_process_ppdu_stats_user_cmpltn_common_tlv(
  2113. struct dp_pdev *pdev, uint32_t *tag_buf,
  2114. struct ppdu_info *ppdu_info)
  2115. {
  2116. uint16_t peer_id;
  2117. struct cdp_tx_completion_ppdu *ppdu_desc;
  2118. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2119. uint8_t curr_user_index = 0;
  2120. uint8_t bw_iter;
  2121. htt_ppdu_stats_user_cmpltn_common_tlv *dp_stats_buf =
  2122. (htt_ppdu_stats_user_cmpltn_common_tlv *)tag_buf;
  2123. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2124. tag_buf++;
  2125. peer_id =
  2126. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_SW_PEER_ID_GET(*tag_buf);
  2127. if (!dp_peer_find_by_id_valid(pdev->soc, peer_id))
  2128. return;
  2129. curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id, ppdu_info);
  2130. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  2131. ppdu_user_desc->peer_id = peer_id;
  2132. ppdu_desc->last_usr_index = curr_user_index;
  2133. ppdu_user_desc->completion_status =
  2134. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_COMPLETION_STATUS_GET(
  2135. *tag_buf);
  2136. ppdu_user_desc->tid =
  2137. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_TID_NUM_GET(*tag_buf);
  2138. tag_buf++;
  2139. if (qdf_likely(ppdu_user_desc->completion_status ==
  2140. HTT_PPDU_STATS_USER_STATUS_OK)) {
  2141. ppdu_desc->ack_rssi = dp_stats_buf->ack_rssi;
  2142. ppdu_user_desc->ack_rssi_valid = 1;
  2143. } else {
  2144. ppdu_user_desc->ack_rssi_valid = 0;
  2145. }
  2146. tag_buf++;
  2147. ppdu_user_desc->mpdu_success =
  2148. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_MPDU_SUCCESS_GET(*tag_buf);
  2149. ppdu_user_desc->mpdu_failed =
  2150. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_MPDU_TRIED_GET(*tag_buf) -
  2151. ppdu_user_desc->mpdu_success;
  2152. tag_buf++;
  2153. ppdu_user_desc->long_retries =
  2154. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_LONG_RETRY_GET(*tag_buf);
  2155. ppdu_user_desc->short_retries =
  2156. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_SHORT_RETRY_GET(*tag_buf);
  2157. ppdu_user_desc->retry_msdus =
  2158. ppdu_user_desc->long_retries + ppdu_user_desc->short_retries;
  2159. ppdu_user_desc->is_ampdu =
  2160. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_IS_AMPDU_GET(*tag_buf);
  2161. ppdu_info->is_ampdu = ppdu_user_desc->is_ampdu;
  2162. /*
  2163. * increase successful mpdu counter from
  2164. * htt_ppdu_stats_user_cmpltn_common_tlv
  2165. */
  2166. ppdu_info->mpdu_compltn_common_tlv += ppdu_user_desc->mpdu_success;
  2167. /*
  2168. * MU BAR may send request to n users but we may received ack only from
  2169. * m users. To have count of number of users respond back, we have a
  2170. * separate counter bar_num_users per PPDU that get increment for every
  2171. * htt_ppdu_stats_user_cmpltn_common_tlv
  2172. */
  2173. ppdu_desc->bar_num_users++;
  2174. tag_buf++;
  2175. for (bw_iter = 0; bw_iter < CDP_RSSI_CHAIN_LEN; bw_iter++) {
  2176. ppdu_user_desc->rssi_chain[bw_iter] =
  2177. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_CHAIN_RSSI_GET(*tag_buf);
  2178. tag_buf++;
  2179. }
  2180. ppdu_user_desc->sa_tx_antenna =
  2181. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_TX_ANTENNA_MASK_GET(*tag_buf);
  2182. tag_buf++;
  2183. ppdu_user_desc->sa_is_training =
  2184. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_IS_TRAINING_GET(*tag_buf);
  2185. if (ppdu_user_desc->sa_is_training) {
  2186. ppdu_user_desc->sa_goodput =
  2187. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_PENDING_TRAINING_PKTS_GET(*tag_buf);
  2188. }
  2189. tag_buf++;
  2190. for (bw_iter = 0; bw_iter < CDP_NUM_SA_BW; bw_iter++) {
  2191. ppdu_user_desc->sa_max_rates[bw_iter] =
  2192. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_MAX_RATES_GET(tag_buf[bw_iter]);
  2193. }
  2194. tag_buf += CDP_NUM_SA_BW;
  2195. ppdu_user_desc->current_rate_per =
  2196. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_CURRENT_RATE_PER_GET(*tag_buf);
  2197. }
  2198. /*
  2199. * dp_process_ppdu_stats_user_compltn_ba_bitmap_64_tlv: Process
  2200. * htt_ppdu_stats_user_compltn_ba_bitmap_64_tlv
  2201. * pdev: DP PDEV handle
  2202. * @tag_buf: buffer containing the htt_ppdu_stats_user_compltn_ba_bitmap_64_tlv
  2203. * @ppdu_info: per ppdu tlv structure
  2204. *
  2205. * return:void
  2206. */
  2207. static void dp_process_ppdu_stats_user_compltn_ba_bitmap_64_tlv(
  2208. struct dp_pdev *pdev, uint32_t *tag_buf,
  2209. struct ppdu_info *ppdu_info)
  2210. {
  2211. htt_ppdu_stats_user_compltn_ba_bitmap_64_tlv *dp_stats_buf =
  2212. (htt_ppdu_stats_user_compltn_ba_bitmap_64_tlv *)tag_buf;
  2213. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2214. struct cdp_tx_completion_ppdu *ppdu_desc;
  2215. uint8_t curr_user_index = 0;
  2216. uint16_t peer_id;
  2217. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2218. tag_buf++;
  2219. peer_id =
  2220. HTT_PPDU_STATS_USER_CMPLTN_BA_BITMAP_TLV_SW_PEER_ID_GET(*tag_buf);
  2221. if (!dp_peer_find_by_id_valid(pdev->soc, peer_id))
  2222. return;
  2223. curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id, ppdu_info);
  2224. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  2225. ppdu_user_desc->peer_id = peer_id;
  2226. ppdu_user_desc->ba_seq_no = dp_stats_buf->ba_seq_no;
  2227. qdf_mem_copy(&ppdu_user_desc->ba_bitmap, &dp_stats_buf->ba_bitmap,
  2228. sizeof(uint32_t) * CDP_BA_64_BIT_MAP_SIZE_DWORDS);
  2229. ppdu_user_desc->ba_size = CDP_BA_64_BIT_MAP_SIZE_DWORDS * 32;
  2230. }
  2231. /*
  2232. * dp_process_ppdu_stats_user_compltn_ba_bitmap_256_tlv: Process
  2233. * htt_ppdu_stats_user_compltn_ba_bitmap_256_tlv
  2234. * pdev: DP PDEV handle
  2235. * @tag_buf: buffer containing the htt_ppdu_stats_user_compltn_ba_bitmap_256_tlv
  2236. * @ppdu_info: per ppdu tlv structure
  2237. *
  2238. * return:void
  2239. */
  2240. static void dp_process_ppdu_stats_user_compltn_ba_bitmap_256_tlv(
  2241. struct dp_pdev *pdev, uint32_t *tag_buf,
  2242. struct ppdu_info *ppdu_info)
  2243. {
  2244. htt_ppdu_stats_user_compltn_ba_bitmap_256_tlv *dp_stats_buf =
  2245. (htt_ppdu_stats_user_compltn_ba_bitmap_256_tlv *)tag_buf;
  2246. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2247. struct cdp_tx_completion_ppdu *ppdu_desc;
  2248. uint8_t curr_user_index = 0;
  2249. uint16_t peer_id;
  2250. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2251. tag_buf++;
  2252. peer_id =
  2253. HTT_PPDU_STATS_USER_CMPLTN_BA_BITMAP_TLV_SW_PEER_ID_GET(*tag_buf);
  2254. if (!dp_peer_find_by_id_valid(pdev->soc, peer_id))
  2255. return;
  2256. curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id, ppdu_info);
  2257. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  2258. ppdu_user_desc->peer_id = peer_id;
  2259. ppdu_user_desc->ba_seq_no = dp_stats_buf->ba_seq_no;
  2260. qdf_mem_copy(&ppdu_user_desc->ba_bitmap, &dp_stats_buf->ba_bitmap,
  2261. sizeof(uint32_t) * CDP_BA_256_BIT_MAP_SIZE_DWORDS);
  2262. ppdu_user_desc->ba_size = CDP_BA_256_BIT_MAP_SIZE_DWORDS * 32;
  2263. }
  2264. /*
  2265. * dp_process_ppdu_stats_user_compltn_ack_ba_status_tlv: Process
  2266. * htt_ppdu_stats_user_compltn_ack_ba_status_tlv
  2267. * pdev: DP PDE handle
  2268. * @tag_buf: buffer containing the htt_ppdu_stats_user_compltn_ack_ba_status_tlv
  2269. * @ppdu_info: per ppdu tlv structure
  2270. *
  2271. * return:void
  2272. */
  2273. static void dp_process_ppdu_stats_user_compltn_ack_ba_status_tlv(
  2274. struct dp_pdev *pdev, uint32_t *tag_buf,
  2275. struct ppdu_info *ppdu_info)
  2276. {
  2277. uint16_t peer_id;
  2278. struct cdp_tx_completion_ppdu *ppdu_desc;
  2279. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2280. uint8_t curr_user_index = 0;
  2281. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2282. tag_buf += 2;
  2283. peer_id =
  2284. HTT_PPDU_STATS_USER_CMPLTN_ACK_BA_STATUS_TLV_SW_PEER_ID_GET(*tag_buf);
  2285. if (!dp_peer_find_by_id_valid(pdev->soc, peer_id))
  2286. return;
  2287. curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id, ppdu_info);
  2288. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  2289. ppdu_user_desc->peer_id = peer_id;
  2290. tag_buf++;
  2291. ppdu_user_desc->tid =
  2292. HTT_PPDU_STATS_USER_CMPLTN_ACK_BA_STATUS_TLV_TID_NUM_GET(*tag_buf);
  2293. ppdu_user_desc->num_mpdu =
  2294. HTT_PPDU_STATS_USER_CMPLTN_ACK_BA_STATUS_TLV_NUM_MPDU_GET(*tag_buf);
  2295. ppdu_user_desc->num_msdu =
  2296. HTT_PPDU_STATS_USER_CMPLTN_ACK_BA_STATUS_TLV_NUM_MSDU_GET(*tag_buf);
  2297. ppdu_user_desc->success_msdus = ppdu_user_desc->num_msdu;
  2298. tag_buf++;
  2299. ppdu_user_desc->start_seq =
  2300. HTT_PPDU_STATS_USER_CMPLTN_ACK_BA_STATUS_TLV_START_SEQ_GET(
  2301. *tag_buf);
  2302. tag_buf++;
  2303. ppdu_user_desc->success_bytes = *tag_buf;
  2304. /* increase successful mpdu counter */
  2305. ppdu_info->mpdu_ack_ba_tlv += ppdu_user_desc->num_mpdu;
  2306. }
  2307. /*
  2308. * dp_process_ppdu_stats_user_common_array_tlv: Process
  2309. * htt_ppdu_stats_user_common_array_tlv
  2310. * pdev: DP PDEV handle
  2311. * @tag_buf: buffer containing the htt_ppdu_stats_user_compltn_ack_ba_status_tlv
  2312. * @ppdu_info: per ppdu tlv structure
  2313. *
  2314. * return:void
  2315. */
  2316. static void dp_process_ppdu_stats_user_common_array_tlv(
  2317. struct dp_pdev *pdev, uint32_t *tag_buf,
  2318. struct ppdu_info *ppdu_info)
  2319. {
  2320. uint32_t peer_id;
  2321. struct cdp_tx_completion_ppdu *ppdu_desc;
  2322. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2323. uint8_t curr_user_index = 0;
  2324. struct htt_tx_ppdu_stats_info *dp_stats_buf;
  2325. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2326. tag_buf++;
  2327. dp_stats_buf = (struct htt_tx_ppdu_stats_info *)tag_buf;
  2328. tag_buf += 3;
  2329. peer_id =
  2330. HTT_PPDU_STATS_ARRAY_ITEM_TLV_PEERID_GET(*tag_buf);
  2331. if (!dp_peer_find_by_id_valid(pdev->soc, peer_id)) {
  2332. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  2333. "Invalid peer");
  2334. return;
  2335. }
  2336. curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id, ppdu_info);
  2337. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  2338. ppdu_user_desc->retry_bytes = dp_stats_buf->tx_retry_bytes;
  2339. ppdu_user_desc->failed_bytes = dp_stats_buf->tx_failed_bytes;
  2340. tag_buf++;
  2341. ppdu_user_desc->success_msdus =
  2342. HTT_PPDU_STATS_ARRAY_ITEM_TLV_TX_SUCC_MSDUS_GET(*tag_buf);
  2343. ppdu_user_desc->retry_bytes =
  2344. HTT_PPDU_STATS_ARRAY_ITEM_TLV_TX_RETRY_MSDUS_GET(*tag_buf);
  2345. tag_buf++;
  2346. ppdu_user_desc->failed_msdus =
  2347. HTT_PPDU_STATS_ARRAY_ITEM_TLV_TX_FAILED_MSDUS_GET(*tag_buf);
  2348. }
  2349. /*
  2350. * dp_process_ppdu_stats_flush_tlv: Process
  2351. * htt_ppdu_stats_flush_tlv
  2352. * @pdev: DP PDEV handle
  2353. * @tag_buf: buffer containing the htt_ppdu_stats_flush_tlv
  2354. *
  2355. * return:void
  2356. */
  2357. static void dp_process_ppdu_stats_user_compltn_flush_tlv(struct dp_pdev *pdev,
  2358. uint32_t *tag_buf)
  2359. {
  2360. uint32_t peer_id;
  2361. uint32_t drop_reason;
  2362. uint8_t tid;
  2363. uint32_t num_msdu;
  2364. struct dp_peer *peer;
  2365. tag_buf++;
  2366. drop_reason = *tag_buf;
  2367. tag_buf++;
  2368. num_msdu = HTT_PPDU_STATS_FLUSH_TLV_NUM_MSDU_GET(*tag_buf);
  2369. tag_buf++;
  2370. peer_id =
  2371. HTT_PPDU_STATS_FLUSH_TLV_SW_PEER_ID_GET(*tag_buf);
  2372. peer = dp_peer_find_by_id(pdev->soc, peer_id);
  2373. if (!peer)
  2374. return;
  2375. tid = HTT_PPDU_STATS_FLUSH_TLV_TID_NUM_GET(*tag_buf);
  2376. if (drop_reason == HTT_FLUSH_EXCESS_RETRIES) {
  2377. DP_STATS_INC(peer, tx.excess_retries_per_ac[TID_TO_WME_AC(tid)],
  2378. num_msdu);
  2379. }
  2380. dp_peer_unref_del_find_by_id(peer);
  2381. }
  2382. #ifndef WLAN_TX_PKT_CAPTURE_ENH
  2383. /*
  2384. * dp_deliver_mgmt_frm: Process
  2385. * @pdev: DP PDEV handle
  2386. * @nbuf: buffer containing the htt_ppdu_stats_tx_mgmtctrl_payload_tlv
  2387. *
  2388. * return: void
  2389. */
  2390. void dp_deliver_mgmt_frm(struct dp_pdev *pdev, qdf_nbuf_t nbuf)
  2391. {
  2392. if (pdev->tx_sniffer_enable || pdev->mcopy_mode) {
  2393. dp_wdi_event_handler(WDI_EVENT_TX_MGMT_CTRL, pdev->soc,
  2394. nbuf, HTT_INVALID_PEER,
  2395. WDI_NO_VAL, pdev->pdev_id);
  2396. }
  2397. }
  2398. #endif
  2399. /*
  2400. * dp_process_ppdu_stats_tx_mgmtctrl_payload_tlv: Process
  2401. * htt_ppdu_stats_tx_mgmtctrl_payload_tlv
  2402. * @pdev: DP PDEV handle
  2403. * @tag_buf: buffer containing the htt_ppdu_stats_tx_mgmtctrl_payload_tlv
  2404. * @length: tlv_length
  2405. *
  2406. * return:QDF_STATUS_SUCCESS if nbuf as to be freed in caller
  2407. */
  2408. static QDF_STATUS
  2409. dp_process_ppdu_stats_tx_mgmtctrl_payload_tlv(struct dp_pdev *pdev,
  2410. qdf_nbuf_t tag_buf,
  2411. uint32_t ppdu_id)
  2412. {
  2413. uint32_t *nbuf_ptr;
  2414. uint8_t trim_size;
  2415. if ((!pdev->tx_sniffer_enable) && (!pdev->mcopy_mode) &&
  2416. (!pdev->bpr_enable) && (!pdev->tx_capture_enabled))
  2417. return QDF_STATUS_SUCCESS;
  2418. trim_size = ((pdev->mgmtctrl_frm_info.mgmt_buf +
  2419. HTT_MGMT_CTRL_TLV_HDR_RESERVERD_LEN) -
  2420. qdf_nbuf_data(tag_buf));
  2421. if (!qdf_nbuf_pull_head(tag_buf, trim_size))
  2422. return QDF_STATUS_SUCCESS;
  2423. qdf_nbuf_trim_tail(tag_buf, qdf_nbuf_len(tag_buf) -
  2424. pdev->mgmtctrl_frm_info.mgmt_buf_len);
  2425. nbuf_ptr = (uint32_t *)qdf_nbuf_push_head(
  2426. tag_buf, sizeof(ppdu_id));
  2427. *nbuf_ptr = ppdu_id;
  2428. if (pdev->bpr_enable) {
  2429. dp_wdi_event_handler(WDI_EVENT_TX_BEACON, pdev->soc,
  2430. tag_buf, HTT_INVALID_PEER,
  2431. WDI_NO_VAL, pdev->pdev_id);
  2432. }
  2433. dp_deliver_mgmt_frm(pdev, tag_buf);
  2434. return QDF_STATUS_E_ALREADY;
  2435. }
  2436. /**
  2437. * dp_validate_fix_ppdu_tlv(): Function to validate the length of PPDU
  2438. *
  2439. * If the TLV length sent as part of PPDU TLV is less that expected size i.e
  2440. * size of corresponding data structure, pad the remaining bytes with zeros
  2441. * and continue processing the TLVs
  2442. *
  2443. * @pdev: DP pdev handle
  2444. * @tag_buf: TLV buffer
  2445. * @tlv_expected_size: Expected size of Tag
  2446. * @tlv_len: TLV length received from FW
  2447. *
  2448. * Return: Pointer to updated TLV
  2449. */
  2450. static inline uint32_t *dp_validate_fix_ppdu_tlv(struct dp_pdev *pdev,
  2451. uint32_t *tag_buf,
  2452. uint16_t tlv_expected_size,
  2453. uint16_t tlv_len)
  2454. {
  2455. uint32_t *tlv_desc = tag_buf;
  2456. qdf_assert_always(tlv_len != 0);
  2457. if (tlv_len < tlv_expected_size) {
  2458. qdf_mem_zero(pdev->ppdu_tlv_buf, tlv_expected_size);
  2459. qdf_mem_copy(pdev->ppdu_tlv_buf, tag_buf, tlv_len);
  2460. tlv_desc = pdev->ppdu_tlv_buf;
  2461. }
  2462. return tlv_desc;
  2463. }
  2464. /**
  2465. * dp_process_ppdu_tag(): Function to process the PPDU TLVs
  2466. * @pdev: DP pdev handle
  2467. * @tag_buf: TLV buffer
  2468. * @tlv_len: length of tlv
  2469. * @ppdu_info: per ppdu tlv structure
  2470. *
  2471. * return: void
  2472. */
  2473. static void dp_process_ppdu_tag(struct dp_pdev *pdev, uint32_t *tag_buf,
  2474. uint32_t tlv_len, struct ppdu_info *ppdu_info)
  2475. {
  2476. uint32_t tlv_type = HTT_STATS_TLV_TAG_GET(*tag_buf);
  2477. uint16_t tlv_expected_size;
  2478. uint32_t *tlv_desc;
  2479. switch (tlv_type) {
  2480. case HTT_PPDU_STATS_COMMON_TLV:
  2481. tlv_expected_size = sizeof(htt_ppdu_stats_common_tlv);
  2482. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  2483. tlv_expected_size, tlv_len);
  2484. dp_process_ppdu_stats_common_tlv(pdev, tlv_desc, ppdu_info);
  2485. break;
  2486. case HTT_PPDU_STATS_USR_COMMON_TLV:
  2487. tlv_expected_size = sizeof(htt_ppdu_stats_user_common_tlv);
  2488. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  2489. tlv_expected_size, tlv_len);
  2490. dp_process_ppdu_stats_user_common_tlv(pdev, tlv_desc,
  2491. ppdu_info);
  2492. break;
  2493. case HTT_PPDU_STATS_USR_RATE_TLV:
  2494. tlv_expected_size = sizeof(htt_ppdu_stats_user_rate_tlv);
  2495. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  2496. tlv_expected_size, tlv_len);
  2497. dp_process_ppdu_stats_user_rate_tlv(pdev, tlv_desc,
  2498. ppdu_info);
  2499. break;
  2500. case HTT_PPDU_STATS_USR_MPDU_ENQ_BITMAP_64_TLV:
  2501. tlv_expected_size =
  2502. sizeof(htt_ppdu_stats_enq_mpdu_bitmap_64_tlv);
  2503. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  2504. tlv_expected_size, tlv_len);
  2505. dp_process_ppdu_stats_enq_mpdu_bitmap_64_tlv(
  2506. pdev, tlv_desc, ppdu_info);
  2507. break;
  2508. case HTT_PPDU_STATS_USR_MPDU_ENQ_BITMAP_256_TLV:
  2509. tlv_expected_size =
  2510. sizeof(htt_ppdu_stats_enq_mpdu_bitmap_256_tlv);
  2511. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  2512. tlv_expected_size, tlv_len);
  2513. dp_process_ppdu_stats_enq_mpdu_bitmap_256_tlv(
  2514. pdev, tlv_desc, ppdu_info);
  2515. break;
  2516. case HTT_PPDU_STATS_USR_COMPLTN_COMMON_TLV:
  2517. tlv_expected_size =
  2518. sizeof(htt_ppdu_stats_user_cmpltn_common_tlv);
  2519. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  2520. tlv_expected_size, tlv_len);
  2521. dp_process_ppdu_stats_user_cmpltn_common_tlv(
  2522. pdev, tlv_desc, ppdu_info);
  2523. break;
  2524. case HTT_PPDU_STATS_USR_COMPLTN_BA_BITMAP_64_TLV:
  2525. tlv_expected_size =
  2526. sizeof(htt_ppdu_stats_user_compltn_ba_bitmap_64_tlv);
  2527. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  2528. tlv_expected_size, tlv_len);
  2529. dp_process_ppdu_stats_user_compltn_ba_bitmap_64_tlv(
  2530. pdev, tlv_desc, ppdu_info);
  2531. break;
  2532. case HTT_PPDU_STATS_USR_COMPLTN_BA_BITMAP_256_TLV:
  2533. tlv_expected_size =
  2534. sizeof(htt_ppdu_stats_user_compltn_ba_bitmap_256_tlv);
  2535. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  2536. tlv_expected_size, tlv_len);
  2537. dp_process_ppdu_stats_user_compltn_ba_bitmap_256_tlv(
  2538. pdev, tlv_desc, ppdu_info);
  2539. break;
  2540. case HTT_PPDU_STATS_USR_COMPLTN_ACK_BA_STATUS_TLV:
  2541. tlv_expected_size =
  2542. sizeof(htt_ppdu_stats_user_compltn_ack_ba_status_tlv);
  2543. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  2544. tlv_expected_size, tlv_len);
  2545. dp_process_ppdu_stats_user_compltn_ack_ba_status_tlv(
  2546. pdev, tlv_desc, ppdu_info);
  2547. break;
  2548. case HTT_PPDU_STATS_USR_COMMON_ARRAY_TLV:
  2549. tlv_expected_size =
  2550. sizeof(htt_ppdu_stats_usr_common_array_tlv_v);
  2551. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  2552. tlv_expected_size, tlv_len);
  2553. dp_process_ppdu_stats_user_common_array_tlv(
  2554. pdev, tlv_desc, ppdu_info);
  2555. break;
  2556. case HTT_PPDU_STATS_USR_COMPLTN_FLUSH_TLV:
  2557. tlv_expected_size = sizeof(htt_ppdu_stats_flush_tlv);
  2558. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  2559. tlv_expected_size, tlv_len);
  2560. dp_process_ppdu_stats_user_compltn_flush_tlv(
  2561. pdev, tlv_desc);
  2562. break;
  2563. default:
  2564. break;
  2565. }
  2566. }
  2567. /**
  2568. * dp_ppdu_desc_user_stats_update(): Function to update TX user stats
  2569. * @pdev: DP pdev handle
  2570. * @ppdu_info: per PPDU TLV descriptor
  2571. *
  2572. * return: void
  2573. */
  2574. void
  2575. dp_ppdu_desc_user_stats_update(struct dp_pdev *pdev,
  2576. struct ppdu_info *ppdu_info)
  2577. {
  2578. struct cdp_tx_completion_ppdu *ppdu_desc = NULL;
  2579. struct dp_peer *peer = NULL;
  2580. uint32_t tlv_bitmap_expected;
  2581. uint32_t tlv_bitmap_default;
  2582. uint16_t i;
  2583. uint32_t num_users;
  2584. ppdu_desc = (struct cdp_tx_completion_ppdu *)
  2585. qdf_nbuf_data(ppdu_info->nbuf);
  2586. ppdu_desc->num_users = ppdu_info->last_user;
  2587. ppdu_desc->ppdu_id = ppdu_info->ppdu_id;
  2588. tlv_bitmap_expected = HTT_PPDU_DEFAULT_TLV_BITMAP;
  2589. if (pdev->tx_sniffer_enable || pdev->mcopy_mode) {
  2590. if (ppdu_info->is_ampdu)
  2591. tlv_bitmap_expected =
  2592. dp_htt_get_ppdu_sniffer_ampdu_tlv_bitmap(
  2593. ppdu_info->tlv_bitmap);
  2594. }
  2595. tlv_bitmap_default = tlv_bitmap_expected;
  2596. if (ppdu_desc->frame_type == CDP_PPDU_FTYPE_BAR) {
  2597. num_users = ppdu_desc->bar_num_users;
  2598. ppdu_desc->num_users = ppdu_desc->bar_num_users;
  2599. } else {
  2600. num_users = ppdu_desc->num_users;
  2601. }
  2602. for (i = 0; i < num_users; i++) {
  2603. ppdu_desc->num_mpdu += ppdu_desc->user[i].num_mpdu;
  2604. ppdu_desc->num_msdu += ppdu_desc->user[i].num_msdu;
  2605. peer = dp_peer_find_by_id(pdev->soc,
  2606. ppdu_desc->user[i].peer_id);
  2607. /**
  2608. * This check is to make sure peer is not deleted
  2609. * after processing the TLVs.
  2610. */
  2611. if (!peer)
  2612. continue;
  2613. ppdu_desc->user[i].cookie = (void *)peer->wlanstats_ctx;
  2614. if (ppdu_desc->user[i].completion_status !=
  2615. HTT_PPDU_STATS_USER_STATUS_OK) {
  2616. tlv_bitmap_expected = tlv_bitmap_expected & 0xFF;
  2617. if ((ppdu_desc->user[i].tid < CDP_DATA_TID_MAX ||
  2618. (ppdu_desc->user[i].tid == CDP_DATA_NON_QOS_TID)) &&
  2619. (ppdu_desc->frame_type == CDP_PPDU_FTYPE_DATA)) {
  2620. DP_STATS_INC(peer, tx.retries,
  2621. (ppdu_desc->user[i].long_retries +
  2622. ppdu_desc->user[i].short_retries));
  2623. DP_STATS_INC(peer, tx.tx_failed,
  2624. ppdu_desc->user[i].failed_msdus);
  2625. }
  2626. }
  2627. /*
  2628. * different frame like DATA, BAR or CTRL has different
  2629. * tlv bitmap expected. Apart from ACK_BA_STATUS TLV, we
  2630. * receive other tlv in-order/sequential from fw.
  2631. * Since ACK_BA_STATUS TLV come from Hardware it is
  2632. * asynchronous So we need to depend on some tlv to confirm
  2633. * all tlv is received for a ppdu.
  2634. * So we depend on both HTT_PPDU_STATS_COMMON_TLV and
  2635. * ACK_BA_STATUS_TLV.
  2636. */
  2637. if (!(ppdu_info->tlv_bitmap &
  2638. (1 << HTT_PPDU_STATS_COMMON_TLV)) ||
  2639. !(ppdu_info->tlv_bitmap &
  2640. (1 << HTT_PPDU_STATS_USR_COMPLTN_ACK_BA_STATUS_TLV))) {
  2641. dp_peer_unref_del_find_by_id(peer);
  2642. continue;
  2643. }
  2644. /**
  2645. * Update tx stats for data frames having Qos as well as
  2646. * non-Qos data tid
  2647. */
  2648. if ((ppdu_desc->user[i].tid < CDP_DATA_TID_MAX ||
  2649. (ppdu_desc->user[i].tid == CDP_DATA_NON_QOS_TID)) &&
  2650. (ppdu_desc->frame_type != CDP_PPDU_FTYPE_CTRL)) {
  2651. dp_tx_stats_update(pdev, peer,
  2652. &ppdu_desc->user[i],
  2653. ppdu_desc->ack_rssi);
  2654. dp_tx_rate_stats_update(peer, &ppdu_desc->user[i]);
  2655. }
  2656. dp_peer_unref_del_find_by_id(peer);
  2657. tlv_bitmap_expected = tlv_bitmap_default;
  2658. }
  2659. }
  2660. #ifndef WLAN_TX_PKT_CAPTURE_ENH
  2661. /**
  2662. * dp_ppdu_desc_deliver(): Function to deliver Tx PPDU status descriptor
  2663. * to upper layer
  2664. * @pdev: DP pdev handle
  2665. * @ppdu_info: per PPDU TLV descriptor
  2666. *
  2667. * return: void
  2668. */
  2669. static
  2670. void dp_ppdu_desc_deliver(struct dp_pdev *pdev,
  2671. struct ppdu_info *ppdu_info)
  2672. {
  2673. struct cdp_tx_completion_ppdu *ppdu_desc = NULL;
  2674. qdf_nbuf_t nbuf;
  2675. ppdu_desc = (struct cdp_tx_completion_ppdu *)
  2676. qdf_nbuf_data(ppdu_info->nbuf);
  2677. dp_ppdu_desc_user_stats_update(pdev, ppdu_info);
  2678. /*
  2679. * Remove from the list
  2680. */
  2681. TAILQ_REMOVE(&pdev->ppdu_info_list, ppdu_info, ppdu_info_list_elem);
  2682. nbuf = ppdu_info->nbuf;
  2683. pdev->list_depth--;
  2684. qdf_mem_free(ppdu_info);
  2685. qdf_assert_always(nbuf);
  2686. ppdu_desc = (struct cdp_tx_completion_ppdu *)
  2687. qdf_nbuf_data(nbuf);
  2688. /**
  2689. * Deliver PPDU stats only for valid (acked) data frames if
  2690. * sniffer mode is not enabled.
  2691. * If sniffer mode is enabled, PPDU stats for all frames
  2692. * including mgmt/control frames should be delivered to upper layer
  2693. */
  2694. if (pdev->tx_sniffer_enable || pdev->mcopy_mode) {
  2695. dp_wdi_event_handler(WDI_EVENT_TX_PPDU_DESC, pdev->soc,
  2696. nbuf, HTT_INVALID_PEER,
  2697. WDI_NO_VAL, pdev->pdev_id);
  2698. } else {
  2699. if (ppdu_desc->num_mpdu != 0 && ppdu_desc->num_users != 0 &&
  2700. ppdu_desc->frame_ctrl & HTT_FRAMECTRL_DATATYPE) {
  2701. dp_wdi_event_handler(WDI_EVENT_TX_PPDU_DESC,
  2702. pdev->soc, nbuf, HTT_INVALID_PEER,
  2703. WDI_NO_VAL, pdev->pdev_id);
  2704. } else
  2705. qdf_nbuf_free(nbuf);
  2706. }
  2707. return;
  2708. }
  2709. #endif
  2710. /**
  2711. * dp_get_ppdu_desc(): Function to allocate new PPDU status
  2712. * desc for new ppdu id
  2713. * @pdev: DP pdev handle
  2714. * @ppdu_id: PPDU unique identifier
  2715. * @tlv_type: TLV type received
  2716. *
  2717. * return: ppdu_info per ppdu tlv structure
  2718. */
  2719. static
  2720. struct ppdu_info *dp_get_ppdu_desc(struct dp_pdev *pdev, uint32_t ppdu_id,
  2721. uint8_t tlv_type)
  2722. {
  2723. struct ppdu_info *ppdu_info = NULL;
  2724. /*
  2725. * Find ppdu_id node exists or not
  2726. */
  2727. TAILQ_FOREACH(ppdu_info, &pdev->ppdu_info_list, ppdu_info_list_elem) {
  2728. if (ppdu_info && (ppdu_info->ppdu_id == ppdu_id)) {
  2729. break;
  2730. }
  2731. }
  2732. if (ppdu_info) {
  2733. if (ppdu_info->tlv_bitmap & (1 << tlv_type)) {
  2734. /**
  2735. * if we get tlv_type that is already been processed
  2736. * for ppdu, that means we got a new ppdu with same
  2737. * ppdu id. Hence Flush the older ppdu
  2738. * for MUMIMO and OFDMA, In a PPDU we have
  2739. * multiple user with same tlv types. tlv bitmap is
  2740. * used to check whether SU or MU_MIMO/OFDMA
  2741. */
  2742. if (!(ppdu_info->tlv_bitmap &
  2743. (1 << HTT_PPDU_STATS_SCH_CMD_STATUS_TLV)))
  2744. return ppdu_info;
  2745. /**
  2746. * apart from ACK BA STATUS TLV rest all comes in order
  2747. * so if tlv type not ACK BA STATUS TLV we can deliver
  2748. * ppdu_info
  2749. */
  2750. if (tlv_type ==
  2751. HTT_PPDU_STATS_USR_COMPLTN_ACK_BA_STATUS_TLV)
  2752. return ppdu_info;
  2753. dp_ppdu_desc_deliver(pdev, ppdu_info);
  2754. } else {
  2755. return ppdu_info;
  2756. }
  2757. }
  2758. /**
  2759. * Flush the head ppdu descriptor if ppdu desc list reaches max
  2760. * threshold
  2761. */
  2762. if (pdev->list_depth > HTT_PPDU_DESC_MAX_DEPTH) {
  2763. ppdu_info = TAILQ_FIRST(&pdev->ppdu_info_list);
  2764. dp_ppdu_desc_deliver(pdev, ppdu_info);
  2765. }
  2766. /*
  2767. * Allocate new ppdu_info node
  2768. */
  2769. ppdu_info = qdf_mem_malloc(sizeof(struct ppdu_info));
  2770. if (!ppdu_info)
  2771. return NULL;
  2772. ppdu_info->nbuf = qdf_nbuf_alloc(pdev->soc->osdev,
  2773. sizeof(struct cdp_tx_completion_ppdu), 0, 4,
  2774. TRUE);
  2775. if (!ppdu_info->nbuf) {
  2776. qdf_mem_free(ppdu_info);
  2777. return NULL;
  2778. }
  2779. ppdu_info->ppdu_desc =
  2780. (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2781. qdf_mem_zero(qdf_nbuf_data(ppdu_info->nbuf),
  2782. sizeof(struct cdp_tx_completion_ppdu));
  2783. if (qdf_nbuf_put_tail(ppdu_info->nbuf,
  2784. sizeof(struct cdp_tx_completion_ppdu)) == NULL) {
  2785. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  2786. "No tailroom for HTT PPDU");
  2787. qdf_nbuf_free(ppdu_info->nbuf);
  2788. ppdu_info->nbuf = NULL;
  2789. ppdu_info->last_user = 0;
  2790. qdf_mem_free(ppdu_info);
  2791. return NULL;
  2792. }
  2793. /**
  2794. * No lock is needed because all PPDU TLVs are processed in
  2795. * same context and this list is updated in same context
  2796. */
  2797. TAILQ_INSERT_TAIL(&pdev->ppdu_info_list, ppdu_info,
  2798. ppdu_info_list_elem);
  2799. pdev->list_depth++;
  2800. return ppdu_info;
  2801. }
  2802. /**
  2803. * dp_htt_process_tlv(): Function to process each PPDU TLVs
  2804. * @pdev: DP pdev handle
  2805. * @htt_t2h_msg: HTT target to host message
  2806. *
  2807. * return: ppdu_info per ppdu tlv structure
  2808. */
  2809. static struct ppdu_info *dp_htt_process_tlv(struct dp_pdev *pdev,
  2810. qdf_nbuf_t htt_t2h_msg)
  2811. {
  2812. uint32_t length;
  2813. uint32_t ppdu_id;
  2814. uint8_t tlv_type;
  2815. uint32_t tlv_length, tlv_bitmap_expected;
  2816. uint8_t *tlv_buf;
  2817. struct ppdu_info *ppdu_info = NULL;
  2818. struct cdp_tx_completion_ppdu *ppdu_desc = NULL;
  2819. struct dp_peer *peer;
  2820. uint32_t i = 0;
  2821. uint32_t *msg_word = (uint32_t *) qdf_nbuf_data(htt_t2h_msg);
  2822. length = HTT_T2H_PPDU_STATS_PAYLOAD_SIZE_GET(*msg_word);
  2823. msg_word = msg_word + 1;
  2824. ppdu_id = HTT_T2H_PPDU_STATS_PPDU_ID_GET(*msg_word);
  2825. msg_word = msg_word + 3;
  2826. while (length > 0) {
  2827. tlv_buf = (uint8_t *)msg_word;
  2828. tlv_type = HTT_STATS_TLV_TAG_GET(*msg_word);
  2829. tlv_length = HTT_STATS_TLV_LENGTH_GET(*msg_word);
  2830. if (qdf_likely(tlv_type < CDP_PPDU_STATS_MAX_TAG))
  2831. pdev->stats.ppdu_stats_counter[tlv_type]++;
  2832. if (tlv_length == 0)
  2833. break;
  2834. tlv_length += HTT_TLV_HDR_LEN;
  2835. /**
  2836. * Not allocating separate ppdu descriptor for MGMT Payload
  2837. * TLV as this is sent as separate WDI indication and it
  2838. * doesn't contain any ppdu information
  2839. */
  2840. if (tlv_type == HTT_PPDU_STATS_TX_MGMTCTRL_PAYLOAD_TLV) {
  2841. pdev->mgmtctrl_frm_info.mgmt_buf = tlv_buf;
  2842. pdev->mgmtctrl_frm_info.ppdu_id = ppdu_id;
  2843. pdev->mgmtctrl_frm_info.mgmt_buf_len =
  2844. HTT_PPDU_STATS_TX_MGMTCTRL_TLV_FRAME_LENGTH_GET
  2845. (*(msg_word + 1));
  2846. msg_word =
  2847. (uint32_t *)((uint8_t *)tlv_buf + tlv_length);
  2848. length -= (tlv_length);
  2849. continue;
  2850. }
  2851. ppdu_info = dp_get_ppdu_desc(pdev, ppdu_id, tlv_type);
  2852. if (!ppdu_info)
  2853. return NULL;
  2854. ppdu_info->ppdu_id = ppdu_id;
  2855. ppdu_info->tlv_bitmap |= (1 << tlv_type);
  2856. dp_process_ppdu_tag(pdev, msg_word, tlv_length, ppdu_info);
  2857. /**
  2858. * Increment pdev level tlv count to monitor
  2859. * missing TLVs
  2860. */
  2861. pdev->tlv_count++;
  2862. ppdu_info->last_tlv_cnt = pdev->tlv_count;
  2863. msg_word = (uint32_t *)((uint8_t *)tlv_buf + tlv_length);
  2864. length -= (tlv_length);
  2865. }
  2866. if (!ppdu_info)
  2867. return NULL;
  2868. pdev->last_ppdu_id = ppdu_id;
  2869. tlv_bitmap_expected = HTT_PPDU_DEFAULT_TLV_BITMAP;
  2870. if (pdev->tx_sniffer_enable || pdev->mcopy_mode) {
  2871. if (ppdu_info->is_ampdu)
  2872. tlv_bitmap_expected =
  2873. dp_htt_get_ppdu_sniffer_ampdu_tlv_bitmap(
  2874. ppdu_info->tlv_bitmap);
  2875. }
  2876. ppdu_desc = ppdu_info->ppdu_desc;
  2877. if (!ppdu_desc)
  2878. return NULL;
  2879. if (ppdu_desc->user[ppdu_desc->last_usr_index].completion_status !=
  2880. HTT_PPDU_STATS_USER_STATUS_OK) {
  2881. tlv_bitmap_expected = tlv_bitmap_expected & 0xFF;
  2882. }
  2883. if (ppdu_desc->frame_type == CDP_PPDU_FTYPE_DATA &&
  2884. (ppdu_info->tlv_bitmap & (1 << HTT_PPDU_STATS_COMMON_TLV)) &&
  2885. ppdu_desc->delayed_ba) {
  2886. for (i = 0; i < ppdu_desc->num_users; i++) {
  2887. uint32_t ppdu_id;
  2888. ppdu_id = ppdu_desc->ppdu_id;
  2889. peer = dp_peer_find_by_id(pdev->soc,
  2890. ppdu_desc->user[i].peer_id);
  2891. /**
  2892. * This check is to make sure peer is not deleted
  2893. * after processing the TLVs.
  2894. */
  2895. if (!peer)
  2896. continue;
  2897. /**
  2898. * save delayed ba user info
  2899. */
  2900. if (ppdu_desc->user[i].delayed_ba) {
  2901. dp_peer_copy_delay_stats(peer,
  2902. &ppdu_desc->user[i]);
  2903. peer->last_delayed_ba_ppduid = ppdu_id;
  2904. }
  2905. dp_peer_unref_del_find_by_id(peer);
  2906. }
  2907. }
  2908. /*
  2909. * when frame type is BAR and STATS_COMMON_TLV is set
  2910. * copy the store peer delayed info to BAR status
  2911. */
  2912. if (ppdu_desc->frame_type == CDP_PPDU_FTYPE_BAR &&
  2913. (ppdu_info->tlv_bitmap & (1 << HTT_PPDU_STATS_COMMON_TLV))) {
  2914. for (i = 0; i < ppdu_desc->bar_num_users; i++) {
  2915. peer = dp_peer_find_by_id(pdev->soc,
  2916. ppdu_desc->user[i].peer_id);
  2917. /**
  2918. * This check is to make sure peer is not deleted
  2919. * after processing the TLVs.
  2920. */
  2921. if (!peer)
  2922. continue;
  2923. if (peer->last_delayed_ba) {
  2924. dp_peer_copy_stats_to_bar(peer,
  2925. &ppdu_desc->user[i]);
  2926. }
  2927. dp_peer_unref_del_find_by_id(peer);
  2928. }
  2929. }
  2930. /*
  2931. * for frame type DATA and BAR, we update stats based on MSDU,
  2932. * successful msdu and mpdu are populate from ACK BA STATUS TLV
  2933. * which comes out of order. successful mpdu also populated from
  2934. * COMPLTN COMMON TLV which comes in order. for every ppdu_info
  2935. * we store successful mpdu from both tlv and compare before delivering
  2936. * to make sure we received ACK BA STATUS TLV.
  2937. */
  2938. if (ppdu_desc->frame_type != CDP_PPDU_FTYPE_CTRL) {
  2939. /*
  2940. * successful mpdu count should match with both tlv
  2941. */
  2942. if (ppdu_info->mpdu_compltn_common_tlv !=
  2943. ppdu_info->mpdu_ack_ba_tlv)
  2944. return NULL;
  2945. }
  2946. /**
  2947. * Once all the TLVs for a given PPDU has been processed,
  2948. * return PPDU status to be delivered to higher layer
  2949. */
  2950. if (ppdu_info->tlv_bitmap != 0 &&
  2951. ppdu_info->tlv_bitmap == tlv_bitmap_expected)
  2952. return ppdu_info;
  2953. return NULL;
  2954. }
  2955. #endif /* FEATURE_PERPKT_INFO */
  2956. /**
  2957. * dp_txrx_ppdu_stats_handler() - Function to process HTT PPDU stats from FW
  2958. * @soc: DP SOC handle
  2959. * @pdev_id: pdev id
  2960. * @htt_t2h_msg: HTT message nbuf
  2961. *
  2962. * return:void
  2963. */
  2964. #if defined(WDI_EVENT_ENABLE)
  2965. #ifdef FEATURE_PERPKT_INFO
  2966. static bool dp_txrx_ppdu_stats_handler(struct dp_soc *soc,
  2967. uint8_t pdev_id, qdf_nbuf_t htt_t2h_msg)
  2968. {
  2969. struct dp_pdev *pdev = soc->pdev_list[pdev_id];
  2970. struct ppdu_info *ppdu_info = NULL;
  2971. bool free_buf = true;
  2972. if (!pdev)
  2973. return true;
  2974. if (!pdev->enhanced_stats_en && !pdev->tx_sniffer_enable &&
  2975. !pdev->mcopy_mode && !pdev->bpr_enable)
  2976. return free_buf;
  2977. ppdu_info = dp_htt_process_tlv(pdev, htt_t2h_msg);
  2978. if (pdev->mgmtctrl_frm_info.mgmt_buf) {
  2979. if (dp_process_ppdu_stats_tx_mgmtctrl_payload_tlv
  2980. (pdev, htt_t2h_msg, pdev->mgmtctrl_frm_info.ppdu_id) !=
  2981. QDF_STATUS_SUCCESS)
  2982. free_buf = false;
  2983. }
  2984. if (ppdu_info)
  2985. dp_ppdu_desc_deliver(pdev, ppdu_info);
  2986. pdev->mgmtctrl_frm_info.mgmt_buf = NULL;
  2987. pdev->mgmtctrl_frm_info.mgmt_buf_len = 0;
  2988. pdev->mgmtctrl_frm_info.ppdu_id = 0;
  2989. return free_buf;
  2990. }
  2991. #else
  2992. static bool dp_txrx_ppdu_stats_handler(struct dp_soc *soc,
  2993. uint8_t pdev_id, qdf_nbuf_t htt_t2h_msg)
  2994. {
  2995. return true;
  2996. }
  2997. #endif
  2998. #endif
  2999. /**
  3000. * dp_txrx_fw_stats_handler() - Function to process HTT EXT stats
  3001. * @soc: DP SOC handle
  3002. * @htt_t2h_msg: HTT message nbuf
  3003. *
  3004. * return:void
  3005. */
  3006. static inline void dp_txrx_fw_stats_handler(struct dp_soc *soc,
  3007. qdf_nbuf_t htt_t2h_msg)
  3008. {
  3009. uint8_t done;
  3010. qdf_nbuf_t msg_copy;
  3011. uint32_t *msg_word;
  3012. msg_word = (uint32_t *) qdf_nbuf_data(htt_t2h_msg);
  3013. msg_word = msg_word + 3;
  3014. done = HTT_T2H_EXT_STATS_CONF_TLV_DONE_GET(*msg_word);
  3015. /*
  3016. * HTT EXT stats response comes as stream of TLVs which span over
  3017. * multiple T2H messages.
  3018. * The first message will carry length of the response.
  3019. * For rest of the messages length will be zero.
  3020. *
  3021. * Clone the T2H message buffer and store it in a list to process
  3022. * it later.
  3023. *
  3024. * The original T2H message buffers gets freed in the T2H HTT event
  3025. * handler
  3026. */
  3027. msg_copy = qdf_nbuf_clone(htt_t2h_msg);
  3028. if (!msg_copy) {
  3029. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO,
  3030. "T2H messge clone failed for HTT EXT STATS");
  3031. goto error;
  3032. }
  3033. qdf_spin_lock_bh(&soc->htt_stats.lock);
  3034. qdf_nbuf_queue_add(&soc->htt_stats.msg, msg_copy);
  3035. /*
  3036. * Done bit signifies that this is the last T2H buffer in the stream of
  3037. * HTT EXT STATS message
  3038. */
  3039. if (done) {
  3040. soc->htt_stats.num_stats++;
  3041. qdf_sched_work(0, &soc->htt_stats.work);
  3042. }
  3043. qdf_spin_unlock_bh(&soc->htt_stats.lock);
  3044. return;
  3045. error:
  3046. qdf_spin_lock_bh(&soc->htt_stats.lock);
  3047. while ((msg_copy = qdf_nbuf_queue_remove(&soc->htt_stats.msg))
  3048. != NULL) {
  3049. qdf_nbuf_free(msg_copy);
  3050. }
  3051. soc->htt_stats.num_stats = 0;
  3052. qdf_spin_unlock_bh(&soc->htt_stats.lock);
  3053. return;
  3054. }
  3055. /*
  3056. * htt_soc_attach_target() - SOC level HTT setup
  3057. * @htt_soc: HTT SOC handle
  3058. *
  3059. * Return: 0 on success; error code on failure
  3060. */
  3061. int htt_soc_attach_target(struct htt_soc *htt_soc)
  3062. {
  3063. struct htt_soc *soc = (struct htt_soc *)htt_soc;
  3064. return htt_h2t_ver_req_msg(soc);
  3065. }
  3066. void htt_set_htc_handle(struct htt_soc *htt_soc, HTC_HANDLE htc_soc)
  3067. {
  3068. htt_soc->htc_soc = htc_soc;
  3069. }
  3070. HTC_HANDLE htt_get_htc_handle(struct htt_soc *htt_soc)
  3071. {
  3072. return htt_soc->htc_soc;
  3073. }
  3074. struct htt_soc *htt_soc_attach(struct dp_soc *soc, HTC_HANDLE htc_handle)
  3075. {
  3076. int i;
  3077. int j;
  3078. int alloc_size = HTT_SW_UMAC_RING_IDX_MAX * sizeof(unsigned long);
  3079. struct htt_soc *htt_soc = NULL;
  3080. htt_soc = qdf_mem_malloc(sizeof(*htt_soc));
  3081. if (!htt_soc) {
  3082. dp_err("HTT attach failed");
  3083. return NULL;
  3084. }
  3085. for (i = 0; i < MAX_PDEV_CNT; i++) {
  3086. htt_soc->pdevid_tt[i].umac_ttt = qdf_mem_malloc(alloc_size);
  3087. if (!htt_soc->pdevid_tt[i].umac_ttt)
  3088. break;
  3089. qdf_mem_set(htt_soc->pdevid_tt[i].umac_ttt, alloc_size, -1);
  3090. htt_soc->pdevid_tt[i].lmac_ttt = qdf_mem_malloc(alloc_size);
  3091. if (!htt_soc->pdevid_tt[i].lmac_ttt) {
  3092. qdf_mem_free(htt_soc->pdevid_tt[i].umac_ttt);
  3093. break;
  3094. }
  3095. qdf_mem_set(htt_soc->pdevid_tt[i].lmac_ttt, alloc_size, -1);
  3096. }
  3097. if (i != MAX_PDEV_CNT) {
  3098. for (j = 0; j < i; j++) {
  3099. qdf_mem_free(htt_soc->pdevid_tt[i].umac_ttt);
  3100. qdf_mem_free(htt_soc->pdevid_tt[i].lmac_ttt);
  3101. }
  3102. return NULL;
  3103. }
  3104. htt_soc->dp_soc = soc;
  3105. htt_soc->htc_soc = htc_handle;
  3106. HTT_TX_MUTEX_INIT(&htt_soc->htt_tx_mutex);
  3107. return htt_soc;
  3108. }
  3109. #if defined(WDI_EVENT_ENABLE) && !defined(REMOVE_PKT_LOG)
  3110. /*
  3111. * dp_ppdu_stats_ind_handler() - PPDU stats msg handler
  3112. * @htt_soc: HTT SOC handle
  3113. * @msg_word: Pointer to payload
  3114. * @htt_t2h_msg: HTT msg nbuf
  3115. *
  3116. * Return: True if buffer should be freed by caller.
  3117. */
  3118. static bool
  3119. dp_ppdu_stats_ind_handler(struct htt_soc *soc,
  3120. uint32_t *msg_word,
  3121. qdf_nbuf_t htt_t2h_msg)
  3122. {
  3123. u_int8_t pdev_id;
  3124. bool free_buf;
  3125. qdf_nbuf_set_pktlen(htt_t2h_msg, HTT_T2H_MAX_MSG_SIZE);
  3126. pdev_id = HTT_T2H_PPDU_STATS_PDEV_ID_GET(*msg_word);
  3127. pdev_id = DP_HW2SW_MACID(pdev_id);
  3128. free_buf = dp_txrx_ppdu_stats_handler(soc->dp_soc, pdev_id,
  3129. htt_t2h_msg);
  3130. dp_wdi_event_handler(WDI_EVENT_LITE_T2H, soc->dp_soc,
  3131. htt_t2h_msg, HTT_INVALID_PEER, WDI_NO_VAL,
  3132. pdev_id);
  3133. return free_buf;
  3134. }
  3135. #else
  3136. static bool
  3137. dp_ppdu_stats_ind_handler(struct htt_soc *soc,
  3138. uint32_t *msg_word,
  3139. qdf_nbuf_t htt_t2h_msg)
  3140. {
  3141. return true;
  3142. }
  3143. #endif
  3144. #if defined(WDI_EVENT_ENABLE) && \
  3145. !defined(REMOVE_PKT_LOG)
  3146. /*
  3147. * dp_pktlog_msg_handler() - Pktlog msg handler
  3148. * @htt_soc: HTT SOC handle
  3149. * @msg_word: Pointer to payload
  3150. *
  3151. * Return: None
  3152. */
  3153. static void
  3154. dp_pktlog_msg_handler(struct htt_soc *soc,
  3155. uint32_t *msg_word)
  3156. {
  3157. uint8_t pdev_id;
  3158. uint32_t *pl_hdr;
  3159. pdev_id = HTT_T2H_PKTLOG_PDEV_ID_GET(*msg_word);
  3160. pdev_id = DP_HW2SW_MACID(pdev_id);
  3161. pl_hdr = (msg_word + 1);
  3162. dp_wdi_event_handler(WDI_EVENT_OFFLOAD_ALL, soc->dp_soc,
  3163. pl_hdr, HTT_INVALID_PEER, WDI_NO_VAL,
  3164. pdev_id);
  3165. }
  3166. #else
  3167. static void
  3168. dp_pktlog_msg_handler(struct htt_soc *soc,
  3169. uint32_t *msg_word)
  3170. {
  3171. }
  3172. #endif
  3173. /*
  3174. * time_allow_print() - time allow print
  3175. * @htt_ring_tt: ringi_id array of timestamps
  3176. * @ring_id: ring_id (index)
  3177. *
  3178. * Return: 1 for successfully saving timestamp in array
  3179. * and 0 for timestamp falling within 2 seconds after last one
  3180. */
  3181. static bool time_allow_print(unsigned long *htt_ring_tt, u_int8_t ring_id)
  3182. {
  3183. unsigned long tstamp;
  3184. unsigned long delta;
  3185. tstamp = qdf_get_system_timestamp();
  3186. if (!htt_ring_tt)
  3187. return 0; //unable to print backpressure messages
  3188. if (htt_ring_tt[ring_id] == -1) {
  3189. htt_ring_tt[ring_id] = tstamp;
  3190. return 1;
  3191. }
  3192. delta = tstamp - htt_ring_tt[ring_id];
  3193. if (delta >= 2000) {
  3194. htt_ring_tt[ring_id] = tstamp;
  3195. return 1;
  3196. }
  3197. return 0;
  3198. }
  3199. static void dp_htt_alert_print(enum htt_t2h_msg_type msg_type,
  3200. u_int8_t pdev_id, u_int8_t ring_id,
  3201. u_int16_t hp_idx, u_int16_t tp_idx,
  3202. u_int32_t bkp_time, char *ring_stype)
  3203. {
  3204. dp_alert("msg_type: %d pdev_id: %d ring_type: %s ",
  3205. msg_type, pdev_id, ring_stype);
  3206. dp_alert("ring_id: %d hp_idx: %d tp_idx: %d bkpressure_time_ms: %d ",
  3207. ring_id, hp_idx, tp_idx, bkp_time);
  3208. }
  3209. /*
  3210. * dp_htt_bkp_event_alert() - htt backpressure event alert
  3211. * @msg_word: htt packet context
  3212. * @htt_soc: HTT SOC handle
  3213. *
  3214. * Return: after attempting to print stats
  3215. */
  3216. static void dp_htt_bkp_event_alert(u_int32_t *msg_word, struct htt_soc *soc)
  3217. {
  3218. u_int8_t ring_type;
  3219. u_int8_t pdev_id;
  3220. u_int8_t ring_id;
  3221. u_int16_t hp_idx;
  3222. u_int16_t tp_idx;
  3223. u_int32_t bkp_time;
  3224. enum htt_t2h_msg_type msg_type;
  3225. struct dp_soc *dpsoc;
  3226. struct dp_pdev *pdev;
  3227. struct dp_htt_timestamp *radio_tt;
  3228. if (!soc)
  3229. return;
  3230. dpsoc = (struct dp_soc *)soc->dp_soc;
  3231. msg_type = HTT_T2H_MSG_TYPE_GET(*msg_word);
  3232. ring_type = HTT_T2H_RX_BKPRESSURE_RING_TYPE_GET(*msg_word);
  3233. pdev_id = HTT_T2H_RX_BKPRESSURE_PDEV_ID_GET(*msg_word);
  3234. pdev_id = DP_HW2SW_MACID(pdev_id);
  3235. pdev = (struct dp_pdev *)dpsoc->pdev_list[pdev_id];
  3236. ring_id = HTT_T2H_RX_BKPRESSURE_RINGID_GET(*msg_word);
  3237. hp_idx = HTT_T2H_RX_BKPRESSURE_HEAD_IDX_GET(*(msg_word + 1));
  3238. tp_idx = HTT_T2H_RX_BKPRESSURE_TAIL_IDX_GET(*(msg_word + 1));
  3239. bkp_time = HTT_T2H_RX_BKPRESSURE_TIME_MS_GET(*(msg_word + 2));
  3240. radio_tt = &soc->pdevid_tt[pdev_id];
  3241. switch (ring_type) {
  3242. case HTT_SW_RING_TYPE_UMAC:
  3243. if (!time_allow_print(radio_tt->umac_ttt, ring_id))
  3244. return;
  3245. dp_htt_alert_print(msg_type, pdev_id, ring_id, hp_idx, tp_idx,
  3246. bkp_time, "HTT_SW_RING_TYPE_LMAC");
  3247. break;
  3248. case HTT_SW_RING_TYPE_LMAC:
  3249. if (!time_allow_print(radio_tt->lmac_ttt, ring_id))
  3250. return;
  3251. dp_htt_alert_print(msg_type, pdev_id, ring_id, hp_idx, tp_idx,
  3252. bkp_time, "HTT_SW_RING_TYPE_LMAC");
  3253. break;
  3254. default:
  3255. dp_htt_alert_print(msg_type, pdev_id, ring_id, hp_idx, tp_idx,
  3256. bkp_time, "UNKNOWN");
  3257. break;
  3258. }
  3259. dp_print_ring_stats(pdev);
  3260. dp_print_napi_stats(pdev->soc);
  3261. }
  3262. /*
  3263. * dp_htt_t2h_msg_handler() - Generic Target to host Msg/event handler
  3264. * @context: Opaque context (HTT SOC handle)
  3265. * @pkt: HTC packet
  3266. */
  3267. static void dp_htt_t2h_msg_handler(void *context, HTC_PACKET *pkt)
  3268. {
  3269. struct htt_soc *soc = (struct htt_soc *) context;
  3270. qdf_nbuf_t htt_t2h_msg = (qdf_nbuf_t) pkt->pPktContext;
  3271. u_int32_t *msg_word;
  3272. enum htt_t2h_msg_type msg_type;
  3273. bool free_buf = true;
  3274. /* check for successful message reception */
  3275. if (pkt->Status != QDF_STATUS_SUCCESS) {
  3276. if (pkt->Status != QDF_STATUS_E_CANCELED)
  3277. soc->stats.htc_err_cnt++;
  3278. qdf_nbuf_free(htt_t2h_msg);
  3279. return;
  3280. }
  3281. /* TODO: Check if we should pop the HTC/HTT header alignment padding */
  3282. msg_word = (u_int32_t *) qdf_nbuf_data(htt_t2h_msg);
  3283. msg_type = HTT_T2H_MSG_TYPE_GET(*msg_word);
  3284. htt_event_record(soc->htt_logger_handle,
  3285. msg_type, (uint8_t *)msg_word);
  3286. switch (msg_type) {
  3287. case HTT_T2H_MSG_TYPE_BKPRESSURE_EVENT_IND:
  3288. {
  3289. dp_htt_bkp_event_alert(msg_word, soc);
  3290. break;
  3291. }
  3292. case HTT_T2H_MSG_TYPE_PEER_MAP:
  3293. {
  3294. u_int8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  3295. u_int8_t *peer_mac_addr;
  3296. u_int16_t peer_id;
  3297. u_int16_t hw_peer_id;
  3298. u_int8_t vdev_id;
  3299. u_int8_t is_wds;
  3300. struct dp_soc *dpsoc = (struct dp_soc *)soc->dp_soc;
  3301. peer_id = HTT_RX_PEER_MAP_PEER_ID_GET(*msg_word);
  3302. hw_peer_id =
  3303. HTT_RX_PEER_MAP_HW_PEER_ID_GET(*(msg_word+2));
  3304. vdev_id = HTT_RX_PEER_MAP_VDEV_ID_GET(*msg_word);
  3305. peer_mac_addr = htt_t2h_mac_addr_deswizzle(
  3306. (u_int8_t *) (msg_word+1),
  3307. &mac_addr_deswizzle_buf[0]);
  3308. QDF_TRACE(QDF_MODULE_ID_TXRX,
  3309. QDF_TRACE_LEVEL_INFO,
  3310. "HTT_T2H_MSG_TYPE_PEER_MAP msg for peer id %d vdev id %d n",
  3311. peer_id, vdev_id);
  3312. /*
  3313. * check if peer already exists for this peer_id, if so
  3314. * this peer map event is in response for a wds peer add
  3315. * wmi command sent during wds source port learning.
  3316. * in this case just add the ast entry to the existing
  3317. * peer ast_list.
  3318. */
  3319. is_wds = !!(dpsoc->peer_id_to_obj_map[peer_id]);
  3320. dp_rx_peer_map_handler(soc->dp_soc, peer_id, hw_peer_id,
  3321. vdev_id, peer_mac_addr, 0,
  3322. is_wds);
  3323. break;
  3324. }
  3325. case HTT_T2H_MSG_TYPE_PEER_UNMAP:
  3326. {
  3327. u_int16_t peer_id;
  3328. u_int8_t vdev_id;
  3329. u_int8_t mac_addr[QDF_MAC_ADDR_SIZE] = {0};
  3330. peer_id = HTT_RX_PEER_UNMAP_PEER_ID_GET(*msg_word);
  3331. vdev_id = HTT_RX_PEER_UNMAP_VDEV_ID_GET(*msg_word);
  3332. dp_rx_peer_unmap_handler(soc->dp_soc, peer_id,
  3333. vdev_id, mac_addr, 0);
  3334. break;
  3335. }
  3336. case HTT_T2H_MSG_TYPE_SEC_IND:
  3337. {
  3338. u_int16_t peer_id;
  3339. enum cdp_sec_type sec_type;
  3340. int is_unicast;
  3341. peer_id = HTT_SEC_IND_PEER_ID_GET(*msg_word);
  3342. sec_type = HTT_SEC_IND_SEC_TYPE_GET(*msg_word);
  3343. is_unicast = HTT_SEC_IND_UNICAST_GET(*msg_word);
  3344. /* point to the first part of the Michael key */
  3345. msg_word++;
  3346. dp_rx_sec_ind_handler(
  3347. soc->dp_soc, peer_id, sec_type, is_unicast,
  3348. msg_word, msg_word + 2);
  3349. break;
  3350. }
  3351. case HTT_T2H_MSG_TYPE_PPDU_STATS_IND:
  3352. {
  3353. free_buf = dp_ppdu_stats_ind_handler(soc, msg_word,
  3354. htt_t2h_msg);
  3355. break;
  3356. }
  3357. case HTT_T2H_MSG_TYPE_PKTLOG:
  3358. {
  3359. dp_pktlog_msg_handler(soc, msg_word);
  3360. break;
  3361. }
  3362. case HTT_T2H_MSG_TYPE_VERSION_CONF:
  3363. {
  3364. htc_pm_runtime_put(soc->htc_soc);
  3365. soc->tgt_ver.major = HTT_VER_CONF_MAJOR_GET(*msg_word);
  3366. soc->tgt_ver.minor = HTT_VER_CONF_MINOR_GET(*msg_word);
  3367. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_HIGH,
  3368. "target uses HTT version %d.%d; host uses %d.%d",
  3369. soc->tgt_ver.major, soc->tgt_ver.minor,
  3370. HTT_CURRENT_VERSION_MAJOR,
  3371. HTT_CURRENT_VERSION_MINOR);
  3372. if (soc->tgt_ver.major != HTT_CURRENT_VERSION_MAJOR) {
  3373. QDF_TRACE(QDF_MODULE_ID_TXRX,
  3374. QDF_TRACE_LEVEL_ERROR,
  3375. "*** Incompatible host/target HTT versions!");
  3376. }
  3377. /* abort if the target is incompatible with the host */
  3378. qdf_assert(soc->tgt_ver.major ==
  3379. HTT_CURRENT_VERSION_MAJOR);
  3380. if (soc->tgt_ver.minor != HTT_CURRENT_VERSION_MINOR) {
  3381. QDF_TRACE(QDF_MODULE_ID_TXRX,
  3382. QDF_TRACE_LEVEL_WARN,
  3383. "*** Warning: host/target HTT versions"
  3384. " are different, though compatible!");
  3385. }
  3386. break;
  3387. }
  3388. case HTT_T2H_MSG_TYPE_RX_ADDBA:
  3389. {
  3390. uint16_t peer_id;
  3391. uint8_t tid;
  3392. uint8_t win_sz;
  3393. uint16_t status;
  3394. struct dp_peer *peer;
  3395. /*
  3396. * Update REO Queue Desc with new values
  3397. */
  3398. peer_id = HTT_RX_ADDBA_PEER_ID_GET(*msg_word);
  3399. tid = HTT_RX_ADDBA_TID_GET(*msg_word);
  3400. win_sz = HTT_RX_ADDBA_WIN_SIZE_GET(*msg_word);
  3401. peer = dp_peer_find_by_id(soc->dp_soc, peer_id);
  3402. /*
  3403. * Window size needs to be incremented by 1
  3404. * since fw needs to represent a value of 256
  3405. * using just 8 bits
  3406. */
  3407. if (peer) {
  3408. status = dp_addba_requestprocess_wifi3(peer,
  3409. 0, tid, 0, win_sz + 1, 0xffff);
  3410. /*
  3411. * If PEER_LOCK_REF_PROTECT enbled dec ref
  3412. * which is inc by dp_peer_find_by_id
  3413. */
  3414. dp_peer_unref_del_find_by_id(peer);
  3415. QDF_TRACE(QDF_MODULE_ID_TXRX,
  3416. QDF_TRACE_LEVEL_INFO,
  3417. FL("PeerID %d BAW %d TID %d stat %d"),
  3418. peer_id, win_sz, tid, status);
  3419. } else {
  3420. QDF_TRACE(QDF_MODULE_ID_TXRX,
  3421. QDF_TRACE_LEVEL_ERROR,
  3422. FL("Peer not found peer id %d"),
  3423. peer_id);
  3424. }
  3425. break;
  3426. }
  3427. case HTT_T2H_MSG_TYPE_EXT_STATS_CONF:
  3428. {
  3429. dp_txrx_fw_stats_handler(soc->dp_soc, htt_t2h_msg);
  3430. break;
  3431. }
  3432. case HTT_T2H_MSG_TYPE_PEER_MAP_V2:
  3433. {
  3434. u_int8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  3435. u_int8_t *peer_mac_addr;
  3436. u_int16_t peer_id;
  3437. u_int16_t hw_peer_id;
  3438. u_int8_t vdev_id;
  3439. bool is_wds;
  3440. u_int16_t ast_hash;
  3441. peer_id = HTT_RX_PEER_MAP_V2_SW_PEER_ID_GET(*msg_word);
  3442. hw_peer_id =
  3443. HTT_RX_PEER_MAP_V2_HW_PEER_ID_GET(*(msg_word + 2));
  3444. vdev_id = HTT_RX_PEER_MAP_V2_VDEV_ID_GET(*msg_word);
  3445. peer_mac_addr =
  3446. htt_t2h_mac_addr_deswizzle((u_int8_t *)(msg_word + 1),
  3447. &mac_addr_deswizzle_buf[0]);
  3448. is_wds =
  3449. HTT_RX_PEER_MAP_V2_NEXT_HOP_GET(*(msg_word + 3));
  3450. ast_hash =
  3451. HTT_RX_PEER_MAP_V2_AST_HASH_VALUE_GET(*(msg_word + 3));
  3452. QDF_TRACE(QDF_MODULE_ID_TXRX,
  3453. QDF_TRACE_LEVEL_INFO,
  3454. "HTT_T2H_MSG_TYPE_PEER_MAP msg for peer id %d vdev id %d n",
  3455. peer_id, vdev_id);
  3456. dp_rx_peer_map_handler(soc->dp_soc, peer_id,
  3457. hw_peer_id, vdev_id,
  3458. peer_mac_addr, ast_hash,
  3459. is_wds);
  3460. break;
  3461. }
  3462. case HTT_T2H_MSG_TYPE_PEER_UNMAP_V2:
  3463. {
  3464. u_int8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  3465. u_int8_t *mac_addr;
  3466. u_int16_t peer_id;
  3467. u_int8_t vdev_id;
  3468. u_int8_t is_wds;
  3469. peer_id =
  3470. HTT_RX_PEER_UNMAP_V2_SW_PEER_ID_GET(*msg_word);
  3471. vdev_id = HTT_RX_PEER_UNMAP_V2_VDEV_ID_GET(*msg_word);
  3472. mac_addr =
  3473. htt_t2h_mac_addr_deswizzle((u_int8_t *)(msg_word + 1),
  3474. &mac_addr_deswizzle_buf[0]);
  3475. is_wds =
  3476. HTT_RX_PEER_UNMAP_V2_NEXT_HOP_GET(*(msg_word + 2));
  3477. QDF_TRACE(QDF_MODULE_ID_TXRX,
  3478. QDF_TRACE_LEVEL_INFO,
  3479. "HTT_T2H_MSG_TYPE_PEER_UNMAP msg for peer id %d vdev id %d n",
  3480. peer_id, vdev_id);
  3481. dp_rx_peer_unmap_handler(soc->dp_soc, peer_id,
  3482. vdev_id, mac_addr,
  3483. is_wds);
  3484. break;
  3485. }
  3486. default:
  3487. break;
  3488. };
  3489. /* Free the indication buffer */
  3490. if (free_buf)
  3491. qdf_nbuf_free(htt_t2h_msg);
  3492. }
  3493. /*
  3494. * dp_htt_h2t_full() - Send full handler (called from HTC)
  3495. * @context: Opaque context (HTT SOC handle)
  3496. * @pkt: HTC packet
  3497. *
  3498. * Return: enum htc_send_full_action
  3499. */
  3500. static enum htc_send_full_action
  3501. dp_htt_h2t_full(void *context, HTC_PACKET *pkt)
  3502. {
  3503. return HTC_SEND_FULL_KEEP;
  3504. }
  3505. /*
  3506. * dp_htt_hif_t2h_hp_callback() - HIF callback for high priority T2H messages
  3507. * @context: Opaque context (HTT SOC handle)
  3508. * @nbuf: nbuf containing T2H message
  3509. * @pipe_id: HIF pipe ID
  3510. *
  3511. * Return: QDF_STATUS
  3512. *
  3513. * TODO: Temporary change to bypass HTC connection for this new HIF pipe, which
  3514. * will be used for packet log and other high-priority HTT messages. Proper
  3515. * HTC connection to be added later once required FW changes are available
  3516. */
  3517. static QDF_STATUS
  3518. dp_htt_hif_t2h_hp_callback (void *context, qdf_nbuf_t nbuf, uint8_t pipe_id)
  3519. {
  3520. QDF_STATUS rc = QDF_STATUS_SUCCESS;
  3521. HTC_PACKET htc_pkt;
  3522. qdf_assert_always(pipe_id == DP_HTT_T2H_HP_PIPE);
  3523. qdf_mem_zero(&htc_pkt, sizeof(htc_pkt));
  3524. htc_pkt.Status = QDF_STATUS_SUCCESS;
  3525. htc_pkt.pPktContext = (void *)nbuf;
  3526. dp_htt_t2h_msg_handler(context, &htc_pkt);
  3527. return rc;
  3528. }
  3529. /*
  3530. * htt_htc_soc_attach() - Register SOC level HTT instance with HTC
  3531. * @htt_soc: HTT SOC handle
  3532. *
  3533. * Return: QDF_STATUS
  3534. */
  3535. static QDF_STATUS
  3536. htt_htc_soc_attach(struct htt_soc *soc)
  3537. {
  3538. struct htc_service_connect_req connect;
  3539. struct htc_service_connect_resp response;
  3540. QDF_STATUS status;
  3541. struct dp_soc *dpsoc = soc->dp_soc;
  3542. qdf_mem_zero(&connect, sizeof(connect));
  3543. qdf_mem_zero(&response, sizeof(response));
  3544. connect.pMetaData = NULL;
  3545. connect.MetaDataLength = 0;
  3546. connect.EpCallbacks.pContext = soc;
  3547. connect.EpCallbacks.EpTxComplete = dp_htt_h2t_send_complete;
  3548. connect.EpCallbacks.EpTxCompleteMultiple = NULL;
  3549. connect.EpCallbacks.EpRecv = dp_htt_t2h_msg_handler;
  3550. /* rx buffers currently are provided by HIF, not by EpRecvRefill */
  3551. connect.EpCallbacks.EpRecvRefill = NULL;
  3552. /* N/A, fill is done by HIF */
  3553. connect.EpCallbacks.RecvRefillWaterMark = 1;
  3554. connect.EpCallbacks.EpSendFull = dp_htt_h2t_full;
  3555. /*
  3556. * Specify how deep to let a queue get before htc_send_pkt will
  3557. * call the EpSendFull function due to excessive send queue depth.
  3558. */
  3559. connect.MaxSendQueueDepth = DP_HTT_MAX_SEND_QUEUE_DEPTH;
  3560. /* disable flow control for HTT data message service */
  3561. connect.ConnectionFlags |= HTC_CONNECT_FLAGS_DISABLE_CREDIT_FLOW_CTRL;
  3562. /* connect to control service */
  3563. connect.service_id = HTT_DATA_MSG_SVC;
  3564. status = htc_connect_service(soc->htc_soc, &connect, &response);
  3565. if (status != QDF_STATUS_SUCCESS)
  3566. return status;
  3567. soc->htc_endpoint = response.Endpoint;
  3568. hif_save_htc_htt_config_endpoint(dpsoc->hif_handle, soc->htc_endpoint);
  3569. htt_interface_logging_init(&soc->htt_logger_handle);
  3570. dp_hif_update_pipe_callback(soc->dp_soc, (void *)soc,
  3571. dp_htt_hif_t2h_hp_callback, DP_HTT_T2H_HP_PIPE);
  3572. return QDF_STATUS_SUCCESS; /* success */
  3573. }
  3574. /*
  3575. * htt_soc_initialize() - SOC level HTT initialization
  3576. * @htt_soc: Opaque htt SOC handle
  3577. * @ctrl_psoc: Opaque ctrl SOC handle
  3578. * @htc_soc: SOC level HTC handle
  3579. * @hal_soc: Opaque HAL SOC handle
  3580. * @osdev: QDF device
  3581. *
  3582. * Return: HTT handle on success; NULL on failure
  3583. */
  3584. void *
  3585. htt_soc_initialize(struct htt_soc *htt_soc,
  3586. struct cdp_ctrl_objmgr_psoc *ctrl_psoc,
  3587. HTC_HANDLE htc_soc,
  3588. hal_soc_handle_t hal_soc_hdl, qdf_device_t osdev)
  3589. {
  3590. struct htt_soc *soc = (struct htt_soc *)htt_soc;
  3591. soc->osdev = osdev;
  3592. soc->ctrl_psoc = ctrl_psoc;
  3593. soc->htc_soc = htc_soc;
  3594. soc->hal_soc = hal_soc_hdl;
  3595. if (htt_htc_soc_attach(soc))
  3596. goto fail2;
  3597. return soc;
  3598. fail2:
  3599. return NULL;
  3600. }
  3601. void htt_soc_htc_dealloc(struct htt_soc *htt_handle)
  3602. {
  3603. htt_interface_logging_deinit(htt_handle->htt_logger_handle);
  3604. htt_htc_misc_pkt_pool_free(htt_handle);
  3605. htt_htc_pkt_pool_free(htt_handle);
  3606. }
  3607. /*
  3608. * htt_soc_htc_prealloc() - HTC memory prealloc
  3609. * @htt_soc: SOC level HTT handle
  3610. *
  3611. * Return: QDF_STATUS_SUCCESS on Success or
  3612. * QDF_STATUS_E_NOMEM on allocation failure
  3613. */
  3614. QDF_STATUS htt_soc_htc_prealloc(struct htt_soc *soc)
  3615. {
  3616. int i;
  3617. soc->htt_htc_pkt_freelist = NULL;
  3618. /* pre-allocate some HTC_PACKET objects */
  3619. for (i = 0; i < HTT_HTC_PKT_POOL_INIT_SIZE; i++) {
  3620. struct dp_htt_htc_pkt_union *pkt;
  3621. pkt = qdf_mem_malloc(sizeof(*pkt));
  3622. if (!pkt)
  3623. return QDF_STATUS_E_NOMEM;
  3624. htt_htc_pkt_free(soc, &pkt->u.pkt);
  3625. }
  3626. return QDF_STATUS_SUCCESS;
  3627. }
  3628. /*
  3629. * htt_soc_detach() - Free SOC level HTT handle
  3630. * @htt_hdl: HTT SOC handle
  3631. */
  3632. void htt_soc_detach(struct htt_soc *htt_hdl)
  3633. {
  3634. int i;
  3635. struct htt_soc *htt_handle = (struct htt_soc *)htt_hdl;
  3636. for (i = 0; i < MAX_PDEV_CNT; i++) {
  3637. qdf_mem_free(htt_handle->pdevid_tt[i].umac_ttt);
  3638. qdf_mem_free(htt_handle->pdevid_tt[i].lmac_ttt);
  3639. }
  3640. HTT_TX_MUTEX_DESTROY(&htt_handle->htt_tx_mutex);
  3641. qdf_mem_free(htt_handle);
  3642. }
  3643. /**
  3644. * dp_h2t_ext_stats_msg_send(): function to contruct HTT message to pass to FW
  3645. * @pdev: DP PDEV handle
  3646. * @stats_type_upload_mask: stats type requested by user
  3647. * @config_param_0: extra configuration parameters
  3648. * @config_param_1: extra configuration parameters
  3649. * @config_param_2: extra configuration parameters
  3650. * @config_param_3: extra configuration parameters
  3651. * @mac_id: mac number
  3652. *
  3653. * return: QDF STATUS
  3654. */
  3655. QDF_STATUS dp_h2t_ext_stats_msg_send(struct dp_pdev *pdev,
  3656. uint32_t stats_type_upload_mask, uint32_t config_param_0,
  3657. uint32_t config_param_1, uint32_t config_param_2,
  3658. uint32_t config_param_3, int cookie_val, int cookie_msb,
  3659. uint8_t mac_id)
  3660. {
  3661. struct htt_soc *soc = pdev->soc->htt_handle;
  3662. struct dp_htt_htc_pkt *pkt;
  3663. qdf_nbuf_t msg;
  3664. uint32_t *msg_word;
  3665. uint8_t pdev_mask = 0;
  3666. uint8_t *htt_logger_bufp;
  3667. msg = qdf_nbuf_alloc(
  3668. soc->osdev,
  3669. HTT_MSG_BUF_SIZE(HTT_H2T_EXT_STATS_REQ_MSG_SZ),
  3670. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  3671. if (!msg)
  3672. return QDF_STATUS_E_NOMEM;
  3673. /*TODO:Add support for SOC stats
  3674. * Bit 0: SOC Stats
  3675. * Bit 1: Pdev stats for pdev id 0
  3676. * Bit 2: Pdev stats for pdev id 1
  3677. * Bit 3: Pdev stats for pdev id 2
  3678. */
  3679. mac_id = dp_get_mac_id_for_pdev(mac_id, pdev->pdev_id);
  3680. pdev_mask = 1 << DP_SW2HW_MACID(mac_id);
  3681. /*
  3682. * Set the length of the message.
  3683. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  3684. * separately during the below call to qdf_nbuf_push_head.
  3685. * The contribution from the HTC header is added separately inside HTC.
  3686. */
  3687. if (qdf_nbuf_put_tail(msg, HTT_H2T_EXT_STATS_REQ_MSG_SZ) == NULL) {
  3688. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  3689. "Failed to expand head for HTT_EXT_STATS");
  3690. qdf_nbuf_free(msg);
  3691. return QDF_STATUS_E_FAILURE;
  3692. }
  3693. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  3694. "-----%s:%d----\n cookie <-> %d\n config_param_0 %u\n"
  3695. "config_param_1 %u\n config_param_2 %u\n"
  3696. "config_param_4 %u\n -------------",
  3697. __func__, __LINE__, cookie_val, config_param_0,
  3698. config_param_1, config_param_2, config_param_3);
  3699. msg_word = (uint32_t *) qdf_nbuf_data(msg);
  3700. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  3701. htt_logger_bufp = (uint8_t *)msg_word;
  3702. *msg_word = 0;
  3703. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_EXT_STATS_REQ);
  3704. HTT_H2T_EXT_STATS_REQ_PDEV_MASK_SET(*msg_word, pdev_mask);
  3705. HTT_H2T_EXT_STATS_REQ_STATS_TYPE_SET(*msg_word, stats_type_upload_mask);
  3706. /* word 1 */
  3707. msg_word++;
  3708. *msg_word = 0;
  3709. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_0);
  3710. /* word 2 */
  3711. msg_word++;
  3712. *msg_word = 0;
  3713. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_1);
  3714. /* word 3 */
  3715. msg_word++;
  3716. *msg_word = 0;
  3717. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_2);
  3718. /* word 4 */
  3719. msg_word++;
  3720. *msg_word = 0;
  3721. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_3);
  3722. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, 0);
  3723. /* word 5 */
  3724. msg_word++;
  3725. /* word 6 */
  3726. msg_word++;
  3727. *msg_word = 0;
  3728. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, cookie_val);
  3729. /* word 7 */
  3730. msg_word++;
  3731. *msg_word = 0;
  3732. /*Using last 2 bits for pdev_id */
  3733. cookie_msb = ((cookie_msb << 2) | pdev->pdev_id);
  3734. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, cookie_msb);
  3735. pkt = htt_htc_pkt_alloc(soc);
  3736. if (!pkt) {
  3737. qdf_nbuf_free(msg);
  3738. return QDF_STATUS_E_NOMEM;
  3739. }
  3740. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  3741. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  3742. dp_htt_h2t_send_complete_free_netbuf,
  3743. qdf_nbuf_data(msg), qdf_nbuf_len(msg),
  3744. soc->htc_endpoint,
  3745. /* tag for FW response msg not guaranteed */
  3746. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  3747. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  3748. DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_EXT_STATS_REQ,
  3749. htt_logger_bufp);
  3750. return 0;
  3751. }
  3752. /* This macro will revert once proper HTT header will define for
  3753. * HTT_H2T_MSG_TYPE_PPDU_STATS_CFG in htt.h file
  3754. * */
  3755. #if defined(WDI_EVENT_ENABLE)
  3756. /**
  3757. * dp_h2t_cfg_stats_msg_send(): function to construct HTT message to pass to FW
  3758. * @pdev: DP PDEV handle
  3759. * @stats_type_upload_mask: stats type requested by user
  3760. * @mac_id: Mac id number
  3761. *
  3762. * return: QDF STATUS
  3763. */
  3764. QDF_STATUS dp_h2t_cfg_stats_msg_send(struct dp_pdev *pdev,
  3765. uint32_t stats_type_upload_mask, uint8_t mac_id)
  3766. {
  3767. struct htt_soc *soc = pdev->soc->htt_handle;
  3768. struct dp_htt_htc_pkt *pkt;
  3769. qdf_nbuf_t msg;
  3770. uint32_t *msg_word;
  3771. uint8_t pdev_mask;
  3772. msg = qdf_nbuf_alloc(
  3773. soc->osdev,
  3774. HTT_MSG_BUF_SIZE(HTT_H2T_PPDU_STATS_CFG_MSG_SZ),
  3775. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, true);
  3776. if (!msg) {
  3777. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  3778. "Fail to allocate HTT_H2T_PPDU_STATS_CFG_MSG_SZ msg buffer");
  3779. qdf_assert(0);
  3780. return QDF_STATUS_E_NOMEM;
  3781. }
  3782. /*TODO:Add support for SOC stats
  3783. * Bit 0: SOC Stats
  3784. * Bit 1: Pdev stats for pdev id 0
  3785. * Bit 2: Pdev stats for pdev id 1
  3786. * Bit 3: Pdev stats for pdev id 2
  3787. */
  3788. pdev_mask = 1 << DP_SW2HW_MACID(mac_id);
  3789. /*
  3790. * Set the length of the message.
  3791. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  3792. * separately during the below call to qdf_nbuf_push_head.
  3793. * The contribution from the HTC header is added separately inside HTC.
  3794. */
  3795. if (qdf_nbuf_put_tail(msg, HTT_H2T_PPDU_STATS_CFG_MSG_SZ) == NULL) {
  3796. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  3797. "Failed to expand head for HTT_CFG_STATS");
  3798. qdf_nbuf_free(msg);
  3799. return QDF_STATUS_E_FAILURE;
  3800. }
  3801. msg_word = (uint32_t *) qdf_nbuf_data(msg);
  3802. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  3803. *msg_word = 0;
  3804. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_PPDU_STATS_CFG);
  3805. HTT_H2T_PPDU_STATS_CFG_PDEV_MASK_SET(*msg_word, pdev_mask);
  3806. HTT_H2T_PPDU_STATS_CFG_TLV_BITMASK_SET(*msg_word,
  3807. stats_type_upload_mask);
  3808. pkt = htt_htc_pkt_alloc(soc);
  3809. if (!pkt) {
  3810. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  3811. "Fail to allocate dp_htt_htc_pkt buffer");
  3812. qdf_assert(0);
  3813. qdf_nbuf_free(msg);
  3814. return QDF_STATUS_E_NOMEM;
  3815. }
  3816. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  3817. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  3818. dp_htt_h2t_send_complete_free_netbuf,
  3819. qdf_nbuf_data(msg), qdf_nbuf_len(msg),
  3820. soc->htc_endpoint,
  3821. 1); /* tag - not relevant here */
  3822. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  3823. DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_PPDU_STATS_CFG,
  3824. (uint8_t *)msg_word);
  3825. return 0;
  3826. }
  3827. #endif
  3828. void
  3829. dp_peer_update_inactive_time(struct dp_pdev *pdev, uint32_t tag_type,
  3830. uint32_t *tag_buf)
  3831. {
  3832. switch (tag_type) {
  3833. case HTT_STATS_PEER_DETAILS_TAG:
  3834. {
  3835. htt_peer_details_tlv *dp_stats_buf =
  3836. (htt_peer_details_tlv *)tag_buf;
  3837. pdev->fw_stats_peer_id = dp_stats_buf->sw_peer_id;
  3838. }
  3839. break;
  3840. case HTT_STATS_PEER_STATS_CMN_TAG:
  3841. {
  3842. htt_peer_stats_cmn_tlv *dp_stats_buf =
  3843. (htt_peer_stats_cmn_tlv *)tag_buf;
  3844. struct dp_peer *peer = dp_peer_find_by_id(pdev->soc,
  3845. pdev->fw_stats_peer_id);
  3846. if (peer && !peer->bss_peer) {
  3847. peer->stats.tx.inactive_time =
  3848. dp_stats_buf->inactive_time;
  3849. qdf_event_set(&pdev->fw_peer_stats_event);
  3850. }
  3851. if (peer)
  3852. dp_peer_unref_del_find_by_id(peer);
  3853. }
  3854. break;
  3855. default:
  3856. qdf_err("Invalid tag_type");
  3857. }
  3858. }
  3859. /**
  3860. * dp_htt_rx_flow_fst_setup(): Send HTT Rx FST setup message to FW
  3861. * @pdev: DP pdev handle
  3862. * @fse_setup_info: FST setup parameters
  3863. *
  3864. * Return: Success when HTT message is sent, error on failure
  3865. */
  3866. QDF_STATUS
  3867. dp_htt_rx_flow_fst_setup(struct dp_pdev *pdev,
  3868. struct dp_htt_rx_flow_fst_setup *fse_setup_info)
  3869. {
  3870. struct htt_soc *soc = pdev->soc->htt_handle;
  3871. struct dp_htt_htc_pkt *pkt;
  3872. qdf_nbuf_t msg;
  3873. u_int32_t *msg_word;
  3874. struct htt_h2t_msg_rx_fse_setup_t *fse_setup;
  3875. uint8_t *htt_logger_bufp;
  3876. u_int32_t *key;
  3877. msg = qdf_nbuf_alloc(
  3878. soc->osdev,
  3879. HTT_MSG_BUF_SIZE(sizeof(struct htt_h2t_msg_rx_fse_setup_t)),
  3880. /* reserve room for the HTC header */
  3881. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  3882. if (!msg)
  3883. return QDF_STATUS_E_NOMEM;
  3884. /*
  3885. * Set the length of the message.
  3886. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  3887. * separately during the below call to qdf_nbuf_push_head.
  3888. * The contribution from the HTC header is added separately inside HTC.
  3889. */
  3890. if (!qdf_nbuf_put_tail(msg,
  3891. sizeof(struct htt_h2t_msg_rx_fse_setup_t))) {
  3892. qdf_err("Failed to expand head for HTT RX_FSE_SETUP msg");
  3893. return QDF_STATUS_E_FAILURE;
  3894. }
  3895. /* fill in the message contents */
  3896. msg_word = (u_int32_t *)qdf_nbuf_data(msg);
  3897. memset(msg_word, 0, sizeof(struct htt_h2t_msg_rx_fse_setup_t));
  3898. /* rewind beyond alignment pad to get to the HTC header reserved area */
  3899. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  3900. htt_logger_bufp = (uint8_t *)msg_word;
  3901. *msg_word = 0;
  3902. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RX_FSE_SETUP_CFG);
  3903. fse_setup = (struct htt_h2t_msg_rx_fse_setup_t *)msg_word;
  3904. HTT_RX_FSE_SETUP_PDEV_ID_SET(*msg_word, fse_setup_info->pdev_id);
  3905. msg_word++;
  3906. HTT_RX_FSE_SETUP_NUM_REC_SET(*msg_word, fse_setup_info->max_entries);
  3907. HTT_RX_FSE_SETUP_MAX_SEARCH_SET(*msg_word, fse_setup_info->max_search);
  3908. HTT_RX_FSE_SETUP_IP_DA_SA_PREFIX_SET(*msg_word,
  3909. fse_setup_info->ip_da_sa_prefix);
  3910. msg_word++;
  3911. HTT_RX_FSE_SETUP_BASE_ADDR_LO_SET(*msg_word,
  3912. fse_setup_info->base_addr_lo);
  3913. msg_word++;
  3914. HTT_RX_FSE_SETUP_BASE_ADDR_HI_SET(*msg_word,
  3915. fse_setup_info->base_addr_hi);
  3916. key = (u_int32_t *)fse_setup_info->hash_key;
  3917. fse_setup->toeplitz31_0 = *key++;
  3918. fse_setup->toeplitz63_32 = *key++;
  3919. fse_setup->toeplitz95_64 = *key++;
  3920. fse_setup->toeplitz127_96 = *key++;
  3921. fse_setup->toeplitz159_128 = *key++;
  3922. fse_setup->toeplitz191_160 = *key++;
  3923. fse_setup->toeplitz223_192 = *key++;
  3924. fse_setup->toeplitz255_224 = *key++;
  3925. fse_setup->toeplitz287_256 = *key++;
  3926. fse_setup->toeplitz314_288 = *key;
  3927. msg_word++;
  3928. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz31_0);
  3929. msg_word++;
  3930. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz63_32);
  3931. msg_word++;
  3932. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz95_64);
  3933. msg_word++;
  3934. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz127_96);
  3935. msg_word++;
  3936. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz159_128);
  3937. msg_word++;
  3938. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz191_160);
  3939. msg_word++;
  3940. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz223_192);
  3941. msg_word++;
  3942. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz255_224);
  3943. msg_word++;
  3944. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz287_256);
  3945. msg_word++;
  3946. HTT_RX_FSE_SETUP_HASH_314_288_SET(*msg_word,
  3947. fse_setup->toeplitz314_288);
  3948. pkt = htt_htc_pkt_alloc(soc);
  3949. if (!pkt) {
  3950. qdf_err("Fail to allocate dp_htt_htc_pkt buffer");
  3951. qdf_assert(0);
  3952. qdf_nbuf_free(msg);
  3953. return QDF_STATUS_E_RESOURCES; /* failure */
  3954. }
  3955. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  3956. SET_HTC_PACKET_INFO_TX(
  3957. &pkt->htc_pkt,
  3958. dp_htt_h2t_send_complete_free_netbuf,
  3959. qdf_nbuf_data(msg),
  3960. qdf_nbuf_len(msg),
  3961. soc->htc_endpoint,
  3962. 1); /* tag - not relevant here */
  3963. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  3964. DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_RX_FSE_SETUP_CFG,
  3965. htt_logger_bufp);
  3966. qdf_info("HTT_H2T RX_FSE_SETUP sent to FW for pdev = %u",
  3967. fse_setup_info->pdev_id);
  3968. QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_ANY, QDF_TRACE_LEVEL_DEBUG,
  3969. (void *)fse_setup_info->hash_key,
  3970. fse_setup_info->hash_key_len);
  3971. return QDF_STATUS_SUCCESS;
  3972. }
  3973. /**
  3974. * dp_htt_rx_flow_fse_operation(): Send HTT Flow Search Entry msg to
  3975. * add/del a flow in HW
  3976. * @pdev: DP pdev handle
  3977. * @fse_op_info: Flow entry parameters
  3978. *
  3979. * Return: Success when HTT message is sent, error on failure
  3980. */
  3981. QDF_STATUS
  3982. dp_htt_rx_flow_fse_operation(struct dp_pdev *pdev,
  3983. struct dp_htt_rx_flow_fst_operation *fse_op_info)
  3984. {
  3985. struct htt_soc *soc = pdev->soc->htt_handle;
  3986. struct dp_htt_htc_pkt *pkt;
  3987. qdf_nbuf_t msg;
  3988. u_int32_t *msg_word;
  3989. struct htt_h2t_msg_rx_fse_operation_t *fse_operation;
  3990. uint8_t *htt_logger_bufp;
  3991. msg = qdf_nbuf_alloc(
  3992. soc->osdev,
  3993. HTT_MSG_BUF_SIZE(sizeof(struct htt_h2t_msg_rx_fse_operation_t)),
  3994. /* reserve room for the HTC header */
  3995. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  3996. if (!msg)
  3997. return QDF_STATUS_E_NOMEM;
  3998. /*
  3999. * Set the length of the message.
  4000. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4001. * separately during the below call to qdf_nbuf_push_head.
  4002. * The contribution from the HTC header is added separately inside HTC.
  4003. */
  4004. if (!qdf_nbuf_put_tail(msg,
  4005. sizeof(struct htt_h2t_msg_rx_fse_operation_t))) {
  4006. qdf_err("Failed to expand head for HTT_RX_FSE_OPERATION msg");
  4007. return QDF_STATUS_E_FAILURE;
  4008. }
  4009. /* fill in the message contents */
  4010. msg_word = (u_int32_t *)qdf_nbuf_data(msg);
  4011. memset(msg_word, 0, sizeof(struct htt_h2t_msg_rx_fse_operation_t));
  4012. /* rewind beyond alignment pad to get to the HTC header reserved area */
  4013. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4014. htt_logger_bufp = (uint8_t *)msg_word;
  4015. *msg_word = 0;
  4016. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RX_FSE_OPERATION_CFG);
  4017. fse_operation = (struct htt_h2t_msg_rx_fse_operation_t *)msg_word;
  4018. HTT_RX_FSE_OPERATION_PDEV_ID_SET(*msg_word, fse_op_info->pdev_id);
  4019. msg_word++;
  4020. HTT_RX_FSE_IPSEC_VALID_SET(*msg_word, false);
  4021. if (fse_op_info->op_code == DP_HTT_FST_CACHE_INVALIDATE_ENTRY) {
  4022. HTT_RX_FSE_OPERATION_SET(*msg_word,
  4023. HTT_RX_FSE_CACHE_INVALIDATE_ENTRY);
  4024. msg_word++;
  4025. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4026. *msg_word,
  4027. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_31_0));
  4028. msg_word++;
  4029. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4030. *msg_word,
  4031. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_63_32));
  4032. msg_word++;
  4033. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4034. *msg_word,
  4035. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_95_64));
  4036. msg_word++;
  4037. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4038. *msg_word,
  4039. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_127_96));
  4040. msg_word++;
  4041. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4042. *msg_word,
  4043. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.dest_ip_31_0));
  4044. msg_word++;
  4045. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4046. *msg_word,
  4047. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.dest_ip_63_32));
  4048. msg_word++;
  4049. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4050. *msg_word,
  4051. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.dest_ip_95_64));
  4052. msg_word++;
  4053. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4054. *msg_word,
  4055. qdf_htonl(
  4056. fse_op_info->rx_flow->flow_tuple_info.dest_ip_127_96));
  4057. msg_word++;
  4058. HTT_RX_FSE_SOURCEPORT_SET(
  4059. *msg_word,
  4060. fse_op_info->rx_flow->flow_tuple_info.src_port);
  4061. HTT_RX_FSE_DESTPORT_SET(
  4062. *msg_word,
  4063. fse_op_info->rx_flow->flow_tuple_info.dest_port);
  4064. msg_word++;
  4065. HTT_RX_FSE_L4_PROTO_SET(
  4066. *msg_word,
  4067. fse_op_info->rx_flow->flow_tuple_info.l4_protocol);
  4068. } else if (fse_op_info->op_code == DP_HTT_FST_CACHE_INVALIDATE_FULL) {
  4069. HTT_RX_FSE_OPERATION_SET(*msg_word,
  4070. HTT_RX_FSE_CACHE_INVALIDATE_FULL);
  4071. } else if (fse_op_info->op_code == DP_HTT_FST_DISABLE) {
  4072. HTT_RX_FSE_OPERATION_SET(*msg_word, HTT_RX_FSE_DISABLE);
  4073. } else if (fse_op_info->op_code == DP_HTT_FST_ENABLE) {
  4074. HTT_RX_FSE_OPERATION_SET(*msg_word, HTT_RX_FSE_ENABLE);
  4075. }
  4076. pkt = htt_htc_pkt_alloc(soc);
  4077. if (!pkt) {
  4078. qdf_err("Fail to allocate dp_htt_htc_pkt buffer");
  4079. qdf_assert(0);
  4080. qdf_nbuf_free(msg);
  4081. return QDF_STATUS_E_RESOURCES; /* failure */
  4082. }
  4083. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4084. SET_HTC_PACKET_INFO_TX(
  4085. &pkt->htc_pkt,
  4086. dp_htt_h2t_send_complete_free_netbuf,
  4087. qdf_nbuf_data(msg),
  4088. qdf_nbuf_len(msg),
  4089. soc->htc_endpoint,
  4090. 1); /* tag - not relevant here */
  4091. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4092. DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_RX_FSE_OPERATION_CFG,
  4093. htt_logger_bufp);
  4094. qdf_info("HTT_H2T RX_FSE_OPERATION_CFG sent to FW for pdev = %u",
  4095. fse_op_info->pdev_id);
  4096. return QDF_STATUS_SUCCESS;
  4097. }