dp_htt.c 140 KB

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