dp_htt.c 134 KB

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