dp_htt.c 116 KB

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