dp_htt.c 153 KB

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