dp_htt.c 165 KB

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