dp_htt.c 156 KB

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