dp_htt.c 155 KB

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