dp_htt.c 165 KB

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