dp_htt.c 126 KB

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