dp_htt.c 163 KB

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