dp_htt.c 163 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647
  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 =
  2165. dp_get_vdev_from_soc_vdev_id_wifi3(pdev->soc,
  2166. ppdu_desc->vdev_id);
  2167. if (!vdev)
  2168. return;
  2169. qdf_mem_copy(ppdu_user_desc->mac_addr, vdev->mac_addr.raw,
  2170. QDF_MAC_ADDR_SIZE);
  2171. } else {
  2172. peer = dp_peer_get_ref_by_id(pdev->soc, peer_id,
  2173. DP_MOD_ID_TX_PPDU_STATS);
  2174. if (!peer) {
  2175. /*
  2176. * fw sends peer_id which is about to removed but
  2177. * it was already removed in host.
  2178. * eg: for disassoc, fw send ppdu stats
  2179. * with peer id equal to previously associated
  2180. * peer's peer_id but it was removed
  2181. */
  2182. vdev =
  2183. dp_get_vdev_from_soc_vdev_id_wifi3(pdev->soc,
  2184. ppdu_desc->vdev_id);
  2185. if (!vdev)
  2186. return;
  2187. qdf_mem_copy(ppdu_user_desc->mac_addr,
  2188. vdev->mac_addr.raw, QDF_MAC_ADDR_SIZE);
  2189. return;
  2190. }
  2191. qdf_mem_copy(ppdu_user_desc->mac_addr,
  2192. peer->mac_addr.raw, QDF_MAC_ADDR_SIZE);
  2193. dp_peer_unref_delete(peer, DP_MOD_ID_TX_PPDU_STATS);
  2194. }
  2195. }
  2196. /**
  2197. * dp_process_ppdu_stats_user_rate_tlv() - Process htt_ppdu_stats_user_rate_tlv
  2198. * @pdev: DP pdev handle
  2199. * @tag_buf: T2H message buffer carrying the user rate TLV
  2200. * @ppdu_info: per ppdu tlv structure
  2201. *
  2202. * return:void
  2203. */
  2204. static void dp_process_ppdu_stats_user_rate_tlv(struct dp_pdev *pdev,
  2205. uint32_t *tag_buf,
  2206. struct ppdu_info *ppdu_info)
  2207. {
  2208. uint16_t peer_id;
  2209. struct cdp_tx_completion_ppdu *ppdu_desc;
  2210. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2211. uint8_t curr_user_index = 0;
  2212. struct dp_vdev *vdev;
  2213. uint32_t tlv_type = HTT_STATS_TLV_TAG_GET(*tag_buf);
  2214. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2215. tag_buf++;
  2216. peer_id = HTT_PPDU_STATS_USER_RATE_TLV_SW_PEER_ID_GET(*tag_buf);
  2217. curr_user_index =
  2218. dp_get_ppdu_info_user_index(pdev,
  2219. peer_id, ppdu_info);
  2220. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  2221. ppdu_user_desc->tlv_bitmap |= (1 << tlv_type);
  2222. if (peer_id == DP_SCAN_PEER_ID) {
  2223. vdev =
  2224. dp_get_vdev_from_soc_vdev_id_wifi3(pdev->soc,
  2225. ppdu_desc->vdev_id);
  2226. if (!vdev)
  2227. return;
  2228. }
  2229. ppdu_user_desc->peer_id = peer_id;
  2230. ppdu_user_desc->tid =
  2231. HTT_PPDU_STATS_USER_RATE_TLV_TID_NUM_GET(*tag_buf);
  2232. tag_buf += 1;
  2233. ppdu_user_desc->user_pos =
  2234. HTT_PPDU_STATS_USER_RATE_TLV_USER_POS_GET(*tag_buf);
  2235. ppdu_user_desc->mu_group_id =
  2236. HTT_PPDU_STATS_USER_RATE_TLV_MU_GROUPID_GET(*tag_buf);
  2237. tag_buf += 1;
  2238. ppdu_user_desc->ru_start =
  2239. HTT_PPDU_STATS_USER_RATE_TLV_RU_START_GET(*tag_buf);
  2240. ppdu_user_desc->ru_tones =
  2241. (HTT_PPDU_STATS_USER_RATE_TLV_RU_END_GET(*tag_buf) -
  2242. HTT_PPDU_STATS_USER_RATE_TLV_RU_START_GET(*tag_buf)) + 1;
  2243. ppdu_desc->usr_ru_tones_sum += ppdu_user_desc->ru_tones;
  2244. tag_buf += 2;
  2245. ppdu_user_desc->ppdu_type =
  2246. HTT_PPDU_STATS_USER_RATE_TLV_PPDU_TYPE_GET(*tag_buf);
  2247. tag_buf++;
  2248. ppdu_user_desc->tx_rate = *tag_buf;
  2249. ppdu_user_desc->ltf_size =
  2250. HTT_PPDU_STATS_USER_RATE_TLV_LTF_SIZE_GET(*tag_buf);
  2251. ppdu_user_desc->stbc =
  2252. HTT_PPDU_STATS_USER_RATE_TLV_STBC_GET(*tag_buf);
  2253. ppdu_user_desc->he_re =
  2254. HTT_PPDU_STATS_USER_RATE_TLV_HE_RE_GET(*tag_buf);
  2255. ppdu_user_desc->txbf =
  2256. HTT_PPDU_STATS_USER_RATE_TLV_TXBF_GET(*tag_buf);
  2257. ppdu_user_desc->bw =
  2258. HTT_PPDU_STATS_USER_RATE_TLV_BW_GET(*tag_buf) - 2;
  2259. ppdu_user_desc->nss = HTT_PPDU_STATS_USER_RATE_TLV_NSS_GET(*tag_buf);
  2260. ppdu_desc->usr_nss_sum += ppdu_user_desc->nss;
  2261. ppdu_user_desc->mcs = HTT_PPDU_STATS_USER_RATE_TLV_MCS_GET(*tag_buf);
  2262. ppdu_user_desc->preamble =
  2263. HTT_PPDU_STATS_USER_RATE_TLV_PREAMBLE_GET(*tag_buf);
  2264. ppdu_user_desc->gi = HTT_PPDU_STATS_USER_RATE_TLV_GI_GET(*tag_buf);
  2265. ppdu_user_desc->dcm = HTT_PPDU_STATS_USER_RATE_TLV_DCM_GET(*tag_buf);
  2266. ppdu_user_desc->ldpc = HTT_PPDU_STATS_USER_RATE_TLV_LDPC_GET(*tag_buf);
  2267. }
  2268. /*
  2269. * dp_process_ppdu_stats_enq_mpdu_bitmap_64_tlv: Process
  2270. * htt_ppdu_stats_enq_mpdu_bitmap_64_tlv
  2271. * pdev: DP PDEV handle
  2272. * @tag_buf: buffer containing the tlv htt_ppdu_stats_enq_mpdu_bitmap_64_tlv
  2273. * @ppdu_info: per ppdu tlv structure
  2274. *
  2275. * return:void
  2276. */
  2277. static void dp_process_ppdu_stats_enq_mpdu_bitmap_64_tlv(
  2278. struct dp_pdev *pdev, uint32_t *tag_buf,
  2279. struct ppdu_info *ppdu_info)
  2280. {
  2281. htt_ppdu_stats_enq_mpdu_bitmap_64_tlv *dp_stats_buf =
  2282. (htt_ppdu_stats_enq_mpdu_bitmap_64_tlv *)tag_buf;
  2283. struct cdp_tx_completion_ppdu *ppdu_desc;
  2284. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2285. uint8_t curr_user_index = 0;
  2286. uint16_t peer_id;
  2287. uint32_t size = CDP_BA_64_BIT_MAP_SIZE_DWORDS;
  2288. uint32_t tlv_type = HTT_STATS_TLV_TAG_GET(*tag_buf);
  2289. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2290. tag_buf++;
  2291. peer_id =
  2292. HTT_PPDU_STATS_ENQ_MPDU_BITMAP_TLV_SW_PEER_ID_GET(*tag_buf);
  2293. curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id, ppdu_info);
  2294. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  2295. ppdu_user_desc->tlv_bitmap |= (1 << tlv_type);
  2296. ppdu_user_desc->peer_id = peer_id;
  2297. ppdu_user_desc->start_seq = dp_stats_buf->start_seq;
  2298. qdf_mem_copy(&ppdu_user_desc->enq_bitmap, &dp_stats_buf->enq_bitmap,
  2299. sizeof(uint32_t) * CDP_BA_64_BIT_MAP_SIZE_DWORDS);
  2300. dp_process_ppdu_stats_update_failed_bitmap(pdev,
  2301. (void *)ppdu_user_desc,
  2302. ppdu_info->ppdu_id,
  2303. size);
  2304. }
  2305. /*
  2306. * dp_process_ppdu_stats_enq_mpdu_bitmap_256_tlv: Process
  2307. * htt_ppdu_stats_enq_mpdu_bitmap_256_tlv
  2308. * soc: DP SOC handle
  2309. * @tag_buf: buffer containing the tlv htt_ppdu_stats_enq_mpdu_bitmap_256_tlv
  2310. * @ppdu_info: per ppdu tlv structure
  2311. *
  2312. * return:void
  2313. */
  2314. static void dp_process_ppdu_stats_enq_mpdu_bitmap_256_tlv(
  2315. struct dp_pdev *pdev, uint32_t *tag_buf,
  2316. struct ppdu_info *ppdu_info)
  2317. {
  2318. htt_ppdu_stats_enq_mpdu_bitmap_256_tlv *dp_stats_buf =
  2319. (htt_ppdu_stats_enq_mpdu_bitmap_256_tlv *)tag_buf;
  2320. struct cdp_tx_completion_ppdu *ppdu_desc;
  2321. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2322. uint8_t curr_user_index = 0;
  2323. uint16_t peer_id;
  2324. uint32_t size = CDP_BA_256_BIT_MAP_SIZE_DWORDS;
  2325. uint32_t tlv_type = HTT_STATS_TLV_TAG_GET(*tag_buf);
  2326. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2327. tag_buf++;
  2328. peer_id =
  2329. HTT_PPDU_STATS_ENQ_MPDU_BITMAP_TLV_SW_PEER_ID_GET(*tag_buf);
  2330. curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id, ppdu_info);
  2331. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  2332. ppdu_user_desc->tlv_bitmap |= (1 << tlv_type);
  2333. ppdu_user_desc->peer_id = peer_id;
  2334. ppdu_user_desc->start_seq = dp_stats_buf->start_seq;
  2335. qdf_mem_copy(&ppdu_user_desc->enq_bitmap, &dp_stats_buf->enq_bitmap,
  2336. sizeof(uint32_t) * CDP_BA_256_BIT_MAP_SIZE_DWORDS);
  2337. dp_process_ppdu_stats_update_failed_bitmap(pdev,
  2338. (void *)ppdu_user_desc,
  2339. ppdu_info->ppdu_id,
  2340. size);
  2341. }
  2342. /*
  2343. * dp_process_ppdu_stats_user_cmpltn_common_tlv: Process
  2344. * htt_ppdu_stats_user_cmpltn_common_tlv
  2345. * soc: DP SOC handle
  2346. * @tag_buf: buffer containing the tlv htt_ppdu_stats_user_cmpltn_common_tlv
  2347. * @ppdu_info: per ppdu tlv structure
  2348. *
  2349. * return:void
  2350. */
  2351. static void dp_process_ppdu_stats_user_cmpltn_common_tlv(
  2352. struct dp_pdev *pdev, uint32_t *tag_buf,
  2353. struct ppdu_info *ppdu_info)
  2354. {
  2355. uint16_t peer_id;
  2356. struct cdp_tx_completion_ppdu *ppdu_desc;
  2357. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2358. uint8_t curr_user_index = 0;
  2359. uint8_t bw_iter;
  2360. htt_ppdu_stats_user_cmpltn_common_tlv *dp_stats_buf =
  2361. (htt_ppdu_stats_user_cmpltn_common_tlv *)tag_buf;
  2362. uint32_t tlv_type = HTT_STATS_TLV_TAG_GET(*tag_buf);
  2363. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2364. tag_buf++;
  2365. peer_id =
  2366. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_SW_PEER_ID_GET(*tag_buf);
  2367. curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id, ppdu_info);
  2368. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  2369. ppdu_user_desc->tlv_bitmap |= (1 << tlv_type);
  2370. ppdu_user_desc->peer_id = peer_id;
  2371. ppdu_user_desc->completion_status =
  2372. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_COMPLETION_STATUS_GET(
  2373. *tag_buf);
  2374. ppdu_user_desc->tid =
  2375. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_TID_NUM_GET(*tag_buf);
  2376. tag_buf++;
  2377. if (qdf_likely(ppdu_user_desc->completion_status ==
  2378. HTT_PPDU_STATS_USER_STATUS_OK)) {
  2379. ppdu_desc->ack_rssi = dp_stats_buf->ack_rssi;
  2380. ppdu_user_desc->usr_ack_rssi = dp_stats_buf->ack_rssi;
  2381. ppdu_user_desc->ack_rssi_valid = 1;
  2382. } else {
  2383. ppdu_user_desc->ack_rssi_valid = 0;
  2384. }
  2385. tag_buf++;
  2386. ppdu_user_desc->mpdu_success =
  2387. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_MPDU_SUCCESS_GET(*tag_buf);
  2388. ppdu_user_desc->mpdu_failed =
  2389. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_MPDU_TRIED_GET(*tag_buf) -
  2390. ppdu_user_desc->mpdu_success;
  2391. tag_buf++;
  2392. ppdu_user_desc->long_retries =
  2393. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_LONG_RETRY_GET(*tag_buf);
  2394. ppdu_user_desc->short_retries =
  2395. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_SHORT_RETRY_GET(*tag_buf);
  2396. ppdu_user_desc->retry_msdus =
  2397. ppdu_user_desc->long_retries + ppdu_user_desc->short_retries;
  2398. ppdu_user_desc->is_ampdu =
  2399. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_IS_AMPDU_GET(*tag_buf);
  2400. ppdu_info->is_ampdu = ppdu_user_desc->is_ampdu;
  2401. ppdu_desc->resp_type =
  2402. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_RESP_TYPE_GET(*tag_buf);
  2403. ppdu_desc->mprot_type =
  2404. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_MPROT_TYPE_GET(*tag_buf);
  2405. ppdu_desc->rts_success =
  2406. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_RTS_SUCCESS_GET(*tag_buf);
  2407. ppdu_desc->rts_failure =
  2408. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_RTS_FAILURE_GET(*tag_buf);
  2409. ppdu_info->compltn_common_tlv++;
  2410. /*
  2411. * MU BAR may send request to n users but we may received ack only from
  2412. * m users. To have count of number of users respond back, we have a
  2413. * separate counter bar_num_users per PPDU that get increment for every
  2414. * htt_ppdu_stats_user_cmpltn_common_tlv
  2415. */
  2416. ppdu_desc->bar_num_users++;
  2417. tag_buf++;
  2418. for (bw_iter = 0; bw_iter < CDP_RSSI_CHAIN_LEN; bw_iter++) {
  2419. ppdu_user_desc->rssi_chain[bw_iter] =
  2420. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_CHAIN_RSSI_GET(*tag_buf);
  2421. tag_buf++;
  2422. }
  2423. ppdu_user_desc->sa_tx_antenna =
  2424. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_TX_ANTENNA_MASK_GET(*tag_buf);
  2425. tag_buf++;
  2426. ppdu_user_desc->sa_is_training =
  2427. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_IS_TRAINING_GET(*tag_buf);
  2428. if (ppdu_user_desc->sa_is_training) {
  2429. ppdu_user_desc->sa_goodput =
  2430. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_PENDING_TRAINING_PKTS_GET(*tag_buf);
  2431. }
  2432. tag_buf++;
  2433. for (bw_iter = 0; bw_iter < CDP_NUM_SA_BW; bw_iter++) {
  2434. ppdu_user_desc->sa_max_rates[bw_iter] =
  2435. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_MAX_RATES_GET(tag_buf[bw_iter]);
  2436. }
  2437. tag_buf += CDP_NUM_SA_BW;
  2438. ppdu_user_desc->current_rate_per =
  2439. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_CURRENT_RATE_PER_GET(*tag_buf);
  2440. }
  2441. /*
  2442. * dp_process_ppdu_stats_user_compltn_ba_bitmap_64_tlv: Process
  2443. * htt_ppdu_stats_user_compltn_ba_bitmap_64_tlv
  2444. * pdev: DP PDEV handle
  2445. * @tag_buf: buffer containing the htt_ppdu_stats_user_compltn_ba_bitmap_64_tlv
  2446. * @ppdu_info: per ppdu tlv structure
  2447. *
  2448. * return:void
  2449. */
  2450. static void dp_process_ppdu_stats_user_compltn_ba_bitmap_64_tlv(
  2451. struct dp_pdev *pdev, uint32_t *tag_buf,
  2452. struct ppdu_info *ppdu_info)
  2453. {
  2454. htt_ppdu_stats_user_compltn_ba_bitmap_64_tlv *dp_stats_buf =
  2455. (htt_ppdu_stats_user_compltn_ba_bitmap_64_tlv *)tag_buf;
  2456. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2457. struct cdp_tx_completion_ppdu *ppdu_desc;
  2458. uint8_t curr_user_index = 0;
  2459. uint16_t peer_id;
  2460. uint32_t tlv_type = HTT_STATS_TLV_TAG_GET(*tag_buf);
  2461. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2462. tag_buf++;
  2463. peer_id =
  2464. HTT_PPDU_STATS_USER_CMPLTN_BA_BITMAP_TLV_SW_PEER_ID_GET(*tag_buf);
  2465. curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id, ppdu_info);
  2466. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  2467. ppdu_user_desc->tlv_bitmap |= (1 << tlv_type);
  2468. ppdu_user_desc->peer_id = peer_id;
  2469. ppdu_user_desc->ba_seq_no = dp_stats_buf->ba_seq_no;
  2470. qdf_mem_copy(&ppdu_user_desc->ba_bitmap, &dp_stats_buf->ba_bitmap,
  2471. sizeof(uint32_t) * CDP_BA_64_BIT_MAP_SIZE_DWORDS);
  2472. ppdu_user_desc->ba_size = CDP_BA_64_BIT_MAP_SIZE_DWORDS * 32;
  2473. }
  2474. /*
  2475. * dp_process_ppdu_stats_user_compltn_ba_bitmap_256_tlv: Process
  2476. * htt_ppdu_stats_user_compltn_ba_bitmap_256_tlv
  2477. * pdev: DP PDEV handle
  2478. * @tag_buf: buffer containing the htt_ppdu_stats_user_compltn_ba_bitmap_256_tlv
  2479. * @ppdu_info: per ppdu tlv structure
  2480. *
  2481. * return:void
  2482. */
  2483. static void dp_process_ppdu_stats_user_compltn_ba_bitmap_256_tlv(
  2484. struct dp_pdev *pdev, uint32_t *tag_buf,
  2485. struct ppdu_info *ppdu_info)
  2486. {
  2487. htt_ppdu_stats_user_compltn_ba_bitmap_256_tlv *dp_stats_buf =
  2488. (htt_ppdu_stats_user_compltn_ba_bitmap_256_tlv *)tag_buf;
  2489. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2490. struct cdp_tx_completion_ppdu *ppdu_desc;
  2491. uint8_t curr_user_index = 0;
  2492. uint16_t peer_id;
  2493. uint32_t tlv_type = HTT_STATS_TLV_TAG_GET(*tag_buf);
  2494. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2495. tag_buf++;
  2496. peer_id =
  2497. HTT_PPDU_STATS_USER_CMPLTN_BA_BITMAP_TLV_SW_PEER_ID_GET(*tag_buf);
  2498. curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id, ppdu_info);
  2499. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  2500. ppdu_user_desc->tlv_bitmap |= (1 << tlv_type);
  2501. ppdu_user_desc->peer_id = peer_id;
  2502. ppdu_user_desc->ba_seq_no = dp_stats_buf->ba_seq_no;
  2503. qdf_mem_copy(&ppdu_user_desc->ba_bitmap, &dp_stats_buf->ba_bitmap,
  2504. sizeof(uint32_t) * CDP_BA_256_BIT_MAP_SIZE_DWORDS);
  2505. ppdu_user_desc->ba_size = CDP_BA_256_BIT_MAP_SIZE_DWORDS * 32;
  2506. }
  2507. /*
  2508. * dp_process_ppdu_stats_user_compltn_ack_ba_status_tlv: Process
  2509. * htt_ppdu_stats_user_compltn_ack_ba_status_tlv
  2510. * pdev: DP PDE handle
  2511. * @tag_buf: buffer containing the htt_ppdu_stats_user_compltn_ack_ba_status_tlv
  2512. * @ppdu_info: per ppdu tlv structure
  2513. *
  2514. * return:void
  2515. */
  2516. static void dp_process_ppdu_stats_user_compltn_ack_ba_status_tlv(
  2517. struct dp_pdev *pdev, uint32_t *tag_buf,
  2518. struct ppdu_info *ppdu_info)
  2519. {
  2520. uint16_t peer_id;
  2521. struct cdp_tx_completion_ppdu *ppdu_desc;
  2522. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2523. uint8_t curr_user_index = 0;
  2524. uint32_t tlv_type = HTT_STATS_TLV_TAG_GET(*tag_buf);
  2525. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2526. tag_buf += 2;
  2527. peer_id =
  2528. HTT_PPDU_STATS_USER_CMPLTN_ACK_BA_STATUS_TLV_SW_PEER_ID_GET(*tag_buf);
  2529. curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id, ppdu_info);
  2530. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  2531. ppdu_user_desc->tlv_bitmap |= (1 << tlv_type);
  2532. if (!ppdu_user_desc->ack_ba_tlv) {
  2533. ppdu_user_desc->ack_ba_tlv = 1;
  2534. } else {
  2535. pdev->stats.ack_ba_comes_twice++;
  2536. return;
  2537. }
  2538. ppdu_user_desc->peer_id = peer_id;
  2539. tag_buf++;
  2540. /* not to update ppdu_desc->tid from this TLV */
  2541. ppdu_user_desc->num_mpdu =
  2542. HTT_PPDU_STATS_USER_CMPLTN_ACK_BA_STATUS_TLV_NUM_MPDU_GET(*tag_buf);
  2543. ppdu_user_desc->num_msdu =
  2544. HTT_PPDU_STATS_USER_CMPLTN_ACK_BA_STATUS_TLV_NUM_MSDU_GET(*tag_buf);
  2545. ppdu_user_desc->success_msdus = ppdu_user_desc->num_msdu;
  2546. tag_buf++;
  2547. ppdu_user_desc->start_seq =
  2548. HTT_PPDU_STATS_USER_CMPLTN_ACK_BA_STATUS_TLV_START_SEQ_GET(
  2549. *tag_buf);
  2550. tag_buf++;
  2551. ppdu_user_desc->success_bytes = *tag_buf;
  2552. /* increase ack ba tlv counter on successful mpdu */
  2553. if (ppdu_user_desc->num_mpdu)
  2554. ppdu_info->ack_ba_tlv++;
  2555. if (ppdu_user_desc->ba_size == 0) {
  2556. ppdu_user_desc->ba_seq_no = ppdu_user_desc->start_seq;
  2557. ppdu_user_desc->ba_bitmap[0] = 1;
  2558. ppdu_user_desc->ba_size = 1;
  2559. }
  2560. }
  2561. /*
  2562. * dp_process_ppdu_stats_user_common_array_tlv: Process
  2563. * htt_ppdu_stats_user_common_array_tlv
  2564. * pdev: DP PDEV handle
  2565. * @tag_buf: buffer containing the htt_ppdu_stats_user_compltn_ack_ba_status_tlv
  2566. * @ppdu_info: per ppdu tlv structure
  2567. *
  2568. * return:void
  2569. */
  2570. static void dp_process_ppdu_stats_user_common_array_tlv(
  2571. struct dp_pdev *pdev, uint32_t *tag_buf,
  2572. struct ppdu_info *ppdu_info)
  2573. {
  2574. uint32_t peer_id;
  2575. struct cdp_tx_completion_ppdu *ppdu_desc;
  2576. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2577. uint8_t curr_user_index = 0;
  2578. struct htt_tx_ppdu_stats_info *dp_stats_buf;
  2579. uint32_t tlv_type = HTT_STATS_TLV_TAG_GET(*tag_buf);
  2580. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2581. tag_buf++;
  2582. dp_stats_buf = (struct htt_tx_ppdu_stats_info *)tag_buf;
  2583. tag_buf += 3;
  2584. peer_id =
  2585. HTT_PPDU_STATS_ARRAY_ITEM_TLV_PEERID_GET(*tag_buf);
  2586. if (!dp_peer_find_by_id_valid(pdev->soc, peer_id)) {
  2587. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  2588. "Invalid peer");
  2589. return;
  2590. }
  2591. curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id, ppdu_info);
  2592. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  2593. ppdu_user_desc->tlv_bitmap |= (1 << tlv_type);
  2594. ppdu_user_desc->retry_bytes = dp_stats_buf->tx_retry_bytes;
  2595. ppdu_user_desc->failed_bytes = dp_stats_buf->tx_failed_bytes;
  2596. tag_buf++;
  2597. ppdu_user_desc->success_msdus =
  2598. HTT_PPDU_STATS_ARRAY_ITEM_TLV_TX_SUCC_MSDUS_GET(*tag_buf);
  2599. ppdu_user_desc->retry_bytes =
  2600. HTT_PPDU_STATS_ARRAY_ITEM_TLV_TX_RETRY_MSDUS_GET(*tag_buf);
  2601. tag_buf++;
  2602. ppdu_user_desc->failed_msdus =
  2603. HTT_PPDU_STATS_ARRAY_ITEM_TLV_TX_FAILED_MSDUS_GET(*tag_buf);
  2604. }
  2605. /*
  2606. * dp_process_ppdu_stats_flush_tlv: Process
  2607. * htt_ppdu_stats_flush_tlv
  2608. * @pdev: DP PDEV handle
  2609. * @tag_buf: buffer containing the htt_ppdu_stats_flush_tlv
  2610. * @ppdu_info: per ppdu tlv structure
  2611. *
  2612. * return:void
  2613. */
  2614. static void
  2615. dp_process_ppdu_stats_user_compltn_flush_tlv(struct dp_pdev *pdev,
  2616. uint32_t *tag_buf,
  2617. struct ppdu_info *ppdu_info)
  2618. {
  2619. struct cdp_tx_completion_ppdu *ppdu_desc;
  2620. uint32_t peer_id;
  2621. uint8_t tid;
  2622. struct dp_peer *peer;
  2623. ppdu_desc = (struct cdp_tx_completion_ppdu *)
  2624. qdf_nbuf_data(ppdu_info->nbuf);
  2625. ppdu_desc->is_flush = 1;
  2626. tag_buf++;
  2627. ppdu_desc->drop_reason = *tag_buf;
  2628. tag_buf++;
  2629. ppdu_desc->num_msdu = HTT_PPDU_STATS_FLUSH_TLV_NUM_MSDU_GET(*tag_buf);
  2630. ppdu_desc->num_mpdu = HTT_PPDU_STATS_FLUSH_TLV_NUM_MPDU_GET(*tag_buf);
  2631. ppdu_desc->flow_type = HTT_PPDU_STATS_FLUSH_TLV_FLOW_TYPE_GET(*tag_buf);
  2632. tag_buf++;
  2633. peer_id = HTT_PPDU_STATS_FLUSH_TLV_SW_PEER_ID_GET(*tag_buf);
  2634. tid = HTT_PPDU_STATS_FLUSH_TLV_TID_NUM_GET(*tag_buf);
  2635. ppdu_desc->num_users = 1;
  2636. ppdu_desc->user[0].peer_id = peer_id;
  2637. ppdu_desc->user[0].tid = tid;
  2638. ppdu_desc->queue_type =
  2639. HTT_PPDU_STATS_FLUSH_TLV_QUEUE_TYPE_GET(*tag_buf);
  2640. peer = dp_peer_get_ref_by_id(pdev->soc, peer_id,
  2641. DP_MOD_ID_TX_PPDU_STATS);
  2642. if (!peer)
  2643. goto add_ppdu_to_sched_list;
  2644. if (ppdu_desc->drop_reason == HTT_FLUSH_EXCESS_RETRIES) {
  2645. DP_STATS_INC(peer,
  2646. tx.excess_retries_per_ac[TID_TO_WME_AC(tid)],
  2647. ppdu_desc->num_msdu);
  2648. }
  2649. dp_peer_unref_delete(peer, DP_MOD_ID_TX_PPDU_STATS);
  2650. add_ppdu_to_sched_list:
  2651. ppdu_info->done = 1;
  2652. TAILQ_REMOVE(&pdev->ppdu_info_list, ppdu_info, ppdu_info_list_elem);
  2653. pdev->list_depth--;
  2654. TAILQ_INSERT_TAIL(&pdev->sched_comp_ppdu_list, ppdu_info,
  2655. ppdu_info_list_elem);
  2656. pdev->sched_comp_list_depth++;
  2657. }
  2658. /**
  2659. * dp_process_ppdu_stats_sch_cmd_status_tlv: Process schedule command status tlv
  2660. * Here we are not going to process the buffer.
  2661. * @pdev: DP PDEV handle
  2662. * @ppdu_info: per ppdu tlv structure
  2663. *
  2664. * return:void
  2665. */
  2666. static void
  2667. dp_process_ppdu_stats_sch_cmd_status_tlv(struct dp_pdev *pdev,
  2668. struct ppdu_info *ppdu_info)
  2669. {
  2670. struct cdp_tx_completion_ppdu *ppdu_desc;
  2671. struct dp_peer *peer;
  2672. uint8_t num_users;
  2673. uint8_t i;
  2674. ppdu_desc = (struct cdp_tx_completion_ppdu *)
  2675. qdf_nbuf_data(ppdu_info->nbuf);
  2676. num_users = ppdu_desc->bar_num_users;
  2677. if (ppdu_desc->frame_type == CDP_PPDU_FTYPE_BAR) {
  2678. for (i = 0; i < num_users; i++) {
  2679. if (ppdu_desc->user[i].user_pos == 0) {
  2680. /* update phy mode for bar frame */
  2681. ppdu_desc->phy_mode =
  2682. ppdu_desc->user[i].preamble;
  2683. ppdu_desc->user[0].mcs = ppdu_desc->user[i].mcs;
  2684. break;
  2685. }
  2686. }
  2687. }
  2688. if (ppdu_desc->frame_type == CDP_PPDU_FTYPE_DATA &&
  2689. ppdu_desc->delayed_ba) {
  2690. qdf_assert_always(ppdu_desc->num_users <= ppdu_desc->max_users);
  2691. for (i = 0; i < ppdu_desc->num_users; i++) {
  2692. struct cdp_delayed_tx_completion_ppdu_user *delay_ppdu;
  2693. uint64_t start_tsf;
  2694. uint64_t end_tsf;
  2695. uint32_t ppdu_id;
  2696. ppdu_id = ppdu_desc->ppdu_id;
  2697. peer = dp_peer_get_ref_by_id
  2698. (pdev->soc, ppdu_desc->user[i].peer_id,
  2699. DP_MOD_ID_TX_PPDU_STATS);
  2700. /**
  2701. * This check is to make sure peer is not deleted
  2702. * after processing the TLVs.
  2703. */
  2704. if (!peer)
  2705. continue;
  2706. delay_ppdu = &peer->delayed_ba_ppdu_stats;
  2707. start_tsf = ppdu_desc->ppdu_start_timestamp;
  2708. end_tsf = ppdu_desc->ppdu_end_timestamp;
  2709. /**
  2710. * save delayed ba user info
  2711. */
  2712. if (ppdu_desc->user[i].delayed_ba) {
  2713. dp_peer_copy_delay_stats(peer,
  2714. &ppdu_desc->user[i],
  2715. ppdu_id);
  2716. peer->last_delayed_ba_ppduid = ppdu_id;
  2717. delay_ppdu->ppdu_start_timestamp = start_tsf;
  2718. delay_ppdu->ppdu_end_timestamp = end_tsf;
  2719. }
  2720. ppdu_desc->user[i].peer_last_delayed_ba =
  2721. peer->last_delayed_ba;
  2722. dp_peer_unref_delete(peer, DP_MOD_ID_TX_PPDU_STATS);
  2723. if (ppdu_desc->user[i].delayed_ba &&
  2724. !ppdu_desc->user[i].debug_copied) {
  2725. QDF_TRACE(QDF_MODULE_ID_TXRX,
  2726. QDF_TRACE_LEVEL_INFO_MED,
  2727. "%s: %d ppdu_id[%d] bar_ppdu_id[%d] num_users[%d] usr[%d] htt_frame_type[%d]\n",
  2728. __func__, __LINE__,
  2729. ppdu_desc->ppdu_id,
  2730. ppdu_desc->bar_ppdu_id,
  2731. ppdu_desc->num_users,
  2732. i,
  2733. ppdu_desc->htt_frame_type);
  2734. }
  2735. }
  2736. }
  2737. /*
  2738. * when frame type is BAR and STATS_COMMON_TLV is set
  2739. * copy the store peer delayed info to BAR status
  2740. */
  2741. if (ppdu_desc->frame_type == CDP_PPDU_FTYPE_BAR) {
  2742. for (i = 0; i < ppdu_desc->bar_num_users; i++) {
  2743. struct cdp_delayed_tx_completion_ppdu_user *delay_ppdu;
  2744. uint64_t start_tsf;
  2745. uint64_t end_tsf;
  2746. peer = dp_peer_get_ref_by_id
  2747. (pdev->soc,
  2748. ppdu_desc->user[i].peer_id,
  2749. DP_MOD_ID_TX_PPDU_STATS);
  2750. /**
  2751. * This check is to make sure peer is not deleted
  2752. * after processing the TLVs.
  2753. */
  2754. if (!peer)
  2755. continue;
  2756. if (ppdu_desc->user[i].completion_status !=
  2757. HTT_PPDU_STATS_USER_STATUS_OK) {
  2758. dp_peer_unref_delete(peer,
  2759. DP_MOD_ID_TX_PPDU_STATS);
  2760. continue;
  2761. }
  2762. delay_ppdu = &peer->delayed_ba_ppdu_stats;
  2763. start_tsf = delay_ppdu->ppdu_start_timestamp;
  2764. end_tsf = delay_ppdu->ppdu_end_timestamp;
  2765. if (peer->last_delayed_ba) {
  2766. dp_peer_copy_stats_to_bar(peer,
  2767. &ppdu_desc->user[i]);
  2768. ppdu_desc->ppdu_id =
  2769. peer->last_delayed_ba_ppduid;
  2770. ppdu_desc->ppdu_start_timestamp = start_tsf;
  2771. ppdu_desc->ppdu_end_timestamp = end_tsf;
  2772. }
  2773. ppdu_desc->user[i].peer_last_delayed_ba =
  2774. peer->last_delayed_ba;
  2775. dp_peer_unref_delete(peer, DP_MOD_ID_TX_PPDU_STATS);
  2776. }
  2777. }
  2778. TAILQ_REMOVE(&pdev->ppdu_info_list, ppdu_info, ppdu_info_list_elem);
  2779. pdev->list_depth--;
  2780. TAILQ_INSERT_TAIL(&pdev->sched_comp_ppdu_list, ppdu_info,
  2781. ppdu_info_list_elem);
  2782. pdev->sched_comp_list_depth++;
  2783. }
  2784. #ifndef WLAN_TX_PKT_CAPTURE_ENH
  2785. /*
  2786. * dp_deliver_mgmt_frm: Process
  2787. * @pdev: DP PDEV handle
  2788. * @nbuf: buffer containing the htt_ppdu_stats_tx_mgmtctrl_payload_tlv
  2789. *
  2790. * return: void
  2791. */
  2792. void dp_deliver_mgmt_frm(struct dp_pdev *pdev, qdf_nbuf_t nbuf)
  2793. {
  2794. if (pdev->tx_sniffer_enable || pdev->mcopy_mode) {
  2795. dp_wdi_event_handler(WDI_EVENT_TX_MGMT_CTRL, pdev->soc,
  2796. nbuf, HTT_INVALID_PEER,
  2797. WDI_NO_VAL, pdev->pdev_id);
  2798. } else {
  2799. if (!pdev->bpr_enable)
  2800. qdf_nbuf_free(nbuf);
  2801. }
  2802. }
  2803. #endif
  2804. /*
  2805. * dp_process_ppdu_stats_tx_mgmtctrl_payload_tlv: Process
  2806. * htt_ppdu_stats_tx_mgmtctrl_payload_tlv
  2807. * @pdev: DP PDEV handle
  2808. * @tag_buf: buffer containing the htt_ppdu_stats_tx_mgmtctrl_payload_tlv
  2809. * @length: tlv_length
  2810. *
  2811. * return:QDF_STATUS_SUCCESS if nbuf as to be freed in caller
  2812. */
  2813. static QDF_STATUS
  2814. dp_process_ppdu_stats_tx_mgmtctrl_payload_tlv(struct dp_pdev *pdev,
  2815. qdf_nbuf_t tag_buf,
  2816. uint32_t ppdu_id)
  2817. {
  2818. uint32_t *nbuf_ptr;
  2819. uint8_t trim_size;
  2820. size_t head_size;
  2821. struct cdp_tx_mgmt_comp_info *ptr_mgmt_comp_info;
  2822. uint32_t *msg_word;
  2823. uint32_t tsf_hdr;
  2824. if ((!pdev->tx_sniffer_enable) && (!pdev->mcopy_mode) &&
  2825. (!pdev->bpr_enable) && (!pdev->tx_capture_enabled))
  2826. return QDF_STATUS_SUCCESS;
  2827. /*
  2828. * get timestamp from htt_t2h_ppdu_stats_ind_hdr_t
  2829. */
  2830. msg_word = (uint32_t *)qdf_nbuf_data(tag_buf);
  2831. msg_word = msg_word + 2;
  2832. tsf_hdr = *msg_word;
  2833. trim_size = ((pdev->mgmtctrl_frm_info.mgmt_buf +
  2834. HTT_MGMT_CTRL_TLV_HDR_RESERVERD_LEN) -
  2835. qdf_nbuf_data(tag_buf));
  2836. if (!qdf_nbuf_pull_head(tag_buf, trim_size))
  2837. return QDF_STATUS_SUCCESS;
  2838. qdf_nbuf_trim_tail(tag_buf, qdf_nbuf_len(tag_buf) -
  2839. pdev->mgmtctrl_frm_info.mgmt_buf_len);
  2840. if (pdev->tx_capture_enabled) {
  2841. head_size = sizeof(struct cdp_tx_mgmt_comp_info);
  2842. if (qdf_unlikely(qdf_nbuf_headroom(tag_buf) < head_size)) {
  2843. qdf_err("Fail to get headroom h_sz %d h_avail %d\n",
  2844. head_size, qdf_nbuf_headroom(tag_buf));
  2845. qdf_assert_always(0);
  2846. return QDF_STATUS_E_NOMEM;
  2847. }
  2848. ptr_mgmt_comp_info = (struct cdp_tx_mgmt_comp_info *)
  2849. qdf_nbuf_push_head(tag_buf, head_size);
  2850. qdf_assert_always(ptr_mgmt_comp_info);
  2851. ptr_mgmt_comp_info->ppdu_id = ppdu_id;
  2852. ptr_mgmt_comp_info->is_sgen_pkt = true;
  2853. ptr_mgmt_comp_info->tx_tsf = tsf_hdr;
  2854. } else {
  2855. head_size = sizeof(ppdu_id);
  2856. nbuf_ptr = (uint32_t *)qdf_nbuf_push_head(tag_buf, head_size);
  2857. *nbuf_ptr = ppdu_id;
  2858. }
  2859. if (pdev->bpr_enable) {
  2860. dp_wdi_event_handler(WDI_EVENT_TX_BEACON, pdev->soc,
  2861. tag_buf, HTT_INVALID_PEER,
  2862. WDI_NO_VAL, pdev->pdev_id);
  2863. }
  2864. dp_deliver_mgmt_frm(pdev, tag_buf);
  2865. return QDF_STATUS_E_ALREADY;
  2866. }
  2867. /**
  2868. * dp_validate_fix_ppdu_tlv(): Function to validate the length of PPDU
  2869. *
  2870. * If the TLV length sent as part of PPDU TLV is less that expected size i.e
  2871. * size of corresponding data structure, pad the remaining bytes with zeros
  2872. * and continue processing the TLVs
  2873. *
  2874. * @pdev: DP pdev handle
  2875. * @tag_buf: TLV buffer
  2876. * @tlv_expected_size: Expected size of Tag
  2877. * @tlv_len: TLV length received from FW
  2878. *
  2879. * Return: Pointer to updated TLV
  2880. */
  2881. static inline uint32_t *dp_validate_fix_ppdu_tlv(struct dp_pdev *pdev,
  2882. uint32_t *tag_buf,
  2883. uint16_t tlv_expected_size,
  2884. uint16_t tlv_len)
  2885. {
  2886. uint32_t *tlv_desc = tag_buf;
  2887. qdf_assert_always(tlv_len != 0);
  2888. if (tlv_len < tlv_expected_size) {
  2889. qdf_mem_zero(pdev->ppdu_tlv_buf, tlv_expected_size);
  2890. qdf_mem_copy(pdev->ppdu_tlv_buf, tag_buf, tlv_len);
  2891. tlv_desc = pdev->ppdu_tlv_buf;
  2892. }
  2893. return tlv_desc;
  2894. }
  2895. /**
  2896. * dp_process_ppdu_tag(): Function to process the PPDU TLVs
  2897. * @pdev: DP pdev handle
  2898. * @tag_buf: TLV buffer
  2899. * @tlv_len: length of tlv
  2900. * @ppdu_info: per ppdu tlv structure
  2901. *
  2902. * return: void
  2903. */
  2904. static void dp_process_ppdu_tag(struct dp_pdev *pdev, uint32_t *tag_buf,
  2905. uint32_t tlv_len, struct ppdu_info *ppdu_info)
  2906. {
  2907. uint32_t tlv_type = HTT_STATS_TLV_TAG_GET(*tag_buf);
  2908. uint16_t tlv_expected_size;
  2909. uint32_t *tlv_desc;
  2910. switch (tlv_type) {
  2911. case HTT_PPDU_STATS_COMMON_TLV:
  2912. tlv_expected_size = sizeof(htt_ppdu_stats_common_tlv);
  2913. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  2914. tlv_expected_size, tlv_len);
  2915. dp_process_ppdu_stats_common_tlv(pdev, tlv_desc, ppdu_info);
  2916. break;
  2917. case HTT_PPDU_STATS_USR_COMMON_TLV:
  2918. tlv_expected_size = sizeof(htt_ppdu_stats_user_common_tlv);
  2919. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  2920. tlv_expected_size, tlv_len);
  2921. dp_process_ppdu_stats_user_common_tlv(pdev, tlv_desc,
  2922. ppdu_info);
  2923. break;
  2924. case HTT_PPDU_STATS_USR_RATE_TLV:
  2925. tlv_expected_size = sizeof(htt_ppdu_stats_user_rate_tlv);
  2926. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  2927. tlv_expected_size, tlv_len);
  2928. dp_process_ppdu_stats_user_rate_tlv(pdev, tlv_desc,
  2929. ppdu_info);
  2930. break;
  2931. case HTT_PPDU_STATS_USR_MPDU_ENQ_BITMAP_64_TLV:
  2932. tlv_expected_size =
  2933. sizeof(htt_ppdu_stats_enq_mpdu_bitmap_64_tlv);
  2934. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  2935. tlv_expected_size, tlv_len);
  2936. dp_process_ppdu_stats_enq_mpdu_bitmap_64_tlv(
  2937. pdev, tlv_desc, ppdu_info);
  2938. break;
  2939. case HTT_PPDU_STATS_USR_MPDU_ENQ_BITMAP_256_TLV:
  2940. tlv_expected_size =
  2941. sizeof(htt_ppdu_stats_enq_mpdu_bitmap_256_tlv);
  2942. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  2943. tlv_expected_size, tlv_len);
  2944. dp_process_ppdu_stats_enq_mpdu_bitmap_256_tlv(
  2945. pdev, tlv_desc, ppdu_info);
  2946. break;
  2947. case HTT_PPDU_STATS_USR_COMPLTN_COMMON_TLV:
  2948. tlv_expected_size =
  2949. sizeof(htt_ppdu_stats_user_cmpltn_common_tlv);
  2950. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  2951. tlv_expected_size, tlv_len);
  2952. dp_process_ppdu_stats_user_cmpltn_common_tlv(
  2953. pdev, tlv_desc, ppdu_info);
  2954. break;
  2955. case HTT_PPDU_STATS_USR_COMPLTN_BA_BITMAP_64_TLV:
  2956. tlv_expected_size =
  2957. sizeof(htt_ppdu_stats_user_compltn_ba_bitmap_64_tlv);
  2958. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  2959. tlv_expected_size, tlv_len);
  2960. dp_process_ppdu_stats_user_compltn_ba_bitmap_64_tlv(
  2961. pdev, tlv_desc, ppdu_info);
  2962. break;
  2963. case HTT_PPDU_STATS_USR_COMPLTN_BA_BITMAP_256_TLV:
  2964. tlv_expected_size =
  2965. sizeof(htt_ppdu_stats_user_compltn_ba_bitmap_256_tlv);
  2966. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  2967. tlv_expected_size, tlv_len);
  2968. dp_process_ppdu_stats_user_compltn_ba_bitmap_256_tlv(
  2969. pdev, tlv_desc, ppdu_info);
  2970. break;
  2971. case HTT_PPDU_STATS_USR_COMPLTN_ACK_BA_STATUS_TLV:
  2972. tlv_expected_size =
  2973. sizeof(htt_ppdu_stats_user_compltn_ack_ba_status_tlv);
  2974. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  2975. tlv_expected_size, tlv_len);
  2976. dp_process_ppdu_stats_user_compltn_ack_ba_status_tlv(
  2977. pdev, tlv_desc, ppdu_info);
  2978. break;
  2979. case HTT_PPDU_STATS_USR_COMMON_ARRAY_TLV:
  2980. tlv_expected_size =
  2981. sizeof(htt_ppdu_stats_usr_common_array_tlv_v);
  2982. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  2983. tlv_expected_size, tlv_len);
  2984. dp_process_ppdu_stats_user_common_array_tlv(
  2985. pdev, tlv_desc, ppdu_info);
  2986. break;
  2987. case HTT_PPDU_STATS_USR_COMPLTN_FLUSH_TLV:
  2988. tlv_expected_size = sizeof(htt_ppdu_stats_flush_tlv);
  2989. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  2990. tlv_expected_size, tlv_len);
  2991. dp_process_ppdu_stats_user_compltn_flush_tlv(pdev, tlv_desc,
  2992. ppdu_info);
  2993. break;
  2994. case HTT_PPDU_STATS_SCH_CMD_STATUS_TLV:
  2995. dp_process_ppdu_stats_sch_cmd_status_tlv(pdev, ppdu_info);
  2996. break;
  2997. default:
  2998. break;
  2999. }
  3000. }
  3001. #ifdef WLAN_ATF_ENABLE
  3002. static void
  3003. dp_ppdu_desc_user_phy_tx_time_update(struct dp_pdev *pdev,
  3004. struct cdp_tx_completion_ppdu *ppdu_desc,
  3005. struct cdp_tx_completion_ppdu_user *user)
  3006. {
  3007. uint32_t nss_ru_width_sum = 0;
  3008. if (!pdev || !ppdu_desc || !user)
  3009. return;
  3010. if (!pdev->dp_atf_stats_enable)
  3011. return;
  3012. if (ppdu_desc->frame_type != CDP_PPDU_FTYPE_DATA)
  3013. return;
  3014. nss_ru_width_sum = ppdu_desc->usr_nss_sum * ppdu_desc->usr_ru_tones_sum;
  3015. if (!nss_ru_width_sum)
  3016. nss_ru_width_sum = 1;
  3017. /**
  3018. * For SU-MIMO PPDU phy Tx time is same for the single user.
  3019. * For MU-MIMO phy Tx time is calculated per user as below
  3020. * user phy tx time =
  3021. * Entire PPDU duration * MU Ratio * OFDMA Ratio
  3022. * MU Ratio = usr_nss / Sum_of_nss_of_all_users
  3023. * OFDMA_ratio = usr_ru_width / Sum_of_ru_width_of_all_users
  3024. * usr_ru_widt = ru_end – ru_start + 1
  3025. */
  3026. if (ppdu_desc->htt_frame_type == HTT_STATS_FTYPE_TIDQ_DATA_SU) {
  3027. user->phy_tx_time_us = ppdu_desc->phy_ppdu_tx_time_us;
  3028. } else {
  3029. user->phy_tx_time_us = (ppdu_desc->phy_ppdu_tx_time_us *
  3030. user->nss * user->ru_tones) / nss_ru_width_sum;
  3031. }
  3032. }
  3033. #else
  3034. static void
  3035. dp_ppdu_desc_user_phy_tx_time_update(struct dp_pdev *pdev,
  3036. struct cdp_tx_completion_ppdu *ppdu_desc,
  3037. struct cdp_tx_completion_ppdu_user *user)
  3038. {
  3039. }
  3040. #endif
  3041. /**
  3042. * dp_ppdu_desc_user_stats_update(): Function to update TX user stats
  3043. * @pdev: DP pdev handle
  3044. * @ppdu_info: per PPDU TLV descriptor
  3045. *
  3046. * return: void
  3047. */
  3048. void
  3049. dp_ppdu_desc_user_stats_update(struct dp_pdev *pdev,
  3050. struct ppdu_info *ppdu_info)
  3051. {
  3052. struct cdp_tx_completion_ppdu *ppdu_desc = NULL;
  3053. struct dp_peer *peer = NULL;
  3054. uint32_t tlv_bitmap_expected;
  3055. uint32_t tlv_bitmap_default;
  3056. uint16_t i;
  3057. uint32_t num_users;
  3058. ppdu_desc = (struct cdp_tx_completion_ppdu *)
  3059. qdf_nbuf_data(ppdu_info->nbuf);
  3060. if (ppdu_desc->frame_type != CDP_PPDU_FTYPE_BAR)
  3061. ppdu_desc->ppdu_id = ppdu_info->ppdu_id;
  3062. tlv_bitmap_expected = HTT_PPDU_DEFAULT_TLV_BITMAP;
  3063. if (pdev->tx_sniffer_enable || pdev->mcopy_mode ||
  3064. pdev->tx_capture_enabled) {
  3065. if (ppdu_info->is_ampdu)
  3066. tlv_bitmap_expected =
  3067. dp_htt_get_ppdu_sniffer_ampdu_tlv_bitmap(
  3068. ppdu_info->tlv_bitmap);
  3069. }
  3070. tlv_bitmap_default = tlv_bitmap_expected;
  3071. if (ppdu_desc->frame_type == CDP_PPDU_FTYPE_BAR) {
  3072. num_users = ppdu_desc->bar_num_users;
  3073. ppdu_desc->num_users = ppdu_desc->bar_num_users;
  3074. } else {
  3075. num_users = ppdu_desc->num_users;
  3076. }
  3077. qdf_assert_always(ppdu_desc->num_users <= ppdu_desc->max_users);
  3078. for (i = 0; i < num_users; i++) {
  3079. ppdu_desc->num_mpdu += ppdu_desc->user[i].num_mpdu;
  3080. ppdu_desc->num_msdu += ppdu_desc->user[i].num_msdu;
  3081. peer = dp_peer_get_ref_by_id(pdev->soc,
  3082. ppdu_desc->user[i].peer_id,
  3083. DP_MOD_ID_TX_PPDU_STATS);
  3084. /**
  3085. * This check is to make sure peer is not deleted
  3086. * after processing the TLVs.
  3087. */
  3088. if (!peer)
  3089. continue;
  3090. /*
  3091. * different frame like DATA, BAR or CTRL has different
  3092. * tlv bitmap expected. Apart from ACK_BA_STATUS TLV, we
  3093. * receive other tlv in-order/sequential from fw.
  3094. * Since ACK_BA_STATUS TLV come from Hardware it is
  3095. * asynchronous So we need to depend on some tlv to confirm
  3096. * all tlv is received for a ppdu.
  3097. * So we depend on both SCHED_CMD_STATUS_TLV and
  3098. * ACK_BA_STATUS_TLV. for failure packet we won't get
  3099. * ACK_BA_STATUS_TLV.
  3100. */
  3101. if (!(ppdu_info->tlv_bitmap &
  3102. (1 << HTT_PPDU_STATS_SCH_CMD_STATUS_TLV)) ||
  3103. (!(ppdu_info->tlv_bitmap &
  3104. (1 << HTT_PPDU_STATS_USR_COMPLTN_ACK_BA_STATUS_TLV)) &&
  3105. (ppdu_desc->user[i].completion_status ==
  3106. HTT_PPDU_STATS_USER_STATUS_OK))) {
  3107. dp_peer_unref_delete(peer, DP_MOD_ID_TX_PPDU_STATS);
  3108. continue;
  3109. }
  3110. /**
  3111. * Update tx stats for data frames having Qos as well as
  3112. * non-Qos data tid
  3113. */
  3114. if ((ppdu_desc->user[i].tid < CDP_DATA_TID_MAX ||
  3115. (ppdu_desc->user[i].tid == CDP_DATA_NON_QOS_TID) ||
  3116. (ppdu_desc->htt_frame_type ==
  3117. HTT_STATS_FTYPE_SGEN_QOS_NULL) ||
  3118. ((ppdu_desc->frame_type == CDP_PPDU_FTYPE_BAR) &&
  3119. (ppdu_desc->num_mpdu > 1))) &&
  3120. (ppdu_desc->frame_type != CDP_PPDU_FTYPE_CTRL)) {
  3121. dp_tx_stats_update(pdev, peer,
  3122. &ppdu_desc->user[i],
  3123. ppdu_desc->ack_rssi);
  3124. dp_tx_rate_stats_update(peer, &ppdu_desc->user[i]);
  3125. }
  3126. dp_ppdu_desc_user_phy_tx_time_update(pdev, ppdu_desc,
  3127. &ppdu_desc->user[i]);
  3128. dp_peer_unref_delete(peer, DP_MOD_ID_TX_PPDU_STATS);
  3129. tlv_bitmap_expected = tlv_bitmap_default;
  3130. }
  3131. }
  3132. #ifndef WLAN_TX_PKT_CAPTURE_ENH
  3133. /**
  3134. * dp_ppdu_desc_deliver(): Function to deliver Tx PPDU status descriptor
  3135. * to upper layer
  3136. * @pdev: DP pdev handle
  3137. * @ppdu_info: per PPDU TLV descriptor
  3138. *
  3139. * return: void
  3140. */
  3141. static
  3142. void dp_ppdu_desc_deliver(struct dp_pdev *pdev,
  3143. struct ppdu_info *ppdu_info)
  3144. {
  3145. struct ppdu_info *s_ppdu_info = NULL;
  3146. struct ppdu_info *ppdu_info_next = NULL;
  3147. struct cdp_tx_completion_ppdu *ppdu_desc = NULL;
  3148. qdf_nbuf_t nbuf;
  3149. uint32_t time_delta = 0;
  3150. bool starved = 0;
  3151. bool matched = 0;
  3152. bool recv_ack_ba_done = 0;
  3153. if (ppdu_info->tlv_bitmap &
  3154. (1 << HTT_PPDU_STATS_USR_COMPLTN_ACK_BA_STATUS_TLV) &&
  3155. ppdu_info->done)
  3156. recv_ack_ba_done = 1;
  3157. pdev->last_sched_cmdid = ppdu_info->sched_cmdid;
  3158. s_ppdu_info = TAILQ_FIRST(&pdev->sched_comp_ppdu_list);
  3159. TAILQ_FOREACH_SAFE(s_ppdu_info, &pdev->sched_comp_ppdu_list,
  3160. ppdu_info_list_elem, ppdu_info_next) {
  3161. if (s_ppdu_info->tsf_l32 > ppdu_info->tsf_l32)
  3162. time_delta = (MAX_TSF_32 - s_ppdu_info->tsf_l32) +
  3163. ppdu_info->tsf_l32;
  3164. else
  3165. time_delta = ppdu_info->tsf_l32 - s_ppdu_info->tsf_l32;
  3166. if (!s_ppdu_info->done && !recv_ack_ba_done) {
  3167. if (time_delta < MAX_SCHED_STARVE) {
  3168. qdf_err("pdev[%d] ppdu_id[%d] sched_cmdid[%d] TLV_B[0x%x] TSF[%u] D[%d]",
  3169. pdev->pdev_id,
  3170. s_ppdu_info->ppdu_id,
  3171. s_ppdu_info->sched_cmdid,
  3172. s_ppdu_info->tlv_bitmap,
  3173. s_ppdu_info->tsf_l32,
  3174. s_ppdu_info->done);
  3175. break;
  3176. }
  3177. starved = 1;
  3178. }
  3179. pdev->delivered_sched_cmdid = s_ppdu_info->sched_cmdid;
  3180. TAILQ_REMOVE(&pdev->sched_comp_ppdu_list, s_ppdu_info,
  3181. ppdu_info_list_elem);
  3182. pdev->sched_comp_list_depth--;
  3183. nbuf = s_ppdu_info->nbuf;
  3184. qdf_assert_always(nbuf);
  3185. ppdu_desc = (struct cdp_tx_completion_ppdu *)
  3186. qdf_nbuf_data(nbuf);
  3187. ppdu_desc->tlv_bitmap = s_ppdu_info->tlv_bitmap;
  3188. if (starved) {
  3189. qdf_err("ppdu starved fc[0x%x] h_ftype[%d] tlv_bitmap[0x%x] cs[%d]\n",
  3190. ppdu_desc->frame_ctrl,
  3191. ppdu_desc->htt_frame_type,
  3192. ppdu_desc->tlv_bitmap,
  3193. ppdu_desc->user[0].completion_status);
  3194. starved = 0;
  3195. }
  3196. if (ppdu_info->ppdu_id == s_ppdu_info->ppdu_id &&
  3197. ppdu_info->sched_cmdid == s_ppdu_info->sched_cmdid)
  3198. matched = 1;
  3199. dp_ppdu_desc_user_stats_update(pdev, s_ppdu_info);
  3200. qdf_mem_free(s_ppdu_info);
  3201. /**
  3202. * Deliver PPDU stats only for valid (acked) data
  3203. * frames if sniffer mode is not enabled.
  3204. * If sniffer mode is enabled, PPDU stats
  3205. * for all frames including mgmt/control
  3206. * frames should be delivered to upper layer
  3207. */
  3208. if (pdev->tx_sniffer_enable || pdev->mcopy_mode) {
  3209. dp_wdi_event_handler(WDI_EVENT_TX_PPDU_DESC,
  3210. pdev->soc,
  3211. nbuf, HTT_INVALID_PEER,
  3212. WDI_NO_VAL,
  3213. pdev->pdev_id);
  3214. } else {
  3215. if (ppdu_desc->num_mpdu != 0 &&
  3216. ppdu_desc->num_users != 0 &&
  3217. ppdu_desc->frame_ctrl &
  3218. HTT_FRAMECTRL_DATATYPE) {
  3219. dp_wdi_event_handler(WDI_EVENT_TX_PPDU_DESC,
  3220. pdev->soc,
  3221. nbuf, HTT_INVALID_PEER,
  3222. WDI_NO_VAL,
  3223. pdev->pdev_id);
  3224. } else {
  3225. qdf_nbuf_free(nbuf);
  3226. }
  3227. }
  3228. if (matched)
  3229. break;
  3230. }
  3231. return;
  3232. }
  3233. #endif
  3234. /**
  3235. * dp_get_ppdu_desc(): Function to allocate new PPDU status
  3236. * desc for new ppdu id
  3237. * @pdev: DP pdev handle
  3238. * @ppdu_id: PPDU unique identifier
  3239. * @tlv_type: TLV type received
  3240. * @tsf_l32: timestamp received along with ppdu stats indication header
  3241. * @max_users: Maximum user for that particular ppdu
  3242. *
  3243. * return: ppdu_info per ppdu tlv structure
  3244. */
  3245. static
  3246. struct ppdu_info *dp_get_ppdu_desc(struct dp_pdev *pdev, uint32_t ppdu_id,
  3247. uint8_t tlv_type, uint32_t tsf_l32,
  3248. uint8_t max_users)
  3249. {
  3250. struct ppdu_info *ppdu_info = NULL;
  3251. struct ppdu_info *s_ppdu_info = NULL;
  3252. struct ppdu_info *ppdu_info_next = NULL;
  3253. struct cdp_tx_completion_ppdu *ppdu_desc = NULL;
  3254. uint32_t size = 0;
  3255. struct cdp_tx_completion_ppdu *tmp_ppdu_desc = NULL;
  3256. struct cdp_tx_completion_ppdu_user *tmp_user;
  3257. uint32_t time_delta;
  3258. /*
  3259. * Find ppdu_id node exists or not
  3260. */
  3261. TAILQ_FOREACH_SAFE(ppdu_info, &pdev->ppdu_info_list,
  3262. ppdu_info_list_elem, ppdu_info_next) {
  3263. if (ppdu_info && (ppdu_info->ppdu_id == ppdu_id)) {
  3264. if (ppdu_info->tsf_l32 > tsf_l32)
  3265. time_delta = (MAX_TSF_32 -
  3266. ppdu_info->tsf_l32) + tsf_l32;
  3267. else
  3268. time_delta = tsf_l32 - ppdu_info->tsf_l32;
  3269. if (time_delta > WRAP_DROP_TSF_DELTA) {
  3270. TAILQ_REMOVE(&pdev->ppdu_info_list,
  3271. ppdu_info, ppdu_info_list_elem);
  3272. pdev->list_depth--;
  3273. pdev->stats.ppdu_wrap_drop++;
  3274. tmp_ppdu_desc =
  3275. (struct cdp_tx_completion_ppdu *)
  3276. qdf_nbuf_data(ppdu_info->nbuf);
  3277. tmp_user = &tmp_ppdu_desc->user[0];
  3278. QDF_TRACE(QDF_MODULE_ID_TX_CAPTURE,
  3279. QDF_TRACE_LEVEL_INFO_MED,
  3280. "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",
  3281. ppdu_info->ppdu_id,
  3282. ppdu_info->tsf_l32,
  3283. ppdu_info->tlv_bitmap,
  3284. tmp_user->completion_status,
  3285. ppdu_info->compltn_common_tlv,
  3286. ppdu_info->ack_ba_tlv,
  3287. ppdu_id, tsf_l32, tlv_type);
  3288. qdf_nbuf_free(ppdu_info->nbuf);
  3289. ppdu_info->nbuf = NULL;
  3290. qdf_mem_free(ppdu_info);
  3291. } else {
  3292. break;
  3293. }
  3294. }
  3295. }
  3296. /*
  3297. * check if it is ack ba tlv and if it is not there in ppdu info
  3298. * list then check it in sched completion ppdu list
  3299. */
  3300. if (!ppdu_info &&
  3301. tlv_type == HTT_PPDU_STATS_USR_COMPLTN_ACK_BA_STATUS_TLV) {
  3302. TAILQ_FOREACH(s_ppdu_info,
  3303. &pdev->sched_comp_ppdu_list,
  3304. ppdu_info_list_elem) {
  3305. if (s_ppdu_info && (s_ppdu_info->ppdu_id == ppdu_id)) {
  3306. if (s_ppdu_info->tsf_l32 > tsf_l32)
  3307. time_delta = (MAX_TSF_32 -
  3308. s_ppdu_info->tsf_l32) +
  3309. tsf_l32;
  3310. else
  3311. time_delta = tsf_l32 -
  3312. s_ppdu_info->tsf_l32;
  3313. if (time_delta < WRAP_DROP_TSF_DELTA) {
  3314. ppdu_info = s_ppdu_info;
  3315. break;
  3316. }
  3317. } else {
  3318. /*
  3319. * ACK BA STATUS TLV comes sequential order
  3320. * if we received ack ba status tlv for second
  3321. * ppdu and first ppdu is still waiting for
  3322. * ACK BA STATUS TLV. Based on fw comment
  3323. * we won't receive it tlv later. So we can
  3324. * set ppdu info done.
  3325. */
  3326. if (s_ppdu_info)
  3327. s_ppdu_info->done = 1;
  3328. }
  3329. }
  3330. }
  3331. if (ppdu_info) {
  3332. if (ppdu_info->tlv_bitmap & (1 << tlv_type)) {
  3333. /**
  3334. * if we get tlv_type that is already been processed
  3335. * for ppdu, that means we got a new ppdu with same
  3336. * ppdu id. Hence Flush the older ppdu
  3337. * for MUMIMO and OFDMA, In a PPDU we have
  3338. * multiple user with same tlv types. tlv bitmap is
  3339. * used to check whether SU or MU_MIMO/OFDMA
  3340. */
  3341. if (!(ppdu_info->tlv_bitmap &
  3342. (1 << HTT_PPDU_STATS_SCH_CMD_STATUS_TLV)))
  3343. return ppdu_info;
  3344. ppdu_desc = (struct cdp_tx_completion_ppdu *)
  3345. qdf_nbuf_data(ppdu_info->nbuf);
  3346. /**
  3347. * apart from ACK BA STATUS TLV rest all comes in order
  3348. * so if tlv type not ACK BA STATUS TLV we can deliver
  3349. * ppdu_info
  3350. */
  3351. if ((tlv_type ==
  3352. HTT_PPDU_STATS_USR_COMPLTN_ACK_BA_STATUS_TLV) &&
  3353. (ppdu_desc->htt_frame_type ==
  3354. HTT_STATS_FTYPE_SGEN_MU_BAR))
  3355. return ppdu_info;
  3356. dp_ppdu_desc_deliver(pdev, ppdu_info);
  3357. } else {
  3358. return ppdu_info;
  3359. }
  3360. }
  3361. /**
  3362. * Flush the head ppdu descriptor if ppdu desc list reaches max
  3363. * threshold
  3364. */
  3365. if (pdev->list_depth > HTT_PPDU_DESC_MAX_DEPTH) {
  3366. ppdu_info = TAILQ_FIRST(&pdev->ppdu_info_list);
  3367. TAILQ_REMOVE(&pdev->ppdu_info_list,
  3368. ppdu_info, ppdu_info_list_elem);
  3369. pdev->list_depth--;
  3370. pdev->stats.ppdu_drop++;
  3371. qdf_nbuf_free(ppdu_info->nbuf);
  3372. ppdu_info->nbuf = NULL;
  3373. qdf_mem_free(ppdu_info);
  3374. }
  3375. size = sizeof(struct cdp_tx_completion_ppdu) +
  3376. (max_users * sizeof(struct cdp_tx_completion_ppdu_user));
  3377. /*
  3378. * Allocate new ppdu_info node
  3379. */
  3380. ppdu_info = qdf_mem_malloc(sizeof(struct ppdu_info));
  3381. if (!ppdu_info)
  3382. return NULL;
  3383. ppdu_info->nbuf = qdf_nbuf_alloc(pdev->soc->osdev, size,
  3384. 0, 4, TRUE);
  3385. if (!ppdu_info->nbuf) {
  3386. qdf_mem_free(ppdu_info);
  3387. return NULL;
  3388. }
  3389. ppdu_info->ppdu_desc =
  3390. (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  3391. qdf_mem_zero(qdf_nbuf_data(ppdu_info->nbuf), size);
  3392. if (qdf_nbuf_put_tail(ppdu_info->nbuf, size) == NULL) {
  3393. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  3394. "No tailroom for HTT PPDU");
  3395. qdf_nbuf_free(ppdu_info->nbuf);
  3396. ppdu_info->nbuf = NULL;
  3397. ppdu_info->last_user = 0;
  3398. qdf_mem_free(ppdu_info);
  3399. return NULL;
  3400. }
  3401. ppdu_info->ppdu_desc->max_users = max_users;
  3402. ppdu_info->tsf_l32 = tsf_l32;
  3403. /**
  3404. * No lock is needed because all PPDU TLVs are processed in
  3405. * same context and this list is updated in same context
  3406. */
  3407. TAILQ_INSERT_TAIL(&pdev->ppdu_info_list, ppdu_info,
  3408. ppdu_info_list_elem);
  3409. pdev->list_depth++;
  3410. return ppdu_info;
  3411. }
  3412. /**
  3413. * dp_htt_process_tlv(): Function to process each PPDU TLVs
  3414. * @pdev: DP pdev handle
  3415. * @htt_t2h_msg: HTT target to host message
  3416. *
  3417. * return: ppdu_info per ppdu tlv structure
  3418. */
  3419. static struct ppdu_info *dp_htt_process_tlv(struct dp_pdev *pdev,
  3420. qdf_nbuf_t htt_t2h_msg)
  3421. {
  3422. uint32_t length;
  3423. uint32_t ppdu_id;
  3424. uint8_t tlv_type;
  3425. uint32_t tlv_length, tlv_bitmap_expected;
  3426. uint8_t *tlv_buf;
  3427. struct ppdu_info *ppdu_info = NULL;
  3428. struct cdp_tx_completion_ppdu *ppdu_desc = NULL;
  3429. uint8_t max_users = CDP_MU_MAX_USERS;
  3430. uint32_t tsf_l32;
  3431. uint32_t *msg_word = (uint32_t *) qdf_nbuf_data(htt_t2h_msg);
  3432. length = HTT_T2H_PPDU_STATS_PAYLOAD_SIZE_GET(*msg_word);
  3433. msg_word = msg_word + 1;
  3434. ppdu_id = HTT_T2H_PPDU_STATS_PPDU_ID_GET(*msg_word);
  3435. msg_word = msg_word + 1;
  3436. tsf_l32 = (uint32_t)(*msg_word);
  3437. msg_word = msg_word + 2;
  3438. while (length > 0) {
  3439. tlv_buf = (uint8_t *)msg_word;
  3440. tlv_type = HTT_STATS_TLV_TAG_GET(*msg_word);
  3441. tlv_length = HTT_STATS_TLV_LENGTH_GET(*msg_word);
  3442. if (qdf_likely(tlv_type < CDP_PPDU_STATS_MAX_TAG))
  3443. pdev->stats.ppdu_stats_counter[tlv_type]++;
  3444. if (tlv_length == 0)
  3445. break;
  3446. tlv_length += HTT_TLV_HDR_LEN;
  3447. /**
  3448. * Not allocating separate ppdu descriptor for MGMT Payload
  3449. * TLV as this is sent as separate WDI indication and it
  3450. * doesn't contain any ppdu information
  3451. */
  3452. if (tlv_type == HTT_PPDU_STATS_TX_MGMTCTRL_PAYLOAD_TLV) {
  3453. pdev->mgmtctrl_frm_info.mgmt_buf = tlv_buf;
  3454. pdev->mgmtctrl_frm_info.ppdu_id = ppdu_id;
  3455. pdev->mgmtctrl_frm_info.mgmt_buf_len =
  3456. HTT_PPDU_STATS_TX_MGMTCTRL_TLV_FRAME_LENGTH_GET
  3457. (*(msg_word + 1));
  3458. msg_word =
  3459. (uint32_t *)((uint8_t *)tlv_buf + tlv_length);
  3460. length -= (tlv_length);
  3461. continue;
  3462. }
  3463. /*
  3464. * retrieve max_users if it's USERS_INFO,
  3465. * else, it's 1 for COMPLTN_FLUSH,
  3466. * else, use CDP_MU_MAX_USERS
  3467. */
  3468. if (tlv_type == HTT_PPDU_STATS_USERS_INFO_TLV) {
  3469. max_users =
  3470. HTT_PPDU_STATS_USERS_INFO_TLV_MAX_USERS_GET(*(msg_word + 1));
  3471. } else if (tlv_type == HTT_PPDU_STATS_USR_COMPLTN_FLUSH_TLV) {
  3472. max_users = 1;
  3473. }
  3474. ppdu_info = dp_get_ppdu_desc(pdev, ppdu_id, tlv_type,
  3475. tsf_l32, max_users);
  3476. if (!ppdu_info)
  3477. return NULL;
  3478. ppdu_info->ppdu_desc->bss_color =
  3479. pdev->rx_mon_recv_status.bsscolor;
  3480. ppdu_info->ppdu_id = ppdu_id;
  3481. ppdu_info->tlv_bitmap |= (1 << tlv_type);
  3482. dp_process_ppdu_tag(pdev, msg_word, tlv_length, ppdu_info);
  3483. /**
  3484. * Increment pdev level tlv count to monitor
  3485. * missing TLVs
  3486. */
  3487. pdev->tlv_count++;
  3488. ppdu_info->last_tlv_cnt = pdev->tlv_count;
  3489. msg_word = (uint32_t *)((uint8_t *)tlv_buf + tlv_length);
  3490. length -= (tlv_length);
  3491. }
  3492. if (!ppdu_info)
  3493. return NULL;
  3494. pdev->last_ppdu_id = ppdu_id;
  3495. tlv_bitmap_expected = HTT_PPDU_DEFAULT_TLV_BITMAP;
  3496. if (pdev->tx_sniffer_enable || pdev->mcopy_mode ||
  3497. pdev->tx_capture_enabled) {
  3498. if (ppdu_info->is_ampdu)
  3499. tlv_bitmap_expected =
  3500. dp_htt_get_ppdu_sniffer_ampdu_tlv_bitmap(
  3501. ppdu_info->tlv_bitmap);
  3502. }
  3503. ppdu_desc = ppdu_info->ppdu_desc;
  3504. if (!ppdu_desc)
  3505. return NULL;
  3506. if (ppdu_desc->user[ppdu_desc->last_usr_index].completion_status !=
  3507. HTT_PPDU_STATS_USER_STATUS_OK) {
  3508. tlv_bitmap_expected = tlv_bitmap_expected & 0xFF;
  3509. }
  3510. /*
  3511. * for frame type DATA and BAR, we update stats based on MSDU,
  3512. * successful msdu and mpdu are populate from ACK BA STATUS TLV
  3513. * which comes out of order. successful mpdu also populated from
  3514. * COMPLTN COMMON TLV which comes in order. for every ppdu_info
  3515. * we store successful mpdu from both tlv and compare before delivering
  3516. * to make sure we received ACK BA STATUS TLV. For some self generated
  3517. * frame we won't get ack ba status tlv so no need to wait for
  3518. * ack ba status tlv.
  3519. */
  3520. if (ppdu_desc->frame_type != CDP_PPDU_FTYPE_CTRL &&
  3521. ppdu_desc->htt_frame_type != HTT_STATS_FTYPE_SGEN_QOS_NULL) {
  3522. /*
  3523. * most of the time bar frame will have duplicate ack ba
  3524. * status tlv
  3525. */
  3526. if (ppdu_desc->frame_type == CDP_PPDU_FTYPE_BAR &&
  3527. (ppdu_info->compltn_common_tlv != ppdu_info->ack_ba_tlv))
  3528. return NULL;
  3529. /*
  3530. * For data frame, compltn common tlv should match ack ba status
  3531. * tlv and completion status. Reason we are checking first user
  3532. * for ofdma, completion seen at next MU BAR frm, for mimo
  3533. * only for first user completion will be immediate.
  3534. */
  3535. if (ppdu_desc->frame_type == CDP_PPDU_FTYPE_DATA &&
  3536. (ppdu_desc->user[0].completion_status == 0 &&
  3537. (ppdu_info->compltn_common_tlv != ppdu_info->ack_ba_tlv)))
  3538. return NULL;
  3539. }
  3540. /**
  3541. * Once all the TLVs for a given PPDU has been processed,
  3542. * return PPDU status to be delivered to higher layer.
  3543. * tlv_bitmap_expected can't be available for different frame type.
  3544. * But SCHED CMD STATS TLV is the last TLV from the FW for a ppdu.
  3545. * apart from ACK BA TLV, FW sends other TLV in sequential order.
  3546. * flush tlv comes separate.
  3547. */
  3548. if ((ppdu_info->tlv_bitmap != 0 &&
  3549. (ppdu_info->tlv_bitmap &
  3550. (1 << HTT_PPDU_STATS_SCH_CMD_STATUS_TLV))) ||
  3551. (ppdu_info->tlv_bitmap &
  3552. (1 << HTT_PPDU_STATS_USR_COMPLTN_FLUSH_TLV))) {
  3553. ppdu_info->done = 1;
  3554. return ppdu_info;
  3555. }
  3556. return NULL;
  3557. }
  3558. #endif /* FEATURE_PERPKT_INFO */
  3559. /**
  3560. * dp_txrx_ppdu_stats_handler() - Function to process HTT PPDU stats from FW
  3561. * @soc: DP SOC handle
  3562. * @pdev_id: pdev id
  3563. * @htt_t2h_msg: HTT message nbuf
  3564. *
  3565. * return:void
  3566. */
  3567. #if defined(WDI_EVENT_ENABLE)
  3568. #ifdef FEATURE_PERPKT_INFO
  3569. static bool dp_txrx_ppdu_stats_handler(struct dp_soc *soc,
  3570. uint8_t pdev_id, qdf_nbuf_t htt_t2h_msg)
  3571. {
  3572. struct dp_pdev *pdev = soc->pdev_list[pdev_id];
  3573. struct ppdu_info *ppdu_info = NULL;
  3574. bool free_buf = true;
  3575. if (pdev_id >= MAX_PDEV_CNT)
  3576. return true;
  3577. pdev = soc->pdev_list[pdev_id];
  3578. if (!pdev)
  3579. return true;
  3580. if (!pdev->enhanced_stats_en && !pdev->tx_sniffer_enable &&
  3581. !pdev->mcopy_mode && !pdev->bpr_enable)
  3582. return free_buf;
  3583. ppdu_info = dp_htt_process_tlv(pdev, htt_t2h_msg);
  3584. if (pdev->mgmtctrl_frm_info.mgmt_buf) {
  3585. if (dp_process_ppdu_stats_tx_mgmtctrl_payload_tlv
  3586. (pdev, htt_t2h_msg, pdev->mgmtctrl_frm_info.ppdu_id) !=
  3587. QDF_STATUS_SUCCESS)
  3588. free_buf = false;
  3589. }
  3590. if (ppdu_info)
  3591. dp_ppdu_desc_deliver(pdev, ppdu_info);
  3592. pdev->mgmtctrl_frm_info.mgmt_buf = NULL;
  3593. pdev->mgmtctrl_frm_info.mgmt_buf_len = 0;
  3594. pdev->mgmtctrl_frm_info.ppdu_id = 0;
  3595. return free_buf;
  3596. }
  3597. #else
  3598. static bool dp_txrx_ppdu_stats_handler(struct dp_soc *soc,
  3599. uint8_t pdev_id, qdf_nbuf_t htt_t2h_msg)
  3600. {
  3601. return true;
  3602. }
  3603. #endif
  3604. #endif
  3605. /**
  3606. * dp_txrx_fw_stats_handler() - Function to process HTT EXT stats
  3607. * @soc: DP SOC handle
  3608. * @htt_t2h_msg: HTT message nbuf
  3609. *
  3610. * return:void
  3611. */
  3612. static inline void dp_txrx_fw_stats_handler(struct dp_soc *soc,
  3613. qdf_nbuf_t htt_t2h_msg)
  3614. {
  3615. uint8_t done;
  3616. qdf_nbuf_t msg_copy;
  3617. uint32_t *msg_word;
  3618. msg_word = (uint32_t *) qdf_nbuf_data(htt_t2h_msg);
  3619. msg_word = msg_word + 3;
  3620. done = HTT_T2H_EXT_STATS_CONF_TLV_DONE_GET(*msg_word);
  3621. /*
  3622. * HTT EXT stats response comes as stream of TLVs which span over
  3623. * multiple T2H messages.
  3624. * The first message will carry length of the response.
  3625. * For rest of the messages length will be zero.
  3626. *
  3627. * Clone the T2H message buffer and store it in a list to process
  3628. * it later.
  3629. *
  3630. * The original T2H message buffers gets freed in the T2H HTT event
  3631. * handler
  3632. */
  3633. msg_copy = qdf_nbuf_clone(htt_t2h_msg);
  3634. if (!msg_copy) {
  3635. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO,
  3636. "T2H messge clone failed for HTT EXT STATS");
  3637. goto error;
  3638. }
  3639. qdf_spin_lock_bh(&soc->htt_stats.lock);
  3640. qdf_nbuf_queue_add(&soc->htt_stats.msg, msg_copy);
  3641. /*
  3642. * Done bit signifies that this is the last T2H buffer in the stream of
  3643. * HTT EXT STATS message
  3644. */
  3645. if (done) {
  3646. soc->htt_stats.num_stats++;
  3647. qdf_sched_work(0, &soc->htt_stats.work);
  3648. }
  3649. qdf_spin_unlock_bh(&soc->htt_stats.lock);
  3650. return;
  3651. error:
  3652. qdf_spin_lock_bh(&soc->htt_stats.lock);
  3653. while ((msg_copy = qdf_nbuf_queue_remove(&soc->htt_stats.msg))
  3654. != NULL) {
  3655. qdf_nbuf_free(msg_copy);
  3656. }
  3657. soc->htt_stats.num_stats = 0;
  3658. qdf_spin_unlock_bh(&soc->htt_stats.lock);
  3659. return;
  3660. }
  3661. /*
  3662. * htt_soc_attach_target() - SOC level HTT setup
  3663. * @htt_soc: HTT SOC handle
  3664. *
  3665. * Return: 0 on success; error code on failure
  3666. */
  3667. int htt_soc_attach_target(struct htt_soc *htt_soc)
  3668. {
  3669. struct htt_soc *soc = (struct htt_soc *)htt_soc;
  3670. return htt_h2t_ver_req_msg(soc);
  3671. }
  3672. void htt_set_htc_handle(struct htt_soc *htt_soc, HTC_HANDLE htc_soc)
  3673. {
  3674. htt_soc->htc_soc = htc_soc;
  3675. }
  3676. HTC_HANDLE htt_get_htc_handle(struct htt_soc *htt_soc)
  3677. {
  3678. return htt_soc->htc_soc;
  3679. }
  3680. struct htt_soc *htt_soc_attach(struct dp_soc *soc, HTC_HANDLE htc_handle)
  3681. {
  3682. int i;
  3683. int j;
  3684. int alloc_size = HTT_SW_UMAC_RING_IDX_MAX * sizeof(unsigned long);
  3685. struct htt_soc *htt_soc = NULL;
  3686. htt_soc = qdf_mem_malloc(sizeof(*htt_soc));
  3687. if (!htt_soc) {
  3688. dp_err("HTT attach failed");
  3689. return NULL;
  3690. }
  3691. for (i = 0; i < MAX_PDEV_CNT; i++) {
  3692. htt_soc->pdevid_tt[i].umac_ttt = qdf_mem_malloc(alloc_size);
  3693. if (!htt_soc->pdevid_tt[i].umac_ttt)
  3694. break;
  3695. qdf_mem_set(htt_soc->pdevid_tt[i].umac_ttt, alloc_size, -1);
  3696. htt_soc->pdevid_tt[i].lmac_ttt = qdf_mem_malloc(alloc_size);
  3697. if (!htt_soc->pdevid_tt[i].lmac_ttt) {
  3698. qdf_mem_free(htt_soc->pdevid_tt[i].umac_ttt);
  3699. break;
  3700. }
  3701. qdf_mem_set(htt_soc->pdevid_tt[i].lmac_ttt, alloc_size, -1);
  3702. }
  3703. if (i != MAX_PDEV_CNT) {
  3704. for (j = 0; j < i; j++) {
  3705. qdf_mem_free(htt_soc->pdevid_tt[j].umac_ttt);
  3706. qdf_mem_free(htt_soc->pdevid_tt[j].lmac_ttt);
  3707. }
  3708. qdf_mem_free(htt_soc);
  3709. return NULL;
  3710. }
  3711. htt_soc->dp_soc = soc;
  3712. htt_soc->htc_soc = htc_handle;
  3713. HTT_TX_MUTEX_INIT(&htt_soc->htt_tx_mutex);
  3714. return htt_soc;
  3715. }
  3716. #if defined(WDI_EVENT_ENABLE) && !defined(REMOVE_PKT_LOG)
  3717. /*
  3718. * dp_ppdu_stats_ind_handler() - PPDU stats msg handler
  3719. * @htt_soc: HTT SOC handle
  3720. * @msg_word: Pointer to payload
  3721. * @htt_t2h_msg: HTT msg nbuf
  3722. *
  3723. * Return: True if buffer should be freed by caller.
  3724. */
  3725. static bool
  3726. dp_ppdu_stats_ind_handler(struct htt_soc *soc,
  3727. uint32_t *msg_word,
  3728. qdf_nbuf_t htt_t2h_msg)
  3729. {
  3730. u_int8_t pdev_id;
  3731. u_int8_t target_pdev_id;
  3732. bool free_buf;
  3733. qdf_nbuf_set_pktlen(htt_t2h_msg, HTT_T2H_MAX_MSG_SIZE);
  3734. target_pdev_id = HTT_T2H_PPDU_STATS_PDEV_ID_GET(*msg_word);
  3735. pdev_id = dp_get_host_pdev_id_for_target_pdev_id(soc->dp_soc,
  3736. target_pdev_id);
  3737. dp_wdi_event_handler(WDI_EVENT_LITE_T2H, soc->dp_soc,
  3738. htt_t2h_msg, HTT_INVALID_PEER, WDI_NO_VAL,
  3739. pdev_id);
  3740. free_buf = dp_txrx_ppdu_stats_handler(soc->dp_soc, pdev_id,
  3741. htt_t2h_msg);
  3742. return free_buf;
  3743. }
  3744. #else
  3745. static bool
  3746. dp_ppdu_stats_ind_handler(struct htt_soc *soc,
  3747. uint32_t *msg_word,
  3748. qdf_nbuf_t htt_t2h_msg)
  3749. {
  3750. return true;
  3751. }
  3752. #endif
  3753. #if defined(WDI_EVENT_ENABLE) && \
  3754. !defined(REMOVE_PKT_LOG)
  3755. /*
  3756. * dp_pktlog_msg_handler() - Pktlog msg handler
  3757. * @htt_soc: HTT SOC handle
  3758. * @msg_word: Pointer to payload
  3759. *
  3760. * Return: None
  3761. */
  3762. static void
  3763. dp_pktlog_msg_handler(struct htt_soc *soc,
  3764. uint32_t *msg_word)
  3765. {
  3766. uint8_t pdev_id;
  3767. uint8_t target_pdev_id;
  3768. uint32_t *pl_hdr;
  3769. target_pdev_id = HTT_T2H_PKTLOG_PDEV_ID_GET(*msg_word);
  3770. pdev_id = dp_get_host_pdev_id_for_target_pdev_id(soc->dp_soc,
  3771. target_pdev_id);
  3772. pl_hdr = (msg_word + 1);
  3773. dp_wdi_event_handler(WDI_EVENT_OFFLOAD_ALL, soc->dp_soc,
  3774. pl_hdr, HTT_INVALID_PEER, WDI_NO_VAL,
  3775. pdev_id);
  3776. }
  3777. #else
  3778. static void
  3779. dp_pktlog_msg_handler(struct htt_soc *soc,
  3780. uint32_t *msg_word)
  3781. {
  3782. }
  3783. #endif
  3784. /*
  3785. * time_allow_print() - time allow print
  3786. * @htt_ring_tt: ringi_id array of timestamps
  3787. * @ring_id: ring_id (index)
  3788. *
  3789. * Return: 1 for successfully saving timestamp in array
  3790. * and 0 for timestamp falling within 2 seconds after last one
  3791. */
  3792. static bool time_allow_print(unsigned long *htt_ring_tt, u_int8_t ring_id)
  3793. {
  3794. unsigned long tstamp;
  3795. unsigned long delta;
  3796. tstamp = qdf_get_system_timestamp();
  3797. if (!htt_ring_tt)
  3798. return 0; //unable to print backpressure messages
  3799. if (htt_ring_tt[ring_id] == -1) {
  3800. htt_ring_tt[ring_id] = tstamp;
  3801. return 1;
  3802. }
  3803. delta = tstamp - htt_ring_tt[ring_id];
  3804. if (delta >= 2000) {
  3805. htt_ring_tt[ring_id] = tstamp;
  3806. return 1;
  3807. }
  3808. return 0;
  3809. }
  3810. static void dp_htt_alert_print(enum htt_t2h_msg_type msg_type,
  3811. u_int8_t pdev_id, u_int8_t ring_id,
  3812. u_int16_t hp_idx, u_int16_t tp_idx,
  3813. u_int32_t bkp_time, char *ring_stype)
  3814. {
  3815. dp_alert("msg_type: %d pdev_id: %d ring_type: %s ",
  3816. msg_type, pdev_id, ring_stype);
  3817. dp_alert("ring_id: %d hp_idx: %d tp_idx: %d bkpressure_time_ms: %d ",
  3818. ring_id, hp_idx, tp_idx, bkp_time);
  3819. }
  3820. /*
  3821. * dp_htt_bkp_event_alert() - htt backpressure event alert
  3822. * @msg_word: htt packet context
  3823. * @htt_soc: HTT SOC handle
  3824. *
  3825. * Return: after attempting to print stats
  3826. */
  3827. static void dp_htt_bkp_event_alert(u_int32_t *msg_word, struct htt_soc *soc)
  3828. {
  3829. u_int8_t ring_type;
  3830. u_int8_t pdev_id;
  3831. uint8_t target_pdev_id;
  3832. u_int8_t ring_id;
  3833. u_int16_t hp_idx;
  3834. u_int16_t tp_idx;
  3835. u_int32_t bkp_time;
  3836. enum htt_t2h_msg_type msg_type;
  3837. struct dp_soc *dpsoc;
  3838. struct dp_pdev *pdev;
  3839. struct dp_htt_timestamp *radio_tt;
  3840. if (!soc)
  3841. return;
  3842. dpsoc = (struct dp_soc *)soc->dp_soc;
  3843. msg_type = HTT_T2H_MSG_TYPE_GET(*msg_word);
  3844. ring_type = HTT_T2H_RX_BKPRESSURE_RING_TYPE_GET(*msg_word);
  3845. target_pdev_id = HTT_T2H_RX_BKPRESSURE_PDEV_ID_GET(*msg_word);
  3846. pdev_id = dp_get_host_pdev_id_for_target_pdev_id(soc->dp_soc,
  3847. target_pdev_id);
  3848. if (pdev_id >= MAX_PDEV_CNT) {
  3849. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  3850. "pdev id %d is invalid", pdev_id);
  3851. return;
  3852. }
  3853. pdev = (struct dp_pdev *)dpsoc->pdev_list[pdev_id];
  3854. ring_id = HTT_T2H_RX_BKPRESSURE_RINGID_GET(*msg_word);
  3855. hp_idx = HTT_T2H_RX_BKPRESSURE_HEAD_IDX_GET(*(msg_word + 1));
  3856. tp_idx = HTT_T2H_RX_BKPRESSURE_TAIL_IDX_GET(*(msg_word + 1));
  3857. bkp_time = HTT_T2H_RX_BKPRESSURE_TIME_MS_GET(*(msg_word + 2));
  3858. radio_tt = &soc->pdevid_tt[pdev_id];
  3859. switch (ring_type) {
  3860. case HTT_SW_RING_TYPE_UMAC:
  3861. if (!time_allow_print(radio_tt->umac_ttt, ring_id))
  3862. return;
  3863. dp_htt_alert_print(msg_type, pdev_id, ring_id, hp_idx, tp_idx,
  3864. bkp_time, "HTT_SW_RING_TYPE_UMAC");
  3865. break;
  3866. case HTT_SW_RING_TYPE_LMAC:
  3867. if (!time_allow_print(radio_tt->lmac_ttt, ring_id))
  3868. return;
  3869. dp_htt_alert_print(msg_type, pdev_id, ring_id, hp_idx, tp_idx,
  3870. bkp_time, "HTT_SW_RING_TYPE_LMAC");
  3871. break;
  3872. default:
  3873. dp_htt_alert_print(msg_type, pdev_id, ring_id, hp_idx, tp_idx,
  3874. bkp_time, "UNKNOWN");
  3875. break;
  3876. }
  3877. dp_print_ring_stats(pdev);
  3878. dp_print_napi_stats(pdev->soc);
  3879. }
  3880. /*
  3881. * dp_htt_t2h_msg_handler() - Generic Target to host Msg/event handler
  3882. * @context: Opaque context (HTT SOC handle)
  3883. * @pkt: HTC packet
  3884. */
  3885. static void dp_htt_t2h_msg_handler(void *context, HTC_PACKET *pkt)
  3886. {
  3887. struct htt_soc *soc = (struct htt_soc *) context;
  3888. qdf_nbuf_t htt_t2h_msg = (qdf_nbuf_t) pkt->pPktContext;
  3889. u_int32_t *msg_word;
  3890. enum htt_t2h_msg_type msg_type;
  3891. bool free_buf = true;
  3892. /* check for successful message reception */
  3893. if (pkt->Status != QDF_STATUS_SUCCESS) {
  3894. if (pkt->Status != QDF_STATUS_E_CANCELED)
  3895. soc->stats.htc_err_cnt++;
  3896. qdf_nbuf_free(htt_t2h_msg);
  3897. return;
  3898. }
  3899. /* TODO: Check if we should pop the HTC/HTT header alignment padding */
  3900. msg_word = (u_int32_t *) qdf_nbuf_data(htt_t2h_msg);
  3901. msg_type = HTT_T2H_MSG_TYPE_GET(*msg_word);
  3902. htt_event_record(soc->htt_logger_handle,
  3903. msg_type, (uint8_t *)msg_word);
  3904. switch (msg_type) {
  3905. case HTT_T2H_MSG_TYPE_BKPRESSURE_EVENT_IND:
  3906. {
  3907. dp_htt_bkp_event_alert(msg_word, soc);
  3908. break;
  3909. }
  3910. case HTT_T2H_MSG_TYPE_PEER_MAP:
  3911. {
  3912. u_int8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  3913. u_int8_t *peer_mac_addr;
  3914. u_int16_t peer_id;
  3915. u_int16_t hw_peer_id;
  3916. u_int8_t vdev_id;
  3917. u_int8_t is_wds;
  3918. struct dp_soc *dpsoc = (struct dp_soc *)soc->dp_soc;
  3919. peer_id = HTT_RX_PEER_MAP_PEER_ID_GET(*msg_word);
  3920. hw_peer_id =
  3921. HTT_RX_PEER_MAP_HW_PEER_ID_GET(*(msg_word+2));
  3922. vdev_id = HTT_RX_PEER_MAP_VDEV_ID_GET(*msg_word);
  3923. peer_mac_addr = htt_t2h_mac_addr_deswizzle(
  3924. (u_int8_t *) (msg_word+1),
  3925. &mac_addr_deswizzle_buf[0]);
  3926. QDF_TRACE(QDF_MODULE_ID_TXRX,
  3927. QDF_TRACE_LEVEL_INFO,
  3928. "HTT_T2H_MSG_TYPE_PEER_MAP msg for peer id %d vdev id %d n",
  3929. peer_id, vdev_id);
  3930. /*
  3931. * check if peer already exists for this peer_id, if so
  3932. * this peer map event is in response for a wds peer add
  3933. * wmi command sent during wds source port learning.
  3934. * in this case just add the ast entry to the existing
  3935. * peer ast_list.
  3936. */
  3937. is_wds = !!(dpsoc->peer_id_to_obj_map[peer_id]);
  3938. dp_rx_peer_map_handler(soc->dp_soc, peer_id, hw_peer_id,
  3939. vdev_id, peer_mac_addr, 0,
  3940. is_wds);
  3941. break;
  3942. }
  3943. case HTT_T2H_MSG_TYPE_PEER_UNMAP:
  3944. {
  3945. u_int16_t peer_id;
  3946. u_int8_t vdev_id;
  3947. u_int8_t mac_addr[QDF_MAC_ADDR_SIZE] = {0};
  3948. peer_id = HTT_RX_PEER_UNMAP_PEER_ID_GET(*msg_word);
  3949. vdev_id = HTT_RX_PEER_UNMAP_VDEV_ID_GET(*msg_word);
  3950. dp_rx_peer_unmap_handler(soc->dp_soc, peer_id,
  3951. vdev_id, mac_addr, 0,
  3952. DP_PEER_WDS_COUNT_INVALID);
  3953. break;
  3954. }
  3955. case HTT_T2H_MSG_TYPE_SEC_IND:
  3956. {
  3957. u_int16_t peer_id;
  3958. enum cdp_sec_type sec_type;
  3959. int is_unicast;
  3960. peer_id = HTT_SEC_IND_PEER_ID_GET(*msg_word);
  3961. sec_type = HTT_SEC_IND_SEC_TYPE_GET(*msg_word);
  3962. is_unicast = HTT_SEC_IND_UNICAST_GET(*msg_word);
  3963. /* point to the first part of the Michael key */
  3964. msg_word++;
  3965. dp_rx_sec_ind_handler(
  3966. soc->dp_soc, peer_id, sec_type, is_unicast,
  3967. msg_word, msg_word + 2);
  3968. break;
  3969. }
  3970. case HTT_T2H_MSG_TYPE_PPDU_STATS_IND:
  3971. {
  3972. free_buf = dp_ppdu_stats_ind_handler(soc, msg_word,
  3973. htt_t2h_msg);
  3974. break;
  3975. }
  3976. case HTT_T2H_MSG_TYPE_PKTLOG:
  3977. {
  3978. dp_pktlog_msg_handler(soc, msg_word);
  3979. break;
  3980. }
  3981. case HTT_T2H_MSG_TYPE_VERSION_CONF:
  3982. {
  3983. htc_pm_runtime_put(soc->htc_soc);
  3984. soc->tgt_ver.major = HTT_VER_CONF_MAJOR_GET(*msg_word);
  3985. soc->tgt_ver.minor = HTT_VER_CONF_MINOR_GET(*msg_word);
  3986. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_LOW,
  3987. "target uses HTT version %d.%d; host uses %d.%d",
  3988. soc->tgt_ver.major, soc->tgt_ver.minor,
  3989. HTT_CURRENT_VERSION_MAJOR,
  3990. HTT_CURRENT_VERSION_MINOR);
  3991. if (soc->tgt_ver.major != HTT_CURRENT_VERSION_MAJOR) {
  3992. QDF_TRACE(QDF_MODULE_ID_TXRX,
  3993. QDF_TRACE_LEVEL_WARN,
  3994. "*** Incompatible host/target HTT versions!");
  3995. }
  3996. /* abort if the target is incompatible with the host */
  3997. qdf_assert(soc->tgt_ver.major ==
  3998. HTT_CURRENT_VERSION_MAJOR);
  3999. if (soc->tgt_ver.minor != HTT_CURRENT_VERSION_MINOR) {
  4000. QDF_TRACE(QDF_MODULE_ID_TXRX,
  4001. QDF_TRACE_LEVEL_INFO_LOW,
  4002. "*** Warning: host/target HTT versions"
  4003. " are different, though compatible!");
  4004. }
  4005. break;
  4006. }
  4007. case HTT_T2H_MSG_TYPE_RX_ADDBA:
  4008. {
  4009. uint16_t peer_id;
  4010. uint8_t tid;
  4011. uint8_t win_sz;
  4012. uint16_t status;
  4013. struct dp_peer *peer;
  4014. /*
  4015. * Update REO Queue Desc with new values
  4016. */
  4017. peer_id = HTT_RX_ADDBA_PEER_ID_GET(*msg_word);
  4018. tid = HTT_RX_ADDBA_TID_GET(*msg_word);
  4019. win_sz = HTT_RX_ADDBA_WIN_SIZE_GET(*msg_word);
  4020. peer = dp_peer_get_ref_by_id(soc->dp_soc, peer_id,
  4021. DP_MOD_ID_HTT);
  4022. /*
  4023. * Window size needs to be incremented by 1
  4024. * since fw needs to represent a value of 256
  4025. * using just 8 bits
  4026. */
  4027. if (peer) {
  4028. status = dp_addba_requestprocess_wifi3(
  4029. (struct cdp_soc_t *)soc->dp_soc,
  4030. peer->mac_addr.raw, peer->vdev->vdev_id,
  4031. 0, tid, 0, win_sz + 1, 0xffff);
  4032. /*
  4033. * If PEER_LOCK_REF_PROTECT enbled dec ref
  4034. * which is inc by dp_peer_get_ref_by_id
  4035. */
  4036. dp_peer_unref_delete(peer, DP_MOD_ID_HTT);
  4037. QDF_TRACE(QDF_MODULE_ID_TXRX,
  4038. QDF_TRACE_LEVEL_INFO,
  4039. FL("PeerID %d BAW %d TID %d stat %d"),
  4040. peer_id, win_sz, tid, status);
  4041. } else {
  4042. QDF_TRACE(QDF_MODULE_ID_TXRX,
  4043. QDF_TRACE_LEVEL_ERROR,
  4044. FL("Peer not found peer id %d"),
  4045. peer_id);
  4046. }
  4047. break;
  4048. }
  4049. case HTT_T2H_MSG_TYPE_EXT_STATS_CONF:
  4050. {
  4051. dp_txrx_fw_stats_handler(soc->dp_soc, htt_t2h_msg);
  4052. break;
  4053. }
  4054. case HTT_T2H_MSG_TYPE_PEER_MAP_V2:
  4055. {
  4056. u_int8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  4057. u_int8_t *peer_mac_addr;
  4058. u_int16_t peer_id;
  4059. u_int16_t hw_peer_id;
  4060. u_int8_t vdev_id;
  4061. bool is_wds;
  4062. u_int16_t ast_hash;
  4063. struct dp_ast_flow_override_info ast_flow_info;
  4064. qdf_mem_set(&ast_flow_info, 0,
  4065. sizeof(struct dp_ast_flow_override_info));
  4066. peer_id = HTT_RX_PEER_MAP_V2_SW_PEER_ID_GET(*msg_word);
  4067. hw_peer_id =
  4068. HTT_RX_PEER_MAP_V2_HW_PEER_ID_GET(*(msg_word + 2));
  4069. vdev_id = HTT_RX_PEER_MAP_V2_VDEV_ID_GET(*msg_word);
  4070. peer_mac_addr =
  4071. htt_t2h_mac_addr_deswizzle((u_int8_t *)(msg_word + 1),
  4072. &mac_addr_deswizzle_buf[0]);
  4073. is_wds =
  4074. HTT_RX_PEER_MAP_V2_NEXT_HOP_GET(*(msg_word + 3));
  4075. ast_hash =
  4076. HTT_RX_PEER_MAP_V2_AST_HASH_VALUE_GET(*(msg_word + 3));
  4077. /*
  4078. * Update 4 ast_index per peer, ast valid mask
  4079. * and TID flow valid mask.
  4080. * AST valid mask is 3 bit field corresponds to
  4081. * ast_index[3:1]. ast_index 0 is always valid.
  4082. */
  4083. ast_flow_info.ast_valid_mask =
  4084. HTT_RX_PEER_MAP_V2_AST_VALID_MASK_GET(*(msg_word + 3));
  4085. ast_flow_info.ast_idx[0] = hw_peer_id;
  4086. ast_flow_info.ast_flow_mask[0] =
  4087. HTT_RX_PEER_MAP_V2_AST_0_FLOW_MASK_GET(*(msg_word + 4));
  4088. ast_flow_info.ast_idx[1] =
  4089. HTT_RX_PEER_MAP_V2_AST_INDEX_1_GET(*(msg_word + 4));
  4090. ast_flow_info.ast_flow_mask[1] =
  4091. HTT_RX_PEER_MAP_V2_AST_1_FLOW_MASK_GET(*(msg_word + 4));
  4092. ast_flow_info.ast_idx[2] =
  4093. HTT_RX_PEER_MAP_V2_AST_INDEX_2_GET(*(msg_word + 5));
  4094. ast_flow_info.ast_flow_mask[2] =
  4095. HTT_RX_PEER_MAP_V2_AST_2_FLOW_MASK_GET(*(msg_word + 4));
  4096. ast_flow_info.ast_idx[3] =
  4097. HTT_RX_PEER_MAP_V2_AST_INDEX_3_GET(*(msg_word + 6));
  4098. ast_flow_info.ast_flow_mask[3] =
  4099. HTT_RX_PEER_MAP_V2_AST_3_FLOW_MASK_GET(*(msg_word + 4));
  4100. /*
  4101. * TID valid mask is applicable only
  4102. * for HI and LOW priority flows.
  4103. * tid_valid_mas is 8 bit field corresponds
  4104. * to TID[7:0]
  4105. */
  4106. ast_flow_info.tid_valid_low_pri_mask =
  4107. HTT_RX_PEER_MAP_V2_TID_VALID_LOW_PRI_GET(*(msg_word + 5));
  4108. ast_flow_info.tid_valid_hi_pri_mask =
  4109. HTT_RX_PEER_MAP_V2_TID_VALID_HI_PRI_GET(*(msg_word + 5));
  4110. QDF_TRACE(QDF_MODULE_ID_TXRX,
  4111. QDF_TRACE_LEVEL_INFO,
  4112. "HTT_T2H_MSG_TYPE_PEER_MAP msg for peer id %d vdev id %d n",
  4113. peer_id, vdev_id);
  4114. dp_rx_peer_map_handler(soc->dp_soc, peer_id,
  4115. hw_peer_id, vdev_id,
  4116. peer_mac_addr, ast_hash,
  4117. is_wds);
  4118. /*
  4119. * Update ast indexes for flow override support
  4120. * Applicable only for non wds peers
  4121. */
  4122. dp_peer_ast_index_flow_queue_map_create(
  4123. soc->dp_soc, is_wds,
  4124. peer_id, peer_mac_addr,
  4125. &ast_flow_info);
  4126. break;
  4127. }
  4128. case HTT_T2H_MSG_TYPE_PEER_UNMAP_V2:
  4129. {
  4130. u_int8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  4131. u_int8_t *mac_addr;
  4132. u_int16_t peer_id;
  4133. u_int8_t vdev_id;
  4134. u_int8_t is_wds;
  4135. u_int32_t free_wds_count;
  4136. peer_id =
  4137. HTT_RX_PEER_UNMAP_V2_SW_PEER_ID_GET(*msg_word);
  4138. vdev_id = HTT_RX_PEER_UNMAP_V2_VDEV_ID_GET(*msg_word);
  4139. mac_addr =
  4140. htt_t2h_mac_addr_deswizzle((u_int8_t *)(msg_word + 1),
  4141. &mac_addr_deswizzle_buf[0]);
  4142. is_wds =
  4143. HTT_RX_PEER_UNMAP_V2_NEXT_HOP_GET(*(msg_word + 2));
  4144. free_wds_count =
  4145. HTT_RX_PEER_UNMAP_V2_PEER_WDS_FREE_COUNT_GET(*(msg_word + 4));
  4146. QDF_TRACE(QDF_MODULE_ID_TXRX,
  4147. QDF_TRACE_LEVEL_INFO,
  4148. "HTT_T2H_MSG_TYPE_PEER_UNMAP msg for peer id %d vdev id %d n",
  4149. peer_id, vdev_id);
  4150. dp_rx_peer_unmap_handler(soc->dp_soc, peer_id,
  4151. vdev_id, mac_addr,
  4152. is_wds, free_wds_count);
  4153. break;
  4154. }
  4155. case HTT_T2H_MSG_TYPE_RX_DELBA:
  4156. {
  4157. uint16_t peer_id;
  4158. uint8_t tid;
  4159. uint8_t win_sz;
  4160. QDF_STATUS status;
  4161. peer_id = HTT_RX_DELBA_PEER_ID_GET(*msg_word);
  4162. tid = HTT_RX_DELBA_TID_GET(*msg_word);
  4163. win_sz = HTT_RX_DELBA_WIN_SIZE_GET(*msg_word);
  4164. status = dp_rx_delba_ind_handler(
  4165. soc->dp_soc,
  4166. peer_id, tid, win_sz);
  4167. QDF_TRACE(QDF_MODULE_ID_TXRX,
  4168. QDF_TRACE_LEVEL_INFO,
  4169. FL("DELBA PeerID %d BAW %d TID %d stat %d"),
  4170. peer_id, win_sz, tid, status);
  4171. break;
  4172. }
  4173. default:
  4174. break;
  4175. };
  4176. /* Free the indication buffer */
  4177. if (free_buf)
  4178. qdf_nbuf_free(htt_t2h_msg);
  4179. }
  4180. /*
  4181. * dp_htt_h2t_full() - Send full handler (called from HTC)
  4182. * @context: Opaque context (HTT SOC handle)
  4183. * @pkt: HTC packet
  4184. *
  4185. * Return: enum htc_send_full_action
  4186. */
  4187. static enum htc_send_full_action
  4188. dp_htt_h2t_full(void *context, HTC_PACKET *pkt)
  4189. {
  4190. return HTC_SEND_FULL_KEEP;
  4191. }
  4192. /*
  4193. * dp_htt_hif_t2h_hp_callback() - HIF callback for high priority T2H messages
  4194. * @context: Opaque context (HTT SOC handle)
  4195. * @nbuf: nbuf containing T2H message
  4196. * @pipe_id: HIF pipe ID
  4197. *
  4198. * Return: QDF_STATUS
  4199. *
  4200. * TODO: Temporary change to bypass HTC connection for this new HIF pipe, which
  4201. * will be used for packet log and other high-priority HTT messages. Proper
  4202. * HTC connection to be added later once required FW changes are available
  4203. */
  4204. static QDF_STATUS
  4205. dp_htt_hif_t2h_hp_callback (void *context, qdf_nbuf_t nbuf, uint8_t pipe_id)
  4206. {
  4207. QDF_STATUS rc = QDF_STATUS_SUCCESS;
  4208. HTC_PACKET htc_pkt;
  4209. qdf_assert_always(pipe_id == DP_HTT_T2H_HP_PIPE);
  4210. qdf_mem_zero(&htc_pkt, sizeof(htc_pkt));
  4211. htc_pkt.Status = QDF_STATUS_SUCCESS;
  4212. htc_pkt.pPktContext = (void *)nbuf;
  4213. dp_htt_t2h_msg_handler(context, &htc_pkt);
  4214. return rc;
  4215. }
  4216. /*
  4217. * htt_htc_soc_attach() - Register SOC level HTT instance with HTC
  4218. * @htt_soc: HTT SOC handle
  4219. *
  4220. * Return: QDF_STATUS
  4221. */
  4222. static QDF_STATUS
  4223. htt_htc_soc_attach(struct htt_soc *soc)
  4224. {
  4225. struct htc_service_connect_req connect;
  4226. struct htc_service_connect_resp response;
  4227. QDF_STATUS status;
  4228. struct dp_soc *dpsoc = soc->dp_soc;
  4229. qdf_mem_zero(&connect, sizeof(connect));
  4230. qdf_mem_zero(&response, sizeof(response));
  4231. connect.pMetaData = NULL;
  4232. connect.MetaDataLength = 0;
  4233. connect.EpCallbacks.pContext = soc;
  4234. connect.EpCallbacks.EpTxComplete = dp_htt_h2t_send_complete;
  4235. connect.EpCallbacks.EpTxCompleteMultiple = NULL;
  4236. connect.EpCallbacks.EpRecv = dp_htt_t2h_msg_handler;
  4237. /* rx buffers currently are provided by HIF, not by EpRecvRefill */
  4238. connect.EpCallbacks.EpRecvRefill = NULL;
  4239. /* N/A, fill is done by HIF */
  4240. connect.EpCallbacks.RecvRefillWaterMark = 1;
  4241. connect.EpCallbacks.EpSendFull = dp_htt_h2t_full;
  4242. /*
  4243. * Specify how deep to let a queue get before htc_send_pkt will
  4244. * call the EpSendFull function due to excessive send queue depth.
  4245. */
  4246. connect.MaxSendQueueDepth = DP_HTT_MAX_SEND_QUEUE_DEPTH;
  4247. /* disable flow control for HTT data message service */
  4248. connect.ConnectionFlags |= HTC_CONNECT_FLAGS_DISABLE_CREDIT_FLOW_CTRL;
  4249. /* connect to control service */
  4250. connect.service_id = HTT_DATA_MSG_SVC;
  4251. status = htc_connect_service(soc->htc_soc, &connect, &response);
  4252. if (status != QDF_STATUS_SUCCESS)
  4253. return status;
  4254. soc->htc_endpoint = response.Endpoint;
  4255. hif_save_htc_htt_config_endpoint(dpsoc->hif_handle, soc->htc_endpoint);
  4256. htt_interface_logging_init(&soc->htt_logger_handle);
  4257. dp_hif_update_pipe_callback(soc->dp_soc, (void *)soc,
  4258. dp_htt_hif_t2h_hp_callback, DP_HTT_T2H_HP_PIPE);
  4259. return QDF_STATUS_SUCCESS; /* success */
  4260. }
  4261. /*
  4262. * htt_soc_initialize() - SOC level HTT initialization
  4263. * @htt_soc: Opaque htt SOC handle
  4264. * @ctrl_psoc: Opaque ctrl SOC handle
  4265. * @htc_soc: SOC level HTC handle
  4266. * @hal_soc: Opaque HAL SOC handle
  4267. * @osdev: QDF device
  4268. *
  4269. * Return: HTT handle on success; NULL on failure
  4270. */
  4271. void *
  4272. htt_soc_initialize(struct htt_soc *htt_soc,
  4273. struct cdp_ctrl_objmgr_psoc *ctrl_psoc,
  4274. HTC_HANDLE htc_soc,
  4275. hal_soc_handle_t hal_soc_hdl, qdf_device_t osdev)
  4276. {
  4277. struct htt_soc *soc = (struct htt_soc *)htt_soc;
  4278. soc->osdev = osdev;
  4279. soc->ctrl_psoc = ctrl_psoc;
  4280. soc->htc_soc = htc_soc;
  4281. soc->hal_soc = hal_soc_hdl;
  4282. if (htt_htc_soc_attach(soc))
  4283. goto fail2;
  4284. return soc;
  4285. fail2:
  4286. return NULL;
  4287. }
  4288. void htt_soc_htc_dealloc(struct htt_soc *htt_handle)
  4289. {
  4290. htt_interface_logging_deinit(htt_handle->htt_logger_handle);
  4291. htt_htc_misc_pkt_pool_free(htt_handle);
  4292. htt_htc_pkt_pool_free(htt_handle);
  4293. }
  4294. /*
  4295. * htt_soc_htc_prealloc() - HTC memory prealloc
  4296. * @htt_soc: SOC level HTT handle
  4297. *
  4298. * Return: QDF_STATUS_SUCCESS on Success or
  4299. * QDF_STATUS_E_NOMEM on allocation failure
  4300. */
  4301. QDF_STATUS htt_soc_htc_prealloc(struct htt_soc *soc)
  4302. {
  4303. int i;
  4304. soc->htt_htc_pkt_freelist = NULL;
  4305. /* pre-allocate some HTC_PACKET objects */
  4306. for (i = 0; i < HTT_HTC_PKT_POOL_INIT_SIZE; i++) {
  4307. struct dp_htt_htc_pkt_union *pkt;
  4308. pkt = qdf_mem_malloc(sizeof(*pkt));
  4309. if (!pkt)
  4310. return QDF_STATUS_E_NOMEM;
  4311. htt_htc_pkt_free(soc, &pkt->u.pkt);
  4312. }
  4313. return QDF_STATUS_SUCCESS;
  4314. }
  4315. /*
  4316. * htt_soc_detach() - Free SOC level HTT handle
  4317. * @htt_hdl: HTT SOC handle
  4318. */
  4319. void htt_soc_detach(struct htt_soc *htt_hdl)
  4320. {
  4321. int i;
  4322. struct htt_soc *htt_handle = (struct htt_soc *)htt_hdl;
  4323. for (i = 0; i < MAX_PDEV_CNT; i++) {
  4324. qdf_mem_free(htt_handle->pdevid_tt[i].umac_ttt);
  4325. qdf_mem_free(htt_handle->pdevid_tt[i].lmac_ttt);
  4326. }
  4327. HTT_TX_MUTEX_DESTROY(&htt_handle->htt_tx_mutex);
  4328. qdf_mem_free(htt_handle);
  4329. }
  4330. /**
  4331. * dp_h2t_ext_stats_msg_send(): function to contruct HTT message to pass to FW
  4332. * @pdev: DP PDEV handle
  4333. * @stats_type_upload_mask: stats type requested by user
  4334. * @config_param_0: extra configuration parameters
  4335. * @config_param_1: extra configuration parameters
  4336. * @config_param_2: extra configuration parameters
  4337. * @config_param_3: extra configuration parameters
  4338. * @mac_id: mac number
  4339. *
  4340. * return: QDF STATUS
  4341. */
  4342. QDF_STATUS dp_h2t_ext_stats_msg_send(struct dp_pdev *pdev,
  4343. uint32_t stats_type_upload_mask, uint32_t config_param_0,
  4344. uint32_t config_param_1, uint32_t config_param_2,
  4345. uint32_t config_param_3, int cookie_val, int cookie_msb,
  4346. uint8_t mac_id)
  4347. {
  4348. struct htt_soc *soc = pdev->soc->htt_handle;
  4349. struct dp_htt_htc_pkt *pkt;
  4350. qdf_nbuf_t msg;
  4351. uint32_t *msg_word;
  4352. uint8_t pdev_mask = 0;
  4353. uint8_t *htt_logger_bufp;
  4354. int mac_for_pdev;
  4355. int target_pdev_id;
  4356. QDF_STATUS status;
  4357. msg = qdf_nbuf_alloc(
  4358. soc->osdev,
  4359. HTT_MSG_BUF_SIZE(HTT_H2T_EXT_STATS_REQ_MSG_SZ),
  4360. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  4361. if (!msg)
  4362. return QDF_STATUS_E_NOMEM;
  4363. /*TODO:Add support for SOC stats
  4364. * Bit 0: SOC Stats
  4365. * Bit 1: Pdev stats for pdev id 0
  4366. * Bit 2: Pdev stats for pdev id 1
  4367. * Bit 3: Pdev stats for pdev id 2
  4368. */
  4369. mac_for_pdev = dp_get_mac_id_for_pdev(mac_id, pdev->pdev_id);
  4370. target_pdev_id =
  4371. dp_get_target_pdev_id_for_host_pdev_id(pdev->soc, mac_for_pdev);
  4372. pdev_mask = 1 << target_pdev_id;
  4373. /*
  4374. * Set the length of the message.
  4375. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4376. * separately during the below call to qdf_nbuf_push_head.
  4377. * The contribution from the HTC header is added separately inside HTC.
  4378. */
  4379. if (qdf_nbuf_put_tail(msg, HTT_H2T_EXT_STATS_REQ_MSG_SZ) == NULL) {
  4380. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  4381. "Failed to expand head for HTT_EXT_STATS");
  4382. qdf_nbuf_free(msg);
  4383. return QDF_STATUS_E_FAILURE;
  4384. }
  4385. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  4386. "-----%s:%d----\n cookie <-> %d\n config_param_0 %u\n"
  4387. "config_param_1 %u\n config_param_2 %u\n"
  4388. "config_param_4 %u\n -------------",
  4389. __func__, __LINE__, cookie_val, config_param_0,
  4390. config_param_1, config_param_2, config_param_3);
  4391. msg_word = (uint32_t *) qdf_nbuf_data(msg);
  4392. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4393. htt_logger_bufp = (uint8_t *)msg_word;
  4394. *msg_word = 0;
  4395. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_EXT_STATS_REQ);
  4396. HTT_H2T_EXT_STATS_REQ_PDEV_MASK_SET(*msg_word, pdev_mask);
  4397. HTT_H2T_EXT_STATS_REQ_STATS_TYPE_SET(*msg_word, stats_type_upload_mask);
  4398. /* word 1 */
  4399. msg_word++;
  4400. *msg_word = 0;
  4401. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_0);
  4402. /* word 2 */
  4403. msg_word++;
  4404. *msg_word = 0;
  4405. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_1);
  4406. /* word 3 */
  4407. msg_word++;
  4408. *msg_word = 0;
  4409. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_2);
  4410. /* word 4 */
  4411. msg_word++;
  4412. *msg_word = 0;
  4413. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_3);
  4414. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, 0);
  4415. /* word 5 */
  4416. msg_word++;
  4417. /* word 6 */
  4418. msg_word++;
  4419. *msg_word = 0;
  4420. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, cookie_val);
  4421. /* word 7 */
  4422. msg_word++;
  4423. *msg_word = 0;
  4424. /*Using last 2 bits for pdev_id */
  4425. cookie_msb = ((cookie_msb << 2) | pdev->pdev_id);
  4426. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, cookie_msb);
  4427. pkt = htt_htc_pkt_alloc(soc);
  4428. if (!pkt) {
  4429. qdf_nbuf_free(msg);
  4430. return QDF_STATUS_E_NOMEM;
  4431. }
  4432. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4433. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  4434. dp_htt_h2t_send_complete_free_netbuf,
  4435. qdf_nbuf_data(msg), qdf_nbuf_len(msg),
  4436. soc->htc_endpoint,
  4437. /* tag for FW response msg not guaranteed */
  4438. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4439. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4440. status = DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_EXT_STATS_REQ,
  4441. htt_logger_bufp);
  4442. if (status != QDF_STATUS_SUCCESS) {
  4443. qdf_nbuf_free(msg);
  4444. htt_htc_pkt_free(soc, pkt);
  4445. }
  4446. return status;
  4447. }
  4448. /**
  4449. * dp_h2t_3tuple_config_send(): function to contruct 3 tuple configuration
  4450. * HTT message to pass to FW
  4451. * @pdev: DP PDEV handle
  4452. * @tuple_mask: tuple configuration to report 3 tuple hash value in either
  4453. * toeplitz_2_or_4 or flow_id_toeplitz in MSDU START TLV.
  4454. *
  4455. * tuple_mask[1:0]:
  4456. * 00 - Do not report 3 tuple hash value
  4457. * 10 - Report 3 tuple hash value in toeplitz_2_or_4
  4458. * 01 - Report 3 tuple hash value in flow_id_toeplitz
  4459. * 11 - Report 3 tuple hash value in both toeplitz_2_or_4 & flow_id_toeplitz
  4460. *
  4461. * return: QDF STATUS
  4462. */
  4463. QDF_STATUS dp_h2t_3tuple_config_send(struct dp_pdev *pdev,
  4464. uint32_t tuple_mask, uint8_t mac_id)
  4465. {
  4466. struct htt_soc *soc = pdev->soc->htt_handle;
  4467. struct dp_htt_htc_pkt *pkt;
  4468. qdf_nbuf_t msg;
  4469. uint32_t *msg_word;
  4470. uint8_t *htt_logger_bufp;
  4471. int mac_for_pdev;
  4472. int target_pdev_id;
  4473. msg = qdf_nbuf_alloc(
  4474. soc->osdev,
  4475. HTT_MSG_BUF_SIZE(HTT_3_TUPLE_HASH_CFG_REQ_BYTES),
  4476. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  4477. if (!msg)
  4478. return QDF_STATUS_E_NOMEM;
  4479. mac_for_pdev = dp_get_mac_id_for_pdev(mac_id, pdev->pdev_id);
  4480. target_pdev_id =
  4481. dp_get_target_pdev_id_for_host_pdev_id(pdev->soc, mac_for_pdev);
  4482. /*
  4483. * Set the length of the message.
  4484. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4485. * separately during the below call to qdf_nbuf_push_head.
  4486. * The contribution from the HTC header is added separately inside HTC.
  4487. */
  4488. if (!qdf_nbuf_put_tail(msg, HTT_3_TUPLE_HASH_CFG_REQ_BYTES)) {
  4489. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  4490. "Failed to expand head for HTT_3TUPLE_CONFIG");
  4491. qdf_nbuf_free(msg);
  4492. return QDF_STATUS_E_FAILURE;
  4493. }
  4494. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  4495. "config_param_sent %s:%d 0x%x for target_pdev %d\n -------------",
  4496. __func__, __LINE__, tuple_mask, target_pdev_id);
  4497. msg_word = (uint32_t *)qdf_nbuf_data(msg);
  4498. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4499. htt_logger_bufp = (uint8_t *)msg_word;
  4500. *msg_word = 0;
  4501. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_3_TUPLE_HASH_CFG);
  4502. HTT_RX_3_TUPLE_HASH_PDEV_ID_SET(*msg_word, target_pdev_id);
  4503. msg_word++;
  4504. *msg_word = 0;
  4505. HTT_H2T_FLOW_ID_TOEPLITZ_FIELD_CONFIG_SET(*msg_word, tuple_mask);
  4506. HTT_H2T_TOEPLITZ_2_OR_4_FIELD_CONFIG_SET(*msg_word, tuple_mask);
  4507. pkt = htt_htc_pkt_alloc(soc);
  4508. if (!pkt) {
  4509. qdf_nbuf_free(msg);
  4510. return QDF_STATUS_E_NOMEM;
  4511. }
  4512. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4513. SET_HTC_PACKET_INFO_TX(
  4514. &pkt->htc_pkt,
  4515. dp_htt_h2t_send_complete_free_netbuf,
  4516. qdf_nbuf_data(msg),
  4517. qdf_nbuf_len(msg),
  4518. soc->htc_endpoint,
  4519. /* tag for no FW response msg */
  4520. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4521. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4522. DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_3_TUPLE_HASH_CFG,
  4523. htt_logger_bufp);
  4524. return QDF_STATUS_SUCCESS;
  4525. }
  4526. /* This macro will revert once proper HTT header will define for
  4527. * HTT_H2T_MSG_TYPE_PPDU_STATS_CFG in htt.h file
  4528. * */
  4529. #if defined(WDI_EVENT_ENABLE)
  4530. /**
  4531. * dp_h2t_cfg_stats_msg_send(): function to construct HTT message to pass to FW
  4532. * @pdev: DP PDEV handle
  4533. * @stats_type_upload_mask: stats type requested by user
  4534. * @mac_id: Mac id number
  4535. *
  4536. * return: QDF STATUS
  4537. */
  4538. QDF_STATUS dp_h2t_cfg_stats_msg_send(struct dp_pdev *pdev,
  4539. uint32_t stats_type_upload_mask, uint8_t mac_id)
  4540. {
  4541. struct htt_soc *soc = pdev->soc->htt_handle;
  4542. struct dp_htt_htc_pkt *pkt;
  4543. qdf_nbuf_t msg;
  4544. uint32_t *msg_word;
  4545. uint8_t pdev_mask;
  4546. QDF_STATUS status;
  4547. msg = qdf_nbuf_alloc(
  4548. soc->osdev,
  4549. HTT_MSG_BUF_SIZE(HTT_H2T_PPDU_STATS_CFG_MSG_SZ),
  4550. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, true);
  4551. if (!msg) {
  4552. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  4553. "Fail to allocate HTT_H2T_PPDU_STATS_CFG_MSG_SZ msg buffer");
  4554. qdf_assert(0);
  4555. return QDF_STATUS_E_NOMEM;
  4556. }
  4557. /*TODO:Add support for SOC stats
  4558. * Bit 0: SOC Stats
  4559. * Bit 1: Pdev stats for pdev id 0
  4560. * Bit 2: Pdev stats for pdev id 1
  4561. * Bit 3: Pdev stats for pdev id 2
  4562. */
  4563. pdev_mask = 1 << dp_get_target_pdev_id_for_host_pdev_id(pdev->soc,
  4564. mac_id);
  4565. /*
  4566. * Set the length of the message.
  4567. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4568. * separately during the below call to qdf_nbuf_push_head.
  4569. * The contribution from the HTC header is added separately inside HTC.
  4570. */
  4571. if (qdf_nbuf_put_tail(msg, HTT_H2T_PPDU_STATS_CFG_MSG_SZ) == NULL) {
  4572. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  4573. "Failed to expand head for HTT_CFG_STATS");
  4574. qdf_nbuf_free(msg);
  4575. return QDF_STATUS_E_FAILURE;
  4576. }
  4577. msg_word = (uint32_t *) qdf_nbuf_data(msg);
  4578. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4579. *msg_word = 0;
  4580. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_PPDU_STATS_CFG);
  4581. HTT_H2T_PPDU_STATS_CFG_PDEV_MASK_SET(*msg_word, pdev_mask);
  4582. HTT_H2T_PPDU_STATS_CFG_TLV_BITMASK_SET(*msg_word,
  4583. stats_type_upload_mask);
  4584. pkt = htt_htc_pkt_alloc(soc);
  4585. if (!pkt) {
  4586. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  4587. "Fail to allocate dp_htt_htc_pkt buffer");
  4588. qdf_assert(0);
  4589. qdf_nbuf_free(msg);
  4590. return QDF_STATUS_E_NOMEM;
  4591. }
  4592. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4593. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  4594. dp_htt_h2t_send_complete_free_netbuf,
  4595. qdf_nbuf_data(msg), qdf_nbuf_len(msg),
  4596. soc->htc_endpoint,
  4597. /* tag for no FW response msg */
  4598. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4599. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4600. status = DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_PPDU_STATS_CFG,
  4601. (uint8_t *)msg_word);
  4602. if (status != QDF_STATUS_SUCCESS) {
  4603. qdf_nbuf_free(msg);
  4604. htt_htc_pkt_free(soc, pkt);
  4605. }
  4606. return status;
  4607. }
  4608. #endif
  4609. void
  4610. dp_peer_update_inactive_time(struct dp_pdev *pdev, uint32_t tag_type,
  4611. uint32_t *tag_buf)
  4612. {
  4613. struct dp_peer *peer = NULL;
  4614. switch (tag_type) {
  4615. case HTT_STATS_PEER_DETAILS_TAG:
  4616. {
  4617. htt_peer_details_tlv *dp_stats_buf =
  4618. (htt_peer_details_tlv *)tag_buf;
  4619. pdev->fw_stats_peer_id = dp_stats_buf->sw_peer_id;
  4620. }
  4621. break;
  4622. case HTT_STATS_PEER_STATS_CMN_TAG:
  4623. {
  4624. htt_peer_stats_cmn_tlv *dp_stats_buf =
  4625. (htt_peer_stats_cmn_tlv *)tag_buf;
  4626. peer = dp_peer_get_ref_by_id(pdev->soc, pdev->fw_stats_peer_id,
  4627. DP_MOD_ID_HTT);
  4628. if (peer && !peer->bss_peer) {
  4629. peer->stats.tx.inactive_time =
  4630. dp_stats_buf->inactive_time;
  4631. qdf_event_set(&pdev->fw_peer_stats_event);
  4632. }
  4633. if (peer)
  4634. dp_peer_unref_delete(peer, DP_MOD_ID_HTT);
  4635. }
  4636. break;
  4637. default:
  4638. qdf_err("Invalid tag_type");
  4639. }
  4640. }
  4641. /**
  4642. * dp_htt_rx_flow_fst_setup(): Send HTT Rx FST setup message to FW
  4643. * @pdev: DP pdev handle
  4644. * @fse_setup_info: FST setup parameters
  4645. *
  4646. * Return: Success when HTT message is sent, error on failure
  4647. */
  4648. QDF_STATUS
  4649. dp_htt_rx_flow_fst_setup(struct dp_pdev *pdev,
  4650. struct dp_htt_rx_flow_fst_setup *fse_setup_info)
  4651. {
  4652. struct htt_soc *soc = pdev->soc->htt_handle;
  4653. struct dp_htt_htc_pkt *pkt;
  4654. qdf_nbuf_t msg;
  4655. u_int32_t *msg_word;
  4656. struct htt_h2t_msg_rx_fse_setup_t *fse_setup;
  4657. uint8_t *htt_logger_bufp;
  4658. u_int32_t *key;
  4659. QDF_STATUS status;
  4660. msg = qdf_nbuf_alloc(
  4661. soc->osdev,
  4662. HTT_MSG_BUF_SIZE(sizeof(struct htt_h2t_msg_rx_fse_setup_t)),
  4663. /* reserve room for the HTC header */
  4664. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  4665. if (!msg)
  4666. return QDF_STATUS_E_NOMEM;
  4667. /*
  4668. * Set the length of the message.
  4669. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4670. * separately during the below call to qdf_nbuf_push_head.
  4671. * The contribution from the HTC header is added separately inside HTC.
  4672. */
  4673. if (!qdf_nbuf_put_tail(msg,
  4674. sizeof(struct htt_h2t_msg_rx_fse_setup_t))) {
  4675. qdf_err("Failed to expand head for HTT RX_FSE_SETUP msg");
  4676. return QDF_STATUS_E_FAILURE;
  4677. }
  4678. /* fill in the message contents */
  4679. msg_word = (u_int32_t *)qdf_nbuf_data(msg);
  4680. memset(msg_word, 0, sizeof(struct htt_h2t_msg_rx_fse_setup_t));
  4681. /* rewind beyond alignment pad to get to the HTC header reserved area */
  4682. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4683. htt_logger_bufp = (uint8_t *)msg_word;
  4684. *msg_word = 0;
  4685. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RX_FSE_SETUP_CFG);
  4686. fse_setup = (struct htt_h2t_msg_rx_fse_setup_t *)msg_word;
  4687. HTT_RX_FSE_SETUP_PDEV_ID_SET(*msg_word, fse_setup_info->pdev_id);
  4688. msg_word++;
  4689. HTT_RX_FSE_SETUP_NUM_REC_SET(*msg_word, fse_setup_info->max_entries);
  4690. HTT_RX_FSE_SETUP_MAX_SEARCH_SET(*msg_word, fse_setup_info->max_search);
  4691. HTT_RX_FSE_SETUP_IP_DA_SA_PREFIX_SET(*msg_word,
  4692. fse_setup_info->ip_da_sa_prefix);
  4693. msg_word++;
  4694. HTT_RX_FSE_SETUP_BASE_ADDR_LO_SET(*msg_word,
  4695. fse_setup_info->base_addr_lo);
  4696. msg_word++;
  4697. HTT_RX_FSE_SETUP_BASE_ADDR_HI_SET(*msg_word,
  4698. fse_setup_info->base_addr_hi);
  4699. key = (u_int32_t *)fse_setup_info->hash_key;
  4700. fse_setup->toeplitz31_0 = *key++;
  4701. fse_setup->toeplitz63_32 = *key++;
  4702. fse_setup->toeplitz95_64 = *key++;
  4703. fse_setup->toeplitz127_96 = *key++;
  4704. fse_setup->toeplitz159_128 = *key++;
  4705. fse_setup->toeplitz191_160 = *key++;
  4706. fse_setup->toeplitz223_192 = *key++;
  4707. fse_setup->toeplitz255_224 = *key++;
  4708. fse_setup->toeplitz287_256 = *key++;
  4709. fse_setup->toeplitz314_288 = *key;
  4710. msg_word++;
  4711. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz31_0);
  4712. msg_word++;
  4713. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz63_32);
  4714. msg_word++;
  4715. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz95_64);
  4716. msg_word++;
  4717. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz127_96);
  4718. msg_word++;
  4719. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz159_128);
  4720. msg_word++;
  4721. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz191_160);
  4722. msg_word++;
  4723. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz223_192);
  4724. msg_word++;
  4725. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz255_224);
  4726. msg_word++;
  4727. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz287_256);
  4728. msg_word++;
  4729. HTT_RX_FSE_SETUP_HASH_314_288_SET(*msg_word,
  4730. fse_setup->toeplitz314_288);
  4731. pkt = htt_htc_pkt_alloc(soc);
  4732. if (!pkt) {
  4733. qdf_err("Fail to allocate dp_htt_htc_pkt buffer");
  4734. qdf_assert(0);
  4735. qdf_nbuf_free(msg);
  4736. return QDF_STATUS_E_RESOURCES; /* failure */
  4737. }
  4738. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4739. SET_HTC_PACKET_INFO_TX(
  4740. &pkt->htc_pkt,
  4741. dp_htt_h2t_send_complete_free_netbuf,
  4742. qdf_nbuf_data(msg),
  4743. qdf_nbuf_len(msg),
  4744. soc->htc_endpoint,
  4745. /* tag for no FW response msg */
  4746. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4747. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4748. status = DP_HTT_SEND_HTC_PKT(soc, pkt,
  4749. HTT_H2T_MSG_TYPE_RX_FSE_SETUP_CFG,
  4750. htt_logger_bufp);
  4751. if (status == QDF_STATUS_SUCCESS) {
  4752. dp_info("HTT_H2T RX_FSE_SETUP sent to FW for pdev = %u",
  4753. fse_setup_info->pdev_id);
  4754. QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_ANY, QDF_TRACE_LEVEL_DEBUG,
  4755. (void *)fse_setup_info->hash_key,
  4756. fse_setup_info->hash_key_len);
  4757. } else {
  4758. qdf_nbuf_free(msg);
  4759. htt_htc_pkt_free(soc, pkt);
  4760. }
  4761. return status;
  4762. }
  4763. /**
  4764. * dp_htt_rx_flow_fse_operation(): Send HTT Flow Search Entry msg to
  4765. * add/del a flow in HW
  4766. * @pdev: DP pdev handle
  4767. * @fse_op_info: Flow entry parameters
  4768. *
  4769. * Return: Success when HTT message is sent, error on failure
  4770. */
  4771. QDF_STATUS
  4772. dp_htt_rx_flow_fse_operation(struct dp_pdev *pdev,
  4773. struct dp_htt_rx_flow_fst_operation *fse_op_info)
  4774. {
  4775. struct htt_soc *soc = pdev->soc->htt_handle;
  4776. struct dp_htt_htc_pkt *pkt;
  4777. qdf_nbuf_t msg;
  4778. u_int32_t *msg_word;
  4779. struct htt_h2t_msg_rx_fse_operation_t *fse_operation;
  4780. uint8_t *htt_logger_bufp;
  4781. QDF_STATUS status;
  4782. msg = qdf_nbuf_alloc(
  4783. soc->osdev,
  4784. HTT_MSG_BUF_SIZE(sizeof(struct htt_h2t_msg_rx_fse_operation_t)),
  4785. /* reserve room for the HTC header */
  4786. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  4787. if (!msg)
  4788. return QDF_STATUS_E_NOMEM;
  4789. /*
  4790. * Set the length of the message.
  4791. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4792. * separately during the below call to qdf_nbuf_push_head.
  4793. * The contribution from the HTC header is added separately inside HTC.
  4794. */
  4795. if (!qdf_nbuf_put_tail(msg,
  4796. sizeof(struct htt_h2t_msg_rx_fse_operation_t))) {
  4797. qdf_err("Failed to expand head for HTT_RX_FSE_OPERATION msg");
  4798. qdf_nbuf_free(msg);
  4799. return QDF_STATUS_E_FAILURE;
  4800. }
  4801. /* fill in the message contents */
  4802. msg_word = (u_int32_t *)qdf_nbuf_data(msg);
  4803. memset(msg_word, 0, sizeof(struct htt_h2t_msg_rx_fse_operation_t));
  4804. /* rewind beyond alignment pad to get to the HTC header reserved area */
  4805. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4806. htt_logger_bufp = (uint8_t *)msg_word;
  4807. *msg_word = 0;
  4808. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RX_FSE_OPERATION_CFG);
  4809. fse_operation = (struct htt_h2t_msg_rx_fse_operation_t *)msg_word;
  4810. HTT_RX_FSE_OPERATION_PDEV_ID_SET(*msg_word, fse_op_info->pdev_id);
  4811. msg_word++;
  4812. HTT_RX_FSE_IPSEC_VALID_SET(*msg_word, false);
  4813. if (fse_op_info->op_code == DP_HTT_FST_CACHE_INVALIDATE_ENTRY) {
  4814. HTT_RX_FSE_OPERATION_SET(*msg_word,
  4815. HTT_RX_FSE_CACHE_INVALIDATE_ENTRY);
  4816. msg_word++;
  4817. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4818. *msg_word,
  4819. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_31_0));
  4820. msg_word++;
  4821. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4822. *msg_word,
  4823. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_63_32));
  4824. msg_word++;
  4825. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4826. *msg_word,
  4827. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_95_64));
  4828. msg_word++;
  4829. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4830. *msg_word,
  4831. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_127_96));
  4832. msg_word++;
  4833. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4834. *msg_word,
  4835. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.dest_ip_31_0));
  4836. msg_word++;
  4837. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4838. *msg_word,
  4839. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.dest_ip_63_32));
  4840. msg_word++;
  4841. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4842. *msg_word,
  4843. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.dest_ip_95_64));
  4844. msg_word++;
  4845. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4846. *msg_word,
  4847. qdf_htonl(
  4848. fse_op_info->rx_flow->flow_tuple_info.dest_ip_127_96));
  4849. msg_word++;
  4850. HTT_RX_FSE_SOURCEPORT_SET(
  4851. *msg_word,
  4852. fse_op_info->rx_flow->flow_tuple_info.src_port);
  4853. HTT_RX_FSE_DESTPORT_SET(
  4854. *msg_word,
  4855. fse_op_info->rx_flow->flow_tuple_info.dest_port);
  4856. msg_word++;
  4857. HTT_RX_FSE_L4_PROTO_SET(
  4858. *msg_word,
  4859. fse_op_info->rx_flow->flow_tuple_info.l4_protocol);
  4860. } else if (fse_op_info->op_code == DP_HTT_FST_CACHE_INVALIDATE_FULL) {
  4861. HTT_RX_FSE_OPERATION_SET(*msg_word,
  4862. HTT_RX_FSE_CACHE_INVALIDATE_FULL);
  4863. } else if (fse_op_info->op_code == DP_HTT_FST_DISABLE) {
  4864. HTT_RX_FSE_OPERATION_SET(*msg_word, HTT_RX_FSE_DISABLE);
  4865. } else if (fse_op_info->op_code == DP_HTT_FST_ENABLE) {
  4866. HTT_RX_FSE_OPERATION_SET(*msg_word, HTT_RX_FSE_ENABLE);
  4867. }
  4868. pkt = htt_htc_pkt_alloc(soc);
  4869. if (!pkt) {
  4870. qdf_err("Fail to allocate dp_htt_htc_pkt buffer");
  4871. qdf_assert(0);
  4872. qdf_nbuf_free(msg);
  4873. return QDF_STATUS_E_RESOURCES; /* failure */
  4874. }
  4875. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4876. SET_HTC_PACKET_INFO_TX(
  4877. &pkt->htc_pkt,
  4878. dp_htt_h2t_send_complete_free_netbuf,
  4879. qdf_nbuf_data(msg),
  4880. qdf_nbuf_len(msg),
  4881. soc->htc_endpoint,
  4882. /* tag for no FW response msg */
  4883. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4884. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4885. status = DP_HTT_SEND_HTC_PKT(soc, pkt,
  4886. HTT_H2T_MSG_TYPE_RX_FSE_OPERATION_CFG,
  4887. htt_logger_bufp);
  4888. if (status == QDF_STATUS_SUCCESS) {
  4889. dp_info("HTT_H2T RX_FSE_OPERATION_CFG sent to FW for pdev = %u",
  4890. fse_op_info->pdev_id);
  4891. } else {
  4892. qdf_nbuf_free(msg);
  4893. htt_htc_pkt_free(soc, pkt);
  4894. }
  4895. return status;
  4896. }
  4897. /**
  4898. * dp_htt_rx_fisa_config(): Send HTT msg to configure FISA
  4899. * @pdev: DP pdev handle
  4900. * @fse_op_info: Flow entry parameters
  4901. *
  4902. * Return: Success when HTT message is sent, error on failure
  4903. */
  4904. QDF_STATUS
  4905. dp_htt_rx_fisa_config(struct dp_pdev *pdev,
  4906. struct dp_htt_rx_fisa_cfg *fisa_config)
  4907. {
  4908. struct htt_soc *soc = pdev->soc->htt_handle;
  4909. struct dp_htt_htc_pkt *pkt;
  4910. qdf_nbuf_t msg;
  4911. u_int32_t *msg_word;
  4912. struct htt_h2t_msg_type_fisa_config_t *htt_fisa_config;
  4913. uint8_t *htt_logger_bufp;
  4914. uint32_t len;
  4915. QDF_STATUS status;
  4916. len = HTT_MSG_BUF_SIZE(sizeof(struct htt_h2t_msg_type_fisa_config_t));
  4917. msg = qdf_nbuf_alloc(soc->osdev,
  4918. len,
  4919. /* reserve room for the HTC header */
  4920. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING,
  4921. 4,
  4922. TRUE);
  4923. if (!msg)
  4924. return QDF_STATUS_E_NOMEM;
  4925. /*
  4926. * Set the length of the message.
  4927. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4928. * separately during the below call to qdf_nbuf_push_head.
  4929. * The contribution from the HTC header is added separately inside HTC.
  4930. */
  4931. if (!qdf_nbuf_put_tail(msg,
  4932. sizeof(struct htt_h2t_msg_type_fisa_config_t))) {
  4933. qdf_err("Failed to expand head for HTT_RX_FSE_OPERATION msg");
  4934. qdf_nbuf_free(msg);
  4935. return QDF_STATUS_E_FAILURE;
  4936. }
  4937. /* fill in the message contents */
  4938. msg_word = (u_int32_t *)qdf_nbuf_data(msg);
  4939. memset(msg_word, 0, sizeof(struct htt_h2t_msg_type_fisa_config_t));
  4940. /* rewind beyond alignment pad to get to the HTC header reserved area */
  4941. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4942. htt_logger_bufp = (uint8_t *)msg_word;
  4943. *msg_word = 0;
  4944. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RX_FISA_CFG);
  4945. htt_fisa_config = (struct htt_h2t_msg_type_fisa_config_t *)msg_word;
  4946. HTT_RX_FSE_OPERATION_PDEV_ID_SET(*msg_word, htt_fisa_config->pdev_id);
  4947. msg_word++;
  4948. HTT_RX_FISA_CONFIG_FISA_V2_ENABLE_SET(*msg_word, 1);
  4949. HTT_RX_FISA_CONFIG_FISA_V2_AGGR_LIMIT_SET(*msg_word, 0xf);
  4950. msg_word++;
  4951. htt_fisa_config->fisa_timeout_threshold = fisa_config->fisa_timeout;
  4952. pkt = htt_htc_pkt_alloc(soc);
  4953. if (!pkt) {
  4954. qdf_err("Fail to allocate dp_htt_htc_pkt buffer");
  4955. qdf_assert(0);
  4956. qdf_nbuf_free(msg);
  4957. return QDF_STATUS_E_RESOURCES; /* failure */
  4958. }
  4959. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4960. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  4961. dp_htt_h2t_send_complete_free_netbuf,
  4962. qdf_nbuf_data(msg),
  4963. qdf_nbuf_len(msg),
  4964. soc->htc_endpoint,
  4965. /* tag for no FW response msg */
  4966. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4967. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4968. status = DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_RX_FISA_CFG,
  4969. htt_logger_bufp);
  4970. if (status == QDF_STATUS_SUCCESS) {
  4971. dp_info("HTT_H2T_MSG_TYPE_RX_FISA_CFG sent to FW for pdev = %u",
  4972. fisa_config->pdev_id);
  4973. } else {
  4974. qdf_nbuf_free(msg);
  4975. htt_htc_pkt_free(soc, pkt);
  4976. }
  4977. return status;
  4978. }