dp_htt.c 124 KB

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