dp_htt.c 147 KB

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