dp_htt.c 118 KB

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