dp_htt.c 114 KB

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