dp_htt.c 142 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086
  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 umac_alloc_size = HTT_SW_UMAC_RING_IDX_MAX *
  1963. sizeof(struct bp_handler);
  1964. int lmac_alloc_size = HTT_SW_LMAC_RING_IDX_MAX *
  1965. sizeof(struct bp_handler);
  1966. struct htt_soc *htt_soc = NULL;
  1967. htt_soc = qdf_mem_malloc(sizeof(*htt_soc));
  1968. if (!htt_soc) {
  1969. dp_err("HTT attach failed");
  1970. return NULL;
  1971. }
  1972. for (i = 0; i < MAX_PDEV_CNT; i++) {
  1973. htt_soc->pdevid_tt[i].umac_path =
  1974. qdf_mem_malloc(umac_alloc_size);
  1975. if (!htt_soc->pdevid_tt[i].umac_path)
  1976. break;
  1977. for (j = 0; j < HTT_SW_UMAC_RING_IDX_MAX; j++)
  1978. htt_soc->pdevid_tt[i].umac_path[j].bp_start_tt = -1;
  1979. htt_soc->pdevid_tt[i].lmac_path =
  1980. qdf_mem_malloc(lmac_alloc_size);
  1981. if (!htt_soc->pdevid_tt[i].lmac_path) {
  1982. qdf_mem_free(htt_soc->pdevid_tt[i].umac_path);
  1983. break;
  1984. }
  1985. for (j = 0; j < HTT_SW_LMAC_RING_IDX_MAX ; j++)
  1986. htt_soc->pdevid_tt[i].lmac_path[j].bp_start_tt = -1;
  1987. }
  1988. if (i != MAX_PDEV_CNT) {
  1989. for (j = 0; j < i; j++) {
  1990. qdf_mem_free(htt_soc->pdevid_tt[j].umac_path);
  1991. qdf_mem_free(htt_soc->pdevid_tt[j].lmac_path);
  1992. }
  1993. qdf_mem_free(htt_soc);
  1994. return NULL;
  1995. }
  1996. htt_soc->dp_soc = soc;
  1997. htt_soc->htc_soc = htc_handle;
  1998. HTT_TX_MUTEX_INIT(&htt_soc->htt_tx_mutex);
  1999. return htt_soc;
  2000. }
  2001. #if defined(WDI_EVENT_ENABLE) && \
  2002. !defined(REMOVE_PKT_LOG)
  2003. /*
  2004. * dp_pktlog_msg_handler() - Pktlog msg handler
  2005. * @htt_soc: HTT SOC handle
  2006. * @msg_word: Pointer to payload
  2007. *
  2008. * Return: None
  2009. */
  2010. static void
  2011. dp_pktlog_msg_handler(struct htt_soc *soc,
  2012. uint32_t *msg_word)
  2013. {
  2014. uint8_t pdev_id;
  2015. uint8_t target_pdev_id;
  2016. uint32_t *pl_hdr;
  2017. target_pdev_id = HTT_T2H_PKTLOG_PDEV_ID_GET(*msg_word);
  2018. pdev_id = dp_get_host_pdev_id_for_target_pdev_id(soc->dp_soc,
  2019. target_pdev_id);
  2020. pl_hdr = (msg_word + 1);
  2021. dp_wdi_event_handler(WDI_EVENT_OFFLOAD_ALL, soc->dp_soc,
  2022. pl_hdr, HTT_INVALID_PEER, WDI_NO_VAL,
  2023. pdev_id);
  2024. }
  2025. #else
  2026. static void
  2027. dp_pktlog_msg_handler(struct htt_soc *soc,
  2028. uint32_t *msg_word)
  2029. {
  2030. }
  2031. #endif
  2032. #ifdef QCA_VDEV_STATS_HW_OFFLOAD_SUPPORT
  2033. /*
  2034. * dp_vdev_txrx_hw_stats_handler - Handle vdev stats received from FW
  2035. * @soc - htt soc handle
  2036. * @ msg_word - buffer containing stats
  2037. *
  2038. * Return: void
  2039. */
  2040. static void dp_vdev_txrx_hw_stats_handler(struct htt_soc *soc,
  2041. uint32_t *msg_word)
  2042. {
  2043. struct dp_soc *dpsoc = (struct dp_soc *)soc->dp_soc;
  2044. uint8_t pdev_id;
  2045. uint8_t vdev_id;
  2046. uint8_t target_pdev_id;
  2047. uint16_t payload_size;
  2048. struct dp_pdev *pdev;
  2049. struct dp_vdev *vdev;
  2050. uint8_t *tlv_buf;
  2051. uint32_t *tlv_buf_temp;
  2052. uint32_t *tag_buf;
  2053. htt_tlv_tag_t tlv_type;
  2054. uint16_t tlv_length;
  2055. uint64_t pkt_count = 0;
  2056. uint64_t byte_count = 0;
  2057. uint64_t soc_drop_cnt = 0;
  2058. struct cdp_pkt_info tx_comp = { 0 };
  2059. struct cdp_pkt_info tx_failed = { 0 };
  2060. target_pdev_id =
  2061. HTT_T2H_VDEVS_TXRX_STATS_PERIODIC_IND_PDEV_ID_GET(*msg_word);
  2062. pdev_id = dp_get_host_pdev_id_for_target_pdev_id(dpsoc,
  2063. target_pdev_id);
  2064. if (pdev_id >= MAX_PDEV_CNT)
  2065. return;
  2066. pdev = dpsoc->pdev_list[pdev_id];
  2067. if (!pdev) {
  2068. dp_err("PDEV is NULL for pdev_id:%d", pdev_id);
  2069. return;
  2070. }
  2071. payload_size =
  2072. HTT_T2H_VDEVS_TXRX_STATS_PERIODIC_IND_PAYLOAD_SIZE_GET(*msg_word);
  2073. qdf_trace_hex_dump(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  2074. (void *)msg_word, payload_size + 16);
  2075. /* Adjust msg_word to point to the first TLV in buffer */
  2076. msg_word = msg_word + 4;
  2077. /* Parse the received buffer till payload size reaches 0 */
  2078. while (payload_size > 0) {
  2079. tlv_buf = (uint8_t *)msg_word;
  2080. tlv_buf_temp = msg_word;
  2081. tlv_type = HTT_STATS_TLV_TAG_GET(*msg_word);
  2082. tlv_length = HTT_STATS_TLV_LENGTH_GET(*msg_word);
  2083. /* Add header size to tlv length*/
  2084. tlv_length += 4;
  2085. switch (tlv_type) {
  2086. case HTT_STATS_SOC_TXRX_STATS_COMMON_TAG:
  2087. {
  2088. tag_buf = tlv_buf_temp +
  2089. HTT_VDEV_STATS_GET_INDEX(SOC_DROP_CNT);
  2090. soc_drop_cnt = HTT_VDEV_GET_STATS_U64(tag_buf);
  2091. DP_STATS_UPD(dpsoc, tx.tqm_drop_no_peer, soc_drop_cnt);
  2092. break;
  2093. }
  2094. case HTT_STATS_VDEV_TXRX_STATS_HW_STATS_TAG:
  2095. {
  2096. tag_buf = tlv_buf_temp +
  2097. HTT_VDEV_STATS_GET_INDEX(VDEV_ID);
  2098. vdev_id = (uint8_t)(*tag_buf);
  2099. vdev = dp_vdev_get_ref_by_id(dpsoc, vdev_id,
  2100. DP_MOD_ID_HTT);
  2101. if (!vdev)
  2102. goto invalid_vdev;
  2103. /* Extract received packet count from buffer */
  2104. tag_buf = tlv_buf_temp +
  2105. HTT_VDEV_STATS_GET_INDEX(RX_PKT_CNT);
  2106. pkt_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2107. DP_STATS_UPD(vdev, rx_i.reo_rcvd_pkt.num, pkt_count);
  2108. /* Extract received packet byte count from buffer */
  2109. tag_buf = tlv_buf_temp +
  2110. HTT_VDEV_STATS_GET_INDEX(RX_BYTE_CNT);
  2111. byte_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2112. DP_STATS_UPD(vdev, rx_i.reo_rcvd_pkt.bytes, byte_count);
  2113. /* Extract tx success packet count from buffer */
  2114. tag_buf = tlv_buf_temp +
  2115. HTT_VDEV_STATS_GET_INDEX(TX_SUCCESS_PKT_CNT);
  2116. pkt_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2117. tx_comp.num = pkt_count;
  2118. /* Extract tx success packet byte count from buffer */
  2119. tag_buf = tlv_buf_temp +
  2120. HTT_VDEV_STATS_GET_INDEX(TX_SUCCESS_BYTE_CNT);
  2121. byte_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2122. tx_comp.bytes = byte_count;
  2123. /* Extract tx retry packet count from buffer */
  2124. tag_buf = tlv_buf_temp +
  2125. HTT_VDEV_STATS_GET_INDEX(TX_RETRY_PKT_CNT);
  2126. pkt_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2127. tx_comp.num += pkt_count;
  2128. tx_failed.num = pkt_count;
  2129. /* Extract tx retry packet byte count from buffer */
  2130. tag_buf = tlv_buf_temp +
  2131. HTT_VDEV_STATS_GET_INDEX(TX_RETRY_BYTE_CNT);
  2132. byte_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2133. tx_comp.bytes += byte_count;
  2134. tx_failed.bytes = byte_count;
  2135. /* Extract tx drop packet count from buffer */
  2136. tag_buf = tlv_buf_temp +
  2137. HTT_VDEV_STATS_GET_INDEX(TX_DROP_PKT_CNT);
  2138. pkt_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2139. tx_comp.num += pkt_count;
  2140. tx_failed.num += pkt_count;
  2141. /* Extract tx drop packet byte count from buffer */
  2142. tag_buf = tlv_buf_temp +
  2143. HTT_VDEV_STATS_GET_INDEX(TX_DROP_BYTE_CNT);
  2144. byte_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2145. tx_comp.bytes += byte_count;
  2146. tx_failed.bytes += byte_count;
  2147. /* Extract tx age-out packet count from buffer */
  2148. tag_buf = tlv_buf_temp +
  2149. HTT_VDEV_STATS_GET_INDEX(TX_AGE_OUT_PKT_CNT);
  2150. pkt_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2151. tx_comp.num += pkt_count;
  2152. tx_failed.num += pkt_count;
  2153. /* Extract tx age-out packet byte count from buffer */
  2154. tag_buf = tlv_buf_temp +
  2155. HTT_VDEV_STATS_GET_INDEX(TX_AGE_OUT_BYTE_CNT);
  2156. byte_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2157. tx_comp.bytes += byte_count;
  2158. tx_failed.bytes += byte_count;
  2159. /* Extract tqm bypass packet count from buffer */
  2160. tag_buf = tlv_buf_temp +
  2161. HTT_VDEV_STATS_GET_INDEX(TX_TQM_BYPASS_PKT_CNT);
  2162. pkt_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2163. tx_comp.num += pkt_count;
  2164. /* Extract tx bypass packet byte count from buffer */
  2165. tag_buf = tlv_buf_temp +
  2166. HTT_VDEV_STATS_GET_INDEX(TX_TQM_BYPASS_BYTE_CNT);
  2167. byte_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2168. tx_comp.bytes += byte_count;
  2169. DP_STATS_UPD(vdev, tx.comp_pkt.num, tx_comp.num);
  2170. DP_STATS_UPD(vdev, tx.comp_pkt.bytes, tx_comp.bytes);
  2171. DP_STATS_UPD(vdev, tx.tx_failed, tx_failed.num);
  2172. dp_vdev_unref_delete(dpsoc, vdev, DP_MOD_ID_HTT);
  2173. break;
  2174. }
  2175. default:
  2176. qdf_assert(0);
  2177. }
  2178. invalid_vdev:
  2179. msg_word = (uint32_t *)((uint8_t *)tlv_buf + tlv_length);
  2180. payload_size -= tlv_length;
  2181. }
  2182. }
  2183. #else
  2184. static void dp_vdev_txrx_hw_stats_handler(struct htt_soc *soc,
  2185. uint32_t *msg_word)
  2186. {}
  2187. #endif
  2188. #ifdef CONFIG_SAWF_DEF_QUEUES
  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. dp_htt_sawf_def_queues_map_report_conf(soc, msg_word, htt_t2h_msg);
  2194. }
  2195. #else
  2196. static void dp_sawf_def_queues_update_map_report_conf(struct htt_soc *soc,
  2197. uint32_t *msg_word,
  2198. qdf_nbuf_t htt_t2h_msg)
  2199. {}
  2200. #endif
  2201. #ifdef CONFIG_SAWF
  2202. /*
  2203. * dp_sawf_msduq_map() - Msdu queue creation information received
  2204. * from target
  2205. * @soc: soc handle.
  2206. * @msg_word: Pointer to htt msg word.
  2207. * @htt_t2h_msg: HTT message nbuf
  2208. *
  2209. * @return: void
  2210. */
  2211. static void dp_sawf_msduq_map(struct htt_soc *soc, uint32_t *msg_word,
  2212. qdf_nbuf_t htt_t2h_msg)
  2213. {
  2214. dp_htt_sawf_msduq_map(soc, msg_word, htt_t2h_msg);
  2215. }
  2216. /*
  2217. * dp_sawf_mpdu_stats_handler() - HTT message handler for MPDU stats
  2218. * @soc: soc handle.
  2219. * @htt_t2h_msg: HTT message nbuf
  2220. *
  2221. * @return: void
  2222. */
  2223. static void dp_sawf_mpdu_stats_handler(struct htt_soc *soc,
  2224. qdf_nbuf_t htt_t2h_msg)
  2225. {
  2226. dp_sawf_htt_mpdu_stats_handler(soc, htt_t2h_msg);
  2227. }
  2228. #else
  2229. static void dp_sawf_msduq_map(struct htt_soc *soc, uint32_t *msg_word,
  2230. qdf_nbuf_t htt_t2h_msg)
  2231. {}
  2232. static void dp_sawf_mpdu_stats_handler(struct htt_soc *soc,
  2233. qdf_nbuf_t htt_t2h_msg)
  2234. {}
  2235. #endif
  2236. /*
  2237. * time_allow_print() - time allow print
  2238. * @htt_ring_tt: ringi_id array of timestamps
  2239. * @ring_id: ring_id (index)
  2240. *
  2241. * Return: 1 for successfully saving timestamp in array
  2242. * and 0 for timestamp falling within 2 seconds after last one
  2243. */
  2244. static bool time_allow_print(struct bp_handler *htt_bp_handler,
  2245. u_int8_t ring_id, u_int32_t th_time)
  2246. {
  2247. unsigned long tstamp;
  2248. struct bp_handler *path = &htt_bp_handler[ring_id];
  2249. tstamp = qdf_get_system_timestamp();
  2250. if (!path)
  2251. return 0; //unable to print backpressure messages
  2252. if (path->bp_start_tt == -1) {
  2253. path->bp_start_tt = tstamp;
  2254. path->bp_duration = 0;
  2255. path->bp_last_tt = tstamp;
  2256. path->bp_counter = 1;
  2257. return 1;
  2258. }
  2259. path->bp_duration = tstamp - path->bp_start_tt;
  2260. path->bp_last_tt = tstamp;
  2261. path->bp_counter++;
  2262. if (path->bp_duration >= th_time) {
  2263. path->bp_start_tt = -1;
  2264. return 1;
  2265. }
  2266. return 0;
  2267. }
  2268. static void dp_htt_alert_print(enum htt_t2h_msg_type msg_type,
  2269. struct dp_pdev *pdev, u_int8_t ring_id,
  2270. u_int16_t hp_idx, u_int16_t tp_idx,
  2271. u_int32_t bkp_time,
  2272. struct bp_handler *htt_bp_handler,
  2273. char *ring_stype)
  2274. {
  2275. dp_alert("seq_num %u msg_type: %d pdev_id: %d ring_type: %s ",
  2276. pdev->bkp_stats.seq_num, msg_type, pdev->pdev_id, ring_stype);
  2277. dp_alert("ring_id: %d hp_idx: %d tp_idx: %d bkpressure_time_ms: %d ",
  2278. ring_id, hp_idx, tp_idx, bkp_time);
  2279. dp_alert("last_bp_event: %ld, total_bp_duration: %ld, bp_counter: %ld",
  2280. htt_bp_handler[ring_id].bp_last_tt,
  2281. htt_bp_handler[ring_id].bp_duration,
  2282. htt_bp_handler[ring_id].bp_counter);
  2283. }
  2284. /**
  2285. * dp_get_srng_ring_state_from_hal(): Get hal level ring stats
  2286. * @soc: DP_SOC handle
  2287. * @srng: DP_SRNG handle
  2288. * @ring_type: srng src/dst ring
  2289. *
  2290. * Return: void
  2291. */
  2292. static QDF_STATUS
  2293. dp_get_srng_ring_state_from_hal(struct dp_soc *soc,
  2294. struct dp_pdev *pdev,
  2295. struct dp_srng *srng,
  2296. enum hal_ring_type ring_type,
  2297. struct dp_srng_ring_state *state)
  2298. {
  2299. struct hal_soc *hal_soc;
  2300. if (!soc || !srng || !srng->hal_srng || !state)
  2301. return QDF_STATUS_E_INVAL;
  2302. hal_soc = (struct hal_soc *)soc->hal_soc;
  2303. hal_get_sw_hptp(soc->hal_soc, srng->hal_srng, &state->sw_tail,
  2304. &state->sw_head);
  2305. hal_get_hw_hptp(soc->hal_soc, srng->hal_srng, &state->hw_head,
  2306. &state->hw_tail, ring_type);
  2307. state->ring_type = ring_type;
  2308. return QDF_STATUS_SUCCESS;
  2309. }
  2310. #ifdef QCA_MONITOR_PKT_SUPPORT
  2311. static void
  2312. dp_queue_mon_ring_stats(struct dp_pdev *pdev,
  2313. int lmac_id, uint32_t *num_srng,
  2314. struct dp_soc_srngs_state *soc_srngs_state)
  2315. {
  2316. QDF_STATUS status;
  2317. if (pdev->soc->wlan_cfg_ctx->rxdma1_enable) {
  2318. status = dp_get_srng_ring_state_from_hal
  2319. (pdev->soc, pdev,
  2320. &pdev->soc->rxdma_mon_buf_ring[lmac_id],
  2321. RXDMA_MONITOR_BUF,
  2322. &soc_srngs_state->ring_state[*num_srng]);
  2323. if (status == QDF_STATUS_SUCCESS)
  2324. qdf_assert_always(++(*num_srng) < DP_MAX_SRNGS);
  2325. status = dp_get_srng_ring_state_from_hal
  2326. (pdev->soc, pdev,
  2327. &pdev->soc->rxdma_mon_dst_ring[lmac_id],
  2328. RXDMA_MONITOR_DST,
  2329. &soc_srngs_state->ring_state[*num_srng]);
  2330. if (status == QDF_STATUS_SUCCESS)
  2331. qdf_assert_always(++(*num_srng) < DP_MAX_SRNGS);
  2332. status = dp_get_srng_ring_state_from_hal
  2333. (pdev->soc, pdev,
  2334. &pdev->soc->rxdma_mon_desc_ring[lmac_id],
  2335. RXDMA_MONITOR_DESC,
  2336. &soc_srngs_state->ring_state[*num_srng]);
  2337. if (status == QDF_STATUS_SUCCESS)
  2338. qdf_assert_always(++(*num_srng) < DP_MAX_SRNGS);
  2339. }
  2340. }
  2341. #else
  2342. static void
  2343. dp_queue_mon_ring_stats(struct dp_pdev *pdev,
  2344. int lmac_id, uint32_t *num_srng,
  2345. struct dp_soc_srngs_state *soc_srngs_state)
  2346. {
  2347. }
  2348. #endif
  2349. #ifndef WLAN_DP_DISABLE_TCL_CMD_CRED_SRNG
  2350. static inline QDF_STATUS
  2351. dp_get_tcl_cmd_cred_ring_state_from_hal(struct dp_pdev *pdev,
  2352. struct dp_srng_ring_state *ring_state)
  2353. {
  2354. return dp_get_srng_ring_state_from_hal(pdev->soc, pdev,
  2355. &pdev->soc->tcl_cmd_credit_ring,
  2356. TCL_CMD_CREDIT, ring_state);
  2357. }
  2358. #else
  2359. static inline QDF_STATUS
  2360. dp_get_tcl_cmd_cred_ring_state_from_hal(struct dp_pdev *pdev,
  2361. struct dp_srng_ring_state *ring_state)
  2362. {
  2363. return QDF_STATUS_SUCCESS;
  2364. }
  2365. #endif
  2366. #ifndef WLAN_DP_DISABLE_TCL_STATUS_SRNG
  2367. static inline QDF_STATUS
  2368. dp_get_tcl_status_ring_state_from_hal(struct dp_pdev *pdev,
  2369. struct dp_srng_ring_state *ring_state)
  2370. {
  2371. return dp_get_srng_ring_state_from_hal(pdev->soc, pdev,
  2372. &pdev->soc->tcl_status_ring,
  2373. TCL_STATUS, ring_state);
  2374. }
  2375. #else
  2376. static inline QDF_STATUS
  2377. dp_get_tcl_status_ring_state_from_hal(struct dp_pdev *pdev,
  2378. struct dp_srng_ring_state *ring_state)
  2379. {
  2380. return QDF_STATUS_SUCCESS;
  2381. }
  2382. #endif
  2383. /**
  2384. * dp_queue_srng_ring_stats(): Print pdev hal level ring stats
  2385. * @pdev: DP_pdev handle
  2386. *
  2387. * Return: void
  2388. */
  2389. static void dp_queue_ring_stats(struct dp_pdev *pdev)
  2390. {
  2391. uint32_t i;
  2392. int mac_id;
  2393. int lmac_id;
  2394. uint32_t j = 0;
  2395. struct dp_soc *soc = pdev->soc;
  2396. struct dp_soc_srngs_state * soc_srngs_state = NULL;
  2397. struct dp_soc_srngs_state *drop_srngs_state = NULL;
  2398. QDF_STATUS status;
  2399. soc_srngs_state = qdf_mem_malloc(sizeof(struct dp_soc_srngs_state));
  2400. if (!soc_srngs_state) {
  2401. dp_htt_alert("Memory alloc failed for back pressure event");
  2402. return;
  2403. }
  2404. status = dp_get_srng_ring_state_from_hal
  2405. (pdev->soc, pdev,
  2406. &pdev->soc->reo_exception_ring,
  2407. REO_EXCEPTION,
  2408. &soc_srngs_state->ring_state[j]);
  2409. if (status == QDF_STATUS_SUCCESS)
  2410. qdf_assert_always(++j < DP_MAX_SRNGS);
  2411. status = dp_get_srng_ring_state_from_hal
  2412. (pdev->soc, pdev,
  2413. &pdev->soc->reo_reinject_ring,
  2414. REO_REINJECT,
  2415. &soc_srngs_state->ring_state[j]);
  2416. if (status == QDF_STATUS_SUCCESS)
  2417. qdf_assert_always(++j < DP_MAX_SRNGS);
  2418. status = dp_get_srng_ring_state_from_hal
  2419. (pdev->soc, pdev,
  2420. &pdev->soc->reo_cmd_ring,
  2421. REO_CMD,
  2422. &soc_srngs_state->ring_state[j]);
  2423. if (status == QDF_STATUS_SUCCESS)
  2424. qdf_assert_always(++j < DP_MAX_SRNGS);
  2425. status = dp_get_srng_ring_state_from_hal
  2426. (pdev->soc, pdev,
  2427. &pdev->soc->reo_status_ring,
  2428. REO_STATUS,
  2429. &soc_srngs_state->ring_state[j]);
  2430. if (status == QDF_STATUS_SUCCESS)
  2431. qdf_assert_always(++j < DP_MAX_SRNGS);
  2432. status = dp_get_srng_ring_state_from_hal
  2433. (pdev->soc, pdev,
  2434. &pdev->soc->rx_rel_ring,
  2435. WBM2SW_RELEASE,
  2436. &soc_srngs_state->ring_state[j]);
  2437. if (status == QDF_STATUS_SUCCESS)
  2438. qdf_assert_always(++j < DP_MAX_SRNGS);
  2439. status = dp_get_tcl_cmd_cred_ring_state_from_hal
  2440. (pdev, &soc_srngs_state->ring_state[j]);
  2441. if (status == QDF_STATUS_SUCCESS)
  2442. qdf_assert_always(++j < DP_MAX_SRNGS);
  2443. status = dp_get_tcl_status_ring_state_from_hal
  2444. (pdev, &soc_srngs_state->ring_state[j]);
  2445. if (status == QDF_STATUS_SUCCESS)
  2446. qdf_assert_always(++j < DP_MAX_SRNGS);
  2447. status = dp_get_srng_ring_state_from_hal
  2448. (pdev->soc, pdev,
  2449. &pdev->soc->wbm_desc_rel_ring,
  2450. SW2WBM_RELEASE,
  2451. &soc_srngs_state->ring_state[j]);
  2452. if (status == QDF_STATUS_SUCCESS)
  2453. qdf_assert_always(++j < DP_MAX_SRNGS);
  2454. for (i = 0; i < MAX_REO_DEST_RINGS; i++) {
  2455. status = dp_get_srng_ring_state_from_hal
  2456. (pdev->soc, pdev,
  2457. &pdev->soc->reo_dest_ring[i],
  2458. REO_DST,
  2459. &soc_srngs_state->ring_state[j]);
  2460. if (status == QDF_STATUS_SUCCESS)
  2461. qdf_assert_always(++j < DP_MAX_SRNGS);
  2462. }
  2463. for (i = 0; i < pdev->soc->num_tcl_data_rings; i++) {
  2464. status = dp_get_srng_ring_state_from_hal
  2465. (pdev->soc, pdev,
  2466. &pdev->soc->tcl_data_ring[i],
  2467. TCL_DATA,
  2468. &soc_srngs_state->ring_state[j]);
  2469. if (status == QDF_STATUS_SUCCESS)
  2470. qdf_assert_always(++j < DP_MAX_SRNGS);
  2471. }
  2472. for (i = 0; i < MAX_TCL_DATA_RINGS; i++) {
  2473. status = dp_get_srng_ring_state_from_hal
  2474. (pdev->soc, pdev,
  2475. &pdev->soc->tx_comp_ring[i],
  2476. WBM2SW_RELEASE,
  2477. &soc_srngs_state->ring_state[j]);
  2478. if (status == QDF_STATUS_SUCCESS)
  2479. qdf_assert_always(++j < DP_MAX_SRNGS);
  2480. }
  2481. lmac_id = dp_get_lmac_id_for_pdev_id(pdev->soc, 0, pdev->pdev_id);
  2482. status = dp_get_srng_ring_state_from_hal
  2483. (pdev->soc, pdev,
  2484. &pdev->soc->rx_refill_buf_ring
  2485. [lmac_id],
  2486. RXDMA_BUF,
  2487. &soc_srngs_state->ring_state[j]);
  2488. if (status == QDF_STATUS_SUCCESS)
  2489. qdf_assert_always(++j < DP_MAX_SRNGS);
  2490. status = dp_get_srng_ring_state_from_hal
  2491. (pdev->soc, pdev,
  2492. &pdev->rx_refill_buf_ring2,
  2493. RXDMA_BUF,
  2494. &soc_srngs_state->ring_state[j]);
  2495. if (status == QDF_STATUS_SUCCESS)
  2496. qdf_assert_always(++j < DP_MAX_SRNGS);
  2497. for (i = 0; i < MAX_RX_MAC_RINGS; i++) {
  2498. dp_get_srng_ring_state_from_hal
  2499. (pdev->soc, pdev,
  2500. &pdev->rx_mac_buf_ring[i],
  2501. RXDMA_BUF,
  2502. &soc_srngs_state->ring_state[j]);
  2503. if (status == QDF_STATUS_SUCCESS)
  2504. qdf_assert_always(++j < DP_MAX_SRNGS);
  2505. }
  2506. for (mac_id = 0;
  2507. mac_id < soc->wlan_cfg_ctx->num_rxdma_status_rings_per_pdev;
  2508. mac_id++) {
  2509. lmac_id = dp_get_lmac_id_for_pdev_id(pdev->soc,
  2510. mac_id, pdev->pdev_id);
  2511. dp_queue_mon_ring_stats(pdev, lmac_id, &j,
  2512. soc_srngs_state);
  2513. status = dp_get_srng_ring_state_from_hal
  2514. (pdev->soc, pdev,
  2515. &pdev->soc->rxdma_mon_status_ring[lmac_id],
  2516. RXDMA_MONITOR_STATUS,
  2517. &soc_srngs_state->ring_state[j]);
  2518. if (status == QDF_STATUS_SUCCESS)
  2519. qdf_assert_always(++j < DP_MAX_SRNGS);
  2520. }
  2521. for (i = 0; i < soc->wlan_cfg_ctx->num_rxdma_dst_rings_per_pdev; i++) {
  2522. lmac_id = dp_get_lmac_id_for_pdev_id(pdev->soc,
  2523. i, pdev->pdev_id);
  2524. status = dp_get_srng_ring_state_from_hal
  2525. (pdev->soc, pdev,
  2526. &pdev->soc->rxdma_err_dst_ring
  2527. [lmac_id],
  2528. RXDMA_DST,
  2529. &soc_srngs_state->ring_state[j]);
  2530. if (status == QDF_STATUS_SUCCESS)
  2531. qdf_assert_always(++j < DP_MAX_SRNGS);
  2532. }
  2533. soc_srngs_state->max_ring_id = j;
  2534. qdf_spin_lock_bh(&pdev->bkp_stats.list_lock);
  2535. soc_srngs_state->seq_num = pdev->bkp_stats.seq_num;
  2536. if (pdev->bkp_stats.queue_depth >= HTT_BKP_STATS_MAX_QUEUE_DEPTH) {
  2537. drop_srngs_state = TAILQ_FIRST(&pdev->bkp_stats.list);
  2538. qdf_assert_always(drop_srngs_state);
  2539. TAILQ_REMOVE(&pdev->bkp_stats.list, drop_srngs_state,
  2540. list_elem);
  2541. qdf_mem_free(drop_srngs_state);
  2542. pdev->bkp_stats.queue_depth--;
  2543. }
  2544. pdev->bkp_stats.queue_depth++;
  2545. TAILQ_INSERT_TAIL(&pdev->bkp_stats.list, soc_srngs_state,
  2546. list_elem);
  2547. pdev->bkp_stats.seq_num++;
  2548. qdf_spin_unlock_bh(&pdev->bkp_stats.list_lock);
  2549. qdf_queue_work(0, pdev->bkp_stats.work_queue,
  2550. &pdev->bkp_stats.work);
  2551. }
  2552. /*
  2553. * dp_htt_bkp_event_alert() - htt backpressure event alert
  2554. * @msg_word: htt packet context
  2555. * @htt_soc: HTT SOC handle
  2556. *
  2557. * Return: after attempting to print stats
  2558. */
  2559. static void dp_htt_bkp_event_alert(u_int32_t *msg_word, struct htt_soc *soc)
  2560. {
  2561. u_int8_t ring_type;
  2562. u_int8_t pdev_id;
  2563. uint8_t target_pdev_id;
  2564. u_int8_t ring_id;
  2565. u_int16_t hp_idx;
  2566. u_int16_t tp_idx;
  2567. u_int32_t bkp_time;
  2568. u_int32_t th_time;
  2569. enum htt_t2h_msg_type msg_type;
  2570. struct dp_soc *dpsoc;
  2571. struct dp_pdev *pdev;
  2572. struct dp_htt_timestamp *radio_tt;
  2573. struct wlan_cfg_dp_soc_ctxt *soc_cfg_ctx;
  2574. if (!soc)
  2575. return;
  2576. dpsoc = (struct dp_soc *)soc->dp_soc;
  2577. soc_cfg_ctx = dpsoc->wlan_cfg_ctx;
  2578. msg_type = HTT_T2H_MSG_TYPE_GET(*msg_word);
  2579. ring_type = HTT_T2H_RX_BKPRESSURE_RING_TYPE_GET(*msg_word);
  2580. target_pdev_id = HTT_T2H_RX_BKPRESSURE_PDEV_ID_GET(*msg_word);
  2581. pdev_id = dp_get_host_pdev_id_for_target_pdev_id(soc->dp_soc,
  2582. target_pdev_id);
  2583. if (pdev_id >= MAX_PDEV_CNT) {
  2584. dp_htt_debug("%pK: pdev id %d is invalid", soc, pdev_id);
  2585. return;
  2586. }
  2587. th_time = wlan_cfg_time_control_bp(soc_cfg_ctx);
  2588. pdev = (struct dp_pdev *)dpsoc->pdev_list[pdev_id];
  2589. ring_id = HTT_T2H_RX_BKPRESSURE_RINGID_GET(*msg_word);
  2590. hp_idx = HTT_T2H_RX_BKPRESSURE_HEAD_IDX_GET(*(msg_word + 1));
  2591. tp_idx = HTT_T2H_RX_BKPRESSURE_TAIL_IDX_GET(*(msg_word + 1));
  2592. bkp_time = HTT_T2H_RX_BKPRESSURE_TIME_MS_GET(*(msg_word + 2));
  2593. radio_tt = &soc->pdevid_tt[pdev_id];
  2594. switch (ring_type) {
  2595. case HTT_SW_RING_TYPE_UMAC:
  2596. if (!time_allow_print(radio_tt->umac_path, ring_id, th_time))
  2597. return;
  2598. dp_htt_alert_print(msg_type, pdev, ring_id, hp_idx, tp_idx,
  2599. bkp_time, radio_tt->umac_path,
  2600. "HTT_SW_RING_TYPE_UMAC");
  2601. break;
  2602. case HTT_SW_RING_TYPE_LMAC:
  2603. if (!time_allow_print(radio_tt->lmac_path, ring_id, th_time))
  2604. return;
  2605. dp_htt_alert_print(msg_type, pdev, ring_id, hp_idx, tp_idx,
  2606. bkp_time, radio_tt->lmac_path,
  2607. "HTT_SW_RING_TYPE_LMAC");
  2608. break;
  2609. default:
  2610. dp_alert("Invalid ring type: %d", ring_type);
  2611. break;
  2612. }
  2613. dp_queue_ring_stats(pdev);
  2614. }
  2615. #ifdef WLAN_FEATURE_PKT_CAPTURE_V2
  2616. /*
  2617. * dp_offload_ind_handler() - offload msg handler
  2618. * @htt_soc: HTT SOC handle
  2619. * @msg_word: Pointer to payload
  2620. *
  2621. * Return: None
  2622. */
  2623. static void
  2624. dp_offload_ind_handler(struct htt_soc *soc, uint32_t *msg_word)
  2625. {
  2626. u_int8_t pdev_id;
  2627. u_int8_t target_pdev_id;
  2628. target_pdev_id = HTT_T2H_PPDU_STATS_PDEV_ID_GET(*msg_word);
  2629. pdev_id = dp_get_host_pdev_id_for_target_pdev_id(soc->dp_soc,
  2630. target_pdev_id);
  2631. dp_wdi_event_handler(WDI_EVENT_PKT_CAPTURE_OFFLOAD_TX_DATA, soc->dp_soc,
  2632. msg_word, HTT_INVALID_VDEV, WDI_NO_VAL,
  2633. pdev_id);
  2634. }
  2635. #else
  2636. static void
  2637. dp_offload_ind_handler(struct htt_soc *soc, uint32_t *msg_word)
  2638. {
  2639. }
  2640. #endif
  2641. #ifdef WLAN_FEATURE_11BE_MLO
  2642. #ifdef WLAN_MLO_MULTI_CHIP
  2643. static inline void dp_update_mlo_ts_offset(struct dp_soc *soc,
  2644. uint32_t ts_lo, uint32_t ts_hi)
  2645. {
  2646. uint64_t mlo_offset;
  2647. mlo_offset = ((uint64_t)(ts_hi) << 32 | ts_lo);
  2648. soc->cdp_soc.ops->mlo_ops->mlo_update_mlo_ts_offset
  2649. ((struct cdp_soc_t *)soc, mlo_offset);
  2650. }
  2651. #else
  2652. static inline void dp_update_mlo_ts_offset(struct dp_soc *soc,
  2653. uint32_t ts_lo, uint32_t ts_hi)
  2654. {}
  2655. #endif
  2656. static void dp_htt_mlo_peer_map_handler(struct htt_soc *soc,
  2657. uint32_t *msg_word)
  2658. {
  2659. uint8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  2660. uint8_t *mlo_peer_mac_addr;
  2661. uint16_t mlo_peer_id;
  2662. uint8_t num_links;
  2663. struct dp_mlo_flow_override_info mlo_flow_info[DP_MLO_FLOW_INFO_MAX];
  2664. struct dp_mlo_link_info mlo_link_info[DP_MAX_MLO_LINKS];
  2665. MLO_PEER_MAP_TLV_TAG_ID tlv_type = 0xff;
  2666. uint16_t tlv_len = 0;
  2667. int i = 0;
  2668. mlo_peer_id = HTT_RX_MLO_PEER_MAP_MLO_PEER_ID_GET(*msg_word);
  2669. num_links =
  2670. HTT_RX_MLO_PEER_MAP_NUM_LOGICAL_LINKS_GET(*msg_word);
  2671. mlo_peer_mac_addr =
  2672. htt_t2h_mac_addr_deswizzle((u_int8_t *)(msg_word + 1),
  2673. &mac_addr_deswizzle_buf[0]);
  2674. mlo_flow_info[0].ast_idx =
  2675. HTT_RX_MLO_PEER_MAP_PRIMARY_AST_INDEX_GET(*(msg_word + 3));
  2676. mlo_flow_info[0].ast_idx_valid =
  2677. HTT_RX_MLO_PEER_MAP_AST_INDEX_VALID_FLAG_GET(*(msg_word + 3));
  2678. mlo_flow_info[0].chip_id =
  2679. HTT_RX_MLO_PEER_MAP_CHIP_ID_AST_INDEX_GET(*(msg_word + 3));
  2680. mlo_flow_info[0].tidmask =
  2681. HTT_RX_MLO_PEER_MAP_TIDMASK_AST_INDEX_GET(*(msg_word + 3));
  2682. mlo_flow_info[0].cache_set_num =
  2683. HTT_RX_MLO_PEER_MAP_CACHE_SET_NUM_AST_INDEX_GET(*(msg_word + 3));
  2684. mlo_flow_info[1].ast_idx =
  2685. HTT_RX_MLO_PEER_MAP_PRIMARY_AST_INDEX_GET(*(msg_word + 3));
  2686. mlo_flow_info[1].ast_idx_valid =
  2687. HTT_RX_MLO_PEER_MAP_AST_INDEX_VALID_FLAG_GET(*(msg_word + 3));
  2688. mlo_flow_info[1].chip_id =
  2689. HTT_RX_MLO_PEER_MAP_CHIP_ID_AST_INDEX_GET(*(msg_word + 3));
  2690. mlo_flow_info[1].tidmask =
  2691. HTT_RX_MLO_PEER_MAP_TIDMASK_AST_INDEX_GET(*(msg_word + 3));
  2692. mlo_flow_info[1].cache_set_num =
  2693. HTT_RX_MLO_PEER_MAP_CACHE_SET_NUM_AST_INDEX_GET(*(msg_word + 3));
  2694. mlo_flow_info[2].ast_idx =
  2695. HTT_RX_MLO_PEER_MAP_PRIMARY_AST_INDEX_GET(*(msg_word + 3));
  2696. mlo_flow_info[2].ast_idx_valid =
  2697. HTT_RX_MLO_PEER_MAP_AST_INDEX_VALID_FLAG_GET(*(msg_word + 3));
  2698. mlo_flow_info[2].chip_id =
  2699. HTT_RX_MLO_PEER_MAP_CHIP_ID_AST_INDEX_GET(*(msg_word + 3));
  2700. mlo_flow_info[2].tidmask =
  2701. HTT_RX_MLO_PEER_MAP_TIDMASK_AST_INDEX_GET(*(msg_word + 3));
  2702. mlo_flow_info[2].cache_set_num =
  2703. HTT_RX_MLO_PEER_MAP_CACHE_SET_NUM_AST_INDEX_GET(*(msg_word + 3));
  2704. msg_word = msg_word + 8;
  2705. while (msg_word && (i < DP_MAX_MLO_LINKS)) {
  2706. mlo_link_info[i].peer_chip_id = 0xFF;
  2707. mlo_link_info[i].vdev_id = 0xFF;
  2708. tlv_type = HTT_RX_MLO_PEER_MAP_TLV_TAG_GET(*msg_word);
  2709. tlv_len = HTT_RX_MLO_PEER_MAP_TLV_LENGTH_GET(*msg_word);
  2710. if (tlv_len == 0) {
  2711. dp_err("TLV Length is 0");
  2712. break;
  2713. }
  2714. if (tlv_type == MLO_PEER_MAP_TLV_STRUCT_SOC_VDEV_PEER_IDS) {
  2715. mlo_link_info[i].peer_chip_id =
  2716. HTT_RX_MLO_PEER_MAP_CHIP_ID_GET(
  2717. *(msg_word + 1));
  2718. mlo_link_info[i].vdev_id =
  2719. HTT_RX_MLO_PEER_MAP_VDEV_ID_GET(
  2720. *(msg_word + 1));
  2721. }
  2722. /* Add header size to tlv length */
  2723. tlv_len = tlv_len + HTT_TLV_HDR_LEN;
  2724. msg_word = (uint32_t *)(((uint8_t *)msg_word) + tlv_len);
  2725. i++;
  2726. }
  2727. dp_rx_mlo_peer_map_handler(soc->dp_soc, mlo_peer_id,
  2728. mlo_peer_mac_addr,
  2729. mlo_flow_info, mlo_link_info);
  2730. }
  2731. static void dp_htt_mlo_peer_unmap_handler(struct htt_soc *soc,
  2732. uint32_t *msg_word)
  2733. {
  2734. uint16_t mlo_peer_id;
  2735. mlo_peer_id = HTT_RX_MLO_PEER_UNMAP_MLO_PEER_ID_GET(*msg_word);
  2736. dp_rx_mlo_peer_unmap_handler(soc->dp_soc, mlo_peer_id);
  2737. }
  2738. static void
  2739. dp_rx_mlo_timestamp_ind_handler(struct dp_soc *soc,
  2740. uint32_t *msg_word)
  2741. {
  2742. uint8_t pdev_id;
  2743. uint8_t target_pdev_id;
  2744. struct dp_pdev *pdev;
  2745. if (!soc)
  2746. return;
  2747. target_pdev_id = HTT_T2H_MLO_TIMESTAMP_OFFSET_PDEV_ID_GET(*msg_word);
  2748. pdev_id = dp_get_host_pdev_id_for_target_pdev_id(soc,
  2749. target_pdev_id);
  2750. if (pdev_id >= MAX_PDEV_CNT) {
  2751. dp_htt_debug("%pK: pdev id %d is invalid", soc, pdev_id);
  2752. return;
  2753. }
  2754. pdev = (struct dp_pdev *)soc->pdev_list[pdev_id];
  2755. if (!pdev) {
  2756. dp_err("Invalid pdev");
  2757. return;
  2758. }
  2759. dp_wdi_event_handler(WDI_EVENT_MLO_TSTMP, soc,
  2760. msg_word, HTT_INVALID_PEER, WDI_NO_VAL,
  2761. pdev_id);
  2762. qdf_spin_lock_bh(&soc->htt_stats.lock);
  2763. pdev->timestamp.msg_type =
  2764. HTT_T2H_MLO_TIMESTAMP_OFFSET_MSG_TYPE_GET(*msg_word);
  2765. pdev->timestamp.pdev_id = pdev_id;
  2766. pdev->timestamp.chip_id =
  2767. HTT_T2H_MLO_TIMESTAMP_OFFSET_CHIP_ID_GET(*msg_word);
  2768. pdev->timestamp.mac_clk_freq =
  2769. HTT_T2H_MLO_TIMESTAMP_OFFSET_MAC_CLK_FREQ_MHZ_GET(*msg_word);
  2770. pdev->timestamp.sync_tstmp_lo_us = *(msg_word + 1);
  2771. pdev->timestamp.sync_tstmp_hi_us = *(msg_word + 2);
  2772. pdev->timestamp.mlo_offset_lo_us = *(msg_word + 3);
  2773. pdev->timestamp.mlo_offset_hi_us = *(msg_word + 4);
  2774. pdev->timestamp.mlo_offset_clks = *(msg_word + 5);
  2775. pdev->timestamp.mlo_comp_us =
  2776. HTT_T2H_MLO_TIMESTAMP_OFFSET_MLO_TIMESTAMP_COMP_US_GET(
  2777. *(msg_word + 6));
  2778. pdev->timestamp.mlo_comp_clks =
  2779. HTT_T2H_MLO_TIMESTAMP_OFFSET_MLO_TIMESTAMP_COMP_CLKS_GET(
  2780. *(msg_word + 6));
  2781. pdev->timestamp.mlo_comp_timer =
  2782. HTT_T2H_MLO_TIMESTAMP_OFFSET_MLO_TIMESTAMP_COMP_PERIOD_US_GET(
  2783. *(msg_word + 7));
  2784. dp_htt_debug("tsf_lo=%d tsf_hi=%d, mlo_ofst_lo=%d, mlo_ofst_hi=%d\n",
  2785. pdev->timestamp.sync_tstmp_lo_us,
  2786. pdev->timestamp.sync_tstmp_hi_us,
  2787. pdev->timestamp.mlo_offset_lo_us,
  2788. pdev->timestamp.mlo_offset_hi_us);
  2789. qdf_spin_unlock_bh(&soc->htt_stats.lock);
  2790. dp_update_mlo_ts_offset(soc,
  2791. pdev->timestamp.mlo_offset_lo_us,
  2792. pdev->timestamp.mlo_offset_hi_us);
  2793. }
  2794. #else
  2795. static void dp_htt_mlo_peer_map_handler(struct htt_soc *soc,
  2796. uint32_t *msg_word)
  2797. {
  2798. qdf_assert_always(0);
  2799. }
  2800. static void dp_htt_mlo_peer_unmap_handler(struct htt_soc *soc,
  2801. uint32_t *msg_word)
  2802. {
  2803. qdf_assert_always(0);
  2804. }
  2805. static void
  2806. dp_rx_mlo_timestamp_ind_handler(void *soc_handle,
  2807. uint32_t *msg_word)
  2808. {
  2809. qdf_assert_always(0);
  2810. }
  2811. #endif
  2812. /*
  2813. * dp_htt_rx_addba_handler() - RX Addba HTT msg handler
  2814. * @soc: DP Soc handler
  2815. * @peer_id: ID of peer
  2816. * @tid: TID number
  2817. * @win_sz: BA window size
  2818. *
  2819. * Return: None
  2820. */
  2821. static void
  2822. dp_htt_rx_addba_handler(struct dp_soc *soc, uint16_t peer_id,
  2823. uint8_t tid, uint16_t win_sz)
  2824. {
  2825. uint16_t status;
  2826. struct dp_peer *peer;
  2827. peer = dp_peer_get_ref_by_id(soc, peer_id, DP_MOD_ID_HTT);
  2828. if (!peer) {
  2829. dp_err("Peer not found peer id %d", peer_id);
  2830. return;
  2831. }
  2832. status = dp_addba_requestprocess_wifi3((struct cdp_soc_t *)soc,
  2833. peer->mac_addr.raw,
  2834. peer->vdev->vdev_id, 0,
  2835. tid, 0, win_sz, 0xffff);
  2836. dp_addba_resp_tx_completion_wifi3(
  2837. (struct cdp_soc_t *)soc,
  2838. peer->mac_addr.raw, peer->vdev->vdev_id,
  2839. tid,
  2840. status);
  2841. dp_peer_unref_delete(peer, DP_MOD_ID_HTT);
  2842. dp_info("PeerID %d BAW %d TID %d stat %d",
  2843. peer_id, win_sz, tid, status);
  2844. }
  2845. /*
  2846. * dp_htt_ppdu_id_fmt_handler() - PPDU ID Format handler
  2847. * @htt_soc: HTT SOC handle
  2848. * @msg_word: Pointer to payload
  2849. *
  2850. * Return: None
  2851. */
  2852. static void
  2853. dp_htt_ppdu_id_fmt_handler(struct dp_soc *soc, uint32_t *msg_word)
  2854. {
  2855. uint8_t msg_type, valid, bits, offset;
  2856. msg_type = HTT_T2H_MSG_TYPE_GET(*msg_word);
  2857. msg_word += HTT_PPDU_ID_FMT_IND_LINK_ID_OFFSET;
  2858. valid = HTT_PPDU_ID_FMT_IND_VALID_GET_BITS31_16(*msg_word);
  2859. bits = HTT_PPDU_ID_FMT_IND_BITS_GET_BITS31_16(*msg_word);
  2860. offset = HTT_PPDU_ID_FMT_IND_OFFSET_GET_BITS31_16(*msg_word);
  2861. dp_info("link_id: valid %u bits %u offset %u", valid, bits, offset);
  2862. if (valid) {
  2863. soc->link_id_offset = offset;
  2864. soc->link_id_bits = bits;
  2865. }
  2866. }
  2867. /*
  2868. * dp_htt_t2h_msg_handler() - Generic Target to host Msg/event handler
  2869. * @context: Opaque context (HTT SOC handle)
  2870. * @pkt: HTC packet
  2871. */
  2872. static void dp_htt_t2h_msg_handler(void *context, HTC_PACKET *pkt)
  2873. {
  2874. struct htt_soc *soc = (struct htt_soc *) context;
  2875. qdf_nbuf_t htt_t2h_msg = (qdf_nbuf_t) pkt->pPktContext;
  2876. u_int32_t *msg_word;
  2877. enum htt_t2h_msg_type msg_type;
  2878. bool free_buf = true;
  2879. /* check for successful message reception */
  2880. if (pkt->Status != QDF_STATUS_SUCCESS) {
  2881. if (pkt->Status != QDF_STATUS_E_CANCELED)
  2882. soc->stats.htc_err_cnt++;
  2883. qdf_nbuf_free(htt_t2h_msg);
  2884. return;
  2885. }
  2886. /* TODO: Check if we should pop the HTC/HTT header alignment padding */
  2887. msg_word = (u_int32_t *) qdf_nbuf_data(htt_t2h_msg);
  2888. msg_type = HTT_T2H_MSG_TYPE_GET(*msg_word);
  2889. htt_event_record(soc->htt_logger_handle,
  2890. msg_type, (uint8_t *)msg_word);
  2891. switch (msg_type) {
  2892. case HTT_T2H_MSG_TYPE_BKPRESSURE_EVENT_IND:
  2893. {
  2894. dp_htt_bkp_event_alert(msg_word, soc);
  2895. break;
  2896. }
  2897. case HTT_T2H_MSG_TYPE_PEER_MAP:
  2898. {
  2899. u_int8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  2900. u_int8_t *peer_mac_addr;
  2901. u_int16_t peer_id;
  2902. u_int16_t hw_peer_id;
  2903. u_int8_t vdev_id;
  2904. u_int8_t is_wds;
  2905. struct dp_soc *dpsoc = (struct dp_soc *)soc->dp_soc;
  2906. peer_id = HTT_RX_PEER_MAP_PEER_ID_GET(*msg_word);
  2907. hw_peer_id =
  2908. HTT_RX_PEER_MAP_HW_PEER_ID_GET(*(msg_word+2));
  2909. vdev_id = HTT_RX_PEER_MAP_VDEV_ID_GET(*msg_word);
  2910. peer_mac_addr = htt_t2h_mac_addr_deswizzle(
  2911. (u_int8_t *) (msg_word+1),
  2912. &mac_addr_deswizzle_buf[0]);
  2913. QDF_TRACE(QDF_MODULE_ID_TXRX,
  2914. QDF_TRACE_LEVEL_DEBUG,
  2915. "HTT_T2H_MSG_TYPE_PEER_MAP msg for peer id %d vdev id %d n",
  2916. peer_id, vdev_id);
  2917. /*
  2918. * check if peer already exists for this peer_id, if so
  2919. * this peer map event is in response for a wds peer add
  2920. * wmi command sent during wds source port learning.
  2921. * in this case just add the ast entry to the existing
  2922. * peer ast_list.
  2923. */
  2924. is_wds = !!(dpsoc->peer_id_to_obj_map[peer_id]);
  2925. dp_rx_peer_map_handler(soc->dp_soc, peer_id, hw_peer_id,
  2926. vdev_id, peer_mac_addr, 0,
  2927. is_wds);
  2928. break;
  2929. }
  2930. case HTT_T2H_MSG_TYPE_PEER_UNMAP:
  2931. {
  2932. u_int16_t peer_id;
  2933. u_int8_t vdev_id;
  2934. u_int8_t mac_addr[QDF_MAC_ADDR_SIZE] = {0};
  2935. peer_id = HTT_RX_PEER_UNMAP_PEER_ID_GET(*msg_word);
  2936. vdev_id = HTT_RX_PEER_UNMAP_VDEV_ID_GET(*msg_word);
  2937. dp_rx_peer_unmap_handler(soc->dp_soc, peer_id,
  2938. vdev_id, mac_addr, 0,
  2939. DP_PEER_WDS_COUNT_INVALID);
  2940. break;
  2941. }
  2942. case HTT_T2H_MSG_TYPE_SEC_IND:
  2943. {
  2944. u_int16_t peer_id;
  2945. enum cdp_sec_type sec_type;
  2946. int is_unicast;
  2947. peer_id = HTT_SEC_IND_PEER_ID_GET(*msg_word);
  2948. sec_type = HTT_SEC_IND_SEC_TYPE_GET(*msg_word);
  2949. is_unicast = HTT_SEC_IND_UNICAST_GET(*msg_word);
  2950. /* point to the first part of the Michael key */
  2951. msg_word++;
  2952. dp_rx_sec_ind_handler(
  2953. soc->dp_soc, peer_id, sec_type, is_unicast,
  2954. msg_word, msg_word + 2);
  2955. break;
  2956. }
  2957. case HTT_T2H_MSG_TYPE_PPDU_STATS_IND:
  2958. {
  2959. free_buf =
  2960. dp_monitor_ppdu_stats_ind_handler(soc,
  2961. msg_word,
  2962. htt_t2h_msg);
  2963. break;
  2964. }
  2965. case HTT_T2H_MSG_TYPE_PKTLOG:
  2966. {
  2967. dp_pktlog_msg_handler(soc, msg_word);
  2968. break;
  2969. }
  2970. case HTT_T2H_MSG_TYPE_VERSION_CONF:
  2971. {
  2972. /*
  2973. * HTC maintains runtime pm count for H2T messages that
  2974. * have a response msg from FW. This count ensures that
  2975. * in the case FW does not sent out the response or host
  2976. * did not process this indication runtime_put happens
  2977. * properly in the cleanup path.
  2978. */
  2979. if (htc_dec_return_runtime_cnt(soc->htc_soc) >= 0)
  2980. htc_pm_runtime_put(soc->htc_soc);
  2981. else
  2982. soc->stats.htt_ver_req_put_skip++;
  2983. soc->tgt_ver.major = HTT_VER_CONF_MAJOR_GET(*msg_word);
  2984. soc->tgt_ver.minor = HTT_VER_CONF_MINOR_GET(*msg_word);
  2985. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_LOW,
  2986. "target uses HTT version %d.%d; host uses %d.%d",
  2987. soc->tgt_ver.major, soc->tgt_ver.minor,
  2988. HTT_CURRENT_VERSION_MAJOR,
  2989. HTT_CURRENT_VERSION_MINOR);
  2990. if (soc->tgt_ver.major != HTT_CURRENT_VERSION_MAJOR) {
  2991. QDF_TRACE(QDF_MODULE_ID_TXRX,
  2992. QDF_TRACE_LEVEL_WARN,
  2993. "*** Incompatible host/target HTT versions!");
  2994. }
  2995. /* abort if the target is incompatible with the host */
  2996. qdf_assert(soc->tgt_ver.major ==
  2997. HTT_CURRENT_VERSION_MAJOR);
  2998. if (soc->tgt_ver.minor != HTT_CURRENT_VERSION_MINOR) {
  2999. QDF_TRACE(QDF_MODULE_ID_TXRX,
  3000. QDF_TRACE_LEVEL_INFO_LOW,
  3001. "*** Warning: host/target HTT versions"
  3002. " are different, though compatible!");
  3003. }
  3004. break;
  3005. }
  3006. case HTT_T2H_MSG_TYPE_RX_ADDBA:
  3007. {
  3008. uint16_t peer_id;
  3009. uint8_t tid;
  3010. uint16_t win_sz;
  3011. /*
  3012. * Update REO Queue Desc with new values
  3013. */
  3014. peer_id = HTT_RX_ADDBA_PEER_ID_GET(*msg_word);
  3015. tid = HTT_RX_ADDBA_TID_GET(*msg_word);
  3016. win_sz = HTT_RX_ADDBA_WIN_SIZE_GET(*msg_word);
  3017. /*
  3018. * Window size needs to be incremented by 1
  3019. * since fw needs to represent a value of 256
  3020. * using just 8 bits
  3021. */
  3022. dp_htt_rx_addba_handler(soc->dp_soc, peer_id,
  3023. tid, win_sz + 1);
  3024. break;
  3025. }
  3026. case HTT_T2H_MSG_TYPE_RX_ADDBA_EXTN:
  3027. {
  3028. uint16_t peer_id;
  3029. uint8_t tid;
  3030. uint16_t win_sz;
  3031. peer_id = HTT_RX_ADDBA_EXTN_PEER_ID_GET(*msg_word);
  3032. tid = HTT_RX_ADDBA_EXTN_TID_GET(*msg_word);
  3033. msg_word++;
  3034. win_sz = HTT_RX_ADDBA_EXTN_WIN_SIZE_GET(*msg_word);
  3035. dp_htt_rx_addba_handler(soc->dp_soc, peer_id,
  3036. tid, win_sz);
  3037. break;
  3038. }
  3039. case HTT_T2H_PPDU_ID_FMT_IND:
  3040. {
  3041. dp_htt_ppdu_id_fmt_handler(soc->dp_soc, msg_word);
  3042. break;
  3043. }
  3044. case HTT_T2H_MSG_TYPE_EXT_STATS_CONF:
  3045. {
  3046. dp_txrx_fw_stats_handler(soc->dp_soc, htt_t2h_msg);
  3047. break;
  3048. }
  3049. case HTT_T2H_MSG_TYPE_PEER_MAP_V2:
  3050. {
  3051. u_int8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  3052. u_int8_t *peer_mac_addr;
  3053. u_int16_t peer_id;
  3054. u_int16_t hw_peer_id;
  3055. u_int8_t vdev_id;
  3056. bool is_wds;
  3057. u_int16_t ast_hash;
  3058. struct dp_ast_flow_override_info ast_flow_info;
  3059. qdf_mem_set(&ast_flow_info, 0,
  3060. sizeof(struct dp_ast_flow_override_info));
  3061. peer_id = HTT_RX_PEER_MAP_V2_SW_PEER_ID_GET(*msg_word);
  3062. hw_peer_id =
  3063. HTT_RX_PEER_MAP_V2_HW_PEER_ID_GET(*(msg_word + 2));
  3064. vdev_id = HTT_RX_PEER_MAP_V2_VDEV_ID_GET(*msg_word);
  3065. peer_mac_addr =
  3066. htt_t2h_mac_addr_deswizzle((u_int8_t *)(msg_word + 1),
  3067. &mac_addr_deswizzle_buf[0]);
  3068. is_wds =
  3069. HTT_RX_PEER_MAP_V2_NEXT_HOP_GET(*(msg_word + 3));
  3070. ast_hash =
  3071. HTT_RX_PEER_MAP_V2_AST_HASH_VALUE_GET(*(msg_word + 3));
  3072. /*
  3073. * Update 4 ast_index per peer, ast valid mask
  3074. * and TID flow valid mask.
  3075. * AST valid mask is 3 bit field corresponds to
  3076. * ast_index[3:1]. ast_index 0 is always valid.
  3077. */
  3078. ast_flow_info.ast_valid_mask =
  3079. HTT_RX_PEER_MAP_V2_AST_VALID_MASK_GET(*(msg_word + 3));
  3080. ast_flow_info.ast_idx[0] = hw_peer_id;
  3081. ast_flow_info.ast_flow_mask[0] =
  3082. HTT_RX_PEER_MAP_V2_AST_0_FLOW_MASK_GET(*(msg_word + 4));
  3083. ast_flow_info.ast_idx[1] =
  3084. HTT_RX_PEER_MAP_V2_AST_INDEX_1_GET(*(msg_word + 4));
  3085. ast_flow_info.ast_flow_mask[1] =
  3086. HTT_RX_PEER_MAP_V2_AST_1_FLOW_MASK_GET(*(msg_word + 4));
  3087. ast_flow_info.ast_idx[2] =
  3088. HTT_RX_PEER_MAP_V2_AST_INDEX_2_GET(*(msg_word + 5));
  3089. ast_flow_info.ast_flow_mask[2] =
  3090. HTT_RX_PEER_MAP_V2_AST_2_FLOW_MASK_GET(*(msg_word + 4));
  3091. ast_flow_info.ast_idx[3] =
  3092. HTT_RX_PEER_MAP_V2_AST_INDEX_3_GET(*(msg_word + 6));
  3093. ast_flow_info.ast_flow_mask[3] =
  3094. HTT_RX_PEER_MAP_V2_AST_3_FLOW_MASK_GET(*(msg_word + 4));
  3095. /*
  3096. * TID valid mask is applicable only
  3097. * for HI and LOW priority flows.
  3098. * tid_valid_mas is 8 bit field corresponds
  3099. * to TID[7:0]
  3100. */
  3101. ast_flow_info.tid_valid_low_pri_mask =
  3102. HTT_RX_PEER_MAP_V2_TID_VALID_LOW_PRI_GET(*(msg_word + 5));
  3103. ast_flow_info.tid_valid_hi_pri_mask =
  3104. HTT_RX_PEER_MAP_V2_TID_VALID_HI_PRI_GET(*(msg_word + 5));
  3105. QDF_TRACE(QDF_MODULE_ID_TXRX,
  3106. QDF_TRACE_LEVEL_DEBUG,
  3107. "HTT_T2H_MSG_TYPE_PEER_MAP msg for peer id %d vdev id %d n",
  3108. peer_id, vdev_id);
  3109. QDF_TRACE(QDF_MODULE_ID_TXRX,
  3110. QDF_TRACE_LEVEL_INFO,
  3111. "ast_idx[0] %d ast_idx[1] %d ast_idx[2] %d ast_idx[3] %d n",
  3112. ast_flow_info.ast_idx[0],
  3113. ast_flow_info.ast_idx[1],
  3114. ast_flow_info.ast_idx[2],
  3115. ast_flow_info.ast_idx[3]);
  3116. dp_rx_peer_map_handler(soc->dp_soc, peer_id,
  3117. hw_peer_id, vdev_id,
  3118. peer_mac_addr, ast_hash,
  3119. is_wds);
  3120. /*
  3121. * Update ast indexes for flow override support
  3122. * Applicable only for non wds peers
  3123. */
  3124. if (!soc->dp_soc->ast_offload_support)
  3125. dp_peer_ast_index_flow_queue_map_create(
  3126. soc->dp_soc, is_wds,
  3127. peer_id, peer_mac_addr,
  3128. &ast_flow_info);
  3129. break;
  3130. }
  3131. case HTT_T2H_MSG_TYPE_PEER_UNMAP_V2:
  3132. {
  3133. u_int8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  3134. u_int8_t *mac_addr;
  3135. u_int16_t peer_id;
  3136. u_int8_t vdev_id;
  3137. u_int8_t is_wds;
  3138. u_int32_t free_wds_count;
  3139. peer_id =
  3140. HTT_RX_PEER_UNMAP_V2_SW_PEER_ID_GET(*msg_word);
  3141. vdev_id = HTT_RX_PEER_UNMAP_V2_VDEV_ID_GET(*msg_word);
  3142. mac_addr =
  3143. htt_t2h_mac_addr_deswizzle((u_int8_t *)(msg_word + 1),
  3144. &mac_addr_deswizzle_buf[0]);
  3145. is_wds =
  3146. HTT_RX_PEER_UNMAP_V2_NEXT_HOP_GET(*(msg_word + 2));
  3147. free_wds_count =
  3148. HTT_RX_PEER_UNMAP_V2_PEER_WDS_FREE_COUNT_GET(*(msg_word + 4));
  3149. QDF_TRACE(QDF_MODULE_ID_TXRX,
  3150. QDF_TRACE_LEVEL_INFO,
  3151. "HTT_T2H_MSG_TYPE_PEER_UNMAP msg for peer id %d vdev id %d n",
  3152. peer_id, vdev_id);
  3153. dp_rx_peer_unmap_handler(soc->dp_soc, peer_id,
  3154. vdev_id, mac_addr,
  3155. is_wds, free_wds_count);
  3156. break;
  3157. }
  3158. case HTT_T2H_MSG_TYPE_RX_DELBA:
  3159. {
  3160. uint16_t peer_id;
  3161. uint8_t tid;
  3162. uint8_t win_sz;
  3163. QDF_STATUS status;
  3164. peer_id = HTT_RX_DELBA_PEER_ID_GET(*msg_word);
  3165. tid = HTT_RX_DELBA_TID_GET(*msg_word);
  3166. win_sz = HTT_RX_DELBA_WIN_SIZE_GET(*msg_word);
  3167. status = dp_rx_delba_ind_handler(
  3168. soc->dp_soc,
  3169. peer_id, tid, win_sz);
  3170. QDF_TRACE(QDF_MODULE_ID_TXRX,
  3171. QDF_TRACE_LEVEL_INFO,
  3172. FL("DELBA PeerID %d BAW %d TID %d stat %d"),
  3173. peer_id, win_sz, tid, status);
  3174. break;
  3175. }
  3176. case HTT_T2H_MSG_TYPE_RX_DELBA_EXTN:
  3177. {
  3178. uint16_t peer_id;
  3179. uint8_t tid;
  3180. uint16_t win_sz;
  3181. QDF_STATUS status;
  3182. peer_id = HTT_RX_DELBA_EXTN_PEER_ID_GET(*msg_word);
  3183. tid = HTT_RX_DELBA_EXTN_TID_GET(*msg_word);
  3184. msg_word++;
  3185. win_sz = HTT_RX_DELBA_EXTN_WIN_SIZE_GET(*msg_word);
  3186. status = dp_rx_delba_ind_handler(soc->dp_soc,
  3187. peer_id, tid,
  3188. win_sz);
  3189. dp_info("DELBA PeerID %d BAW %d TID %d stat %d",
  3190. peer_id, win_sz, tid, status);
  3191. break;
  3192. }
  3193. case HTT_T2H_MSG_TYPE_FSE_CMEM_BASE_SEND:
  3194. {
  3195. uint16_t num_entries;
  3196. uint32_t cmem_ba_lo;
  3197. uint32_t cmem_ba_hi;
  3198. num_entries = HTT_CMEM_BASE_SEND_NUM_ENTRIES_GET(*msg_word);
  3199. cmem_ba_lo = *(msg_word + 1);
  3200. cmem_ba_hi = *(msg_word + 2);
  3201. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO,
  3202. FL("CMEM FSE num_entries %u CMEM BA LO %x HI %x"),
  3203. num_entries, cmem_ba_lo, cmem_ba_hi);
  3204. dp_rx_fst_update_cmem_params(soc->dp_soc, num_entries,
  3205. cmem_ba_lo, cmem_ba_hi);
  3206. break;
  3207. }
  3208. case HTT_T2H_MSG_TYPE_TX_OFFLOAD_DELIVER_IND:
  3209. {
  3210. dp_offload_ind_handler(soc, msg_word);
  3211. break;
  3212. }
  3213. case HTT_T2H_MSG_TYPE_PEER_MAP_V3:
  3214. {
  3215. u_int8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  3216. u_int8_t *peer_mac_addr;
  3217. u_int16_t peer_id;
  3218. u_int16_t hw_peer_id;
  3219. u_int8_t vdev_id;
  3220. uint8_t is_wds;
  3221. u_int16_t ast_hash = 0;
  3222. peer_id = HTT_RX_PEER_MAP_V3_SW_PEER_ID_GET(*msg_word);
  3223. vdev_id = HTT_RX_PEER_MAP_V3_VDEV_ID_GET(*msg_word);
  3224. peer_mac_addr =
  3225. htt_t2h_mac_addr_deswizzle((u_int8_t *)(msg_word + 1),
  3226. &mac_addr_deswizzle_buf[0]);
  3227. hw_peer_id = HTT_RX_PEER_MAP_V3_HW_PEER_ID_GET(*(msg_word + 3));
  3228. ast_hash = HTT_RX_PEER_MAP_V3_CACHE_SET_NUM_GET(*(msg_word + 3));
  3229. is_wds = HTT_RX_PEER_MAP_V3_NEXT_HOP_GET(*(msg_word + 4));
  3230. dp_htt_info("HTT_T2H_MSG_TYPE_PEER_MAP_V3 msg for peer id %d vdev id %d n",
  3231. peer_id, vdev_id);
  3232. dp_rx_peer_map_handler(soc->dp_soc, peer_id,
  3233. hw_peer_id, vdev_id,
  3234. peer_mac_addr, ast_hash,
  3235. is_wds);
  3236. break;
  3237. }
  3238. case HTT_T2H_MSG_TYPE_MLO_RX_PEER_MAP:
  3239. {
  3240. dp_htt_mlo_peer_map_handler(soc, msg_word);
  3241. break;
  3242. }
  3243. case HTT_T2H_MSG_TYPE_MLO_RX_PEER_UNMAP:
  3244. {
  3245. dp_htt_mlo_peer_unmap_handler(soc, msg_word);
  3246. break;
  3247. }
  3248. case HTT_T2H_MSG_TYPE_MLO_TIMESTAMP_OFFSET_IND:
  3249. {
  3250. dp_rx_mlo_timestamp_ind_handler(soc->dp_soc, msg_word);
  3251. break;
  3252. }
  3253. case HTT_T2H_MSG_TYPE_VDEVS_TXRX_STATS_PERIODIC_IND:
  3254. {
  3255. dp_vdev_txrx_hw_stats_handler(soc, msg_word);
  3256. break;
  3257. }
  3258. case HTT_T2H_SAWF_DEF_QUEUES_MAP_REPORT_CONF:
  3259. {
  3260. dp_sawf_def_queues_update_map_report_conf(soc, msg_word,
  3261. htt_t2h_msg);
  3262. break;
  3263. }
  3264. case HTT_T2H_SAWF_MSDUQ_INFO_IND:
  3265. {
  3266. dp_sawf_msduq_map(soc, msg_word, htt_t2h_msg);
  3267. break;
  3268. }
  3269. case HTT_T2H_MSG_TYPE_STREAMING_STATS_IND:
  3270. {
  3271. dp_sawf_mpdu_stats_handler(soc, htt_t2h_msg);
  3272. break;
  3273. }
  3274. default:
  3275. break;
  3276. };
  3277. /* Free the indication buffer */
  3278. if (free_buf)
  3279. qdf_nbuf_free(htt_t2h_msg);
  3280. }
  3281. /*
  3282. * dp_htt_h2t_full() - Send full handler (called from HTC)
  3283. * @context: Opaque context (HTT SOC handle)
  3284. * @pkt: HTC packet
  3285. *
  3286. * Return: enum htc_send_full_action
  3287. */
  3288. static enum htc_send_full_action
  3289. dp_htt_h2t_full(void *context, HTC_PACKET *pkt)
  3290. {
  3291. return HTC_SEND_FULL_KEEP;
  3292. }
  3293. /*
  3294. * dp_htt_hif_t2h_hp_callback() - HIF callback for high priority T2H messages
  3295. * @context: Opaque context (HTT SOC handle)
  3296. * @nbuf: nbuf containing T2H message
  3297. * @pipe_id: HIF pipe ID
  3298. *
  3299. * Return: QDF_STATUS
  3300. *
  3301. * TODO: Temporary change to bypass HTC connection for this new HIF pipe, which
  3302. * will be used for packet log and other high-priority HTT messages. Proper
  3303. * HTC connection to be added later once required FW changes are available
  3304. */
  3305. static QDF_STATUS
  3306. dp_htt_hif_t2h_hp_callback (void *context, qdf_nbuf_t nbuf, uint8_t pipe_id)
  3307. {
  3308. QDF_STATUS rc = QDF_STATUS_SUCCESS;
  3309. HTC_PACKET htc_pkt;
  3310. qdf_assert_always(pipe_id == DP_HTT_T2H_HP_PIPE);
  3311. qdf_mem_zero(&htc_pkt, sizeof(htc_pkt));
  3312. htc_pkt.Status = QDF_STATUS_SUCCESS;
  3313. htc_pkt.pPktContext = (void *)nbuf;
  3314. dp_htt_t2h_msg_handler(context, &htc_pkt);
  3315. return rc;
  3316. }
  3317. /*
  3318. * htt_htc_soc_attach() - Register SOC level HTT instance with HTC
  3319. * @htt_soc: HTT SOC handle
  3320. *
  3321. * Return: QDF_STATUS
  3322. */
  3323. static QDF_STATUS
  3324. htt_htc_soc_attach(struct htt_soc *soc)
  3325. {
  3326. struct htc_service_connect_req connect;
  3327. struct htc_service_connect_resp response;
  3328. QDF_STATUS status;
  3329. struct dp_soc *dpsoc = soc->dp_soc;
  3330. qdf_mem_zero(&connect, sizeof(connect));
  3331. qdf_mem_zero(&response, sizeof(response));
  3332. connect.pMetaData = NULL;
  3333. connect.MetaDataLength = 0;
  3334. connect.EpCallbacks.pContext = soc;
  3335. connect.EpCallbacks.EpTxComplete = dp_htt_h2t_send_complete;
  3336. connect.EpCallbacks.EpTxCompleteMultiple = NULL;
  3337. connect.EpCallbacks.EpRecv = dp_htt_t2h_msg_handler;
  3338. /* rx buffers currently are provided by HIF, not by EpRecvRefill */
  3339. connect.EpCallbacks.EpRecvRefill = NULL;
  3340. /* N/A, fill is done by HIF */
  3341. connect.EpCallbacks.RecvRefillWaterMark = 1;
  3342. connect.EpCallbacks.EpSendFull = dp_htt_h2t_full;
  3343. /*
  3344. * Specify how deep to let a queue get before htc_send_pkt will
  3345. * call the EpSendFull function due to excessive send queue depth.
  3346. */
  3347. connect.MaxSendQueueDepth = DP_HTT_MAX_SEND_QUEUE_DEPTH;
  3348. /* disable flow control for HTT data message service */
  3349. connect.ConnectionFlags |= HTC_CONNECT_FLAGS_DISABLE_CREDIT_FLOW_CTRL;
  3350. /* connect to control service */
  3351. connect.service_id = HTT_DATA_MSG_SVC;
  3352. status = htc_connect_service(soc->htc_soc, &connect, &response);
  3353. if (status != QDF_STATUS_SUCCESS)
  3354. return status;
  3355. soc->htc_endpoint = response.Endpoint;
  3356. hif_save_htc_htt_config_endpoint(dpsoc->hif_handle, soc->htc_endpoint);
  3357. htt_interface_logging_init(&soc->htt_logger_handle, soc->ctrl_psoc);
  3358. dp_hif_update_pipe_callback(soc->dp_soc, (void *)soc,
  3359. dp_htt_hif_t2h_hp_callback, DP_HTT_T2H_HP_PIPE);
  3360. return QDF_STATUS_SUCCESS; /* success */
  3361. }
  3362. /*
  3363. * htt_soc_initialize() - SOC level HTT initialization
  3364. * @htt_soc: Opaque htt SOC handle
  3365. * @ctrl_psoc: Opaque ctrl SOC handle
  3366. * @htc_soc: SOC level HTC handle
  3367. * @hal_soc: Opaque HAL SOC handle
  3368. * @osdev: QDF device
  3369. *
  3370. * Return: HTT handle on success; NULL on failure
  3371. */
  3372. void *
  3373. htt_soc_initialize(struct htt_soc *htt_soc,
  3374. struct cdp_ctrl_objmgr_psoc *ctrl_psoc,
  3375. HTC_HANDLE htc_soc,
  3376. hal_soc_handle_t hal_soc_hdl, qdf_device_t osdev)
  3377. {
  3378. struct htt_soc *soc = (struct htt_soc *)htt_soc;
  3379. soc->osdev = osdev;
  3380. soc->ctrl_psoc = ctrl_psoc;
  3381. soc->htc_soc = htc_soc;
  3382. soc->hal_soc = hal_soc_hdl;
  3383. if (htt_htc_soc_attach(soc))
  3384. goto fail2;
  3385. return soc;
  3386. fail2:
  3387. return NULL;
  3388. }
  3389. void htt_soc_htc_dealloc(struct htt_soc *htt_handle)
  3390. {
  3391. htt_interface_logging_deinit(htt_handle->htt_logger_handle);
  3392. htt_htc_misc_pkt_pool_free(htt_handle);
  3393. htt_htc_pkt_pool_free(htt_handle);
  3394. }
  3395. /*
  3396. * htt_soc_htc_prealloc() - HTC memory prealloc
  3397. * @htt_soc: SOC level HTT handle
  3398. *
  3399. * Return: QDF_STATUS_SUCCESS on Success or
  3400. * QDF_STATUS_E_NOMEM on allocation failure
  3401. */
  3402. QDF_STATUS htt_soc_htc_prealloc(struct htt_soc *soc)
  3403. {
  3404. int i;
  3405. soc->htt_htc_pkt_freelist = NULL;
  3406. /* pre-allocate some HTC_PACKET objects */
  3407. for (i = 0; i < HTT_HTC_PKT_POOL_INIT_SIZE; i++) {
  3408. struct dp_htt_htc_pkt_union *pkt;
  3409. pkt = qdf_mem_malloc(sizeof(*pkt));
  3410. if (!pkt)
  3411. return QDF_STATUS_E_NOMEM;
  3412. htt_htc_pkt_free(soc, &pkt->u.pkt);
  3413. }
  3414. return QDF_STATUS_SUCCESS;
  3415. }
  3416. /*
  3417. * htt_soc_detach() - Free SOC level HTT handle
  3418. * @htt_hdl: HTT SOC handle
  3419. */
  3420. void htt_soc_detach(struct htt_soc *htt_hdl)
  3421. {
  3422. int i;
  3423. struct htt_soc *htt_handle = (struct htt_soc *)htt_hdl;
  3424. for (i = 0; i < MAX_PDEV_CNT; i++) {
  3425. qdf_mem_free(htt_handle->pdevid_tt[i].umac_path);
  3426. qdf_mem_free(htt_handle->pdevid_tt[i].lmac_path);
  3427. }
  3428. HTT_TX_MUTEX_DESTROY(&htt_handle->htt_tx_mutex);
  3429. qdf_mem_free(htt_handle);
  3430. }
  3431. /**
  3432. * dp_h2t_ext_stats_msg_send(): function to contruct HTT message to pass to FW
  3433. * @pdev: DP PDEV handle
  3434. * @stats_type_upload_mask: stats type requested by user
  3435. * @config_param_0: extra configuration parameters
  3436. * @config_param_1: extra configuration parameters
  3437. * @config_param_2: extra configuration parameters
  3438. * @config_param_3: extra configuration parameters
  3439. * @mac_id: mac number
  3440. *
  3441. * return: QDF STATUS
  3442. */
  3443. QDF_STATUS dp_h2t_ext_stats_msg_send(struct dp_pdev *pdev,
  3444. uint32_t stats_type_upload_mask, uint32_t config_param_0,
  3445. uint32_t config_param_1, uint32_t config_param_2,
  3446. uint32_t config_param_3, int cookie_val, int cookie_msb,
  3447. uint8_t mac_id)
  3448. {
  3449. struct htt_soc *soc = pdev->soc->htt_handle;
  3450. struct dp_htt_htc_pkt *pkt;
  3451. qdf_nbuf_t msg;
  3452. uint32_t *msg_word;
  3453. uint8_t pdev_mask = 0;
  3454. uint8_t *htt_logger_bufp;
  3455. int mac_for_pdev;
  3456. int target_pdev_id;
  3457. QDF_STATUS status;
  3458. msg = qdf_nbuf_alloc(
  3459. soc->osdev,
  3460. HTT_MSG_BUF_SIZE(HTT_H2T_EXT_STATS_REQ_MSG_SZ),
  3461. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  3462. if (!msg)
  3463. return QDF_STATUS_E_NOMEM;
  3464. /*TODO:Add support for SOC stats
  3465. * Bit 0: SOC Stats
  3466. * Bit 1: Pdev stats for pdev id 0
  3467. * Bit 2: Pdev stats for pdev id 1
  3468. * Bit 3: Pdev stats for pdev id 2
  3469. */
  3470. mac_for_pdev = dp_get_mac_id_for_pdev(mac_id, pdev->pdev_id);
  3471. target_pdev_id =
  3472. dp_get_target_pdev_id_for_host_pdev_id(pdev->soc, mac_for_pdev);
  3473. pdev_mask = 1 << target_pdev_id;
  3474. /*
  3475. * Set the length of the message.
  3476. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  3477. * separately during the below call to qdf_nbuf_push_head.
  3478. * The contribution from the HTC header is added separately inside HTC.
  3479. */
  3480. if (qdf_nbuf_put_tail(msg, HTT_H2T_EXT_STATS_REQ_MSG_SZ) == NULL) {
  3481. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  3482. "Failed to expand head for HTT_EXT_STATS");
  3483. qdf_nbuf_free(msg);
  3484. return QDF_STATUS_E_FAILURE;
  3485. }
  3486. msg_word = (uint32_t *) qdf_nbuf_data(msg);
  3487. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  3488. htt_logger_bufp = (uint8_t *)msg_word;
  3489. *msg_word = 0;
  3490. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_EXT_STATS_REQ);
  3491. HTT_H2T_EXT_STATS_REQ_PDEV_MASK_SET(*msg_word, pdev_mask);
  3492. HTT_H2T_EXT_STATS_REQ_STATS_TYPE_SET(*msg_word, stats_type_upload_mask);
  3493. /* word 1 */
  3494. msg_word++;
  3495. *msg_word = 0;
  3496. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_0);
  3497. /* word 2 */
  3498. msg_word++;
  3499. *msg_word = 0;
  3500. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_1);
  3501. /* word 3 */
  3502. msg_word++;
  3503. *msg_word = 0;
  3504. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_2);
  3505. /* word 4 */
  3506. msg_word++;
  3507. *msg_word = 0;
  3508. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_3);
  3509. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, 0);
  3510. /* word 5 */
  3511. msg_word++;
  3512. /* word 6 */
  3513. msg_word++;
  3514. *msg_word = 0;
  3515. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, cookie_val);
  3516. /* word 7 */
  3517. msg_word++;
  3518. *msg_word = 0;
  3519. /* Currently Using last 2 bits for pdev_id
  3520. * For future reference, reserving 3 bits in cookie_msb for pdev_id
  3521. */
  3522. cookie_msb = (cookie_msb | pdev->pdev_id);
  3523. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, cookie_msb);
  3524. pkt = htt_htc_pkt_alloc(soc);
  3525. if (!pkt) {
  3526. qdf_nbuf_free(msg);
  3527. return QDF_STATUS_E_NOMEM;
  3528. }
  3529. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  3530. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  3531. dp_htt_h2t_send_complete_free_netbuf,
  3532. qdf_nbuf_data(msg), qdf_nbuf_len(msg),
  3533. soc->htc_endpoint,
  3534. /* tag for FW response msg not guaranteed */
  3535. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  3536. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  3537. status = DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_EXT_STATS_REQ,
  3538. htt_logger_bufp);
  3539. if (status != QDF_STATUS_SUCCESS) {
  3540. qdf_nbuf_free(msg);
  3541. htt_htc_pkt_free(soc, pkt);
  3542. }
  3543. return status;
  3544. }
  3545. #ifdef QCA_VDEV_STATS_HW_OFFLOAD_SUPPORT
  3546. #define HTT_VDEV_TXRX_STATS_RESET_BITMASK_L32_MASK 0xFFFFFFFF
  3547. #define HTT_VDEV_TXRX_STATS_RESET_BITMASK_U32_MASK 0xFFFFFFFF00000000
  3548. #define HTT_VDEV_TXRX_STATS_RESET_BITMASK_U32_SHIFT 32
  3549. QDF_STATUS dp_h2t_hw_vdev_stats_config_send(struct dp_soc *dpsoc,
  3550. uint8_t pdev_id, bool enable,
  3551. bool reset, uint64_t reset_bitmask)
  3552. {
  3553. struct htt_soc *soc = dpsoc->htt_handle;
  3554. struct dp_htt_htc_pkt *pkt;
  3555. qdf_nbuf_t msg;
  3556. uint32_t *msg_word;
  3557. uint8_t *htt_logger_bufp;
  3558. QDF_STATUS status;
  3559. int duration;
  3560. uint32_t bitmask;
  3561. int target_pdev_id;
  3562. msg = qdf_nbuf_alloc(
  3563. soc->osdev,
  3564. HTT_MSG_BUF_SIZE(sizeof(struct htt_h2t_vdevs_txrx_stats_cfg)),
  3565. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, true);
  3566. if (!msg) {
  3567. dp_htt_err("%pK: Fail to allocate "
  3568. "HTT_H2T_HW_VDEV_TXRX_STATS_CFG_MSG_SZ msg buffer", dpsoc);
  3569. return QDF_STATUS_E_NOMEM;
  3570. }
  3571. if (pdev_id != INVALID_PDEV_ID)
  3572. target_pdev_id = DP_SW2HW_MACID(pdev_id);
  3573. else
  3574. target_pdev_id = 0;
  3575. duration =
  3576. wlan_cfg_get_vdev_stats_hw_offload_timer(dpsoc->wlan_cfg_ctx);
  3577. /*
  3578. * Set the length of the message.
  3579. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  3580. * separately during the below call to qdf_nbuf_push_head.
  3581. * The contribution from the HTC header is added separately inside HTC.
  3582. */
  3583. if (!qdf_nbuf_put_tail(msg,
  3584. sizeof(struct htt_h2t_vdevs_txrx_stats_cfg))) {
  3585. dp_htt_err("%pK: Failed to expand head for HTT_HW_VDEV_STATS"
  3586. , dpsoc);
  3587. qdf_nbuf_free(msg);
  3588. return QDF_STATUS_E_FAILURE;
  3589. }
  3590. msg_word = (uint32_t *)qdf_nbuf_data(msg);
  3591. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  3592. htt_logger_bufp = (uint8_t *)msg_word;
  3593. *msg_word = 0;
  3594. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_VDEVS_TXRX_STATS_CFG);
  3595. HTT_RX_VDEVS_TXRX_STATS_PDEV_ID_SET(*msg_word, target_pdev_id);
  3596. HTT_RX_VDEVS_TXRX_STATS_ENABLE_SET(*msg_word, enable);
  3597. HTT_RX_VDEVS_TXRX_STATS_PERIODIC_INTERVAL_SET(*msg_word,
  3598. (duration >> 3));
  3599. HTT_RX_VDEVS_TXRX_STATS_RESET_STATS_BITS_SET(*msg_word, reset);
  3600. msg_word++;
  3601. *msg_word = 0;
  3602. bitmask = (reset_bitmask & HTT_VDEV_TXRX_STATS_RESET_BITMASK_L32_MASK);
  3603. *msg_word = bitmask;
  3604. msg_word++;
  3605. *msg_word = 0;
  3606. bitmask =
  3607. ((reset_bitmask & HTT_VDEV_TXRX_STATS_RESET_BITMASK_U32_MASK) >>
  3608. HTT_VDEV_TXRX_STATS_RESET_BITMASK_U32_SHIFT);
  3609. *msg_word = bitmask;
  3610. pkt = htt_htc_pkt_alloc(soc);
  3611. if (!pkt) {
  3612. dp_htt_err("%pK: Fail to allocate dp_htt_htc_pkt buffer",
  3613. dpsoc);
  3614. qdf_assert(0);
  3615. qdf_nbuf_free(msg);
  3616. return QDF_STATUS_E_NOMEM;
  3617. }
  3618. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  3619. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  3620. dp_htt_h2t_send_complete_free_netbuf,
  3621. qdf_nbuf_data(msg), qdf_nbuf_len(msg),
  3622. soc->htc_endpoint,
  3623. /* tag for no FW response msg */
  3624. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  3625. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  3626. status = DP_HTT_SEND_HTC_PKT(soc, pkt,
  3627. HTT_H2T_MSG_TYPE_VDEVS_TXRX_STATS_CFG,
  3628. htt_logger_bufp);
  3629. if (status != QDF_STATUS_SUCCESS) {
  3630. qdf_nbuf_free(msg);
  3631. htt_htc_pkt_free(soc, pkt);
  3632. }
  3633. return status;
  3634. }
  3635. #else
  3636. QDF_STATUS dp_h2t_hw_vdev_stats_config_send(struct dp_soc *dpsoc,
  3637. uint8_t pdev_id, bool enable,
  3638. bool reset, uint64_t reset_bitmask)
  3639. {
  3640. return QDF_STATUS_SUCCESS;
  3641. }
  3642. #endif
  3643. /**
  3644. * dp_h2t_3tuple_config_send(): function to contruct 3 tuple configuration
  3645. * HTT message to pass to FW
  3646. * @pdev: DP PDEV handle
  3647. * @tuple_mask: tuple configuration to report 3 tuple hash value in either
  3648. * toeplitz_2_or_4 or flow_id_toeplitz in MSDU START TLV.
  3649. *
  3650. * tuple_mask[1:0]:
  3651. * 00 - Do not report 3 tuple hash value
  3652. * 10 - Report 3 tuple hash value in toeplitz_2_or_4
  3653. * 01 - Report 3 tuple hash value in flow_id_toeplitz
  3654. * 11 - Report 3 tuple hash value in both toeplitz_2_or_4 & flow_id_toeplitz
  3655. *
  3656. * return: QDF STATUS
  3657. */
  3658. QDF_STATUS dp_h2t_3tuple_config_send(struct dp_pdev *pdev,
  3659. uint32_t tuple_mask, uint8_t mac_id)
  3660. {
  3661. struct htt_soc *soc = pdev->soc->htt_handle;
  3662. struct dp_htt_htc_pkt *pkt;
  3663. qdf_nbuf_t msg;
  3664. uint32_t *msg_word;
  3665. uint8_t *htt_logger_bufp;
  3666. int mac_for_pdev;
  3667. int target_pdev_id;
  3668. msg = qdf_nbuf_alloc(
  3669. soc->osdev,
  3670. HTT_MSG_BUF_SIZE(HTT_3_TUPLE_HASH_CFG_REQ_BYTES),
  3671. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  3672. if (!msg)
  3673. return QDF_STATUS_E_NOMEM;
  3674. mac_for_pdev = dp_get_mac_id_for_pdev(mac_id, pdev->pdev_id);
  3675. target_pdev_id =
  3676. dp_get_target_pdev_id_for_host_pdev_id(pdev->soc, mac_for_pdev);
  3677. /*
  3678. * Set the length of the message.
  3679. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  3680. * separately during the below call to qdf_nbuf_push_head.
  3681. * The contribution from the HTC header is added separately inside HTC.
  3682. */
  3683. if (!qdf_nbuf_put_tail(msg, HTT_3_TUPLE_HASH_CFG_REQ_BYTES)) {
  3684. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  3685. "Failed to expand head for HTT_3TUPLE_CONFIG");
  3686. qdf_nbuf_free(msg);
  3687. return QDF_STATUS_E_FAILURE;
  3688. }
  3689. dp_htt_info("%pK: config_param_sent 0x%x for target_pdev %d\n -------------",
  3690. pdev->soc, tuple_mask, target_pdev_id);
  3691. msg_word = (uint32_t *)qdf_nbuf_data(msg);
  3692. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  3693. htt_logger_bufp = (uint8_t *)msg_word;
  3694. *msg_word = 0;
  3695. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_3_TUPLE_HASH_CFG);
  3696. HTT_RX_3_TUPLE_HASH_PDEV_ID_SET(*msg_word, target_pdev_id);
  3697. msg_word++;
  3698. *msg_word = 0;
  3699. HTT_H2T_FLOW_ID_TOEPLITZ_FIELD_CONFIG_SET(*msg_word, tuple_mask);
  3700. HTT_H2T_TOEPLITZ_2_OR_4_FIELD_CONFIG_SET(*msg_word, tuple_mask);
  3701. pkt = htt_htc_pkt_alloc(soc);
  3702. if (!pkt) {
  3703. qdf_nbuf_free(msg);
  3704. return QDF_STATUS_E_NOMEM;
  3705. }
  3706. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  3707. SET_HTC_PACKET_INFO_TX(
  3708. &pkt->htc_pkt,
  3709. dp_htt_h2t_send_complete_free_netbuf,
  3710. qdf_nbuf_data(msg),
  3711. qdf_nbuf_len(msg),
  3712. soc->htc_endpoint,
  3713. /* tag for no FW response msg */
  3714. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  3715. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  3716. DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_3_TUPLE_HASH_CFG,
  3717. htt_logger_bufp);
  3718. return QDF_STATUS_SUCCESS;
  3719. }
  3720. /* This macro will revert once proper HTT header will define for
  3721. * HTT_H2T_MSG_TYPE_PPDU_STATS_CFG in htt.h file
  3722. * */
  3723. #if defined(WDI_EVENT_ENABLE)
  3724. /**
  3725. * dp_h2t_cfg_stats_msg_send(): function to construct HTT message to pass to FW
  3726. * @pdev: DP PDEV handle
  3727. * @stats_type_upload_mask: stats type requested by user
  3728. * @mac_id: Mac id number
  3729. *
  3730. * return: QDF STATUS
  3731. */
  3732. QDF_STATUS dp_h2t_cfg_stats_msg_send(struct dp_pdev *pdev,
  3733. uint32_t stats_type_upload_mask, uint8_t mac_id)
  3734. {
  3735. struct htt_soc *soc = pdev->soc->htt_handle;
  3736. struct dp_htt_htc_pkt *pkt;
  3737. qdf_nbuf_t msg;
  3738. uint32_t *msg_word;
  3739. uint8_t pdev_mask;
  3740. QDF_STATUS status;
  3741. msg = qdf_nbuf_alloc(
  3742. soc->osdev,
  3743. HTT_MSG_BUF_SIZE(HTT_H2T_PPDU_STATS_CFG_MSG_SZ),
  3744. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, true);
  3745. if (!msg) {
  3746. dp_htt_err("%pK: Fail to allocate HTT_H2T_PPDU_STATS_CFG_MSG_SZ msg buffer"
  3747. , pdev->soc);
  3748. qdf_assert(0);
  3749. return QDF_STATUS_E_NOMEM;
  3750. }
  3751. /*TODO:Add support for SOC stats
  3752. * Bit 0: SOC Stats
  3753. * Bit 1: Pdev stats for pdev id 0
  3754. * Bit 2: Pdev stats for pdev id 1
  3755. * Bit 3: Pdev stats for pdev id 2
  3756. */
  3757. pdev_mask = 1 << dp_get_target_pdev_id_for_host_pdev_id(pdev->soc,
  3758. mac_id);
  3759. /*
  3760. * Set the length of the message.
  3761. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  3762. * separately during the below call to qdf_nbuf_push_head.
  3763. * The contribution from the HTC header is added separately inside HTC.
  3764. */
  3765. if (qdf_nbuf_put_tail(msg, HTT_H2T_PPDU_STATS_CFG_MSG_SZ) == NULL) {
  3766. dp_htt_err("%pK: Failed to expand head for HTT_CFG_STATS"
  3767. , pdev->soc);
  3768. qdf_nbuf_free(msg);
  3769. return QDF_STATUS_E_FAILURE;
  3770. }
  3771. msg_word = (uint32_t *) qdf_nbuf_data(msg);
  3772. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  3773. *msg_word = 0;
  3774. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_PPDU_STATS_CFG);
  3775. HTT_H2T_PPDU_STATS_CFG_PDEV_MASK_SET(*msg_word, pdev_mask);
  3776. HTT_H2T_PPDU_STATS_CFG_TLV_BITMASK_SET(*msg_word,
  3777. stats_type_upload_mask);
  3778. pkt = htt_htc_pkt_alloc(soc);
  3779. if (!pkt) {
  3780. dp_htt_err("%pK: Fail to allocate dp_htt_htc_pkt buffer", pdev->soc);
  3781. qdf_assert(0);
  3782. qdf_nbuf_free(msg);
  3783. return QDF_STATUS_E_NOMEM;
  3784. }
  3785. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  3786. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  3787. dp_htt_h2t_send_complete_free_netbuf,
  3788. qdf_nbuf_data(msg), qdf_nbuf_len(msg),
  3789. soc->htc_endpoint,
  3790. /* tag for no FW response msg */
  3791. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  3792. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  3793. status = DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_PPDU_STATS_CFG,
  3794. (uint8_t *)msg_word);
  3795. if (status != QDF_STATUS_SUCCESS) {
  3796. qdf_nbuf_free(msg);
  3797. htt_htc_pkt_free(soc, pkt);
  3798. }
  3799. return status;
  3800. }
  3801. qdf_export_symbol(dp_h2t_cfg_stats_msg_send);
  3802. #endif
  3803. void
  3804. dp_peer_update_inactive_time(struct dp_pdev *pdev, uint32_t tag_type,
  3805. uint32_t *tag_buf)
  3806. {
  3807. struct dp_peer *peer = NULL;
  3808. switch (tag_type) {
  3809. case HTT_STATS_PEER_DETAILS_TAG:
  3810. {
  3811. htt_peer_details_tlv *dp_stats_buf =
  3812. (htt_peer_details_tlv *)tag_buf;
  3813. pdev->fw_stats_peer_id = dp_stats_buf->sw_peer_id;
  3814. }
  3815. break;
  3816. case HTT_STATS_PEER_STATS_CMN_TAG:
  3817. {
  3818. htt_peer_stats_cmn_tlv *dp_stats_buf =
  3819. (htt_peer_stats_cmn_tlv *)tag_buf;
  3820. peer = dp_peer_get_ref_by_id(pdev->soc, pdev->fw_stats_peer_id,
  3821. DP_MOD_ID_HTT);
  3822. if (peer && !peer->bss_peer) {
  3823. peer->stats.tx.inactive_time =
  3824. dp_stats_buf->inactive_time;
  3825. qdf_event_set(&pdev->fw_peer_stats_event);
  3826. }
  3827. if (peer)
  3828. dp_peer_unref_delete(peer, DP_MOD_ID_HTT);
  3829. }
  3830. break;
  3831. default:
  3832. qdf_err("Invalid tag_type");
  3833. }
  3834. }
  3835. /**
  3836. * dp_htt_rx_flow_fst_setup(): Send HTT Rx FST setup message to FW
  3837. * @pdev: DP pdev handle
  3838. * @fse_setup_info: FST setup parameters
  3839. *
  3840. * Return: Success when HTT message is sent, error on failure
  3841. */
  3842. QDF_STATUS
  3843. dp_htt_rx_flow_fst_setup(struct dp_pdev *pdev,
  3844. struct dp_htt_rx_flow_fst_setup *fse_setup_info)
  3845. {
  3846. struct htt_soc *soc = pdev->soc->htt_handle;
  3847. struct dp_htt_htc_pkt *pkt;
  3848. qdf_nbuf_t msg;
  3849. u_int32_t *msg_word;
  3850. struct htt_h2t_msg_rx_fse_setup_t *fse_setup;
  3851. uint8_t *htt_logger_bufp;
  3852. u_int32_t *key;
  3853. QDF_STATUS status;
  3854. msg = qdf_nbuf_alloc(
  3855. soc->osdev,
  3856. HTT_MSG_BUF_SIZE(sizeof(struct htt_h2t_msg_rx_fse_setup_t)),
  3857. /* reserve room for the HTC header */
  3858. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  3859. if (!msg)
  3860. return QDF_STATUS_E_NOMEM;
  3861. /*
  3862. * Set the length of the message.
  3863. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  3864. * separately during the below call to qdf_nbuf_push_head.
  3865. * The contribution from the HTC header is added separately inside HTC.
  3866. */
  3867. if (!qdf_nbuf_put_tail(msg,
  3868. sizeof(struct htt_h2t_msg_rx_fse_setup_t))) {
  3869. qdf_err("Failed to expand head for HTT RX_FSE_SETUP msg");
  3870. return QDF_STATUS_E_FAILURE;
  3871. }
  3872. /* fill in the message contents */
  3873. msg_word = (u_int32_t *)qdf_nbuf_data(msg);
  3874. memset(msg_word, 0, sizeof(struct htt_h2t_msg_rx_fse_setup_t));
  3875. /* rewind beyond alignment pad to get to the HTC header reserved area */
  3876. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  3877. htt_logger_bufp = (uint8_t *)msg_word;
  3878. *msg_word = 0;
  3879. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RX_FSE_SETUP_CFG);
  3880. fse_setup = (struct htt_h2t_msg_rx_fse_setup_t *)msg_word;
  3881. HTT_RX_FSE_SETUP_PDEV_ID_SET(*msg_word, fse_setup_info->pdev_id);
  3882. msg_word++;
  3883. HTT_RX_FSE_SETUP_NUM_REC_SET(*msg_word, fse_setup_info->max_entries);
  3884. HTT_RX_FSE_SETUP_MAX_SEARCH_SET(*msg_word, fse_setup_info->max_search);
  3885. HTT_RX_FSE_SETUP_IP_DA_SA_PREFIX_SET(*msg_word,
  3886. fse_setup_info->ip_da_sa_prefix);
  3887. msg_word++;
  3888. HTT_RX_FSE_SETUP_BASE_ADDR_LO_SET(*msg_word,
  3889. fse_setup_info->base_addr_lo);
  3890. msg_word++;
  3891. HTT_RX_FSE_SETUP_BASE_ADDR_HI_SET(*msg_word,
  3892. fse_setup_info->base_addr_hi);
  3893. key = (u_int32_t *)fse_setup_info->hash_key;
  3894. fse_setup->toeplitz31_0 = *key++;
  3895. fse_setup->toeplitz63_32 = *key++;
  3896. fse_setup->toeplitz95_64 = *key++;
  3897. fse_setup->toeplitz127_96 = *key++;
  3898. fse_setup->toeplitz159_128 = *key++;
  3899. fse_setup->toeplitz191_160 = *key++;
  3900. fse_setup->toeplitz223_192 = *key++;
  3901. fse_setup->toeplitz255_224 = *key++;
  3902. fse_setup->toeplitz287_256 = *key++;
  3903. fse_setup->toeplitz314_288 = *key;
  3904. msg_word++;
  3905. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz31_0);
  3906. msg_word++;
  3907. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz63_32);
  3908. msg_word++;
  3909. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz95_64);
  3910. msg_word++;
  3911. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz127_96);
  3912. msg_word++;
  3913. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz159_128);
  3914. msg_word++;
  3915. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz191_160);
  3916. msg_word++;
  3917. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz223_192);
  3918. msg_word++;
  3919. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz255_224);
  3920. msg_word++;
  3921. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz287_256);
  3922. msg_word++;
  3923. HTT_RX_FSE_SETUP_HASH_314_288_SET(*msg_word,
  3924. fse_setup->toeplitz314_288);
  3925. pkt = htt_htc_pkt_alloc(soc);
  3926. if (!pkt) {
  3927. qdf_err("Fail to allocate dp_htt_htc_pkt buffer");
  3928. qdf_assert(0);
  3929. qdf_nbuf_free(msg);
  3930. return QDF_STATUS_E_RESOURCES; /* failure */
  3931. }
  3932. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  3933. SET_HTC_PACKET_INFO_TX(
  3934. &pkt->htc_pkt,
  3935. dp_htt_h2t_send_complete_free_netbuf,
  3936. qdf_nbuf_data(msg),
  3937. qdf_nbuf_len(msg),
  3938. soc->htc_endpoint,
  3939. /* tag for no FW response msg */
  3940. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  3941. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  3942. status = DP_HTT_SEND_HTC_PKT(soc, pkt,
  3943. HTT_H2T_MSG_TYPE_RX_FSE_SETUP_CFG,
  3944. htt_logger_bufp);
  3945. if (status == QDF_STATUS_SUCCESS) {
  3946. dp_info("HTT_H2T RX_FSE_SETUP sent to FW for pdev = %u",
  3947. fse_setup_info->pdev_id);
  3948. QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_ANY, QDF_TRACE_LEVEL_DEBUG,
  3949. (void *)fse_setup_info->hash_key,
  3950. fse_setup_info->hash_key_len);
  3951. } else {
  3952. qdf_nbuf_free(msg);
  3953. htt_htc_pkt_free(soc, pkt);
  3954. }
  3955. return status;
  3956. }
  3957. /**
  3958. * dp_htt_rx_flow_fse_operation(): Send HTT Flow Search Entry msg to
  3959. * add/del a flow in HW
  3960. * @pdev: DP pdev handle
  3961. * @fse_op_info: Flow entry parameters
  3962. *
  3963. * Return: Success when HTT message is sent, error on failure
  3964. */
  3965. QDF_STATUS
  3966. dp_htt_rx_flow_fse_operation(struct dp_pdev *pdev,
  3967. struct dp_htt_rx_flow_fst_operation *fse_op_info)
  3968. {
  3969. struct htt_soc *soc = pdev->soc->htt_handle;
  3970. struct dp_htt_htc_pkt *pkt;
  3971. qdf_nbuf_t msg;
  3972. u_int32_t *msg_word;
  3973. struct htt_h2t_msg_rx_fse_operation_t *fse_operation;
  3974. uint8_t *htt_logger_bufp;
  3975. QDF_STATUS status;
  3976. msg = qdf_nbuf_alloc(
  3977. soc->osdev,
  3978. HTT_MSG_BUF_SIZE(sizeof(struct htt_h2t_msg_rx_fse_operation_t)),
  3979. /* reserve room for the HTC header */
  3980. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  3981. if (!msg)
  3982. return QDF_STATUS_E_NOMEM;
  3983. /*
  3984. * Set the length of the message.
  3985. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  3986. * separately during the below call to qdf_nbuf_push_head.
  3987. * The contribution from the HTC header is added separately inside HTC.
  3988. */
  3989. if (!qdf_nbuf_put_tail(msg,
  3990. sizeof(struct htt_h2t_msg_rx_fse_operation_t))) {
  3991. qdf_err("Failed to expand head for HTT_RX_FSE_OPERATION msg");
  3992. qdf_nbuf_free(msg);
  3993. return QDF_STATUS_E_FAILURE;
  3994. }
  3995. /* fill in the message contents */
  3996. msg_word = (u_int32_t *)qdf_nbuf_data(msg);
  3997. memset(msg_word, 0, sizeof(struct htt_h2t_msg_rx_fse_operation_t));
  3998. /* rewind beyond alignment pad to get to the HTC header reserved area */
  3999. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4000. htt_logger_bufp = (uint8_t *)msg_word;
  4001. *msg_word = 0;
  4002. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RX_FSE_OPERATION_CFG);
  4003. fse_operation = (struct htt_h2t_msg_rx_fse_operation_t *)msg_word;
  4004. HTT_RX_FSE_OPERATION_PDEV_ID_SET(*msg_word, fse_op_info->pdev_id);
  4005. msg_word++;
  4006. HTT_RX_FSE_IPSEC_VALID_SET(*msg_word, false);
  4007. if (fse_op_info->op_code == DP_HTT_FST_CACHE_INVALIDATE_ENTRY) {
  4008. HTT_RX_FSE_OPERATION_SET(*msg_word,
  4009. HTT_RX_FSE_CACHE_INVALIDATE_ENTRY);
  4010. msg_word++;
  4011. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4012. *msg_word,
  4013. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_31_0));
  4014. msg_word++;
  4015. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4016. *msg_word,
  4017. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_63_32));
  4018. msg_word++;
  4019. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4020. *msg_word,
  4021. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_95_64));
  4022. msg_word++;
  4023. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4024. *msg_word,
  4025. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_127_96));
  4026. msg_word++;
  4027. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4028. *msg_word,
  4029. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.dest_ip_31_0));
  4030. msg_word++;
  4031. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4032. *msg_word,
  4033. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.dest_ip_63_32));
  4034. msg_word++;
  4035. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4036. *msg_word,
  4037. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.dest_ip_95_64));
  4038. msg_word++;
  4039. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4040. *msg_word,
  4041. qdf_htonl(
  4042. fse_op_info->rx_flow->flow_tuple_info.dest_ip_127_96));
  4043. msg_word++;
  4044. HTT_RX_FSE_SOURCEPORT_SET(
  4045. *msg_word,
  4046. fse_op_info->rx_flow->flow_tuple_info.src_port);
  4047. HTT_RX_FSE_DESTPORT_SET(
  4048. *msg_word,
  4049. fse_op_info->rx_flow->flow_tuple_info.dest_port);
  4050. msg_word++;
  4051. HTT_RX_FSE_L4_PROTO_SET(
  4052. *msg_word,
  4053. fse_op_info->rx_flow->flow_tuple_info.l4_protocol);
  4054. } else if (fse_op_info->op_code == DP_HTT_FST_CACHE_INVALIDATE_FULL) {
  4055. HTT_RX_FSE_OPERATION_SET(*msg_word,
  4056. HTT_RX_FSE_CACHE_INVALIDATE_FULL);
  4057. } else if (fse_op_info->op_code == DP_HTT_FST_DISABLE) {
  4058. HTT_RX_FSE_OPERATION_SET(*msg_word, HTT_RX_FSE_DISABLE);
  4059. } else if (fse_op_info->op_code == DP_HTT_FST_ENABLE) {
  4060. HTT_RX_FSE_OPERATION_SET(*msg_word, HTT_RX_FSE_ENABLE);
  4061. }
  4062. pkt = htt_htc_pkt_alloc(soc);
  4063. if (!pkt) {
  4064. qdf_err("Fail to allocate dp_htt_htc_pkt buffer");
  4065. qdf_assert(0);
  4066. qdf_nbuf_free(msg);
  4067. return QDF_STATUS_E_RESOURCES; /* failure */
  4068. }
  4069. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4070. SET_HTC_PACKET_INFO_TX(
  4071. &pkt->htc_pkt,
  4072. dp_htt_h2t_send_complete_free_netbuf,
  4073. qdf_nbuf_data(msg),
  4074. qdf_nbuf_len(msg),
  4075. soc->htc_endpoint,
  4076. /* tag for no FW response msg */
  4077. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4078. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4079. status = DP_HTT_SEND_HTC_PKT(soc, pkt,
  4080. HTT_H2T_MSG_TYPE_RX_FSE_OPERATION_CFG,
  4081. htt_logger_bufp);
  4082. if (status == QDF_STATUS_SUCCESS) {
  4083. dp_info("HTT_H2T RX_FSE_OPERATION_CFG sent to FW for pdev = %u",
  4084. fse_op_info->pdev_id);
  4085. } else {
  4086. qdf_nbuf_free(msg);
  4087. htt_htc_pkt_free(soc, pkt);
  4088. }
  4089. return status;
  4090. }
  4091. /**
  4092. * dp_htt_rx_fisa_config(): Send HTT msg to configure FISA
  4093. * @pdev: DP pdev handle
  4094. * @fse_op_info: Flow entry parameters
  4095. *
  4096. * Return: Success when HTT message is sent, error on failure
  4097. */
  4098. QDF_STATUS
  4099. dp_htt_rx_fisa_config(struct dp_pdev *pdev,
  4100. struct dp_htt_rx_fisa_cfg *fisa_config)
  4101. {
  4102. struct htt_soc *soc = pdev->soc->htt_handle;
  4103. struct dp_htt_htc_pkt *pkt;
  4104. qdf_nbuf_t msg;
  4105. u_int32_t *msg_word;
  4106. struct htt_h2t_msg_type_fisa_config_t *htt_fisa_config;
  4107. uint8_t *htt_logger_bufp;
  4108. uint32_t len;
  4109. QDF_STATUS status;
  4110. len = HTT_MSG_BUF_SIZE(sizeof(struct htt_h2t_msg_type_fisa_config_t));
  4111. msg = qdf_nbuf_alloc(soc->osdev,
  4112. len,
  4113. /* reserve room for the HTC header */
  4114. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING,
  4115. 4,
  4116. TRUE);
  4117. if (!msg)
  4118. return QDF_STATUS_E_NOMEM;
  4119. /*
  4120. * Set the length of the message.
  4121. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4122. * separately during the below call to qdf_nbuf_push_head.
  4123. * The contribution from the HTC header is added separately inside HTC.
  4124. */
  4125. if (!qdf_nbuf_put_tail(msg,
  4126. sizeof(struct htt_h2t_msg_type_fisa_config_t))) {
  4127. qdf_err("Failed to expand head for HTT_RX_FSE_OPERATION msg");
  4128. qdf_nbuf_free(msg);
  4129. return QDF_STATUS_E_FAILURE;
  4130. }
  4131. /* fill in the message contents */
  4132. msg_word = (u_int32_t *)qdf_nbuf_data(msg);
  4133. memset(msg_word, 0, sizeof(struct htt_h2t_msg_type_fisa_config_t));
  4134. /* rewind beyond alignment pad to get to the HTC header reserved area */
  4135. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4136. htt_logger_bufp = (uint8_t *)msg_word;
  4137. *msg_word = 0;
  4138. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RX_FISA_CFG);
  4139. htt_fisa_config = (struct htt_h2t_msg_type_fisa_config_t *)msg_word;
  4140. HTT_RX_FSE_OPERATION_PDEV_ID_SET(*msg_word, htt_fisa_config->pdev_id);
  4141. msg_word++;
  4142. HTT_RX_FISA_CONFIG_FISA_V2_ENABLE_SET(*msg_word, 1);
  4143. HTT_RX_FISA_CONFIG_FISA_V2_AGGR_LIMIT_SET(*msg_word, 0xf);
  4144. msg_word++;
  4145. htt_fisa_config->fisa_timeout_threshold = fisa_config->fisa_timeout;
  4146. pkt = htt_htc_pkt_alloc(soc);
  4147. if (!pkt) {
  4148. qdf_err("Fail to allocate dp_htt_htc_pkt buffer");
  4149. qdf_assert(0);
  4150. qdf_nbuf_free(msg);
  4151. return QDF_STATUS_E_RESOURCES; /* failure */
  4152. }
  4153. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4154. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  4155. dp_htt_h2t_send_complete_free_netbuf,
  4156. qdf_nbuf_data(msg),
  4157. qdf_nbuf_len(msg),
  4158. soc->htc_endpoint,
  4159. /* tag for no FW response msg */
  4160. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4161. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4162. status = DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_RX_FISA_CFG,
  4163. htt_logger_bufp);
  4164. if (status == QDF_STATUS_SUCCESS) {
  4165. dp_info("HTT_H2T_MSG_TYPE_RX_FISA_CFG sent to FW for pdev = %u",
  4166. fisa_config->pdev_id);
  4167. } else {
  4168. qdf_nbuf_free(msg);
  4169. htt_htc_pkt_free(soc, pkt);
  4170. }
  4171. return status;
  4172. }
  4173. #ifdef WLAN_SUPPORT_PPEDS
  4174. /**
  4175. * dp_htt_rxdma_rxole_ppe_cfg_set() - Send RxOLE and RxDMA PPE config
  4176. * @dp_osc: Data path SoC handle
  4177. * @cfg: RxDMA and RxOLE PPE config
  4178. *
  4179. * Return: Success when HTT message is sent, error on failure
  4180. */
  4181. QDF_STATUS
  4182. dp_htt_rxdma_rxole_ppe_cfg_set(struct dp_soc *soc,
  4183. struct dp_htt_rxdma_rxole_ppe_config *cfg)
  4184. {
  4185. struct htt_soc *htt_handle = soc->htt_handle;
  4186. uint32_t len;
  4187. qdf_nbuf_t msg;
  4188. u_int32_t *msg_word;
  4189. QDF_STATUS status;
  4190. uint8_t *htt_logger_bufp;
  4191. struct dp_htt_htc_pkt *pkt;
  4192. len = HTT_MSG_BUF_SIZE(
  4193. sizeof(struct htt_h2t_msg_type_rxdma_rxole_ppe_cfg_t));
  4194. msg = qdf_nbuf_alloc(soc->osdev,
  4195. len,
  4196. /* reserve room for the HTC header */
  4197. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING,
  4198. 4,
  4199. TRUE);
  4200. if (!msg)
  4201. return QDF_STATUS_E_NOMEM;
  4202. /*
  4203. * Set the length of the message.
  4204. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4205. * separately during the below call to qdf_nbuf_push_head.
  4206. * The contribution from the HTC header is added separately inside HTC.
  4207. */
  4208. if (!qdf_nbuf_put_tail(
  4209. msg, sizeof(struct htt_h2t_msg_type_rxdma_rxole_ppe_cfg_t))) {
  4210. qdf_err("Failed to expand head for HTT_H2T_MSG_TYPE_RXDMA_RXOLE_PPE_CFG msg");
  4211. qdf_nbuf_free(msg);
  4212. return QDF_STATUS_E_FAILURE;
  4213. }
  4214. /* fill in the message contents */
  4215. msg_word = (u_int32_t *)qdf_nbuf_data(msg);
  4216. memset(msg_word, 0,
  4217. sizeof(struct htt_h2t_msg_type_rxdma_rxole_ppe_cfg_t));
  4218. /* Rewind beyond alignment pad to get to the HTC header reserved area */
  4219. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4220. htt_logger_bufp = (uint8_t *)msg_word;
  4221. *msg_word = 0;
  4222. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RXDMA_RXOLE_PPE_CFG);
  4223. HTT_PPE_CFG_OVERRIDE_SET(*msg_word, cfg->override);
  4224. HTT_PPE_CFG_REO_DEST_IND_SET(
  4225. *msg_word, cfg->reo_destination_indication);
  4226. HTT_PPE_CFG_MULTI_BUF_MSDU_OVERRIDE_EN_SET(
  4227. *msg_word, cfg->multi_buffer_msdu_override_en);
  4228. HTT_PPE_CFG_INTRA_BSS_OVERRIDE_EN_SET(
  4229. *msg_word, cfg->intra_bss_override);
  4230. HTT_PPE_CFG_DECAP_RAW_OVERRIDE_EN_SET(
  4231. *msg_word, cfg->decap_raw_override);
  4232. HTT_PPE_CFG_DECAP_NWIFI_OVERRIDE_EN_SET(
  4233. *msg_word, cfg->decap_nwifi_override);
  4234. HTT_PPE_CFG_IP_FRAG_OVERRIDE_EN_SET(
  4235. *msg_word, cfg->ip_frag_override);
  4236. pkt = htt_htc_pkt_alloc(htt_handle);
  4237. if (!pkt) {
  4238. qdf_err("Fail to allocate dp_htt_htc_pkt buffer");
  4239. qdf_assert(0);
  4240. qdf_nbuf_free(msg);
  4241. return QDF_STATUS_E_RESOURCES; /* failure */
  4242. }
  4243. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4244. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  4245. dp_htt_h2t_send_complete_free_netbuf,
  4246. qdf_nbuf_data(msg),
  4247. qdf_nbuf_len(msg),
  4248. htt_handle->htc_endpoint,
  4249. /* tag for no FW response msg */
  4250. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4251. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4252. status = DP_HTT_SEND_HTC_PKT(htt_handle, pkt,
  4253. HTT_H2T_MSG_TYPE_RXDMA_RXOLE_PPE_CFG,
  4254. htt_logger_bufp);
  4255. if (status != QDF_STATUS_SUCCESS) {
  4256. qdf_nbuf_free(msg);
  4257. htt_htc_pkt_free(htt_handle, pkt);
  4258. return status;
  4259. }
  4260. dp_info("HTT_H2T_MSG_TYPE_RXDMA_RXOLE_PPE_CFG sent");
  4261. return status;
  4262. }
  4263. #endif /* WLAN_SUPPORT_PPEDS */
  4264. /**
  4265. * dp_bk_pressure_stats_handler(): worker function to print back pressure
  4266. * stats
  4267. *
  4268. * @context : argument to work function
  4269. */
  4270. static void dp_bk_pressure_stats_handler(void *context)
  4271. {
  4272. struct dp_pdev *pdev = (struct dp_pdev *)context;
  4273. struct dp_soc_srngs_state *soc_srngs_state = NULL;
  4274. const char *ring_name;
  4275. int i;
  4276. struct dp_srng_ring_state *ring_state;
  4277. bool empty_flag;
  4278. qdf_spin_lock_bh(&pdev->bkp_stats.list_lock);
  4279. /* Extract only first entry for printing in one work event */
  4280. if (pdev->bkp_stats.queue_depth &&
  4281. !TAILQ_EMPTY(&pdev->bkp_stats.list)) {
  4282. soc_srngs_state = TAILQ_FIRST(&pdev->bkp_stats.list);
  4283. TAILQ_REMOVE(&pdev->bkp_stats.list, soc_srngs_state,
  4284. list_elem);
  4285. pdev->bkp_stats.queue_depth--;
  4286. }
  4287. empty_flag = TAILQ_EMPTY(&pdev->bkp_stats.list);
  4288. qdf_spin_unlock_bh(&pdev->bkp_stats.list_lock);
  4289. if (soc_srngs_state) {
  4290. DP_PRINT_STATS("### BKP stats for seq_num %u START ###",
  4291. soc_srngs_state->seq_num);
  4292. for (i = 0; i < soc_srngs_state->max_ring_id; i++) {
  4293. ring_state = &soc_srngs_state->ring_state[i];
  4294. ring_name = dp_srng_get_str_from_hal_ring_type
  4295. (ring_state->ring_type);
  4296. DP_PRINT_STATS("%s: SW:Head pointer = %d Tail Pointer = %d\n",
  4297. ring_name,
  4298. ring_state->sw_head,
  4299. ring_state->sw_tail);
  4300. DP_PRINT_STATS("%s: HW:Head pointer = %d Tail Pointer = %d\n",
  4301. ring_name,
  4302. ring_state->hw_head,
  4303. ring_state->hw_tail);
  4304. }
  4305. DP_PRINT_STATS("### BKP stats for seq_num %u COMPLETE ###",
  4306. soc_srngs_state->seq_num);
  4307. qdf_mem_free(soc_srngs_state);
  4308. }
  4309. dp_print_napi_stats(pdev->soc);
  4310. /* Schedule work again if queue is not empty */
  4311. if (!empty_flag)
  4312. qdf_queue_work(0, pdev->bkp_stats.work_queue,
  4313. &pdev->bkp_stats.work);
  4314. }
  4315. /*
  4316. * dp_pdev_bkp_stats_detach() - detach resources for back pressure stats
  4317. * processing
  4318. * @pdev: Datapath PDEV handle
  4319. *
  4320. */
  4321. void dp_pdev_bkp_stats_detach(struct dp_pdev *pdev)
  4322. {
  4323. struct dp_soc_srngs_state *ring_state, *ring_state_next;
  4324. if (!pdev->bkp_stats.work_queue)
  4325. return;
  4326. qdf_flush_workqueue(0, pdev->bkp_stats.work_queue);
  4327. qdf_destroy_workqueue(0, pdev->bkp_stats.work_queue);
  4328. qdf_flush_work(&pdev->bkp_stats.work);
  4329. qdf_disable_work(&pdev->bkp_stats.work);
  4330. qdf_spin_lock_bh(&pdev->bkp_stats.list_lock);
  4331. TAILQ_FOREACH_SAFE(ring_state, &pdev->bkp_stats.list,
  4332. list_elem, ring_state_next) {
  4333. TAILQ_REMOVE(&pdev->bkp_stats.list, ring_state,
  4334. list_elem);
  4335. qdf_mem_free(ring_state);
  4336. }
  4337. qdf_spin_unlock_bh(&pdev->bkp_stats.list_lock);
  4338. qdf_spinlock_destroy(&pdev->bkp_stats.list_lock);
  4339. }
  4340. /*
  4341. * dp_pdev_bkp_stats_attach() - attach resources for back pressure stats
  4342. * processing
  4343. * @pdev: Datapath PDEV handle
  4344. *
  4345. * Return: QDF_STATUS_SUCCESS: Success
  4346. * QDF_STATUS_E_NOMEM: Error
  4347. */
  4348. QDF_STATUS dp_pdev_bkp_stats_attach(struct dp_pdev *pdev)
  4349. {
  4350. TAILQ_INIT(&pdev->bkp_stats.list);
  4351. pdev->bkp_stats.seq_num = 0;
  4352. pdev->bkp_stats.queue_depth = 0;
  4353. qdf_create_work(0, &pdev->bkp_stats.work,
  4354. dp_bk_pressure_stats_handler, pdev);
  4355. pdev->bkp_stats.work_queue =
  4356. qdf_alloc_unbound_workqueue("dp_bkp_work_queue");
  4357. if (!pdev->bkp_stats.work_queue)
  4358. goto fail;
  4359. qdf_spinlock_create(&pdev->bkp_stats.list_lock);
  4360. return QDF_STATUS_SUCCESS;
  4361. fail:
  4362. dp_htt_alert("BKP stats attach failed");
  4363. qdf_flush_work(&pdev->bkp_stats.work);
  4364. qdf_disable_work(&pdev->bkp_stats.work);
  4365. return QDF_STATUS_E_FAILURE;
  4366. }
  4367. #ifdef DP_UMAC_HW_RESET_SUPPORT
  4368. QDF_STATUS dp_htt_umac_reset_send_setup_cmd(
  4369. struct dp_soc *soc,
  4370. const struct dp_htt_umac_reset_setup_cmd_params *setup_params)
  4371. {
  4372. struct htt_soc *htt_handle = soc->htt_handle;
  4373. uint32_t len;
  4374. qdf_nbuf_t msg;
  4375. u_int32_t *msg_word;
  4376. QDF_STATUS status;
  4377. uint8_t *htt_logger_bufp;
  4378. struct dp_htt_htc_pkt *pkt;
  4379. len = HTT_MSG_BUF_SIZE(
  4380. HTT_H2T_UMAC_HANG_RECOVERY_PREREQUISITE_SETUP_BYTES);
  4381. msg = qdf_nbuf_alloc(soc->osdev,
  4382. len,
  4383. /* reserve room for the HTC header */
  4384. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING,
  4385. 4,
  4386. TRUE);
  4387. if (!msg)
  4388. return QDF_STATUS_E_NOMEM;
  4389. /*
  4390. * Set the length of the message.
  4391. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4392. * separately during the below call to qdf_nbuf_push_head.
  4393. * The contribution from the HTC header is added separately inside HTC.
  4394. */
  4395. if (!qdf_nbuf_put_tail(
  4396. msg, HTT_H2T_UMAC_HANG_RECOVERY_PREREQUISITE_SETUP_BYTES)) {
  4397. dp_htt_err("Failed to expand head");
  4398. qdf_nbuf_free(msg);
  4399. return QDF_STATUS_E_FAILURE;
  4400. }
  4401. /* fill in the message contents */
  4402. msg_word = (uint32_t *)qdf_nbuf_data(msg);
  4403. /* Rewind beyond alignment pad to get to the HTC header reserved area */
  4404. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4405. htt_logger_bufp = (uint8_t *)msg_word;
  4406. qdf_mem_zero(msg_word,
  4407. HTT_H2T_UMAC_HANG_RECOVERY_PREREQUISITE_SETUP_BYTES);
  4408. HTT_H2T_MSG_TYPE_SET(
  4409. *msg_word,
  4410. HTT_H2T_MSG_TYPE_UMAC_HANG_RECOVERY_PREREQUISITE_SETUP);
  4411. HTT_H2T_UMAC_HANG_RECOVERY_PREREQUISITE_SETUP_T2H_MSG_METHOD_SET(
  4412. *msg_word, htt_umac_hang_recovery_msg_t2h_msi_and_h2t_polling);
  4413. HTT_H2T_UMAC_HANG_RECOVERY_PREREQUISITE_SETUP_H2T_MSG_METHOD_SET(
  4414. *msg_word, htt_umac_hang_recovery_msg_t2h_msi_and_h2t_polling);
  4415. msg_word++;
  4416. *msg_word = setup_params->msi_data;
  4417. msg_word++;
  4418. *msg_word = sizeof(htt_umac_hang_recovery_msg_shmem_t);
  4419. msg_word++;
  4420. *msg_word = setup_params->shmem_addr_low;
  4421. msg_word++;
  4422. *msg_word = setup_params->shmem_addr_high;
  4423. pkt = htt_htc_pkt_alloc(htt_handle);
  4424. if (!pkt) {
  4425. qdf_err("Fail to allocate dp_htt_htc_pkt buffer");
  4426. qdf_assert(0);
  4427. qdf_nbuf_free(msg);
  4428. return QDF_STATUS_E_NOMEM;
  4429. }
  4430. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4431. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  4432. dp_htt_h2t_send_complete_free_netbuf,
  4433. qdf_nbuf_data(msg),
  4434. qdf_nbuf_len(msg),
  4435. htt_handle->htc_endpoint,
  4436. /* tag for no FW response msg */
  4437. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4438. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4439. status = DP_HTT_SEND_HTC_PKT(
  4440. htt_handle, pkt,
  4441. HTT_H2T_MSG_TYPE_UMAC_HANG_RECOVERY_PREREQUISITE_SETUP,
  4442. htt_logger_bufp);
  4443. if (QDF_IS_STATUS_ERROR(status)) {
  4444. qdf_nbuf_free(msg);
  4445. htt_htc_pkt_free(htt_handle, pkt);
  4446. return status;
  4447. }
  4448. dp_info("HTT_H2T_MSG_TYPE_UMAC_HANG_RECOVERY_PREREQUISITE_SETUP sent");
  4449. return status;
  4450. }
  4451. #endif