dp_htt.c 142 KB

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