dp_htt.c 164 KB

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