dp_htt.c 136 KB

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