dp_htt.c 154 KB

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