dp_htt.c 128 KB

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