dp_htt.c 153 KB

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