dp_tx.c 153 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779
  1. /*
  2. * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for
  6. * any purpose with or without fee is hereby granted, provided that the
  7. * above copyright notice and this permission notice appear in all
  8. * copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  11. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  12. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  13. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  14. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  15. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  16. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  17. * PERFORMANCE OF THIS SOFTWARE.
  18. */
  19. #include "htt.h"
  20. #include "dp_htt.h"
  21. #include "hal_hw_headers.h"
  22. #include "dp_tx.h"
  23. #include "dp_tx_desc.h"
  24. #include "dp_peer.h"
  25. #include "dp_types.h"
  26. #include "hal_tx.h"
  27. #include "qdf_mem.h"
  28. #include "qdf_nbuf.h"
  29. #include "qdf_net_types.h"
  30. #include "qdf_module.h"
  31. #include <wlan_cfg.h>
  32. #include "dp_ipa.h"
  33. #if defined(MESH_MODE_SUPPORT) || defined(FEATURE_PERPKT_INFO)
  34. #include "if_meta_hdr.h"
  35. #endif
  36. #include "enet.h"
  37. #include "dp_internal.h"
  38. #ifdef ATH_SUPPORT_IQUE
  39. #include "dp_txrx_me.h"
  40. #endif
  41. #include "dp_hist.h"
  42. #ifdef WLAN_DP_FEATURE_SW_LATENCY_MGR
  43. #include <dp_swlm.h>
  44. #endif
  45. #ifdef WIFI_MONITOR_SUPPORT
  46. #include <dp_mon.h>
  47. #endif
  48. #ifdef FEATURE_WDS
  49. #include "dp_txrx_wds.h"
  50. #endif
  51. #include "cdp_txrx_cmn_reg.h"
  52. #ifdef CONFIG_SAWF
  53. #include <dp_sawf.h>
  54. #endif
  55. /* Flag to skip CCE classify when mesh or tid override enabled */
  56. #define DP_TX_SKIP_CCE_CLASSIFY \
  57. (DP_TXRX_HLOS_TID_OVERRIDE_ENABLED | DP_TX_MESH_ENABLED)
  58. /* TODO Add support in TSO */
  59. #define DP_DESC_NUM_FRAG(x) 0
  60. /* disable TQM_BYPASS */
  61. #define TQM_BYPASS_WAR 0
  62. /* invalid peer id for reinject*/
  63. #define DP_INVALID_PEER 0XFFFE
  64. #define DP_RETRY_COUNT 7
  65. #ifdef QCA_DP_TX_FW_METADATA_V2
  66. #define DP_TX_TCL_METADATA_PDEV_ID_SET(_var, _val)\
  67. HTT_TX_TCL_METADATA_V2_PDEV_ID_SET(_var, _val)
  68. #define DP_TX_TCL_METADATA_VALID_HTT_SET(_var, _val) \
  69. HTT_TX_TCL_METADATA_V2_VALID_HTT_SET(_var, _val)
  70. #define DP_TX_TCL_METADATA_TYPE_SET(_var, _val) \
  71. HTT_TX_TCL_METADATA_TYPE_V2_SET(_var, _val)
  72. #define DP_TX_TCL_METADATA_HOST_INSPECTED_SET(_var, _val) \
  73. HTT_TX_TCL_METADATA_V2_HOST_INSPECTED_SET(_var, _val)
  74. #define DP_TX_TCL_METADATA_PEER_ID_SET(_var, _val) \
  75. HTT_TX_TCL_METADATA_V2_PEER_ID_SET(_var, _val)
  76. #define DP_TX_TCL_METADATA_VDEV_ID_SET(_var, _val) \
  77. HTT_TX_TCL_METADATA_V2_VDEV_ID_SET(_var, _val)
  78. #define DP_TCL_METADATA_TYPE_PEER_BASED \
  79. HTT_TCL_METADATA_V2_TYPE_PEER_BASED
  80. #define DP_TCL_METADATA_TYPE_VDEV_BASED \
  81. HTT_TCL_METADATA_V2_TYPE_VDEV_BASED
  82. #else
  83. #define DP_TX_TCL_METADATA_PDEV_ID_SET(_var, _val)\
  84. HTT_TX_TCL_METADATA_PDEV_ID_SET(_var, _val)
  85. #define DP_TX_TCL_METADATA_VALID_HTT_SET(_var, _val) \
  86. HTT_TX_TCL_METADATA_VALID_HTT_SET(_var, _val)
  87. #define DP_TX_TCL_METADATA_TYPE_SET(_var, _val) \
  88. HTT_TX_TCL_METADATA_TYPE_SET(_var, _val)
  89. #define DP_TX_TCL_METADATA_HOST_INSPECTED_SET(_var, _val) \
  90. HTT_TX_TCL_METADATA_HOST_INSPECTED_SET(_var, _val)
  91. #define DP_TX_TCL_METADATA_PEER_ID_SET(_var, _val) \
  92. HTT_TX_TCL_METADATA_PEER_ID_SET(_var, _val)
  93. #define DP_TX_TCL_METADATA_VDEV_ID_SET(_var, _val) \
  94. HTT_TX_TCL_METADATA_VDEV_ID_SET(_var, _val)
  95. #define DP_TCL_METADATA_TYPE_PEER_BASED \
  96. HTT_TCL_METADATA_TYPE_PEER_BASED
  97. #define DP_TCL_METADATA_TYPE_VDEV_BASED \
  98. HTT_TCL_METADATA_TYPE_VDEV_BASED
  99. #endif
  100. /*mapping between hal encrypt type and cdp_sec_type*/
  101. uint8_t sec_type_map[MAX_CDP_SEC_TYPE] = {HAL_TX_ENCRYPT_TYPE_NO_CIPHER,
  102. HAL_TX_ENCRYPT_TYPE_WEP_128,
  103. HAL_TX_ENCRYPT_TYPE_WEP_104,
  104. HAL_TX_ENCRYPT_TYPE_WEP_40,
  105. HAL_TX_ENCRYPT_TYPE_TKIP_WITH_MIC,
  106. HAL_TX_ENCRYPT_TYPE_TKIP_NO_MIC,
  107. HAL_TX_ENCRYPT_TYPE_AES_CCMP_128,
  108. HAL_TX_ENCRYPT_TYPE_WAPI,
  109. HAL_TX_ENCRYPT_TYPE_AES_CCMP_256,
  110. HAL_TX_ENCRYPT_TYPE_AES_GCMP_128,
  111. HAL_TX_ENCRYPT_TYPE_AES_GCMP_256,
  112. HAL_TX_ENCRYPT_TYPE_WAPI_GCM_SM4};
  113. qdf_export_symbol(sec_type_map);
  114. #ifdef CONFIG_WLAN_SYSFS_MEM_STATS
  115. /**
  116. * dp_update_tx_desc_stats - Update the increase or decrease in
  117. * outstanding tx desc count
  118. * values on pdev and soc
  119. * @vdev: DP pdev handle
  120. *
  121. * Return: void
  122. */
  123. static inline void
  124. dp_update_tx_desc_stats(struct dp_pdev *pdev)
  125. {
  126. int32_t tx_descs_cnt =
  127. qdf_atomic_read(&pdev->num_tx_outstanding);
  128. if (pdev->tx_descs_max < tx_descs_cnt)
  129. pdev->tx_descs_max = tx_descs_cnt;
  130. qdf_mem_tx_desc_cnt_update(pdev->num_tx_outstanding,
  131. pdev->tx_descs_max);
  132. }
  133. #else /* CONFIG_WLAN_SYSFS_MEM_STATS */
  134. static inline void
  135. dp_update_tx_desc_stats(struct dp_pdev *pdev)
  136. {
  137. }
  138. #endif /* CONFIG_WLAN_SYSFS_MEM_STATS */
  139. #ifdef QCA_TX_LIMIT_CHECK
  140. /**
  141. * dp_tx_limit_check - Check if allocated tx descriptors reached
  142. * soc max limit and pdev max limit
  143. * @vdev: DP vdev handle
  144. *
  145. * Return: true if allocated tx descriptors reached max configured value, else
  146. * false
  147. */
  148. static inline bool
  149. dp_tx_limit_check(struct dp_vdev *vdev)
  150. {
  151. struct dp_pdev *pdev = vdev->pdev;
  152. struct dp_soc *soc = pdev->soc;
  153. if (qdf_atomic_read(&soc->num_tx_outstanding) >=
  154. soc->num_tx_allowed) {
  155. dp_tx_info("queued packets are more than max tx, drop the frame");
  156. DP_STATS_INC(vdev, tx_i.dropped.desc_na.num, 1);
  157. return true;
  158. }
  159. if (qdf_atomic_read(&pdev->num_tx_outstanding) >=
  160. pdev->num_tx_allowed) {
  161. dp_tx_info("queued packets are more than max tx, drop the frame");
  162. DP_STATS_INC(vdev, tx_i.dropped.desc_na.num, 1);
  163. DP_STATS_INC(vdev, tx_i.dropped.desc_na_exc_outstand.num, 1);
  164. return true;
  165. }
  166. return false;
  167. }
  168. /**
  169. * dp_tx_exception_limit_check - Check if allocated tx exception descriptors
  170. * reached soc max limit
  171. * @vdev: DP vdev handle
  172. *
  173. * Return: true if allocated tx descriptors reached max configured value, else
  174. * false
  175. */
  176. static inline bool
  177. dp_tx_exception_limit_check(struct dp_vdev *vdev)
  178. {
  179. struct dp_pdev *pdev = vdev->pdev;
  180. struct dp_soc *soc = pdev->soc;
  181. if (qdf_atomic_read(&soc->num_tx_exception) >=
  182. soc->num_msdu_exception_desc) {
  183. dp_info("exc packets are more than max drop the exc pkt");
  184. DP_STATS_INC(vdev, tx_i.dropped.exc_desc_na.num, 1);
  185. return true;
  186. }
  187. return false;
  188. }
  189. /**
  190. * dp_tx_outstanding_inc - Increment outstanding tx desc values on pdev and soc
  191. * @vdev: DP pdev handle
  192. *
  193. * Return: void
  194. */
  195. static inline void
  196. dp_tx_outstanding_inc(struct dp_pdev *pdev)
  197. {
  198. struct dp_soc *soc = pdev->soc;
  199. qdf_atomic_inc(&pdev->num_tx_outstanding);
  200. qdf_atomic_inc(&soc->num_tx_outstanding);
  201. dp_update_tx_desc_stats(pdev);
  202. }
  203. /**
  204. * dp_tx_outstanding__dec - Decrement outstanding tx desc values on pdev and soc
  205. * @vdev: DP pdev handle
  206. *
  207. * Return: void
  208. */
  209. static inline void
  210. dp_tx_outstanding_dec(struct dp_pdev *pdev)
  211. {
  212. struct dp_soc *soc = pdev->soc;
  213. qdf_atomic_dec(&pdev->num_tx_outstanding);
  214. qdf_atomic_dec(&soc->num_tx_outstanding);
  215. dp_update_tx_desc_stats(pdev);
  216. }
  217. #else //QCA_TX_LIMIT_CHECK
  218. static inline bool
  219. dp_tx_limit_check(struct dp_vdev *vdev)
  220. {
  221. return false;
  222. }
  223. static inline bool
  224. dp_tx_exception_limit_check(struct dp_vdev *vdev)
  225. {
  226. return false;
  227. }
  228. static inline void
  229. dp_tx_outstanding_inc(struct dp_pdev *pdev)
  230. {
  231. qdf_atomic_inc(&pdev->num_tx_outstanding);
  232. dp_update_tx_desc_stats(pdev);
  233. }
  234. static inline void
  235. dp_tx_outstanding_dec(struct dp_pdev *pdev)
  236. {
  237. qdf_atomic_dec(&pdev->num_tx_outstanding);
  238. dp_update_tx_desc_stats(pdev);
  239. }
  240. #endif //QCA_TX_LIMIT_CHECK
  241. #ifdef WLAN_FEATURE_DP_TX_DESC_HISTORY
  242. static inline enum dp_tx_event_type dp_tx_get_event_type(uint32_t flags)
  243. {
  244. enum dp_tx_event_type type;
  245. if (flags & DP_TX_DESC_FLAG_FLUSH)
  246. type = DP_TX_DESC_FLUSH;
  247. else if (flags & DP_TX_DESC_FLAG_TX_COMP_ERR)
  248. type = DP_TX_COMP_UNMAP_ERR;
  249. else if (flags & DP_TX_DESC_FLAG_COMPLETED_TX)
  250. type = DP_TX_COMP_UNMAP;
  251. else
  252. type = DP_TX_DESC_UNMAP;
  253. return type;
  254. }
  255. static inline void
  256. dp_tx_desc_history_add(struct dp_soc *soc, dma_addr_t paddr,
  257. qdf_nbuf_t skb, uint32_t sw_cookie,
  258. enum dp_tx_event_type type)
  259. {
  260. struct dp_tx_desc_event *entry;
  261. uint32_t idx;
  262. if (qdf_unlikely(!soc->tx_tcl_history || !soc->tx_comp_history))
  263. return;
  264. switch (type) {
  265. case DP_TX_COMP_UNMAP:
  266. case DP_TX_COMP_UNMAP_ERR:
  267. case DP_TX_COMP_MSDU_EXT:
  268. idx = dp_history_get_next_index(&soc->tx_comp_history->index,
  269. DP_TX_COMP_HISTORY_SIZE);
  270. entry = &soc->tx_comp_history->entry[idx];
  271. break;
  272. case DP_TX_DESC_MAP:
  273. case DP_TX_DESC_UNMAP:
  274. case DP_TX_DESC_COOKIE:
  275. case DP_TX_DESC_FLUSH:
  276. idx = dp_history_get_next_index(&soc->tx_tcl_history->index,
  277. DP_TX_TCL_HISTORY_SIZE);
  278. entry = &soc->tx_tcl_history->entry[idx];
  279. break;
  280. default:
  281. dp_info_rl("Invalid dp_tx_event_type: %d", type);
  282. return;
  283. }
  284. entry->skb = skb;
  285. entry->paddr = paddr;
  286. entry->sw_cookie = sw_cookie;
  287. entry->type = type;
  288. entry->ts = qdf_get_log_timestamp();
  289. }
  290. static inline void
  291. dp_tx_tso_seg_history_add(struct dp_soc *soc,
  292. struct qdf_tso_seg_elem_t *tso_seg,
  293. qdf_nbuf_t skb, uint32_t sw_cookie,
  294. enum dp_tx_event_type type)
  295. {
  296. int i;
  297. for (i = 1; i < tso_seg->seg.num_frags; i++) {
  298. dp_tx_desc_history_add(soc, tso_seg->seg.tso_frags[i].paddr,
  299. skb, sw_cookie, type);
  300. }
  301. if (!tso_seg->next)
  302. dp_tx_desc_history_add(soc, tso_seg->seg.tso_frags[0].paddr,
  303. skb, 0xFFFFFFFF, type);
  304. }
  305. static inline void
  306. dp_tx_tso_history_add(struct dp_soc *soc, struct qdf_tso_info_t tso_info,
  307. qdf_nbuf_t skb, uint32_t sw_cookie,
  308. enum dp_tx_event_type type)
  309. {
  310. struct qdf_tso_seg_elem_t *curr_seg = tso_info.tso_seg_list;
  311. uint32_t num_segs = tso_info.num_segs;
  312. while (num_segs) {
  313. dp_tx_tso_seg_history_add(soc, curr_seg, skb, sw_cookie, type);
  314. curr_seg = curr_seg->next;
  315. num_segs--;
  316. }
  317. }
  318. #else
  319. static inline enum dp_tx_event_type dp_tx_get_event_type(uint32_t flags)
  320. {
  321. return DP_TX_DESC_INVAL_EVT;
  322. }
  323. static inline void
  324. dp_tx_desc_history_add(struct dp_soc *soc, dma_addr_t paddr,
  325. qdf_nbuf_t skb, uint32_t sw_cookie,
  326. enum dp_tx_event_type type)
  327. {
  328. }
  329. static inline void
  330. dp_tx_tso_seg_history_add(struct dp_soc *soc,
  331. struct qdf_tso_seg_elem_t *tso_seg,
  332. qdf_nbuf_t skb, uint32_t sw_cookie,
  333. enum dp_tx_event_type type)
  334. {
  335. }
  336. static inline void
  337. dp_tx_tso_history_add(struct dp_soc *soc, struct qdf_tso_info_t tso_info,
  338. qdf_nbuf_t skb, uint32_t sw_cookie,
  339. enum dp_tx_event_type type)
  340. {
  341. }
  342. #endif /* WLAN_FEATURE_DP_TX_DESC_HISTORY */
  343. static int dp_get_rtpm_tput_policy_requirement(struct dp_soc *soc);
  344. /**
  345. * dp_is_tput_high() - Check if throughput is high
  346. *
  347. * @soc - core txrx main context
  348. *
  349. * The current function is based of the RTPM tput policy variable where RTPM is
  350. * avoided based on throughput.
  351. */
  352. static inline int dp_is_tput_high(struct dp_soc *soc)
  353. {
  354. return dp_get_rtpm_tput_policy_requirement(soc);
  355. }
  356. #if defined(FEATURE_TSO)
  357. /**
  358. * dp_tx_tso_unmap_segment() - Unmap TSO segment
  359. *
  360. * @soc - core txrx main context
  361. * @seg_desc - tso segment descriptor
  362. * @num_seg_desc - tso number segment descriptor
  363. */
  364. static void dp_tx_tso_unmap_segment(
  365. struct dp_soc *soc,
  366. struct qdf_tso_seg_elem_t *seg_desc,
  367. struct qdf_tso_num_seg_elem_t *num_seg_desc)
  368. {
  369. TSO_DEBUG("%s: Unmap the tso segment", __func__);
  370. if (qdf_unlikely(!seg_desc)) {
  371. DP_TRACE(ERROR, "%s %d TSO desc is NULL!",
  372. __func__, __LINE__);
  373. qdf_assert(0);
  374. } else if (qdf_unlikely(!num_seg_desc)) {
  375. DP_TRACE(ERROR, "%s %d TSO num desc is NULL!",
  376. __func__, __LINE__);
  377. qdf_assert(0);
  378. } else {
  379. bool is_last_seg;
  380. /* no tso segment left to do dma unmap */
  381. if (num_seg_desc->num_seg.tso_cmn_num_seg < 1)
  382. return;
  383. is_last_seg = (num_seg_desc->num_seg.tso_cmn_num_seg == 1) ?
  384. true : false;
  385. qdf_nbuf_unmap_tso_segment(soc->osdev,
  386. seg_desc, is_last_seg);
  387. num_seg_desc->num_seg.tso_cmn_num_seg--;
  388. }
  389. }
  390. /**
  391. * dp_tx_tso_desc_release() - Release the tso segment and tso_cmn_num_seg
  392. * back to the freelist
  393. *
  394. * @soc - soc device handle
  395. * @tx_desc - Tx software descriptor
  396. */
  397. static void dp_tx_tso_desc_release(struct dp_soc *soc,
  398. struct dp_tx_desc_s *tx_desc)
  399. {
  400. TSO_DEBUG("%s: Free the tso descriptor", __func__);
  401. if (qdf_unlikely(!tx_desc->msdu_ext_desc->tso_desc)) {
  402. dp_tx_err("SO desc is NULL!");
  403. qdf_assert(0);
  404. } else if (qdf_unlikely(!tx_desc->msdu_ext_desc->tso_num_desc)) {
  405. dp_tx_err("TSO num desc is NULL!");
  406. qdf_assert(0);
  407. } else {
  408. struct qdf_tso_num_seg_elem_t *tso_num_desc =
  409. (struct qdf_tso_num_seg_elem_t *)tx_desc->
  410. msdu_ext_desc->tso_num_desc;
  411. /* Add the tso num segment into the free list */
  412. if (tso_num_desc->num_seg.tso_cmn_num_seg == 0) {
  413. dp_tso_num_seg_free(soc, tx_desc->pool_id,
  414. tx_desc->msdu_ext_desc->
  415. tso_num_desc);
  416. tx_desc->msdu_ext_desc->tso_num_desc = NULL;
  417. DP_STATS_INC(tx_desc->pdev, tso_stats.tso_comp, 1);
  418. }
  419. /* Add the tso segment into the free list*/
  420. dp_tx_tso_desc_free(soc,
  421. tx_desc->pool_id, tx_desc->msdu_ext_desc->
  422. tso_desc);
  423. tx_desc->msdu_ext_desc->tso_desc = NULL;
  424. }
  425. }
  426. #else
  427. static void dp_tx_tso_unmap_segment(
  428. struct dp_soc *soc,
  429. struct qdf_tso_seg_elem_t *seg_desc,
  430. struct qdf_tso_num_seg_elem_t *num_seg_desc)
  431. {
  432. }
  433. static void dp_tx_tso_desc_release(struct dp_soc *soc,
  434. struct dp_tx_desc_s *tx_desc)
  435. {
  436. }
  437. #endif
  438. /**
  439. * dp_tx_desc_release() - Release Tx Descriptor
  440. * @tx_desc : Tx Descriptor
  441. * @desc_pool_id: Descriptor Pool ID
  442. *
  443. * Deallocate all resources attached to Tx descriptor and free the Tx
  444. * descriptor.
  445. *
  446. * Return:
  447. */
  448. void
  449. dp_tx_desc_release(struct dp_tx_desc_s *tx_desc, uint8_t desc_pool_id)
  450. {
  451. struct dp_pdev *pdev = tx_desc->pdev;
  452. struct dp_soc *soc;
  453. uint8_t comp_status = 0;
  454. qdf_assert(pdev);
  455. soc = pdev->soc;
  456. dp_tx_outstanding_dec(pdev);
  457. if (tx_desc->msdu_ext_desc) {
  458. if (tx_desc->frm_type == dp_tx_frm_tso)
  459. dp_tx_tso_desc_release(soc, tx_desc);
  460. if (tx_desc->flags & DP_TX_DESC_FLAG_ME)
  461. dp_tx_me_free_buf(tx_desc->pdev,
  462. tx_desc->msdu_ext_desc->me_buffer);
  463. dp_tx_ext_desc_free(soc, tx_desc->msdu_ext_desc, desc_pool_id);
  464. }
  465. if (tx_desc->flags & DP_TX_DESC_FLAG_TO_FW)
  466. qdf_atomic_dec(&soc->num_tx_exception);
  467. if (HAL_TX_COMP_RELEASE_SOURCE_TQM ==
  468. tx_desc->buffer_src)
  469. comp_status = hal_tx_comp_get_release_reason(&tx_desc->comp,
  470. soc->hal_soc);
  471. else
  472. comp_status = HAL_TX_COMP_RELEASE_REASON_FW;
  473. dp_tx_debug("Tx Completion Release desc %d status %d outstanding %d",
  474. tx_desc->id, comp_status,
  475. qdf_atomic_read(&pdev->num_tx_outstanding));
  476. dp_tx_desc_free(soc, tx_desc, desc_pool_id);
  477. return;
  478. }
  479. /**
  480. * dp_tx_htt_metadata_prepare() - Prepare HTT metadata for special frames
  481. * @vdev: DP vdev Handle
  482. * @nbuf: skb
  483. * @msdu_info: msdu_info required to create HTT metadata
  484. *
  485. * Prepares and fills HTT metadata in the frame pre-header for special frames
  486. * that should be transmitted using varying transmit parameters.
  487. * There are 2 VDEV modes that currently needs this special metadata -
  488. * 1) Mesh Mode
  489. * 2) DSRC Mode
  490. *
  491. * Return: HTT metadata size
  492. *
  493. */
  494. static uint8_t dp_tx_prepare_htt_metadata(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  495. struct dp_tx_msdu_info_s *msdu_info)
  496. {
  497. uint32_t *meta_data = msdu_info->meta_data;
  498. struct htt_tx_msdu_desc_ext2_t *desc_ext =
  499. (struct htt_tx_msdu_desc_ext2_t *) meta_data;
  500. uint8_t htt_desc_size;
  501. /* Size rounded of multiple of 8 bytes */
  502. uint8_t htt_desc_size_aligned;
  503. uint8_t *hdr = NULL;
  504. /*
  505. * Metadata - HTT MSDU Extension header
  506. */
  507. htt_desc_size = sizeof(struct htt_tx_msdu_desc_ext2_t);
  508. htt_desc_size_aligned = (htt_desc_size + 7) & ~0x7;
  509. if (vdev->mesh_vdev || msdu_info->is_tx_sniffer ||
  510. HTT_TX_MSDU_EXT2_DESC_FLAG_VALID_KEY_FLAGS_GET(msdu_info->
  511. meta_data[0])) {
  512. if (qdf_unlikely(qdf_nbuf_headroom(nbuf) <
  513. htt_desc_size_aligned)) {
  514. nbuf = qdf_nbuf_realloc_headroom(nbuf,
  515. htt_desc_size_aligned);
  516. if (!nbuf) {
  517. /*
  518. * qdf_nbuf_realloc_headroom won't do skb_clone
  519. * as skb_realloc_headroom does. so, no free is
  520. * needed here.
  521. */
  522. DP_STATS_INC(vdev,
  523. tx_i.dropped.headroom_insufficient,
  524. 1);
  525. qdf_print(" %s[%d] skb_realloc_headroom failed",
  526. __func__, __LINE__);
  527. return 0;
  528. }
  529. }
  530. /* Fill and add HTT metaheader */
  531. hdr = qdf_nbuf_push_head(nbuf, htt_desc_size_aligned);
  532. if (!hdr) {
  533. dp_tx_err("Error in filling HTT metadata");
  534. return 0;
  535. }
  536. qdf_mem_copy(hdr, desc_ext, htt_desc_size);
  537. } else if (vdev->opmode == wlan_op_mode_ocb) {
  538. /* Todo - Add support for DSRC */
  539. }
  540. return htt_desc_size_aligned;
  541. }
  542. /**
  543. * dp_tx_prepare_tso_ext_desc() - Prepare MSDU extension descriptor for TSO
  544. * @tso_seg: TSO segment to process
  545. * @ext_desc: Pointer to MSDU extension descriptor
  546. *
  547. * Return: void
  548. */
  549. #if defined(FEATURE_TSO)
  550. static void dp_tx_prepare_tso_ext_desc(struct qdf_tso_seg_t *tso_seg,
  551. void *ext_desc)
  552. {
  553. uint8_t num_frag;
  554. uint32_t tso_flags;
  555. /*
  556. * Set tso_en, tcp_flags(NS, CWR, ECE, URG, ACK, PSH, RST, SYN, FIN),
  557. * tcp_flag_mask
  558. *
  559. * Checksum enable flags are set in TCL descriptor and not in Extension
  560. * Descriptor (H/W ignores checksum_en flags in MSDU ext descriptor)
  561. */
  562. tso_flags = *(uint32_t *) &tso_seg->tso_flags;
  563. hal_tx_ext_desc_set_tso_flags(ext_desc, tso_flags);
  564. hal_tx_ext_desc_set_msdu_length(ext_desc, tso_seg->tso_flags.l2_len,
  565. tso_seg->tso_flags.ip_len);
  566. hal_tx_ext_desc_set_tcp_seq(ext_desc, tso_seg->tso_flags.tcp_seq_num);
  567. hal_tx_ext_desc_set_ip_id(ext_desc, tso_seg->tso_flags.ip_id);
  568. for (num_frag = 0; num_frag < tso_seg->num_frags; num_frag++) {
  569. uint32_t lo = 0;
  570. uint32_t hi = 0;
  571. qdf_assert_always((tso_seg->tso_frags[num_frag].paddr) &&
  572. (tso_seg->tso_frags[num_frag].length));
  573. qdf_dmaaddr_to_32s(
  574. tso_seg->tso_frags[num_frag].paddr, &lo, &hi);
  575. hal_tx_ext_desc_set_buffer(ext_desc, num_frag, lo, hi,
  576. tso_seg->tso_frags[num_frag].length);
  577. }
  578. return;
  579. }
  580. #else
  581. static void dp_tx_prepare_tso_ext_desc(struct qdf_tso_seg_t *tso_seg,
  582. void *ext_desc)
  583. {
  584. return;
  585. }
  586. #endif
  587. #if defined(FEATURE_TSO)
  588. /**
  589. * dp_tx_free_tso_seg_list() - Loop through the tso segments
  590. * allocated and free them
  591. *
  592. * @soc: soc handle
  593. * @free_seg: list of tso segments
  594. * @msdu_info: msdu descriptor
  595. *
  596. * Return - void
  597. */
  598. static void dp_tx_free_tso_seg_list(
  599. struct dp_soc *soc,
  600. struct qdf_tso_seg_elem_t *free_seg,
  601. struct dp_tx_msdu_info_s *msdu_info)
  602. {
  603. struct qdf_tso_seg_elem_t *next_seg;
  604. while (free_seg) {
  605. next_seg = free_seg->next;
  606. dp_tx_tso_desc_free(soc,
  607. msdu_info->tx_queue.desc_pool_id,
  608. free_seg);
  609. free_seg = next_seg;
  610. }
  611. }
  612. /**
  613. * dp_tx_free_tso_num_seg_list() - Loop through the tso num segments
  614. * allocated and free them
  615. *
  616. * @soc: soc handle
  617. * @free_num_seg: list of tso number segments
  618. * @msdu_info: msdu descriptor
  619. * Return - void
  620. */
  621. static void dp_tx_free_tso_num_seg_list(
  622. struct dp_soc *soc,
  623. struct qdf_tso_num_seg_elem_t *free_num_seg,
  624. struct dp_tx_msdu_info_s *msdu_info)
  625. {
  626. struct qdf_tso_num_seg_elem_t *next_num_seg;
  627. while (free_num_seg) {
  628. next_num_seg = free_num_seg->next;
  629. dp_tso_num_seg_free(soc,
  630. msdu_info->tx_queue.desc_pool_id,
  631. free_num_seg);
  632. free_num_seg = next_num_seg;
  633. }
  634. }
  635. /**
  636. * dp_tx_unmap_tso_seg_list() - Loop through the tso segments
  637. * do dma unmap for each segment
  638. *
  639. * @soc: soc handle
  640. * @free_seg: list of tso segments
  641. * @num_seg_desc: tso number segment descriptor
  642. *
  643. * Return - void
  644. */
  645. static void dp_tx_unmap_tso_seg_list(
  646. struct dp_soc *soc,
  647. struct qdf_tso_seg_elem_t *free_seg,
  648. struct qdf_tso_num_seg_elem_t *num_seg_desc)
  649. {
  650. struct qdf_tso_seg_elem_t *next_seg;
  651. if (qdf_unlikely(!num_seg_desc)) {
  652. DP_TRACE(ERROR, "TSO number seg desc is NULL!");
  653. return;
  654. }
  655. while (free_seg) {
  656. next_seg = free_seg->next;
  657. dp_tx_tso_unmap_segment(soc, free_seg, num_seg_desc);
  658. free_seg = next_seg;
  659. }
  660. }
  661. #ifdef FEATURE_TSO_STATS
  662. /**
  663. * dp_tso_get_stats_idx: Retrieve the tso packet id
  664. * @pdev - pdev handle
  665. *
  666. * Return: id
  667. */
  668. static uint32_t dp_tso_get_stats_idx(struct dp_pdev *pdev)
  669. {
  670. uint32_t stats_idx;
  671. stats_idx = (((uint32_t)qdf_atomic_inc_return(&pdev->tso_idx))
  672. % CDP_MAX_TSO_PACKETS);
  673. return stats_idx;
  674. }
  675. #else
  676. static int dp_tso_get_stats_idx(struct dp_pdev *pdev)
  677. {
  678. return 0;
  679. }
  680. #endif /* FEATURE_TSO_STATS */
  681. /**
  682. * dp_tx_free_remaining_tso_desc() - do dma unmap for tso segments if any,
  683. * free the tso segments descriptor and
  684. * tso num segments descriptor
  685. *
  686. * @soc: soc handle
  687. * @msdu_info: msdu descriptor
  688. * @tso_seg_unmap: flag to show if dma unmap is necessary
  689. *
  690. * Return - void
  691. */
  692. static void dp_tx_free_remaining_tso_desc(struct dp_soc *soc,
  693. struct dp_tx_msdu_info_s *msdu_info,
  694. bool tso_seg_unmap)
  695. {
  696. struct qdf_tso_info_t *tso_info = &msdu_info->u.tso_info;
  697. struct qdf_tso_seg_elem_t *free_seg = tso_info->tso_seg_list;
  698. struct qdf_tso_num_seg_elem_t *tso_num_desc =
  699. tso_info->tso_num_seg_list;
  700. /* do dma unmap for each segment */
  701. if (tso_seg_unmap)
  702. dp_tx_unmap_tso_seg_list(soc, free_seg, tso_num_desc);
  703. /* free all tso number segment descriptor though looks only have 1 */
  704. dp_tx_free_tso_num_seg_list(soc, tso_num_desc, msdu_info);
  705. /* free all tso segment descriptor */
  706. dp_tx_free_tso_seg_list(soc, free_seg, msdu_info);
  707. }
  708. /**
  709. * dp_tx_prepare_tso() - Given a jumbo msdu, prepare the TSO info
  710. * @vdev: virtual device handle
  711. * @msdu: network buffer
  712. * @msdu_info: meta data associated with the msdu
  713. *
  714. * Return: QDF_STATUS_SUCCESS success
  715. */
  716. static QDF_STATUS dp_tx_prepare_tso(struct dp_vdev *vdev,
  717. qdf_nbuf_t msdu, struct dp_tx_msdu_info_s *msdu_info)
  718. {
  719. struct qdf_tso_seg_elem_t *tso_seg;
  720. int num_seg = qdf_nbuf_get_tso_num_seg(msdu);
  721. struct dp_soc *soc = vdev->pdev->soc;
  722. struct dp_pdev *pdev = vdev->pdev;
  723. struct qdf_tso_info_t *tso_info;
  724. struct qdf_tso_num_seg_elem_t *tso_num_seg;
  725. tso_info = &msdu_info->u.tso_info;
  726. tso_info->curr_seg = NULL;
  727. tso_info->tso_seg_list = NULL;
  728. tso_info->num_segs = num_seg;
  729. msdu_info->frm_type = dp_tx_frm_tso;
  730. tso_info->tso_num_seg_list = NULL;
  731. TSO_DEBUG(" %s: num_seg: %d", __func__, num_seg);
  732. while (num_seg) {
  733. tso_seg = dp_tx_tso_desc_alloc(
  734. soc, msdu_info->tx_queue.desc_pool_id);
  735. if (tso_seg) {
  736. tso_seg->next = tso_info->tso_seg_list;
  737. tso_info->tso_seg_list = tso_seg;
  738. num_seg--;
  739. } else {
  740. dp_err_rl("Failed to alloc tso seg desc");
  741. DP_STATS_INC_PKT(vdev->pdev,
  742. tso_stats.tso_no_mem_dropped, 1,
  743. qdf_nbuf_len(msdu));
  744. dp_tx_free_remaining_tso_desc(soc, msdu_info, false);
  745. return QDF_STATUS_E_NOMEM;
  746. }
  747. }
  748. TSO_DEBUG(" %s: num_seg: %d", __func__, num_seg);
  749. tso_num_seg = dp_tso_num_seg_alloc(soc,
  750. msdu_info->tx_queue.desc_pool_id);
  751. if (tso_num_seg) {
  752. tso_num_seg->next = tso_info->tso_num_seg_list;
  753. tso_info->tso_num_seg_list = tso_num_seg;
  754. } else {
  755. DP_TRACE(ERROR, "%s: Failed to alloc - Number of segs desc",
  756. __func__);
  757. dp_tx_free_remaining_tso_desc(soc, msdu_info, false);
  758. return QDF_STATUS_E_NOMEM;
  759. }
  760. msdu_info->num_seg =
  761. qdf_nbuf_get_tso_info(soc->osdev, msdu, tso_info);
  762. TSO_DEBUG(" %s: msdu_info->num_seg: %d", __func__,
  763. msdu_info->num_seg);
  764. if (!(msdu_info->num_seg)) {
  765. /*
  766. * Free allocated TSO seg desc and number seg desc,
  767. * do unmap for segments if dma map has done.
  768. */
  769. DP_TRACE(ERROR, "%s: Failed to get tso info", __func__);
  770. dp_tx_free_remaining_tso_desc(soc, msdu_info, true);
  771. return QDF_STATUS_E_INVAL;
  772. }
  773. dp_tx_tso_history_add(soc, msdu_info->u.tso_info,
  774. msdu, 0, DP_TX_DESC_MAP);
  775. tso_info->curr_seg = tso_info->tso_seg_list;
  776. tso_info->msdu_stats_idx = dp_tso_get_stats_idx(pdev);
  777. dp_tso_packet_update(pdev, tso_info->msdu_stats_idx,
  778. msdu, msdu_info->num_seg);
  779. dp_tso_segment_stats_update(pdev, tso_info->tso_seg_list,
  780. tso_info->msdu_stats_idx);
  781. dp_stats_tso_segment_histogram_update(pdev, msdu_info->num_seg);
  782. return QDF_STATUS_SUCCESS;
  783. }
  784. #else
  785. static QDF_STATUS dp_tx_prepare_tso(struct dp_vdev *vdev,
  786. qdf_nbuf_t msdu, struct dp_tx_msdu_info_s *msdu_info)
  787. {
  788. return QDF_STATUS_E_NOMEM;
  789. }
  790. #endif
  791. QDF_COMPILE_TIME_ASSERT(dp_tx_htt_metadata_len_check,
  792. (DP_TX_MSDU_INFO_META_DATA_DWORDS * 4 >=
  793. sizeof(struct htt_tx_msdu_desc_ext2_t)));
  794. /**
  795. * dp_tx_prepare_ext_desc() - Allocate and prepare MSDU extension descriptor
  796. * @vdev: DP Vdev handle
  797. * @msdu_info: MSDU info to be setup in MSDU extension descriptor
  798. * @desc_pool_id: Descriptor Pool ID
  799. *
  800. * Return:
  801. */
  802. static
  803. struct dp_tx_ext_desc_elem_s *dp_tx_prepare_ext_desc(struct dp_vdev *vdev,
  804. struct dp_tx_msdu_info_s *msdu_info, uint8_t desc_pool_id)
  805. {
  806. uint8_t i;
  807. uint8_t cached_ext_desc[HAL_TX_EXT_DESC_WITH_META_DATA];
  808. struct dp_tx_seg_info_s *seg_info;
  809. struct dp_tx_ext_desc_elem_s *msdu_ext_desc;
  810. struct dp_soc *soc = vdev->pdev->soc;
  811. /* Allocate an extension descriptor */
  812. msdu_ext_desc = dp_tx_ext_desc_alloc(soc, desc_pool_id);
  813. qdf_mem_zero(&cached_ext_desc[0], HAL_TX_EXT_DESC_WITH_META_DATA);
  814. if (!msdu_ext_desc) {
  815. DP_STATS_INC(vdev, tx_i.dropped.desc_na.num, 1);
  816. return NULL;
  817. }
  818. if (msdu_info->exception_fw &&
  819. qdf_unlikely(vdev->mesh_vdev)) {
  820. qdf_mem_copy(&cached_ext_desc[HAL_TX_EXTENSION_DESC_LEN_BYTES],
  821. &msdu_info->meta_data[0],
  822. sizeof(struct htt_tx_msdu_desc_ext2_t));
  823. qdf_atomic_inc(&soc->num_tx_exception);
  824. msdu_ext_desc->flags |= DP_TX_EXT_DESC_FLAG_METADATA_VALID;
  825. }
  826. switch (msdu_info->frm_type) {
  827. case dp_tx_frm_sg:
  828. case dp_tx_frm_me:
  829. case dp_tx_frm_raw:
  830. seg_info = msdu_info->u.sg_info.curr_seg;
  831. /* Update the buffer pointers in MSDU Extension Descriptor */
  832. for (i = 0; i < seg_info->frag_cnt; i++) {
  833. hal_tx_ext_desc_set_buffer(&cached_ext_desc[0], i,
  834. seg_info->frags[i].paddr_lo,
  835. seg_info->frags[i].paddr_hi,
  836. seg_info->frags[i].len);
  837. }
  838. break;
  839. case dp_tx_frm_tso:
  840. dp_tx_prepare_tso_ext_desc(&msdu_info->u.tso_info.curr_seg->seg,
  841. &cached_ext_desc[0]);
  842. break;
  843. default:
  844. break;
  845. }
  846. QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  847. cached_ext_desc, HAL_TX_EXT_DESC_WITH_META_DATA);
  848. hal_tx_ext_desc_sync(&cached_ext_desc[0],
  849. msdu_ext_desc->vaddr);
  850. return msdu_ext_desc;
  851. }
  852. /**
  853. * dp_tx_trace_pkt() - Trace TX packet at DP layer
  854. *
  855. * @skb: skb to be traced
  856. * @msdu_id: msdu_id of the packet
  857. * @vdev_id: vdev_id of the packet
  858. *
  859. * Return: None
  860. */
  861. #ifdef DP_DISABLE_TX_PKT_TRACE
  862. static void dp_tx_trace_pkt(struct dp_soc *soc,
  863. qdf_nbuf_t skb, uint16_t msdu_id,
  864. uint8_t vdev_id)
  865. {
  866. }
  867. #else
  868. static void dp_tx_trace_pkt(struct dp_soc *soc,
  869. qdf_nbuf_t skb, uint16_t msdu_id,
  870. uint8_t vdev_id)
  871. {
  872. if (dp_is_tput_high(soc))
  873. return;
  874. QDF_NBUF_CB_TX_PACKET_TRACK(skb) = QDF_NBUF_TX_PKT_DATA_TRACK;
  875. QDF_NBUF_CB_TX_DP_TRACE(skb) = 1;
  876. DPTRACE(qdf_dp_trace_ptr(skb,
  877. QDF_DP_TRACE_LI_DP_TX_PACKET_PTR_RECORD,
  878. QDF_TRACE_DEFAULT_PDEV_ID,
  879. qdf_nbuf_data_addr(skb),
  880. sizeof(qdf_nbuf_data(skb)),
  881. msdu_id, vdev_id, 0));
  882. qdf_dp_trace_log_pkt(vdev_id, skb, QDF_TX, QDF_TRACE_DEFAULT_PDEV_ID);
  883. DPTRACE(qdf_dp_trace_data_pkt(skb, QDF_TRACE_DEFAULT_PDEV_ID,
  884. QDF_DP_TRACE_LI_DP_TX_PACKET_RECORD,
  885. msdu_id, QDF_TX));
  886. }
  887. #endif
  888. #ifdef WLAN_DP_FEATURE_MARK_ICMP_REQ_TO_FW
  889. /**
  890. * dp_tx_is_nbuf_marked_exception() - Check if the packet has been marked as
  891. * exception by the upper layer (OS_IF)
  892. * @soc: DP soc handle
  893. * @nbuf: packet to be transmitted
  894. *
  895. * Returns: 1 if the packet is marked as exception,
  896. * 0, if the packet is not marked as exception.
  897. */
  898. static inline int dp_tx_is_nbuf_marked_exception(struct dp_soc *soc,
  899. qdf_nbuf_t nbuf)
  900. {
  901. return QDF_NBUF_CB_TX_PACKET_TO_FW(nbuf);
  902. }
  903. #else
  904. static inline int dp_tx_is_nbuf_marked_exception(struct dp_soc *soc,
  905. qdf_nbuf_t nbuf)
  906. {
  907. return 0;
  908. }
  909. #endif
  910. /**
  911. * dp_tx_desc_prepare_single - Allocate and prepare Tx descriptor
  912. * @vdev: DP vdev handle
  913. * @nbuf: skb
  914. * @desc_pool_id: Descriptor pool ID
  915. * @meta_data: Metadata to the fw
  916. * @tx_exc_metadata: Handle that holds exception path metadata
  917. * Allocate and prepare Tx descriptor with msdu information.
  918. *
  919. * Return: Pointer to Tx Descriptor on success,
  920. * NULL on failure
  921. */
  922. static
  923. struct dp_tx_desc_s *dp_tx_prepare_desc_single(struct dp_vdev *vdev,
  924. qdf_nbuf_t nbuf, uint8_t desc_pool_id,
  925. struct dp_tx_msdu_info_s *msdu_info,
  926. struct cdp_tx_exception_metadata *tx_exc_metadata)
  927. {
  928. uint8_t align_pad;
  929. uint8_t is_exception = 0;
  930. uint8_t htt_hdr_size;
  931. struct dp_tx_desc_s *tx_desc;
  932. struct dp_pdev *pdev = vdev->pdev;
  933. struct dp_soc *soc = pdev->soc;
  934. if (dp_tx_limit_check(vdev))
  935. return NULL;
  936. /* Allocate software Tx descriptor */
  937. tx_desc = dp_tx_desc_alloc(soc, desc_pool_id);
  938. if (qdf_unlikely(!tx_desc)) {
  939. DP_STATS_INC(vdev, tx_i.dropped.desc_na.num, 1);
  940. DP_STATS_INC(vdev, tx_i.dropped.desc_na_exc_alloc_fail.num, 1);
  941. return NULL;
  942. }
  943. dp_tx_outstanding_inc(pdev);
  944. /* Initialize the SW tx descriptor */
  945. tx_desc->nbuf = nbuf;
  946. tx_desc->frm_type = dp_tx_frm_std;
  947. tx_desc->tx_encap_type = ((tx_exc_metadata &&
  948. (tx_exc_metadata->tx_encap_type != CDP_INVALID_TX_ENCAP_TYPE)) ?
  949. tx_exc_metadata->tx_encap_type : vdev->tx_encap_type);
  950. tx_desc->vdev_id = vdev->vdev_id;
  951. tx_desc->pdev = pdev;
  952. tx_desc->msdu_ext_desc = NULL;
  953. tx_desc->pkt_offset = 0;
  954. tx_desc->length = qdf_nbuf_headlen(nbuf);
  955. dp_tx_trace_pkt(soc, nbuf, tx_desc->id, vdev->vdev_id);
  956. if (qdf_unlikely(vdev->multipass_en)) {
  957. if (!dp_tx_multipass_process(soc, vdev, nbuf, msdu_info))
  958. goto failure;
  959. }
  960. /* Packets marked by upper layer (OS-IF) to be sent to FW */
  961. if (dp_tx_is_nbuf_marked_exception(soc, nbuf))
  962. is_exception = 1;
  963. /*
  964. * For special modes (vdev_type == ocb or mesh), data frames should be
  965. * transmitted using varying transmit parameters (tx spec) which include
  966. * transmit rate, power, priority, channel, channel bandwidth , nss etc.
  967. * These are filled in HTT MSDU descriptor and sent in frame pre-header.
  968. * These frames are sent as exception packets to firmware.
  969. *
  970. * HW requirement is that metadata should always point to a
  971. * 8-byte aligned address. So we add alignment pad to start of buffer.
  972. * HTT Metadata should be ensured to be multiple of 8-bytes,
  973. * to get 8-byte aligned start address along with align_pad added
  974. *
  975. * |-----------------------------|
  976. * | |
  977. * |-----------------------------| <-----Buffer Pointer Address given
  978. * | | ^ in HW descriptor (aligned)
  979. * | HTT Metadata | |
  980. * | | |
  981. * | | | Packet Offset given in descriptor
  982. * | | |
  983. * |-----------------------------| |
  984. * | Alignment Pad | v
  985. * |-----------------------------| <----- Actual buffer start address
  986. * | SKB Data | (Unaligned)
  987. * | |
  988. * | |
  989. * | |
  990. * | |
  991. * | |
  992. * |-----------------------------|
  993. */
  994. if (qdf_unlikely((msdu_info->exception_fw)) ||
  995. (vdev->opmode == wlan_op_mode_ocb) ||
  996. (tx_exc_metadata &&
  997. tx_exc_metadata->is_tx_sniffer)) {
  998. align_pad = ((unsigned long) qdf_nbuf_data(nbuf)) & 0x7;
  999. if (qdf_unlikely(qdf_nbuf_headroom(nbuf) < align_pad)) {
  1000. DP_STATS_INC(vdev,
  1001. tx_i.dropped.headroom_insufficient, 1);
  1002. goto failure;
  1003. }
  1004. if (qdf_nbuf_push_head(nbuf, align_pad) == NULL) {
  1005. dp_tx_err("qdf_nbuf_push_head failed");
  1006. goto failure;
  1007. }
  1008. htt_hdr_size = dp_tx_prepare_htt_metadata(vdev, nbuf,
  1009. msdu_info);
  1010. if (htt_hdr_size == 0)
  1011. goto failure;
  1012. tx_desc->length = qdf_nbuf_headlen(nbuf);
  1013. tx_desc->pkt_offset = align_pad + htt_hdr_size;
  1014. tx_desc->flags |= DP_TX_DESC_FLAG_TO_FW;
  1015. is_exception = 1;
  1016. tx_desc->length -= tx_desc->pkt_offset;
  1017. }
  1018. #if !TQM_BYPASS_WAR
  1019. if (is_exception || tx_exc_metadata)
  1020. #endif
  1021. {
  1022. /* Temporary WAR due to TQM VP issues */
  1023. tx_desc->flags |= DP_TX_DESC_FLAG_TO_FW;
  1024. qdf_atomic_inc(&soc->num_tx_exception);
  1025. }
  1026. return tx_desc;
  1027. failure:
  1028. dp_tx_desc_release(tx_desc, desc_pool_id);
  1029. return NULL;
  1030. }
  1031. /**
  1032. * dp_tx_prepare_desc() - Allocate and prepare Tx descriptor for multisegment frame
  1033. * @vdev: DP vdev handle
  1034. * @nbuf: skb
  1035. * @msdu_info: Info to be setup in MSDU descriptor and MSDU extension descriptor
  1036. * @desc_pool_id : Descriptor Pool ID
  1037. *
  1038. * Allocate and prepare Tx descriptor with msdu and fragment descritor
  1039. * information. For frames wth fragments, allocate and prepare
  1040. * an MSDU extension descriptor
  1041. *
  1042. * Return: Pointer to Tx Descriptor on success,
  1043. * NULL on failure
  1044. */
  1045. static struct dp_tx_desc_s *dp_tx_prepare_desc(struct dp_vdev *vdev,
  1046. qdf_nbuf_t nbuf, struct dp_tx_msdu_info_s *msdu_info,
  1047. uint8_t desc_pool_id)
  1048. {
  1049. struct dp_tx_desc_s *tx_desc;
  1050. struct dp_tx_ext_desc_elem_s *msdu_ext_desc;
  1051. struct dp_pdev *pdev = vdev->pdev;
  1052. struct dp_soc *soc = pdev->soc;
  1053. if (dp_tx_limit_check(vdev))
  1054. return NULL;
  1055. /* Allocate software Tx descriptor */
  1056. tx_desc = dp_tx_desc_alloc(soc, desc_pool_id);
  1057. if (!tx_desc) {
  1058. DP_STATS_INC(vdev, tx_i.dropped.desc_na.num, 1);
  1059. return NULL;
  1060. }
  1061. dp_tx_tso_seg_history_add(soc, msdu_info->u.tso_info.curr_seg,
  1062. nbuf, tx_desc->id, DP_TX_DESC_COOKIE);
  1063. dp_tx_outstanding_inc(pdev);
  1064. /* Initialize the SW tx descriptor */
  1065. tx_desc->nbuf = nbuf;
  1066. tx_desc->frm_type = msdu_info->frm_type;
  1067. tx_desc->tx_encap_type = vdev->tx_encap_type;
  1068. tx_desc->vdev_id = vdev->vdev_id;
  1069. tx_desc->pdev = pdev;
  1070. tx_desc->pkt_offset = 0;
  1071. dp_tx_trace_pkt(soc, nbuf, tx_desc->id, vdev->vdev_id);
  1072. /* Handle scattered frames - TSO/SG/ME */
  1073. /* Allocate and prepare an extension descriptor for scattered frames */
  1074. msdu_ext_desc = dp_tx_prepare_ext_desc(vdev, msdu_info, desc_pool_id);
  1075. if (!msdu_ext_desc) {
  1076. dp_tx_info("Tx Extension Descriptor Alloc Fail");
  1077. goto failure;
  1078. }
  1079. #if TQM_BYPASS_WAR
  1080. /* Temporary WAR due to TQM VP issues */
  1081. tx_desc->flags |= DP_TX_DESC_FLAG_TO_FW;
  1082. qdf_atomic_inc(&soc->num_tx_exception);
  1083. #endif
  1084. if (qdf_unlikely(msdu_info->exception_fw))
  1085. tx_desc->flags |= DP_TX_DESC_FLAG_TO_FW;
  1086. tx_desc->msdu_ext_desc = msdu_ext_desc;
  1087. tx_desc->flags |= DP_TX_DESC_FLAG_FRAG;
  1088. msdu_ext_desc->tso_desc = msdu_info->u.tso_info.curr_seg;
  1089. msdu_ext_desc->tso_num_desc = msdu_info->u.tso_info.tso_num_seg_list;
  1090. tx_desc->dma_addr = msdu_ext_desc->paddr;
  1091. if (msdu_ext_desc->flags & DP_TX_EXT_DESC_FLAG_METADATA_VALID)
  1092. tx_desc->length = HAL_TX_EXT_DESC_WITH_META_DATA;
  1093. else
  1094. tx_desc->length = HAL_TX_EXTENSION_DESC_LEN_BYTES;
  1095. return tx_desc;
  1096. failure:
  1097. dp_tx_desc_release(tx_desc, desc_pool_id);
  1098. return NULL;
  1099. }
  1100. /**
  1101. * dp_tx_prepare_raw() - Prepare RAW packet TX
  1102. * @vdev: DP vdev handle
  1103. * @nbuf: buffer pointer
  1104. * @seg_info: Pointer to Segment info Descriptor to be prepared
  1105. * @msdu_info: MSDU info to be setup in MSDU descriptor and MSDU extension
  1106. * descriptor
  1107. *
  1108. * Return:
  1109. */
  1110. static qdf_nbuf_t dp_tx_prepare_raw(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  1111. struct dp_tx_seg_info_s *seg_info, struct dp_tx_msdu_info_s *msdu_info)
  1112. {
  1113. qdf_nbuf_t curr_nbuf = NULL;
  1114. uint16_t total_len = 0;
  1115. qdf_dma_addr_t paddr;
  1116. int32_t i;
  1117. int32_t mapped_buf_num = 0;
  1118. struct dp_tx_sg_info_s *sg_info = &msdu_info->u.sg_info;
  1119. qdf_dot3_qosframe_t *qos_wh = (qdf_dot3_qosframe_t *) nbuf->data;
  1120. DP_STATS_INC_PKT(vdev, tx_i.raw.raw_pkt, 1, qdf_nbuf_len(nbuf));
  1121. /* Continue only if frames are of DATA type */
  1122. if (!DP_FRAME_IS_DATA(qos_wh)) {
  1123. DP_STATS_INC(vdev, tx_i.raw.invalid_raw_pkt_datatype, 1);
  1124. dp_tx_debug("Pkt. recd is of not data type");
  1125. goto error;
  1126. }
  1127. /* SWAR for HW: Enable WEP bit in the AMSDU frames for RAW mode */
  1128. if (vdev->raw_mode_war &&
  1129. (qos_wh->i_fc[0] & QDF_IEEE80211_FC0_SUBTYPE_QOS) &&
  1130. (qos_wh->i_qos[0] & IEEE80211_QOS_AMSDU))
  1131. qos_wh->i_fc[1] |= IEEE80211_FC1_WEP;
  1132. for (curr_nbuf = nbuf, i = 0; curr_nbuf;
  1133. curr_nbuf = qdf_nbuf_next(curr_nbuf), i++) {
  1134. /*
  1135. * Number of nbuf's must not exceed the size of the frags
  1136. * array in seg_info.
  1137. */
  1138. if (i >= DP_TX_MAX_NUM_FRAGS) {
  1139. dp_err_rl("nbuf cnt exceeds the max number of segs");
  1140. DP_STATS_INC(vdev, tx_i.raw.num_frags_overflow_err, 1);
  1141. goto error;
  1142. }
  1143. if (QDF_STATUS_SUCCESS !=
  1144. qdf_nbuf_map_nbytes_single(vdev->osdev,
  1145. curr_nbuf,
  1146. QDF_DMA_TO_DEVICE,
  1147. curr_nbuf->len)) {
  1148. dp_tx_err("%s dma map error ", __func__);
  1149. DP_STATS_INC(vdev, tx_i.raw.dma_map_error, 1);
  1150. goto error;
  1151. }
  1152. /* Update the count of mapped nbuf's */
  1153. mapped_buf_num++;
  1154. paddr = qdf_nbuf_get_frag_paddr(curr_nbuf, 0);
  1155. seg_info->frags[i].paddr_lo = paddr;
  1156. seg_info->frags[i].paddr_hi = ((uint64_t)paddr >> 32);
  1157. seg_info->frags[i].len = qdf_nbuf_len(curr_nbuf);
  1158. seg_info->frags[i].vaddr = (void *) curr_nbuf;
  1159. total_len += qdf_nbuf_len(curr_nbuf);
  1160. }
  1161. seg_info->frag_cnt = i;
  1162. seg_info->total_len = total_len;
  1163. seg_info->next = NULL;
  1164. sg_info->curr_seg = seg_info;
  1165. msdu_info->frm_type = dp_tx_frm_raw;
  1166. msdu_info->num_seg = 1;
  1167. return nbuf;
  1168. error:
  1169. i = 0;
  1170. while (nbuf) {
  1171. curr_nbuf = nbuf;
  1172. if (i < mapped_buf_num) {
  1173. qdf_nbuf_unmap_nbytes_single(vdev->osdev, curr_nbuf,
  1174. QDF_DMA_TO_DEVICE,
  1175. curr_nbuf->len);
  1176. i++;
  1177. }
  1178. nbuf = qdf_nbuf_next(nbuf);
  1179. qdf_nbuf_free(curr_nbuf);
  1180. }
  1181. return NULL;
  1182. }
  1183. /**
  1184. * dp_tx_raw_prepare_unset() - unmap the chain of nbufs belonging to RAW frame.
  1185. * @soc: DP soc handle
  1186. * @nbuf: Buffer pointer
  1187. *
  1188. * unmap the chain of nbufs that belong to this RAW frame.
  1189. *
  1190. * Return: None
  1191. */
  1192. static void dp_tx_raw_prepare_unset(struct dp_soc *soc,
  1193. qdf_nbuf_t nbuf)
  1194. {
  1195. qdf_nbuf_t cur_nbuf = nbuf;
  1196. do {
  1197. qdf_nbuf_unmap_nbytes_single(soc->osdev, cur_nbuf,
  1198. QDF_DMA_TO_DEVICE,
  1199. cur_nbuf->len);
  1200. cur_nbuf = qdf_nbuf_next(cur_nbuf);
  1201. } while (cur_nbuf);
  1202. }
  1203. #ifdef VDEV_PEER_PROTOCOL_COUNT
  1204. void dp_vdev_peer_stats_update_protocol_cnt_tx(struct dp_vdev *vdev_hdl,
  1205. qdf_nbuf_t nbuf)
  1206. {
  1207. qdf_nbuf_t nbuf_local;
  1208. struct dp_vdev *vdev_local = vdev_hdl;
  1209. do {
  1210. if (qdf_likely(!((vdev_local)->peer_protocol_count_track)))
  1211. break;
  1212. nbuf_local = nbuf;
  1213. if (qdf_unlikely(((vdev_local)->tx_encap_type) ==
  1214. htt_cmn_pkt_type_raw))
  1215. break;
  1216. else if (qdf_unlikely(qdf_nbuf_is_nonlinear((nbuf_local))))
  1217. break;
  1218. else if (qdf_nbuf_is_tso((nbuf_local)))
  1219. break;
  1220. dp_vdev_peer_stats_update_protocol_cnt((vdev_local),
  1221. (nbuf_local),
  1222. NULL, 1, 0);
  1223. } while (0);
  1224. }
  1225. #endif
  1226. #ifdef WLAN_DP_FEATURE_SW_LATENCY_MGR
  1227. /**
  1228. * dp_tx_update_stats() - Update soc level tx stats
  1229. * @soc: DP soc handle
  1230. * @nbuf: packet being transmitted
  1231. *
  1232. * Returns: none
  1233. */
  1234. void dp_tx_update_stats(struct dp_soc *soc,
  1235. qdf_nbuf_t nbuf)
  1236. {
  1237. DP_STATS_INC_PKT(soc, tx.egress, 1, qdf_nbuf_len(nbuf));
  1238. }
  1239. int
  1240. dp_tx_attempt_coalescing(struct dp_soc *soc, struct dp_vdev *vdev,
  1241. struct dp_tx_desc_s *tx_desc,
  1242. uint8_t tid,
  1243. struct dp_tx_msdu_info_s *msdu_info)
  1244. {
  1245. struct dp_swlm *swlm = &soc->swlm;
  1246. union swlm_data swlm_query_data;
  1247. struct dp_swlm_tcl_data tcl_data;
  1248. QDF_STATUS status;
  1249. int ret;
  1250. if (!swlm->is_enabled)
  1251. return msdu_info->skip_hp_update;
  1252. tcl_data.nbuf = tx_desc->nbuf;
  1253. tcl_data.tid = tid;
  1254. tcl_data.num_ll_connections = vdev->num_latency_critical_conn;
  1255. swlm_query_data.tcl_data = &tcl_data;
  1256. status = dp_swlm_tcl_pre_check(soc, &tcl_data);
  1257. if (QDF_IS_STATUS_ERROR(status)) {
  1258. dp_swlm_tcl_reset_session_data(soc);
  1259. DP_STATS_INC(swlm, tcl.coalesce_fail, 1);
  1260. return 0;
  1261. }
  1262. ret = dp_swlm_query_policy(soc, TCL_DATA, swlm_query_data);
  1263. if (ret) {
  1264. DP_STATS_INC(swlm, tcl.coalesce_success, 1);
  1265. } else {
  1266. DP_STATS_INC(swlm, tcl.coalesce_fail, 1);
  1267. }
  1268. return ret;
  1269. }
  1270. void
  1271. dp_tx_ring_access_end(struct dp_soc *soc, hal_ring_handle_t hal_ring_hdl,
  1272. int coalesce)
  1273. {
  1274. if (coalesce)
  1275. dp_tx_hal_ring_access_end_reap(soc, hal_ring_hdl);
  1276. else
  1277. dp_tx_hal_ring_access_end(soc, hal_ring_hdl);
  1278. }
  1279. static inline void
  1280. dp_tx_is_hp_update_required(uint32_t i, struct dp_tx_msdu_info_s *msdu_info)
  1281. {
  1282. if (((i + 1) < msdu_info->num_seg))
  1283. msdu_info->skip_hp_update = 1;
  1284. else
  1285. msdu_info->skip_hp_update = 0;
  1286. }
  1287. static inline void
  1288. dp_flush_tcp_hp(struct dp_soc *soc, uint8_t ring_id)
  1289. {
  1290. hal_ring_handle_t hal_ring_hdl =
  1291. dp_tx_get_hal_ring_hdl(soc, ring_id);
  1292. if (dp_tx_hal_ring_access_start(soc, hal_ring_hdl)) {
  1293. dp_err("Fillmore: SRNG access start failed");
  1294. return;
  1295. }
  1296. dp_tx_ring_access_end_wrapper(soc, hal_ring_hdl, 0);
  1297. }
  1298. static inline void
  1299. dp_tx_check_and_flush_hp(struct dp_soc *soc,
  1300. QDF_STATUS status,
  1301. struct dp_tx_msdu_info_s *msdu_info)
  1302. {
  1303. if (QDF_IS_STATUS_ERROR(status) && !msdu_info->skip_hp_update) {
  1304. dp_flush_tcp_hp(soc,
  1305. (msdu_info->tx_queue.ring_id & DP_TX_QUEUE_MASK));
  1306. }
  1307. }
  1308. #else
  1309. static inline void
  1310. dp_tx_is_hp_update_required(uint32_t i, struct dp_tx_msdu_info_s *msdu_info)
  1311. {
  1312. }
  1313. static inline void
  1314. dp_tx_check_and_flush_hp(struct dp_soc *soc,
  1315. QDF_STATUS status,
  1316. struct dp_tx_msdu_info_s *msdu_info)
  1317. {
  1318. }
  1319. #endif
  1320. #ifdef FEATURE_RUNTIME_PM
  1321. static inline int dp_get_rtpm_tput_policy_requirement(struct dp_soc *soc)
  1322. {
  1323. return qdf_atomic_read(&soc->rtpm_high_tput_flag);
  1324. }
  1325. /**
  1326. * dp_tx_ring_access_end_wrapper() - Wrapper for ring access end
  1327. * @soc: Datapath soc handle
  1328. * @hal_ring_hdl: HAL ring handle
  1329. * @coalesce: Coalesce the current write or not
  1330. *
  1331. * Wrapper for HAL ring access end for data transmission for
  1332. * FEATURE_RUNTIME_PM
  1333. *
  1334. * Returns: none
  1335. */
  1336. void
  1337. dp_tx_ring_access_end_wrapper(struct dp_soc *soc,
  1338. hal_ring_handle_t hal_ring_hdl,
  1339. int coalesce)
  1340. {
  1341. int ret;
  1342. /*
  1343. * Avoid runtime get and put APIs under high throughput scenarios.
  1344. */
  1345. if (dp_get_rtpm_tput_policy_requirement(soc)) {
  1346. dp_tx_ring_access_end(soc, hal_ring_hdl, coalesce);
  1347. return;
  1348. }
  1349. ret = hif_pm_runtime_get(soc->hif_handle,
  1350. RTPM_ID_DW_TX_HW_ENQUEUE, true);
  1351. switch (ret) {
  1352. case 0:
  1353. if (hif_system_pm_state_check(soc->hif_handle)) {
  1354. dp_tx_hal_ring_access_end_reap(soc, hal_ring_hdl);
  1355. hal_srng_set_event(hal_ring_hdl, HAL_SRNG_FLUSH_EVENT);
  1356. hal_srng_inc_flush_cnt(hal_ring_hdl);
  1357. } else {
  1358. dp_tx_ring_access_end(soc, hal_ring_hdl, coalesce);
  1359. }
  1360. hif_pm_runtime_put(soc->hif_handle,
  1361. RTPM_ID_DW_TX_HW_ENQUEUE);
  1362. break;
  1363. /*
  1364. * If hif_pm_runtime_get returns -EBUSY or -EINPROGRESS,
  1365. * take the dp runtime refcount using dp_runtime_get,
  1366. * check link state,if up, write TX ring HP, else just set flush event.
  1367. * In dp_runtime_resume, wait until dp runtime refcount becomes
  1368. * zero or time out, then flush pending tx.
  1369. */
  1370. case -EBUSY:
  1371. case -EINPROGRESS:
  1372. dp_runtime_get(soc);
  1373. if (hif_pm_get_link_state(soc->hif_handle) ==
  1374. HIF_PM_LINK_STATE_UP) {
  1375. dp_tx_ring_access_end(soc, hal_ring_hdl, coalesce);
  1376. } else {
  1377. dp_tx_hal_ring_access_end_reap(soc, hal_ring_hdl);
  1378. hal_srng_set_event(hal_ring_hdl, HAL_SRNG_FLUSH_EVENT);
  1379. qdf_atomic_inc(&soc->tx_pending_rtpm);
  1380. hal_srng_inc_flush_cnt(hal_ring_hdl);
  1381. }
  1382. dp_runtime_put(soc);
  1383. break;
  1384. default:
  1385. dp_runtime_get(soc);
  1386. dp_tx_hal_ring_access_end_reap(soc, hal_ring_hdl);
  1387. hal_srng_set_event(hal_ring_hdl, HAL_SRNG_FLUSH_EVENT);
  1388. qdf_atomic_inc(&soc->tx_pending_rtpm);
  1389. hal_srng_inc_flush_cnt(hal_ring_hdl);
  1390. dp_runtime_put(soc);
  1391. }
  1392. }
  1393. #else
  1394. #ifdef DP_POWER_SAVE
  1395. void
  1396. dp_tx_ring_access_end_wrapper(struct dp_soc *soc,
  1397. hal_ring_handle_t hal_ring_hdl,
  1398. int coalesce)
  1399. {
  1400. if (hif_system_pm_state_check(soc->hif_handle)) {
  1401. dp_tx_hal_ring_access_end_reap(soc, hal_ring_hdl);
  1402. hal_srng_set_event(hal_ring_hdl, HAL_SRNG_FLUSH_EVENT);
  1403. hal_srng_inc_flush_cnt(hal_ring_hdl);
  1404. } else {
  1405. dp_tx_ring_access_end(soc, hal_ring_hdl, coalesce);
  1406. }
  1407. }
  1408. #endif
  1409. static inline int dp_get_rtpm_tput_policy_requirement(struct dp_soc *soc)
  1410. {
  1411. return 0;
  1412. }
  1413. #endif
  1414. /**
  1415. * dp_tx_get_tid() - Obtain TID to be used for this frame
  1416. * @vdev: DP vdev handle
  1417. * @nbuf: skb
  1418. *
  1419. * Extract the DSCP or PCP information from frame and map into TID value.
  1420. *
  1421. * Return: void
  1422. */
  1423. static void dp_tx_get_tid(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  1424. struct dp_tx_msdu_info_s *msdu_info)
  1425. {
  1426. uint8_t tos = 0, dscp_tid_override = 0;
  1427. uint8_t *hdr_ptr, *L3datap;
  1428. uint8_t is_mcast = 0;
  1429. qdf_ether_header_t *eh = NULL;
  1430. qdf_ethervlan_header_t *evh = NULL;
  1431. uint16_t ether_type;
  1432. qdf_llc_t *llcHdr;
  1433. struct dp_pdev *pdev = (struct dp_pdev *)vdev->pdev;
  1434. DP_TX_TID_OVERRIDE(msdu_info, nbuf);
  1435. if (qdf_likely(vdev->tx_encap_type != htt_cmn_pkt_type_raw)) {
  1436. eh = (qdf_ether_header_t *)nbuf->data;
  1437. hdr_ptr = (uint8_t *)(eh->ether_dhost);
  1438. L3datap = hdr_ptr + sizeof(qdf_ether_header_t);
  1439. } else {
  1440. qdf_dot3_qosframe_t *qos_wh =
  1441. (qdf_dot3_qosframe_t *) nbuf->data;
  1442. msdu_info->tid = qos_wh->i_fc[0] & DP_FC0_SUBTYPE_QOS ?
  1443. qos_wh->i_qos[0] & DP_QOS_TID : 0;
  1444. return;
  1445. }
  1446. is_mcast = DP_FRAME_IS_MULTICAST(hdr_ptr);
  1447. ether_type = eh->ether_type;
  1448. llcHdr = (qdf_llc_t *)(nbuf->data + sizeof(qdf_ether_header_t));
  1449. /*
  1450. * Check if packet is dot3 or eth2 type.
  1451. */
  1452. if (DP_FRAME_IS_LLC(ether_type) && DP_FRAME_IS_SNAP(llcHdr)) {
  1453. ether_type = (uint16_t)*(nbuf->data + 2*QDF_MAC_ADDR_SIZE +
  1454. sizeof(*llcHdr));
  1455. if (ether_type == htons(ETHERTYPE_VLAN)) {
  1456. L3datap = hdr_ptr + sizeof(qdf_ethervlan_header_t) +
  1457. sizeof(*llcHdr);
  1458. ether_type = (uint16_t)*(nbuf->data + 2*QDF_MAC_ADDR_SIZE
  1459. + sizeof(*llcHdr) +
  1460. sizeof(qdf_net_vlanhdr_t));
  1461. } else {
  1462. L3datap = hdr_ptr + sizeof(qdf_ether_header_t) +
  1463. sizeof(*llcHdr);
  1464. }
  1465. } else {
  1466. if (ether_type == htons(ETHERTYPE_VLAN)) {
  1467. evh = (qdf_ethervlan_header_t *) eh;
  1468. ether_type = evh->ether_type;
  1469. L3datap = hdr_ptr + sizeof(qdf_ethervlan_header_t);
  1470. }
  1471. }
  1472. /*
  1473. * Find priority from IP TOS DSCP field
  1474. */
  1475. if (qdf_nbuf_is_ipv4_pkt(nbuf)) {
  1476. qdf_net_iphdr_t *ip = (qdf_net_iphdr_t *) L3datap;
  1477. if (qdf_nbuf_is_ipv4_dhcp_pkt(nbuf)) {
  1478. /* Only for unicast frames */
  1479. if (!is_mcast) {
  1480. /* send it on VO queue */
  1481. msdu_info->tid = DP_VO_TID;
  1482. }
  1483. } else {
  1484. /*
  1485. * IP frame: exclude ECN bits 0-1 and map DSCP bits 2-7
  1486. * from TOS byte.
  1487. */
  1488. tos = ip->ip_tos;
  1489. dscp_tid_override = 1;
  1490. }
  1491. } else if (qdf_nbuf_is_ipv6_pkt(nbuf)) {
  1492. /* TODO
  1493. * use flowlabel
  1494. *igmpmld cases to be handled in phase 2
  1495. */
  1496. unsigned long ver_pri_flowlabel;
  1497. unsigned long pri;
  1498. ver_pri_flowlabel = *(unsigned long *) L3datap;
  1499. pri = (ntohl(ver_pri_flowlabel) & IPV6_FLOWINFO_PRIORITY) >>
  1500. DP_IPV6_PRIORITY_SHIFT;
  1501. tos = pri;
  1502. dscp_tid_override = 1;
  1503. } else if (qdf_nbuf_is_ipv4_eapol_pkt(nbuf))
  1504. msdu_info->tid = DP_VO_TID;
  1505. else if (qdf_nbuf_is_ipv4_arp_pkt(nbuf)) {
  1506. /* Only for unicast frames */
  1507. if (!is_mcast) {
  1508. /* send ucast arp on VO queue */
  1509. msdu_info->tid = DP_VO_TID;
  1510. }
  1511. }
  1512. /*
  1513. * Assign all MCAST packets to BE
  1514. */
  1515. if (qdf_unlikely(vdev->tx_encap_type != htt_cmn_pkt_type_raw)) {
  1516. if (is_mcast) {
  1517. tos = 0;
  1518. dscp_tid_override = 1;
  1519. }
  1520. }
  1521. if (dscp_tid_override == 1) {
  1522. tos = (tos >> DP_IP_DSCP_SHIFT) & DP_IP_DSCP_MASK;
  1523. msdu_info->tid = pdev->dscp_tid_map[vdev->dscp_tid_map_id][tos];
  1524. }
  1525. if (msdu_info->tid >= CDP_MAX_DATA_TIDS)
  1526. msdu_info->tid = CDP_MAX_DATA_TIDS - 1;
  1527. return;
  1528. }
  1529. /**
  1530. * dp_tx_classify_tid() - Obtain TID to be used for this frame
  1531. * @vdev: DP vdev handle
  1532. * @nbuf: skb
  1533. *
  1534. * Software based TID classification is required when more than 2 DSCP-TID
  1535. * mapping tables are needed.
  1536. * Hardware supports 2 DSCP-TID mapping tables for HKv1 and 48 for HKv2.
  1537. *
  1538. * Return: void
  1539. */
  1540. static inline void dp_tx_classify_tid(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  1541. struct dp_tx_msdu_info_s *msdu_info)
  1542. {
  1543. DP_TX_TID_OVERRIDE(msdu_info, nbuf);
  1544. /*
  1545. * skip_sw_tid_classification flag will set in below cases-
  1546. * 1. vdev->dscp_tid_map_id < pdev->soc->num_hw_dscp_tid_map
  1547. * 2. hlos_tid_override enabled for vdev
  1548. * 3. mesh mode enabled for vdev
  1549. */
  1550. if (qdf_likely(vdev->skip_sw_tid_classification)) {
  1551. /* Update tid in msdu_info from skb priority */
  1552. if (qdf_unlikely(vdev->skip_sw_tid_classification
  1553. & DP_TXRX_HLOS_TID_OVERRIDE_ENABLED)) {
  1554. uint32_t tid = qdf_nbuf_get_priority(nbuf);
  1555. if (tid == DP_TX_INVALID_QOS_TAG)
  1556. return;
  1557. msdu_info->tid = tid;
  1558. return;
  1559. }
  1560. return;
  1561. }
  1562. dp_tx_get_tid(vdev, nbuf, msdu_info);
  1563. }
  1564. #ifdef FEATURE_WLAN_TDLS
  1565. /**
  1566. * dp_tx_update_tdls_flags() - Update descriptor flags for TDLS frame
  1567. * @soc: datapath SOC
  1568. * @vdev: datapath vdev
  1569. * @tx_desc: TX descriptor
  1570. *
  1571. * Return: None
  1572. */
  1573. static void dp_tx_update_tdls_flags(struct dp_soc *soc,
  1574. struct dp_vdev *vdev,
  1575. struct dp_tx_desc_s *tx_desc)
  1576. {
  1577. if (vdev) {
  1578. if (vdev->is_tdls_frame) {
  1579. tx_desc->flags |= DP_TX_DESC_FLAG_TDLS_FRAME;
  1580. vdev->is_tdls_frame = false;
  1581. }
  1582. }
  1583. }
  1584. static uint8_t dp_htt_tx_comp_get_status(struct dp_soc *soc, char *htt_desc)
  1585. {
  1586. uint8_t tx_status = HTT_TX_FW2WBM_TX_STATUS_MAX;
  1587. switch (soc->arch_id) {
  1588. case CDP_ARCH_TYPE_LI:
  1589. tx_status = HTT_TX_WBM_COMPLETION_V2_TX_STATUS_GET(htt_desc[0]);
  1590. break;
  1591. case CDP_ARCH_TYPE_BE:
  1592. tx_status = HTT_TX_WBM_COMPLETION_V3_TX_STATUS_GET(htt_desc[0]);
  1593. break;
  1594. default:
  1595. dp_err("Incorrect CDP_ARCH %d", soc->arch_id);
  1596. QDF_BUG(0);
  1597. }
  1598. return tx_status;
  1599. }
  1600. /**
  1601. * dp_non_std_htt_tx_comp_free_buff() - Free the non std tx packet buffer
  1602. * @soc: dp_soc handle
  1603. * @tx_desc: TX descriptor
  1604. * @vdev: datapath vdev handle
  1605. *
  1606. * Return: None
  1607. */
  1608. static void dp_non_std_htt_tx_comp_free_buff(struct dp_soc *soc,
  1609. struct dp_tx_desc_s *tx_desc)
  1610. {
  1611. uint8_t tx_status = 0;
  1612. uint8_t htt_tx_status[HAL_TX_COMP_HTT_STATUS_LEN];
  1613. qdf_nbuf_t nbuf = tx_desc->nbuf;
  1614. struct dp_vdev *vdev = dp_vdev_get_ref_by_id(soc, tx_desc->vdev_id,
  1615. DP_MOD_ID_TDLS);
  1616. if (qdf_unlikely(!vdev)) {
  1617. dp_err_rl("vdev is null!");
  1618. goto error;
  1619. }
  1620. hal_tx_comp_get_htt_desc(&tx_desc->comp, htt_tx_status);
  1621. tx_status = dp_htt_tx_comp_get_status(soc, htt_tx_status);
  1622. dp_debug("vdev_id: %d tx_status: %d", tx_desc->vdev_id, tx_status);
  1623. if (vdev->tx_non_std_data_callback.func) {
  1624. qdf_nbuf_set_next(nbuf, NULL);
  1625. vdev->tx_non_std_data_callback.func(
  1626. vdev->tx_non_std_data_callback.ctxt,
  1627. nbuf, tx_status);
  1628. dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_TDLS);
  1629. return;
  1630. } else {
  1631. dp_err_rl("callback func is null");
  1632. }
  1633. dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_TDLS);
  1634. error:
  1635. qdf_nbuf_unmap_single(soc->osdev, nbuf, QDF_DMA_TO_DEVICE);
  1636. qdf_nbuf_free(nbuf);
  1637. }
  1638. /**
  1639. * dp_tx_msdu_single_map() - do nbuf map
  1640. * @vdev: DP vdev handle
  1641. * @tx_desc: DP TX descriptor pointer
  1642. * @nbuf: skb pointer
  1643. *
  1644. * For TDLS frame, use qdf_nbuf_map_single() to align with the unmap
  1645. * operation done in other component.
  1646. *
  1647. * Return: QDF_STATUS
  1648. */
  1649. static inline QDF_STATUS dp_tx_msdu_single_map(struct dp_vdev *vdev,
  1650. struct dp_tx_desc_s *tx_desc,
  1651. qdf_nbuf_t nbuf)
  1652. {
  1653. if (qdf_likely(!(tx_desc->flags & DP_TX_DESC_FLAG_TDLS_FRAME)))
  1654. return qdf_nbuf_map_nbytes_single(vdev->osdev,
  1655. nbuf,
  1656. QDF_DMA_TO_DEVICE,
  1657. nbuf->len);
  1658. else
  1659. return qdf_nbuf_map_single(vdev->osdev, nbuf,
  1660. QDF_DMA_TO_DEVICE);
  1661. }
  1662. #else
  1663. static inline void dp_tx_update_tdls_flags(struct dp_soc *soc,
  1664. struct dp_vdev *vdev,
  1665. struct dp_tx_desc_s *tx_desc)
  1666. {
  1667. }
  1668. static inline void dp_non_std_htt_tx_comp_free_buff(struct dp_soc *soc,
  1669. struct dp_tx_desc_s *tx_desc)
  1670. {
  1671. }
  1672. static inline QDF_STATUS dp_tx_msdu_single_map(struct dp_vdev *vdev,
  1673. struct dp_tx_desc_s *tx_desc,
  1674. qdf_nbuf_t nbuf)
  1675. {
  1676. return qdf_nbuf_map_nbytes_single(vdev->osdev,
  1677. nbuf,
  1678. QDF_DMA_TO_DEVICE,
  1679. nbuf->len);
  1680. }
  1681. #endif
  1682. static inline
  1683. qdf_dma_addr_t dp_tx_nbuf_map_regular(struct dp_vdev *vdev,
  1684. struct dp_tx_desc_s *tx_desc,
  1685. qdf_nbuf_t nbuf)
  1686. {
  1687. QDF_STATUS ret = QDF_STATUS_E_FAILURE;
  1688. ret = dp_tx_msdu_single_map(vdev, tx_desc, nbuf);
  1689. if (qdf_unlikely(QDF_IS_STATUS_ERROR(ret)))
  1690. return 0;
  1691. return qdf_nbuf_mapped_paddr_get(nbuf);
  1692. }
  1693. static inline
  1694. void dp_tx_nbuf_unmap_regular(struct dp_soc *soc, struct dp_tx_desc_s *desc)
  1695. {
  1696. qdf_nbuf_unmap_nbytes_single_paddr(soc->osdev,
  1697. desc->nbuf,
  1698. desc->dma_addr,
  1699. QDF_DMA_TO_DEVICE,
  1700. desc->length);
  1701. }
  1702. #if defined(QCA_DP_TX_NBUF_NO_MAP_UNMAP) && !defined(BUILD_X86)
  1703. static inline
  1704. qdf_dma_addr_t dp_tx_nbuf_map(struct dp_vdev *vdev,
  1705. struct dp_tx_desc_s *tx_desc,
  1706. qdf_nbuf_t nbuf)
  1707. {
  1708. if (qdf_likely(tx_desc->flags & DP_TX_DESC_FLAG_SIMPLE)) {
  1709. qdf_nbuf_dma_clean_range((void *)nbuf->data,
  1710. (void *)(nbuf->data + nbuf->len));
  1711. return (qdf_dma_addr_t)qdf_mem_virt_to_phys(nbuf->data);
  1712. } else {
  1713. return dp_tx_nbuf_map_regular(vdev, tx_desc, nbuf);
  1714. }
  1715. }
  1716. static inline
  1717. void dp_tx_nbuf_unmap(struct dp_soc *soc,
  1718. struct dp_tx_desc_s *desc)
  1719. {
  1720. if (qdf_unlikely(!(desc->flags & DP_TX_DESC_FLAG_SIMPLE)))
  1721. return dp_tx_nbuf_unmap_regular(soc, desc);
  1722. }
  1723. #else
  1724. static inline
  1725. qdf_dma_addr_t dp_tx_nbuf_map(struct dp_vdev *vdev,
  1726. struct dp_tx_desc_s *tx_desc,
  1727. qdf_nbuf_t nbuf)
  1728. {
  1729. return dp_tx_nbuf_map_regular(vdev, tx_desc, nbuf);
  1730. }
  1731. static inline
  1732. void dp_tx_nbuf_unmap(struct dp_soc *soc,
  1733. struct dp_tx_desc_s *desc)
  1734. {
  1735. return dp_tx_nbuf_unmap_regular(soc, desc);
  1736. }
  1737. #endif
  1738. #if defined(WLAN_TX_PKT_CAPTURE_ENH) || defined(FEATURE_PERPKT_INFO)
  1739. static inline
  1740. void dp_tx_enh_unmap(struct dp_soc *soc, struct dp_tx_desc_s *desc)
  1741. {
  1742. dp_tx_nbuf_unmap(soc, desc);
  1743. desc->flags |= DP_TX_DESC_FLAG_UNMAP_DONE;
  1744. }
  1745. static inline void dp_tx_unmap(struct dp_soc *soc, struct dp_tx_desc_s *desc)
  1746. {
  1747. if (qdf_likely(!(desc->flags & DP_TX_DESC_FLAG_UNMAP_DONE)))
  1748. dp_tx_nbuf_unmap(soc, desc);
  1749. }
  1750. #else
  1751. static inline
  1752. void dp_tx_enh_unmap(struct dp_soc *soc, struct dp_tx_desc_s *desc)
  1753. {
  1754. }
  1755. static inline void dp_tx_unmap(struct dp_soc *soc, struct dp_tx_desc_s *desc)
  1756. {
  1757. dp_tx_nbuf_unmap(soc, desc);
  1758. }
  1759. #endif
  1760. #ifdef MESH_MODE_SUPPORT
  1761. /**
  1762. * dp_tx_update_mesh_flags() - Update descriptor flags for mesh VAP
  1763. * @soc: datapath SOC
  1764. * @vdev: datapath vdev
  1765. * @tx_desc: TX descriptor
  1766. *
  1767. * Return: None
  1768. */
  1769. static inline void dp_tx_update_mesh_flags(struct dp_soc *soc,
  1770. struct dp_vdev *vdev,
  1771. struct dp_tx_desc_s *tx_desc)
  1772. {
  1773. if (qdf_unlikely(vdev->mesh_vdev))
  1774. tx_desc->flags |= DP_TX_DESC_FLAG_MESH_MODE;
  1775. }
  1776. /**
  1777. * dp_mesh_tx_comp_free_buff() - Free the mesh tx packet buffer
  1778. * @soc: dp_soc handle
  1779. * @tx_desc: TX descriptor
  1780. * @vdev: datapath vdev handle
  1781. *
  1782. * Return: None
  1783. */
  1784. static inline void dp_mesh_tx_comp_free_buff(struct dp_soc *soc,
  1785. struct dp_tx_desc_s *tx_desc)
  1786. {
  1787. qdf_nbuf_t nbuf = tx_desc->nbuf;
  1788. struct dp_vdev *vdev = NULL;
  1789. if (tx_desc->flags & DP_TX_DESC_FLAG_TO_FW) {
  1790. qdf_nbuf_free(nbuf);
  1791. DP_STATS_INC(vdev, tx_i.mesh.completion_fw, 1);
  1792. } else {
  1793. vdev = dp_vdev_get_ref_by_id(soc, tx_desc->vdev_id,
  1794. DP_MOD_ID_MESH);
  1795. if (vdev && vdev->osif_tx_free_ext)
  1796. vdev->osif_tx_free_ext((nbuf));
  1797. else
  1798. qdf_nbuf_free(nbuf);
  1799. if (vdev)
  1800. dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_MESH);
  1801. }
  1802. }
  1803. #else
  1804. static inline void dp_tx_update_mesh_flags(struct dp_soc *soc,
  1805. struct dp_vdev *vdev,
  1806. struct dp_tx_desc_s *tx_desc)
  1807. {
  1808. }
  1809. static inline void dp_mesh_tx_comp_free_buff(struct dp_soc *soc,
  1810. struct dp_tx_desc_s *tx_desc)
  1811. {
  1812. }
  1813. #endif
  1814. /**
  1815. * dp_tx_frame_is_drop() - checks if the packet is loopback
  1816. * @vdev: DP vdev handle
  1817. * @nbuf: skb
  1818. *
  1819. * Return: 1 if frame needs to be dropped else 0
  1820. */
  1821. int dp_tx_frame_is_drop(struct dp_vdev *vdev, uint8_t *srcmac, uint8_t *dstmac)
  1822. {
  1823. struct dp_pdev *pdev = NULL;
  1824. struct dp_ast_entry *src_ast_entry = NULL;
  1825. struct dp_ast_entry *dst_ast_entry = NULL;
  1826. struct dp_soc *soc = NULL;
  1827. qdf_assert(vdev);
  1828. pdev = vdev->pdev;
  1829. qdf_assert(pdev);
  1830. soc = pdev->soc;
  1831. dst_ast_entry = dp_peer_ast_hash_find_by_pdevid
  1832. (soc, dstmac, vdev->pdev->pdev_id);
  1833. src_ast_entry = dp_peer_ast_hash_find_by_pdevid
  1834. (soc, srcmac, vdev->pdev->pdev_id);
  1835. if (dst_ast_entry && src_ast_entry) {
  1836. if (dst_ast_entry->peer_id ==
  1837. src_ast_entry->peer_id)
  1838. return 1;
  1839. }
  1840. return 0;
  1841. }
  1842. #if defined(WLAN_FEATURE_11BE_MLO) && defined(WLAN_MLO_MULTI_CHIP) && \
  1843. defined(WLAN_MCAST_MLO)
  1844. /* MLO peer id for reinject*/
  1845. #define DP_MLO_MCAST_REINJECT_PEER_ID 0XFFFD
  1846. /* MLO vdev id inc offset */
  1847. #define DP_MLO_VDEV_ID_OFFSET 0x80
  1848. static inline void
  1849. dp_tx_update_mcast_param(uint16_t peer_id,
  1850. uint16_t *htt_tcl_metadata,
  1851. struct dp_vdev *vdev,
  1852. struct dp_tx_msdu_info_s *msdu_info)
  1853. {
  1854. if (peer_id == DP_MLO_MCAST_REINJECT_PEER_ID) {
  1855. *htt_tcl_metadata = 0;
  1856. DP_TX_TCL_METADATA_TYPE_SET(
  1857. *htt_tcl_metadata,
  1858. HTT_TCL_METADATA_V2_TYPE_GLOBAL_SEQ_BASED);
  1859. HTT_TX_TCL_METADATA_GLBL_SEQ_NO_SET(*htt_tcl_metadata,
  1860. msdu_info->gsn);
  1861. msdu_info->vdev_id = vdev->vdev_id + DP_MLO_VDEV_ID_OFFSET;
  1862. } else {
  1863. msdu_info->vdev_id = vdev->vdev_id;
  1864. }
  1865. }
  1866. #else
  1867. static inline void
  1868. dp_tx_update_mcast_param(uint16_t peer_id,
  1869. uint16_t *htt_tcl_metadata,
  1870. struct dp_vdev *vdev,
  1871. struct dp_tx_msdu_info_s *msdu_info)
  1872. {
  1873. }
  1874. #endif
  1875. /**
  1876. * dp_tx_send_msdu_single() - Setup descriptor and enqueue single MSDU to TCL
  1877. * @vdev: DP vdev handle
  1878. * @nbuf: skb
  1879. * @tid: TID from HLOS for overriding default DSCP-TID mapping
  1880. * @meta_data: Metadata to the fw
  1881. * @tx_q: Tx queue to be used for this Tx frame
  1882. * @peer_id: peer_id of the peer in case of NAWDS frames
  1883. * @tx_exc_metadata: Handle that holds exception path metadata
  1884. *
  1885. * Return: NULL on success,
  1886. * nbuf when it fails to send
  1887. */
  1888. qdf_nbuf_t
  1889. dp_tx_send_msdu_single(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  1890. struct dp_tx_msdu_info_s *msdu_info, uint16_t peer_id,
  1891. struct cdp_tx_exception_metadata *tx_exc_metadata)
  1892. {
  1893. struct dp_pdev *pdev = vdev->pdev;
  1894. struct dp_soc *soc = pdev->soc;
  1895. struct dp_tx_desc_s *tx_desc;
  1896. QDF_STATUS status;
  1897. struct dp_tx_queue *tx_q = &(msdu_info->tx_queue);
  1898. uint16_t htt_tcl_metadata = 0;
  1899. enum cdp_tx_sw_drop drop_code = TX_MAX_DROP;
  1900. uint8_t tid = msdu_info->tid;
  1901. struct cdp_tid_tx_stats *tid_stats = NULL;
  1902. qdf_dma_addr_t paddr;
  1903. /* Setup Tx descriptor for an MSDU, and MSDU extension descriptor */
  1904. tx_desc = dp_tx_prepare_desc_single(vdev, nbuf, tx_q->desc_pool_id,
  1905. msdu_info, tx_exc_metadata);
  1906. if (!tx_desc) {
  1907. dp_err_rl("Tx_desc prepare Fail vdev %pK queue %d",
  1908. vdev, tx_q->desc_pool_id);
  1909. drop_code = TX_DESC_ERR;
  1910. goto fail_return;
  1911. }
  1912. dp_tx_update_tdls_flags(soc, vdev, tx_desc);
  1913. if (qdf_unlikely(peer_id == DP_INVALID_PEER)) {
  1914. htt_tcl_metadata = vdev->htt_tcl_metadata;
  1915. DP_TX_TCL_METADATA_HOST_INSPECTED_SET(htt_tcl_metadata, 1);
  1916. } else if (qdf_unlikely(peer_id != HTT_INVALID_PEER)) {
  1917. DP_TX_TCL_METADATA_TYPE_SET(htt_tcl_metadata,
  1918. DP_TCL_METADATA_TYPE_PEER_BASED);
  1919. DP_TX_TCL_METADATA_PEER_ID_SET(htt_tcl_metadata,
  1920. peer_id);
  1921. } else
  1922. htt_tcl_metadata = vdev->htt_tcl_metadata;
  1923. if (msdu_info->exception_fw)
  1924. DP_TX_TCL_METADATA_VALID_HTT_SET(htt_tcl_metadata, 1);
  1925. dp_tx_desc_update_fast_comp_flag(soc, tx_desc,
  1926. !pdev->enhanced_stats_en);
  1927. dp_tx_update_mesh_flags(soc, vdev, tx_desc);
  1928. paddr = dp_tx_nbuf_map(vdev, tx_desc, nbuf);
  1929. if (!paddr) {
  1930. /* Handle failure */
  1931. dp_err("qdf_nbuf_map failed");
  1932. DP_STATS_INC(vdev, tx_i.dropped.dma_error, 1);
  1933. drop_code = TX_DMA_MAP_ERR;
  1934. goto release_desc;
  1935. }
  1936. tx_desc->dma_addr = paddr;
  1937. dp_tx_desc_history_add(soc, tx_desc->dma_addr, nbuf,
  1938. tx_desc->id, DP_TX_DESC_MAP);
  1939. dp_tx_update_mcast_param(peer_id, &htt_tcl_metadata, vdev, msdu_info);
  1940. /* Enqueue the Tx MSDU descriptor to HW for transmit */
  1941. status = soc->arch_ops.tx_hw_enqueue(soc, vdev, tx_desc,
  1942. htt_tcl_metadata,
  1943. tx_exc_metadata, msdu_info);
  1944. if (status != QDF_STATUS_SUCCESS) {
  1945. dp_tx_err_rl("Tx_hw_enqueue Fail tx_desc %pK queue %d",
  1946. tx_desc, tx_q->ring_id);
  1947. dp_tx_desc_history_add(soc, tx_desc->dma_addr, nbuf,
  1948. tx_desc->id, DP_TX_DESC_UNMAP);
  1949. dp_tx_nbuf_unmap(soc, tx_desc);
  1950. drop_code = TX_HW_ENQUEUE;
  1951. goto release_desc;
  1952. }
  1953. return NULL;
  1954. release_desc:
  1955. dp_tx_desc_release(tx_desc, tx_q->desc_pool_id);
  1956. fail_return:
  1957. dp_tx_get_tid(vdev, nbuf, msdu_info);
  1958. tid_stats = &pdev->stats.tid_stats.
  1959. tid_tx_stats[tx_q->ring_id][tid];
  1960. tid_stats->swdrop_cnt[drop_code]++;
  1961. return nbuf;
  1962. }
  1963. /**
  1964. * dp_tx_comp_free_buf() - Free nbuf associated with the Tx Descriptor
  1965. * @soc: Soc handle
  1966. * @desc: software Tx descriptor to be processed
  1967. *
  1968. * Return: none
  1969. */
  1970. void dp_tx_comp_free_buf(struct dp_soc *soc, struct dp_tx_desc_s *desc)
  1971. {
  1972. qdf_nbuf_t nbuf = desc->nbuf;
  1973. enum dp_tx_event_type type = dp_tx_get_event_type(desc->flags);
  1974. /* nbuf already freed in vdev detach path */
  1975. if (!nbuf)
  1976. return;
  1977. /* If it is TDLS mgmt, don't unmap or free the frame */
  1978. if (desc->flags & DP_TX_DESC_FLAG_TDLS_FRAME)
  1979. return dp_non_std_htt_tx_comp_free_buff(soc, desc);
  1980. /* 0 : MSDU buffer, 1 : MLE */
  1981. if (desc->msdu_ext_desc) {
  1982. /* TSO free */
  1983. if (hal_tx_ext_desc_get_tso_enable(
  1984. desc->msdu_ext_desc->vaddr)) {
  1985. dp_tx_desc_history_add(soc, desc->dma_addr, desc->nbuf,
  1986. desc->id, DP_TX_COMP_MSDU_EXT);
  1987. dp_tx_tso_seg_history_add(soc,
  1988. desc->msdu_ext_desc->tso_desc,
  1989. desc->nbuf, desc->id, type);
  1990. /* unmap eash TSO seg before free the nbuf */
  1991. dp_tx_tso_unmap_segment(soc,
  1992. desc->msdu_ext_desc->tso_desc,
  1993. desc->msdu_ext_desc->
  1994. tso_num_desc);
  1995. qdf_nbuf_free(nbuf);
  1996. return;
  1997. }
  1998. if (qdf_unlikely(desc->frm_type == dp_tx_frm_sg)) {
  1999. void *msdu_ext_desc = desc->msdu_ext_desc->vaddr;
  2000. qdf_dma_addr_t iova;
  2001. uint32_t frag_len;
  2002. uint32_t i;
  2003. qdf_nbuf_unmap_nbytes_single(soc->osdev, nbuf,
  2004. QDF_DMA_TO_DEVICE,
  2005. qdf_nbuf_headlen(nbuf));
  2006. for (i = 1; i < DP_TX_MAX_NUM_FRAGS; i++) {
  2007. hal_tx_ext_desc_get_frag_info(msdu_ext_desc, i,
  2008. &iova,
  2009. &frag_len);
  2010. if (!iova || !frag_len)
  2011. break;
  2012. qdf_mem_unmap_page(soc->osdev, iova, frag_len,
  2013. QDF_DMA_TO_DEVICE);
  2014. }
  2015. qdf_nbuf_free(nbuf);
  2016. return;
  2017. }
  2018. }
  2019. /* If it's ME frame, dont unmap the cloned nbuf's */
  2020. if ((desc->flags & DP_TX_DESC_FLAG_ME) && qdf_nbuf_is_cloned(nbuf))
  2021. goto nbuf_free;
  2022. dp_tx_desc_history_add(soc, desc->dma_addr, desc->nbuf, desc->id, type);
  2023. dp_tx_unmap(soc, desc);
  2024. if (desc->flags & DP_TX_DESC_FLAG_MESH_MODE)
  2025. return dp_mesh_tx_comp_free_buff(soc, desc);
  2026. nbuf_free:
  2027. qdf_nbuf_free(nbuf);
  2028. }
  2029. /**
  2030. * dp_tx_sg_unmap_buf() - Unmap scatter gather fragments
  2031. * @soc: DP soc handle
  2032. * @nbuf: skb
  2033. * @msdu_info: MSDU info
  2034. *
  2035. * Return: None
  2036. */
  2037. static inline void
  2038. dp_tx_sg_unmap_buf(struct dp_soc *soc, qdf_nbuf_t nbuf,
  2039. struct dp_tx_msdu_info_s *msdu_info)
  2040. {
  2041. uint32_t cur_idx;
  2042. struct dp_tx_seg_info_s *seg = msdu_info->u.sg_info.curr_seg;
  2043. qdf_nbuf_unmap_nbytes_single(soc->osdev, nbuf, QDF_DMA_TO_DEVICE,
  2044. qdf_nbuf_headlen(nbuf));
  2045. for (cur_idx = 1; cur_idx < seg->frag_cnt; cur_idx++)
  2046. qdf_mem_unmap_page(soc->osdev, (qdf_dma_addr_t)
  2047. (seg->frags[cur_idx].paddr_lo | ((uint64_t)
  2048. seg->frags[cur_idx].paddr_hi) << 32),
  2049. seg->frags[cur_idx].len,
  2050. QDF_DMA_TO_DEVICE);
  2051. }
  2052. /**
  2053. * dp_tx_send_msdu_multiple() - Enqueue multiple MSDUs
  2054. * @vdev: DP vdev handle
  2055. * @nbuf: skb
  2056. * @msdu_info: MSDU info to be setup in MSDU extension descriptor
  2057. *
  2058. * Prepare descriptors for multiple MSDUs (TSO segments) and enqueue to TCL
  2059. *
  2060. * Return: NULL on success,
  2061. * nbuf when it fails to send
  2062. */
  2063. #if QDF_LOCK_STATS
  2064. noinline
  2065. #else
  2066. #endif
  2067. qdf_nbuf_t dp_tx_send_msdu_multiple(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  2068. struct dp_tx_msdu_info_s *msdu_info)
  2069. {
  2070. uint32_t i;
  2071. struct dp_pdev *pdev = vdev->pdev;
  2072. struct dp_soc *soc = pdev->soc;
  2073. struct dp_tx_desc_s *tx_desc;
  2074. bool is_cce_classified = false;
  2075. QDF_STATUS status;
  2076. uint16_t htt_tcl_metadata = 0;
  2077. struct dp_tx_queue *tx_q = &msdu_info->tx_queue;
  2078. struct cdp_tid_tx_stats *tid_stats = NULL;
  2079. uint8_t prep_desc_fail = 0, hw_enq_fail = 0;
  2080. if (msdu_info->frm_type == dp_tx_frm_me)
  2081. nbuf = msdu_info->u.sg_info.curr_seg->nbuf;
  2082. i = 0;
  2083. /* Print statement to track i and num_seg */
  2084. /*
  2085. * For each segment (maps to 1 MSDU) , prepare software and hardware
  2086. * descriptors using information in msdu_info
  2087. */
  2088. while (i < msdu_info->num_seg) {
  2089. /*
  2090. * Setup Tx descriptor for an MSDU, and MSDU extension
  2091. * descriptor
  2092. */
  2093. tx_desc = dp_tx_prepare_desc(vdev, nbuf, msdu_info,
  2094. tx_q->desc_pool_id);
  2095. if (!tx_desc) {
  2096. if (msdu_info->frm_type == dp_tx_frm_me) {
  2097. prep_desc_fail++;
  2098. dp_tx_me_free_buf(pdev,
  2099. (void *)(msdu_info->u.sg_info
  2100. .curr_seg->frags[0].vaddr));
  2101. if (prep_desc_fail == msdu_info->num_seg) {
  2102. /*
  2103. * Unmap is needed only if descriptor
  2104. * preparation failed for all segments.
  2105. */
  2106. qdf_nbuf_unmap(soc->osdev,
  2107. msdu_info->u.sg_info.
  2108. curr_seg->nbuf,
  2109. QDF_DMA_TO_DEVICE);
  2110. }
  2111. /*
  2112. * Free the nbuf for the current segment
  2113. * and make it point to the next in the list.
  2114. * For me, there are as many segments as there
  2115. * are no of clients.
  2116. */
  2117. qdf_nbuf_free(msdu_info->u.sg_info
  2118. .curr_seg->nbuf);
  2119. if (msdu_info->u.sg_info.curr_seg->next) {
  2120. msdu_info->u.sg_info.curr_seg =
  2121. msdu_info->u.sg_info
  2122. .curr_seg->next;
  2123. nbuf = msdu_info->u.sg_info
  2124. .curr_seg->nbuf;
  2125. }
  2126. i++;
  2127. continue;
  2128. }
  2129. if (msdu_info->frm_type == dp_tx_frm_tso) {
  2130. dp_tx_tso_seg_history_add(
  2131. soc,
  2132. msdu_info->u.tso_info.curr_seg,
  2133. nbuf, 0, DP_TX_DESC_UNMAP);
  2134. dp_tx_tso_unmap_segment(soc,
  2135. msdu_info->u.tso_info.
  2136. curr_seg,
  2137. msdu_info->u.tso_info.
  2138. tso_num_seg_list);
  2139. if (msdu_info->u.tso_info.curr_seg->next) {
  2140. msdu_info->u.tso_info.curr_seg =
  2141. msdu_info->u.tso_info.curr_seg->next;
  2142. i++;
  2143. continue;
  2144. }
  2145. }
  2146. if (msdu_info->frm_type == dp_tx_frm_sg)
  2147. dp_tx_sg_unmap_buf(soc, nbuf, msdu_info);
  2148. goto done;
  2149. }
  2150. if (msdu_info->frm_type == dp_tx_frm_me) {
  2151. tx_desc->msdu_ext_desc->me_buffer =
  2152. (struct dp_tx_me_buf_t *)msdu_info->
  2153. u.sg_info.curr_seg->frags[0].vaddr;
  2154. tx_desc->flags |= DP_TX_DESC_FLAG_ME;
  2155. }
  2156. if (is_cce_classified)
  2157. tx_desc->flags |= DP_TX_DESC_FLAG_TO_FW;
  2158. htt_tcl_metadata = vdev->htt_tcl_metadata;
  2159. if (msdu_info->exception_fw) {
  2160. DP_TX_TCL_METADATA_VALID_HTT_SET(htt_tcl_metadata, 1);
  2161. }
  2162. dp_tx_is_hp_update_required(i, msdu_info);
  2163. /*
  2164. * For frames with multiple segments (TSO, ME), jump to next
  2165. * segment.
  2166. */
  2167. if (msdu_info->frm_type == dp_tx_frm_tso) {
  2168. if (msdu_info->u.tso_info.curr_seg->next) {
  2169. msdu_info->u.tso_info.curr_seg =
  2170. msdu_info->u.tso_info.curr_seg->next;
  2171. /*
  2172. * If this is a jumbo nbuf, then increment the
  2173. * number of nbuf users for each additional
  2174. * segment of the msdu. This will ensure that
  2175. * the skb is freed only after receiving tx
  2176. * completion for all segments of an nbuf
  2177. */
  2178. qdf_nbuf_inc_users(nbuf);
  2179. /* Check with MCL if this is needed */
  2180. /* nbuf = msdu_info->u.tso_info.curr_seg->nbuf;
  2181. */
  2182. }
  2183. }
  2184. dp_tx_update_mcast_param(DP_INVALID_PEER,
  2185. &htt_tcl_metadata,
  2186. vdev,
  2187. msdu_info);
  2188. /*
  2189. * Enqueue the Tx MSDU descriptor to HW for transmit
  2190. */
  2191. status = soc->arch_ops.tx_hw_enqueue(soc, vdev, tx_desc,
  2192. htt_tcl_metadata,
  2193. NULL, msdu_info);
  2194. dp_tx_check_and_flush_hp(soc, status, msdu_info);
  2195. if (status != QDF_STATUS_SUCCESS) {
  2196. dp_info_rl("Tx_hw_enqueue Fail tx_desc %pK queue %d",
  2197. tx_desc, tx_q->ring_id);
  2198. dp_tx_get_tid(vdev, nbuf, msdu_info);
  2199. tid_stats = &pdev->stats.tid_stats.
  2200. tid_tx_stats[tx_q->ring_id][msdu_info->tid];
  2201. tid_stats->swdrop_cnt[TX_HW_ENQUEUE]++;
  2202. if (msdu_info->frm_type == dp_tx_frm_me) {
  2203. hw_enq_fail++;
  2204. if (hw_enq_fail == msdu_info->num_seg) {
  2205. /*
  2206. * Unmap is needed only if enqueue
  2207. * failed for all segments.
  2208. */
  2209. qdf_nbuf_unmap(soc->osdev,
  2210. msdu_info->u.sg_info.
  2211. curr_seg->nbuf,
  2212. QDF_DMA_TO_DEVICE);
  2213. }
  2214. /*
  2215. * Free the nbuf for the current segment
  2216. * and make it point to the next in the list.
  2217. * For me, there are as many segments as there
  2218. * are no of clients.
  2219. */
  2220. qdf_nbuf_free(msdu_info->u.sg_info
  2221. .curr_seg->nbuf);
  2222. if (msdu_info->u.sg_info.curr_seg->next) {
  2223. msdu_info->u.sg_info.curr_seg =
  2224. msdu_info->u.sg_info
  2225. .curr_seg->next;
  2226. nbuf = msdu_info->u.sg_info
  2227. .curr_seg->nbuf;
  2228. } else
  2229. break;
  2230. i++;
  2231. dp_tx_desc_release(tx_desc, tx_q->desc_pool_id);
  2232. continue;
  2233. }
  2234. /*
  2235. * For TSO frames, the nbuf users increment done for
  2236. * the current segment has to be reverted, since the
  2237. * hw enqueue for this segment failed
  2238. */
  2239. if (msdu_info->frm_type == dp_tx_frm_tso &&
  2240. msdu_info->u.tso_info.curr_seg) {
  2241. /*
  2242. * unmap and free current,
  2243. * retransmit remaining segments
  2244. */
  2245. dp_tx_comp_free_buf(soc, tx_desc);
  2246. i++;
  2247. dp_tx_desc_release(tx_desc, tx_q->desc_pool_id);
  2248. continue;
  2249. }
  2250. if (msdu_info->frm_type == dp_tx_frm_sg)
  2251. dp_tx_sg_unmap_buf(soc, nbuf, msdu_info);
  2252. dp_tx_desc_release(tx_desc, tx_q->desc_pool_id);
  2253. goto done;
  2254. }
  2255. /*
  2256. * TODO
  2257. * if tso_info structure can be modified to have curr_seg
  2258. * as first element, following 2 blocks of code (for TSO and SG)
  2259. * can be combined into 1
  2260. */
  2261. /*
  2262. * For Multicast-Unicast converted packets,
  2263. * each converted frame (for a client) is represented as
  2264. * 1 segment
  2265. */
  2266. if ((msdu_info->frm_type == dp_tx_frm_sg) ||
  2267. (msdu_info->frm_type == dp_tx_frm_me)) {
  2268. if (msdu_info->u.sg_info.curr_seg->next) {
  2269. msdu_info->u.sg_info.curr_seg =
  2270. msdu_info->u.sg_info.curr_seg->next;
  2271. nbuf = msdu_info->u.sg_info.curr_seg->nbuf;
  2272. } else
  2273. break;
  2274. }
  2275. i++;
  2276. }
  2277. nbuf = NULL;
  2278. done:
  2279. return nbuf;
  2280. }
  2281. /**
  2282. * dp_tx_prepare_sg()- Extract SG info from NBUF and prepare msdu_info
  2283. * for SG frames
  2284. * @vdev: DP vdev handle
  2285. * @nbuf: skb
  2286. * @seg_info: Pointer to Segment info Descriptor to be prepared
  2287. * @msdu_info: MSDU info to be setup in MSDU descriptor and MSDU extension desc.
  2288. *
  2289. * Return: NULL on success,
  2290. * nbuf when it fails to send
  2291. */
  2292. static qdf_nbuf_t dp_tx_prepare_sg(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  2293. struct dp_tx_seg_info_s *seg_info, struct dp_tx_msdu_info_s *msdu_info)
  2294. {
  2295. uint32_t cur_frag, nr_frags, i;
  2296. qdf_dma_addr_t paddr;
  2297. struct dp_tx_sg_info_s *sg_info;
  2298. sg_info = &msdu_info->u.sg_info;
  2299. nr_frags = qdf_nbuf_get_nr_frags(nbuf);
  2300. if (QDF_STATUS_SUCCESS !=
  2301. qdf_nbuf_map_nbytes_single(vdev->osdev, nbuf,
  2302. QDF_DMA_TO_DEVICE,
  2303. qdf_nbuf_headlen(nbuf))) {
  2304. dp_tx_err("dma map error");
  2305. DP_STATS_INC(vdev, tx_i.sg.dma_map_error, 1);
  2306. qdf_nbuf_free(nbuf);
  2307. return NULL;
  2308. }
  2309. paddr = qdf_nbuf_mapped_paddr_get(nbuf);
  2310. seg_info->frags[0].paddr_lo = paddr;
  2311. seg_info->frags[0].paddr_hi = ((uint64_t) paddr) >> 32;
  2312. seg_info->frags[0].len = qdf_nbuf_headlen(nbuf);
  2313. seg_info->frags[0].vaddr = (void *) nbuf;
  2314. for (cur_frag = 0; cur_frag < nr_frags; cur_frag++) {
  2315. if (QDF_STATUS_SUCCESS != qdf_nbuf_frag_map(vdev->osdev,
  2316. nbuf, 0,
  2317. QDF_DMA_TO_DEVICE,
  2318. cur_frag)) {
  2319. dp_tx_err("frag dma map error");
  2320. DP_STATS_INC(vdev, tx_i.sg.dma_map_error, 1);
  2321. goto map_err;
  2322. }
  2323. paddr = qdf_nbuf_get_tx_frag_paddr(nbuf);
  2324. seg_info->frags[cur_frag + 1].paddr_lo = paddr;
  2325. seg_info->frags[cur_frag + 1].paddr_hi =
  2326. ((uint64_t) paddr) >> 32;
  2327. seg_info->frags[cur_frag + 1].len =
  2328. qdf_nbuf_get_frag_size(nbuf, cur_frag);
  2329. }
  2330. seg_info->frag_cnt = (cur_frag + 1);
  2331. seg_info->total_len = qdf_nbuf_len(nbuf);
  2332. seg_info->next = NULL;
  2333. sg_info->curr_seg = seg_info;
  2334. msdu_info->frm_type = dp_tx_frm_sg;
  2335. msdu_info->num_seg = 1;
  2336. return nbuf;
  2337. map_err:
  2338. /* restore paddr into nbuf before calling unmap */
  2339. qdf_nbuf_mapped_paddr_set(nbuf,
  2340. (qdf_dma_addr_t)(seg_info->frags[0].paddr_lo |
  2341. ((uint64_t)
  2342. seg_info->frags[0].paddr_hi) << 32));
  2343. qdf_nbuf_unmap_nbytes_single(vdev->osdev, nbuf,
  2344. QDF_DMA_TO_DEVICE,
  2345. seg_info->frags[0].len);
  2346. for (i = 1; i <= cur_frag; i++) {
  2347. qdf_mem_unmap_page(vdev->osdev, (qdf_dma_addr_t)
  2348. (seg_info->frags[i].paddr_lo | ((uint64_t)
  2349. seg_info->frags[i].paddr_hi) << 32),
  2350. seg_info->frags[i].len,
  2351. QDF_DMA_TO_DEVICE);
  2352. }
  2353. qdf_nbuf_free(nbuf);
  2354. return NULL;
  2355. }
  2356. /**
  2357. * dp_tx_add_tx_sniffer_meta_data()- Add tx_sniffer meta hdr info
  2358. * @vdev: DP vdev handle
  2359. * @msdu_info: MSDU info to be setup in MSDU descriptor and MSDU extension desc.
  2360. * @ppdu_cookie: PPDU cookie that should be replayed in the ppdu completions
  2361. *
  2362. * Return: NULL on failure,
  2363. * nbuf when extracted successfully
  2364. */
  2365. static
  2366. void dp_tx_add_tx_sniffer_meta_data(struct dp_vdev *vdev,
  2367. struct dp_tx_msdu_info_s *msdu_info,
  2368. uint16_t ppdu_cookie)
  2369. {
  2370. struct htt_tx_msdu_desc_ext2_t *meta_data =
  2371. (struct htt_tx_msdu_desc_ext2_t *)&msdu_info->meta_data[0];
  2372. qdf_mem_zero(meta_data, sizeof(struct htt_tx_msdu_desc_ext2_t));
  2373. HTT_TX_MSDU_EXT2_DESC_FLAG_SEND_AS_STANDALONE_SET
  2374. (msdu_info->meta_data[5], 1);
  2375. HTT_TX_MSDU_EXT2_DESC_FLAG_HOST_OPAQUE_VALID_SET
  2376. (msdu_info->meta_data[5], 1);
  2377. HTT_TX_MSDU_EXT2_DESC_HOST_OPAQUE_COOKIE_SET
  2378. (msdu_info->meta_data[6], ppdu_cookie);
  2379. msdu_info->exception_fw = 1;
  2380. msdu_info->is_tx_sniffer = 1;
  2381. }
  2382. #ifdef MESH_MODE_SUPPORT
  2383. /**
  2384. * dp_tx_extract_mesh_meta_data()- Extract mesh meta hdr info from nbuf
  2385. and prepare msdu_info for mesh frames.
  2386. * @vdev: DP vdev handle
  2387. * @nbuf: skb
  2388. * @msdu_info: MSDU info to be setup in MSDU descriptor and MSDU extension desc.
  2389. *
  2390. * Return: NULL on failure,
  2391. * nbuf when extracted successfully
  2392. */
  2393. static
  2394. qdf_nbuf_t dp_tx_extract_mesh_meta_data(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  2395. struct dp_tx_msdu_info_s *msdu_info)
  2396. {
  2397. struct meta_hdr_s *mhdr;
  2398. struct htt_tx_msdu_desc_ext2_t *meta_data =
  2399. (struct htt_tx_msdu_desc_ext2_t *)&msdu_info->meta_data[0];
  2400. mhdr = (struct meta_hdr_s *)qdf_nbuf_data(nbuf);
  2401. if (CB_FTYPE_MESH_TX_INFO != qdf_nbuf_get_tx_ftype(nbuf)) {
  2402. msdu_info->exception_fw = 0;
  2403. goto remove_meta_hdr;
  2404. }
  2405. msdu_info->exception_fw = 1;
  2406. qdf_mem_zero(meta_data, sizeof(struct htt_tx_msdu_desc_ext2_t));
  2407. meta_data->host_tx_desc_pool = 1;
  2408. meta_data->update_peer_cache = 1;
  2409. meta_data->learning_frame = 1;
  2410. if (!(mhdr->flags & METAHDR_FLAG_AUTO_RATE)) {
  2411. meta_data->power = mhdr->power;
  2412. meta_data->mcs_mask = 1 << mhdr->rate_info[0].mcs;
  2413. meta_data->nss_mask = 1 << mhdr->rate_info[0].nss;
  2414. meta_data->pream_type = mhdr->rate_info[0].preamble_type;
  2415. meta_data->retry_limit = mhdr->rate_info[0].max_tries;
  2416. meta_data->dyn_bw = 1;
  2417. meta_data->valid_pwr = 1;
  2418. meta_data->valid_mcs_mask = 1;
  2419. meta_data->valid_nss_mask = 1;
  2420. meta_data->valid_preamble_type = 1;
  2421. meta_data->valid_retries = 1;
  2422. meta_data->valid_bw_info = 1;
  2423. }
  2424. if (mhdr->flags & METAHDR_FLAG_NOENCRYPT) {
  2425. meta_data->encrypt_type = 0;
  2426. meta_data->valid_encrypt_type = 1;
  2427. meta_data->learning_frame = 0;
  2428. }
  2429. meta_data->valid_key_flags = 1;
  2430. meta_data->key_flags = (mhdr->keyix & 0x3);
  2431. remove_meta_hdr:
  2432. if (qdf_nbuf_pull_head(nbuf, sizeof(struct meta_hdr_s)) == NULL) {
  2433. dp_tx_err("qdf_nbuf_pull_head failed");
  2434. qdf_nbuf_free(nbuf);
  2435. return NULL;
  2436. }
  2437. msdu_info->tid = qdf_nbuf_get_priority(nbuf);
  2438. dp_tx_info("Meta hdr %0x %0x %0x %0x %0x %0x"
  2439. " tid %d to_fw %d",
  2440. msdu_info->meta_data[0],
  2441. msdu_info->meta_data[1],
  2442. msdu_info->meta_data[2],
  2443. msdu_info->meta_data[3],
  2444. msdu_info->meta_data[4],
  2445. msdu_info->meta_data[5],
  2446. msdu_info->tid, msdu_info->exception_fw);
  2447. return nbuf;
  2448. }
  2449. #else
  2450. static
  2451. qdf_nbuf_t dp_tx_extract_mesh_meta_data(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  2452. struct dp_tx_msdu_info_s *msdu_info)
  2453. {
  2454. return nbuf;
  2455. }
  2456. #endif
  2457. /**
  2458. * dp_check_exc_metadata() - Checks if parameters are valid
  2459. * @tx_exc - holds all exception path parameters
  2460. *
  2461. * Returns true when all the parameters are valid else false
  2462. *
  2463. */
  2464. static bool dp_check_exc_metadata(struct cdp_tx_exception_metadata *tx_exc)
  2465. {
  2466. bool invalid_tid = (tx_exc->tid >= DP_MAX_TIDS && tx_exc->tid !=
  2467. HTT_INVALID_TID);
  2468. bool invalid_encap_type =
  2469. (tx_exc->tx_encap_type > htt_cmn_pkt_num_types &&
  2470. tx_exc->tx_encap_type != CDP_INVALID_TX_ENCAP_TYPE);
  2471. bool invalid_sec_type = (tx_exc->sec_type > cdp_num_sec_types &&
  2472. tx_exc->sec_type != CDP_INVALID_SEC_TYPE);
  2473. bool invalid_cookie = (tx_exc->is_tx_sniffer == 1 &&
  2474. tx_exc->ppdu_cookie == 0);
  2475. if (tx_exc->is_intrabss_fwd)
  2476. return true;
  2477. if (invalid_tid || invalid_encap_type || invalid_sec_type ||
  2478. invalid_cookie) {
  2479. return false;
  2480. }
  2481. return true;
  2482. }
  2483. #ifdef ATH_SUPPORT_IQUE
  2484. /**
  2485. * dp_tx_mcast_enhance() - Multicast enhancement on TX
  2486. * @vdev: vdev handle
  2487. * @nbuf: skb
  2488. *
  2489. * Return: true on success,
  2490. * false on failure
  2491. */
  2492. static inline bool dp_tx_mcast_enhance(struct dp_vdev *vdev, qdf_nbuf_t nbuf)
  2493. {
  2494. qdf_ether_header_t *eh;
  2495. /* Mcast to Ucast Conversion*/
  2496. if (qdf_likely(!vdev->mcast_enhancement_en))
  2497. return true;
  2498. eh = (qdf_ether_header_t *)qdf_nbuf_data(nbuf);
  2499. if (DP_FRAME_IS_MULTICAST((eh)->ether_dhost) &&
  2500. !DP_FRAME_IS_BROADCAST((eh)->ether_dhost)) {
  2501. dp_verbose_debug("Mcast frm for ME %pK", vdev);
  2502. qdf_nbuf_set_next(nbuf, NULL);
  2503. DP_STATS_INC_PKT(vdev, tx_i.mcast_en.mcast_pkt, 1,
  2504. qdf_nbuf_len(nbuf));
  2505. if (dp_tx_prepare_send_me(vdev, nbuf) ==
  2506. QDF_STATUS_SUCCESS) {
  2507. return false;
  2508. }
  2509. if (qdf_unlikely(vdev->igmp_mcast_enhanc_en > 0)) {
  2510. if (dp_tx_prepare_send_igmp_me(vdev, nbuf) ==
  2511. QDF_STATUS_SUCCESS) {
  2512. return false;
  2513. }
  2514. }
  2515. }
  2516. return true;
  2517. }
  2518. #else
  2519. static inline bool dp_tx_mcast_enhance(struct dp_vdev *vdev, qdf_nbuf_t nbuf)
  2520. {
  2521. return true;
  2522. }
  2523. #endif
  2524. /**
  2525. * dp_tx_per_pkt_vdev_id_check() - vdev id check for frame
  2526. * @nbuf: qdf_nbuf_t
  2527. * @vdev: struct dp_vdev *
  2528. *
  2529. * Allow packet for processing only if it is for peer client which is
  2530. * connected with same vap. Drop packet if client is connected to
  2531. * different vap.
  2532. *
  2533. * Return: QDF_STATUS
  2534. */
  2535. static inline QDF_STATUS
  2536. dp_tx_per_pkt_vdev_id_check(qdf_nbuf_t nbuf, struct dp_vdev *vdev)
  2537. {
  2538. struct dp_ast_entry *dst_ast_entry = NULL;
  2539. qdf_ether_header_t *eh = (qdf_ether_header_t *)qdf_nbuf_data(nbuf);
  2540. if (DP_FRAME_IS_MULTICAST((eh)->ether_dhost) ||
  2541. DP_FRAME_IS_BROADCAST((eh)->ether_dhost))
  2542. return QDF_STATUS_SUCCESS;
  2543. qdf_spin_lock_bh(&vdev->pdev->soc->ast_lock);
  2544. dst_ast_entry = dp_peer_ast_hash_find_by_vdevid(vdev->pdev->soc,
  2545. eh->ether_dhost,
  2546. vdev->vdev_id);
  2547. /* If there is no ast entry, return failure */
  2548. if (qdf_unlikely(!dst_ast_entry)) {
  2549. qdf_spin_unlock_bh(&vdev->pdev->soc->ast_lock);
  2550. return QDF_STATUS_E_FAILURE;
  2551. }
  2552. qdf_spin_unlock_bh(&vdev->pdev->soc->ast_lock);
  2553. return QDF_STATUS_SUCCESS;
  2554. }
  2555. /**
  2556. * dp_tx_nawds_handler() - NAWDS handler
  2557. *
  2558. * @soc: DP soc handle
  2559. * @vdev_id: id of DP vdev handle
  2560. * @msdu_info: msdu_info required to create HTT metadata
  2561. * @nbuf: skb
  2562. *
  2563. * This API transfers the multicast frames with the peer id
  2564. * on NAWDS enabled peer.
  2565. * Return: none
  2566. */
  2567. static inline
  2568. void dp_tx_nawds_handler(struct dp_soc *soc, struct dp_vdev *vdev,
  2569. struct dp_tx_msdu_info_s *msdu_info,
  2570. qdf_nbuf_t nbuf, uint16_t sa_peer_id)
  2571. {
  2572. struct dp_peer *peer = NULL;
  2573. qdf_nbuf_t nbuf_clone = NULL;
  2574. uint16_t peer_id = DP_INVALID_PEER;
  2575. struct dp_txrx_peer *txrx_peer;
  2576. /* This check avoids pkt forwarding which is entered
  2577. * in the ast table but still doesn't have valid peerid.
  2578. */
  2579. if (sa_peer_id == HTT_INVALID_PEER)
  2580. return;
  2581. qdf_spin_lock_bh(&vdev->peer_list_lock);
  2582. TAILQ_FOREACH(peer, &vdev->peer_list, peer_list_elem) {
  2583. txrx_peer = dp_get_txrx_peer(peer);
  2584. if (!txrx_peer)
  2585. continue;
  2586. if (!txrx_peer->bss_peer && txrx_peer->nawds_enabled) {
  2587. peer_id = peer->peer_id;
  2588. /* Multicast packets needs to be
  2589. * dropped in case of intra bss forwarding
  2590. */
  2591. if (sa_peer_id == peer->peer_id) {
  2592. dp_tx_debug("multicast packet");
  2593. DP_PEER_PER_PKT_STATS_INC(txrx_peer,
  2594. tx.nawds_mcast_drop,
  2595. 1);
  2596. continue;
  2597. }
  2598. nbuf_clone = qdf_nbuf_clone(nbuf);
  2599. if (!nbuf_clone) {
  2600. QDF_TRACE(QDF_MODULE_ID_DP,
  2601. QDF_TRACE_LEVEL_ERROR,
  2602. FL("nbuf clone failed"));
  2603. break;
  2604. }
  2605. nbuf_clone = dp_tx_send_msdu_single(vdev, nbuf_clone,
  2606. msdu_info, peer_id,
  2607. NULL);
  2608. if (nbuf_clone) {
  2609. dp_tx_debug("pkt send failed");
  2610. qdf_nbuf_free(nbuf_clone);
  2611. } else {
  2612. if (peer_id != DP_INVALID_PEER)
  2613. DP_PEER_PER_PKT_STATS_INC_PKT(txrx_peer,
  2614. tx.nawds_mcast,
  2615. 1, qdf_nbuf_len(nbuf));
  2616. }
  2617. }
  2618. }
  2619. qdf_spin_unlock_bh(&vdev->peer_list_lock);
  2620. }
  2621. /**
  2622. * dp_tx_send_exception() - Transmit a frame on a given VAP in exception path
  2623. * @soc: DP soc handle
  2624. * @vdev_id: id of DP vdev handle
  2625. * @nbuf: skb
  2626. * @tx_exc_metadata: Handle that holds exception path meta data
  2627. *
  2628. * Entry point for Core Tx layer (DP_TX) invoked from
  2629. * hard_start_xmit in OSIF/HDD to transmit frames through fw
  2630. *
  2631. * Return: NULL on success,
  2632. * nbuf when it fails to send
  2633. */
  2634. qdf_nbuf_t
  2635. dp_tx_send_exception(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  2636. qdf_nbuf_t nbuf,
  2637. struct cdp_tx_exception_metadata *tx_exc_metadata)
  2638. {
  2639. struct dp_soc *soc = cdp_soc_t_to_dp_soc(soc_hdl);
  2640. qdf_ether_header_t *eh = NULL;
  2641. struct dp_tx_msdu_info_s msdu_info;
  2642. struct dp_vdev *vdev = dp_vdev_get_ref_by_id(soc, vdev_id,
  2643. DP_MOD_ID_TX_EXCEPTION);
  2644. if (qdf_unlikely(!vdev))
  2645. goto fail;
  2646. qdf_mem_zero(&msdu_info, sizeof(msdu_info));
  2647. if (!tx_exc_metadata)
  2648. goto fail;
  2649. msdu_info.tid = tx_exc_metadata->tid;
  2650. eh = (qdf_ether_header_t *)qdf_nbuf_data(nbuf);
  2651. dp_verbose_debug("skb "QDF_MAC_ADDR_FMT,
  2652. QDF_MAC_ADDR_REF(nbuf->data));
  2653. DP_STATS_INC_PKT(vdev, tx_i.rcvd, 1, qdf_nbuf_len(nbuf));
  2654. if (qdf_unlikely(!dp_check_exc_metadata(tx_exc_metadata))) {
  2655. dp_tx_err("Invalid parameters in exception path");
  2656. goto fail;
  2657. }
  2658. /* Basic sanity checks for unsupported packets */
  2659. /* MESH mode */
  2660. if (qdf_unlikely(vdev->mesh_vdev)) {
  2661. dp_tx_err("Mesh mode is not supported in exception path");
  2662. goto fail;
  2663. }
  2664. /*
  2665. * Classify the frame and call corresponding
  2666. * "prepare" function which extracts the segment (TSO)
  2667. * and fragmentation information (for TSO , SG, ME, or Raw)
  2668. * into MSDU_INFO structure which is later used to fill
  2669. * SW and HW descriptors.
  2670. */
  2671. if (qdf_nbuf_is_tso(nbuf)) {
  2672. dp_verbose_debug("TSO frame %pK", vdev);
  2673. DP_STATS_INC_PKT(vdev->pdev, tso_stats.num_tso_pkts, 1,
  2674. qdf_nbuf_len(nbuf));
  2675. if (dp_tx_prepare_tso(vdev, nbuf, &msdu_info)) {
  2676. DP_STATS_INC_PKT(vdev->pdev, tso_stats.dropped_host, 1,
  2677. qdf_nbuf_len(nbuf));
  2678. goto fail;
  2679. }
  2680. goto send_multiple;
  2681. }
  2682. /* SG */
  2683. if (qdf_unlikely(qdf_nbuf_is_nonlinear(nbuf))) {
  2684. struct dp_tx_seg_info_s seg_info = {0};
  2685. nbuf = dp_tx_prepare_sg(vdev, nbuf, &seg_info, &msdu_info);
  2686. if (!nbuf)
  2687. goto fail;
  2688. dp_verbose_debug("non-TSO SG frame %pK", vdev);
  2689. DP_STATS_INC_PKT(vdev, tx_i.sg.sg_pkt, 1,
  2690. qdf_nbuf_len(nbuf));
  2691. goto send_multiple;
  2692. }
  2693. if (qdf_likely(tx_exc_metadata->is_tx_sniffer)) {
  2694. DP_STATS_INC_PKT(vdev, tx_i.sniffer_rcvd, 1,
  2695. qdf_nbuf_len(nbuf));
  2696. dp_tx_add_tx_sniffer_meta_data(vdev, &msdu_info,
  2697. tx_exc_metadata->ppdu_cookie);
  2698. }
  2699. /*
  2700. * Get HW Queue to use for this frame.
  2701. * TCL supports upto 4 DMA rings, out of which 3 rings are
  2702. * dedicated for data and 1 for command.
  2703. * "queue_id" maps to one hardware ring.
  2704. * With each ring, we also associate a unique Tx descriptor pool
  2705. * to minimize lock contention for these resources.
  2706. */
  2707. dp_tx_get_queue(vdev, nbuf, &msdu_info.tx_queue);
  2708. if (qdf_likely(tx_exc_metadata->is_intrabss_fwd)) {
  2709. if (qdf_unlikely(vdev->nawds_enabled)) {
  2710. /*
  2711. * This is a multicast packet
  2712. */
  2713. dp_tx_nawds_handler(soc, vdev, &msdu_info, nbuf,
  2714. tx_exc_metadata->peer_id);
  2715. DP_STATS_INC_PKT(vdev, tx_i.nawds_mcast,
  2716. 1, qdf_nbuf_len(nbuf));
  2717. }
  2718. nbuf = dp_tx_send_msdu_single(vdev, nbuf, &msdu_info,
  2719. DP_INVALID_PEER, NULL);
  2720. } else {
  2721. /*
  2722. * Check exception descriptors
  2723. */
  2724. if (dp_tx_exception_limit_check(vdev))
  2725. goto fail;
  2726. /* Single linear frame */
  2727. /*
  2728. * If nbuf is a simple linear frame, use send_single function to
  2729. * prepare direct-buffer type TCL descriptor and enqueue to TCL
  2730. * SRNG. There is no need to setup a MSDU extension descriptor.
  2731. */
  2732. nbuf = dp_tx_send_msdu_single(vdev, nbuf, &msdu_info,
  2733. tx_exc_metadata->peer_id,
  2734. tx_exc_metadata);
  2735. }
  2736. dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_TX_EXCEPTION);
  2737. return nbuf;
  2738. send_multiple:
  2739. nbuf = dp_tx_send_msdu_multiple(vdev, nbuf, &msdu_info);
  2740. fail:
  2741. if (vdev)
  2742. dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_TX_EXCEPTION);
  2743. dp_verbose_debug("pkt send failed");
  2744. return nbuf;
  2745. }
  2746. /**
  2747. * dp_tx_send_exception_vdev_id_check() - Transmit a frame on a given VAP
  2748. * in exception path in special case to avoid regular exception path chk.
  2749. * @soc: DP soc handle
  2750. * @vdev_id: id of DP vdev handle
  2751. * @nbuf: skb
  2752. * @tx_exc_metadata: Handle that holds exception path meta data
  2753. *
  2754. * Entry point for Core Tx layer (DP_TX) invoked from
  2755. * hard_start_xmit in OSIF/HDD to transmit frames through fw
  2756. *
  2757. * Return: NULL on success,
  2758. * nbuf when it fails to send
  2759. */
  2760. qdf_nbuf_t
  2761. dp_tx_send_exception_vdev_id_check(struct cdp_soc_t *soc_hdl,
  2762. uint8_t vdev_id, qdf_nbuf_t nbuf,
  2763. struct cdp_tx_exception_metadata *tx_exc_metadata)
  2764. {
  2765. struct dp_soc *soc = cdp_soc_t_to_dp_soc(soc_hdl);
  2766. struct dp_vdev *vdev = dp_vdev_get_ref_by_id(soc, vdev_id,
  2767. DP_MOD_ID_TX_EXCEPTION);
  2768. if (qdf_unlikely(!vdev))
  2769. goto fail;
  2770. if (qdf_unlikely(dp_tx_per_pkt_vdev_id_check(nbuf, vdev)
  2771. == QDF_STATUS_E_FAILURE)) {
  2772. DP_STATS_INC(vdev, tx_i.dropped.fail_per_pkt_vdev_id_check, 1);
  2773. goto fail;
  2774. }
  2775. /* Unref count as it will agin be taken inside dp_tx_exception */
  2776. dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_TX_EXCEPTION);
  2777. return dp_tx_send_exception(soc_hdl, vdev_id, nbuf, tx_exc_metadata);
  2778. fail:
  2779. if (vdev)
  2780. dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_TX_EXCEPTION);
  2781. dp_verbose_debug("pkt send failed");
  2782. return nbuf;
  2783. }
  2784. /**
  2785. * dp_tx_send_mesh() - Transmit mesh frame on a given VAP
  2786. * @soc: DP soc handle
  2787. * @vdev_id: DP vdev handle
  2788. * @nbuf: skb
  2789. *
  2790. * Entry point for Core Tx layer (DP_TX) invoked from
  2791. * hard_start_xmit in OSIF/HDD
  2792. *
  2793. * Return: NULL on success,
  2794. * nbuf when it fails to send
  2795. */
  2796. #ifdef MESH_MODE_SUPPORT
  2797. qdf_nbuf_t dp_tx_send_mesh(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  2798. qdf_nbuf_t nbuf)
  2799. {
  2800. struct dp_soc *soc = cdp_soc_t_to_dp_soc(soc_hdl);
  2801. struct meta_hdr_s *mhdr;
  2802. qdf_nbuf_t nbuf_mesh = NULL;
  2803. qdf_nbuf_t nbuf_clone = NULL;
  2804. struct dp_vdev *vdev;
  2805. uint8_t no_enc_frame = 0;
  2806. nbuf_mesh = qdf_nbuf_unshare(nbuf);
  2807. if (!nbuf_mesh) {
  2808. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  2809. "qdf_nbuf_unshare failed");
  2810. return nbuf;
  2811. }
  2812. vdev = dp_vdev_get_ref_by_id(soc, vdev_id, DP_MOD_ID_MESH);
  2813. if (!vdev) {
  2814. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  2815. "vdev is NULL for vdev_id %d", vdev_id);
  2816. return nbuf;
  2817. }
  2818. nbuf = nbuf_mesh;
  2819. mhdr = (struct meta_hdr_s *)qdf_nbuf_data(nbuf);
  2820. if ((vdev->sec_type != cdp_sec_type_none) &&
  2821. (mhdr->flags & METAHDR_FLAG_NOENCRYPT))
  2822. no_enc_frame = 1;
  2823. if (mhdr->flags & METAHDR_FLAG_NOQOS)
  2824. qdf_nbuf_set_priority(nbuf, HTT_TX_EXT_TID_NON_QOS_MCAST_BCAST);
  2825. if ((mhdr->flags & METAHDR_FLAG_INFO_UPDATED) &&
  2826. !no_enc_frame) {
  2827. nbuf_clone = qdf_nbuf_clone(nbuf);
  2828. if (!nbuf_clone) {
  2829. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  2830. "qdf_nbuf_clone failed");
  2831. dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_MESH);
  2832. return nbuf;
  2833. }
  2834. qdf_nbuf_set_tx_ftype(nbuf_clone, CB_FTYPE_MESH_TX_INFO);
  2835. }
  2836. if (nbuf_clone) {
  2837. if (!dp_tx_send(soc_hdl, vdev_id, nbuf_clone)) {
  2838. DP_STATS_INC(vdev, tx_i.mesh.exception_fw, 1);
  2839. } else {
  2840. qdf_nbuf_free(nbuf_clone);
  2841. }
  2842. }
  2843. if (no_enc_frame)
  2844. qdf_nbuf_set_tx_ftype(nbuf, CB_FTYPE_MESH_TX_INFO);
  2845. else
  2846. qdf_nbuf_set_tx_ftype(nbuf, CB_FTYPE_INVALID);
  2847. nbuf = dp_tx_send(soc_hdl, vdev_id, nbuf);
  2848. if ((!nbuf) && no_enc_frame) {
  2849. DP_STATS_INC(vdev, tx_i.mesh.exception_fw, 1);
  2850. }
  2851. dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_MESH);
  2852. return nbuf;
  2853. }
  2854. #else
  2855. qdf_nbuf_t dp_tx_send_mesh(struct cdp_soc_t *soc, uint8_t vdev_id,
  2856. qdf_nbuf_t nbuf)
  2857. {
  2858. return dp_tx_send(soc, vdev_id, nbuf);
  2859. }
  2860. #endif
  2861. #ifdef QCA_DP_TX_NBUF_AND_NBUF_DATA_PREFETCH
  2862. static inline
  2863. void dp_tx_prefetch_nbuf_data(qdf_nbuf_t nbuf)
  2864. {
  2865. if (nbuf) {
  2866. qdf_prefetch(&nbuf->len);
  2867. qdf_prefetch(&nbuf->data);
  2868. }
  2869. }
  2870. #else
  2871. static inline
  2872. void dp_tx_prefetch_nbuf_data(qdf_nbuf_t nbuf)
  2873. {
  2874. }
  2875. #endif
  2876. /**
  2877. * dp_tx_send() - Transmit a frame on a given VAP
  2878. * @soc: DP soc handle
  2879. * @vdev_id: id of DP vdev handle
  2880. * @nbuf: skb
  2881. *
  2882. * Entry point for Core Tx layer (DP_TX) invoked from
  2883. * hard_start_xmit in OSIF/HDD or from dp_rx_process for intravap forwarding
  2884. * cases
  2885. *
  2886. * Return: NULL on success,
  2887. * nbuf when it fails to send
  2888. */
  2889. qdf_nbuf_t dp_tx_send(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  2890. qdf_nbuf_t nbuf)
  2891. {
  2892. struct dp_soc *soc = cdp_soc_t_to_dp_soc(soc_hdl);
  2893. uint16_t peer_id = HTT_INVALID_PEER;
  2894. /*
  2895. * doing a memzero is causing additional function call overhead
  2896. * so doing static stack clearing
  2897. */
  2898. struct dp_tx_msdu_info_s msdu_info = {0};
  2899. struct dp_vdev *vdev = NULL;
  2900. if (qdf_unlikely(vdev_id >= MAX_VDEV_CNT))
  2901. return nbuf;
  2902. /*
  2903. * dp_vdev_get_ref_by_id does does a atomic operation avoid using
  2904. * this in per packet path.
  2905. *
  2906. * As in this path vdev memory is already protected with netdev
  2907. * tx lock
  2908. */
  2909. vdev = soc->vdev_id_map[vdev_id];
  2910. if (qdf_unlikely(!vdev))
  2911. return nbuf;
  2912. dp_verbose_debug("skb "QDF_MAC_ADDR_FMT,
  2913. QDF_MAC_ADDR_REF(nbuf->data));
  2914. /*
  2915. * Set Default Host TID value to invalid TID
  2916. * (TID override disabled)
  2917. */
  2918. msdu_info.tid = HTT_TX_EXT_TID_INVALID;
  2919. DP_STATS_INC_PKT(vdev, tx_i.rcvd, 1, qdf_nbuf_len(nbuf));
  2920. if (qdf_unlikely(vdev->mesh_vdev)) {
  2921. qdf_nbuf_t nbuf_mesh = dp_tx_extract_mesh_meta_data(vdev, nbuf,
  2922. &msdu_info);
  2923. if (!nbuf_mesh) {
  2924. dp_verbose_debug("Extracting mesh metadata failed");
  2925. return nbuf;
  2926. }
  2927. nbuf = nbuf_mesh;
  2928. }
  2929. /*
  2930. * Get HW Queue to use for this frame.
  2931. * TCL supports upto 4 DMA rings, out of which 3 rings are
  2932. * dedicated for data and 1 for command.
  2933. * "queue_id" maps to one hardware ring.
  2934. * With each ring, we also associate a unique Tx descriptor pool
  2935. * to minimize lock contention for these resources.
  2936. */
  2937. dp_tx_get_queue(vdev, nbuf, &msdu_info.tx_queue);
  2938. /*
  2939. * TCL H/W supports 2 DSCP-TID mapping tables.
  2940. * Table 1 - Default DSCP-TID mapping table
  2941. * Table 2 - 1 DSCP-TID override table
  2942. *
  2943. * If we need a different DSCP-TID mapping for this vap,
  2944. * call tid_classify to extract DSCP/ToS from frame and
  2945. * map to a TID and store in msdu_info. This is later used
  2946. * to fill in TCL Input descriptor (per-packet TID override).
  2947. */
  2948. dp_tx_classify_tid(vdev, nbuf, &msdu_info);
  2949. /*
  2950. * Classify the frame and call corresponding
  2951. * "prepare" function which extracts the segment (TSO)
  2952. * and fragmentation information (for TSO , SG, ME, or Raw)
  2953. * into MSDU_INFO structure which is later used to fill
  2954. * SW and HW descriptors.
  2955. */
  2956. if (qdf_nbuf_is_tso(nbuf)) {
  2957. dp_verbose_debug("TSO frame %pK", vdev);
  2958. DP_STATS_INC_PKT(vdev->pdev, tso_stats.num_tso_pkts, 1,
  2959. qdf_nbuf_len(nbuf));
  2960. if (dp_tx_prepare_tso(vdev, nbuf, &msdu_info)) {
  2961. DP_STATS_INC_PKT(vdev->pdev, tso_stats.dropped_host, 1,
  2962. qdf_nbuf_len(nbuf));
  2963. return nbuf;
  2964. }
  2965. goto send_multiple;
  2966. }
  2967. /* SG */
  2968. if (qdf_unlikely(qdf_nbuf_is_nonlinear(nbuf))) {
  2969. if (qdf_nbuf_get_nr_frags(nbuf) > DP_TX_MAX_NUM_FRAGS - 1) {
  2970. if (qdf_unlikely(qdf_nbuf_linearize(nbuf)))
  2971. return nbuf;
  2972. } else {
  2973. struct dp_tx_seg_info_s seg_info = {0};
  2974. nbuf = dp_tx_prepare_sg(vdev, nbuf, &seg_info,
  2975. &msdu_info);
  2976. if (!nbuf)
  2977. return NULL;
  2978. dp_verbose_debug("non-TSO SG frame %pK", vdev);
  2979. DP_STATS_INC_PKT(vdev, tx_i.sg.sg_pkt, 1,
  2980. qdf_nbuf_len(nbuf));
  2981. goto send_multiple;
  2982. }
  2983. }
  2984. if (qdf_unlikely(!dp_tx_mcast_enhance(vdev, nbuf)))
  2985. return NULL;
  2986. /* RAW */
  2987. if (qdf_unlikely(vdev->tx_encap_type == htt_cmn_pkt_type_raw)) {
  2988. struct dp_tx_seg_info_s seg_info = {0};
  2989. nbuf = dp_tx_prepare_raw(vdev, nbuf, &seg_info, &msdu_info);
  2990. if (!nbuf)
  2991. return NULL;
  2992. dp_verbose_debug("Raw frame %pK", vdev);
  2993. goto send_multiple;
  2994. }
  2995. if (qdf_unlikely(vdev->nawds_enabled)) {
  2996. qdf_ether_header_t *eh = (qdf_ether_header_t *)
  2997. qdf_nbuf_data(nbuf);
  2998. if (DP_FRAME_IS_MULTICAST((eh)->ether_dhost)) {
  2999. uint16_t sa_peer_id = DP_INVALID_PEER;
  3000. if (!soc->ast_offload_support) {
  3001. struct dp_ast_entry *ast_entry = NULL;
  3002. qdf_spin_lock_bh(&soc->ast_lock);
  3003. ast_entry = dp_peer_ast_hash_find_by_pdevid
  3004. (soc,
  3005. (uint8_t *)(eh->ether_shost),
  3006. vdev->pdev->pdev_id);
  3007. if (ast_entry)
  3008. sa_peer_id = ast_entry->peer_id;
  3009. qdf_spin_unlock_bh(&soc->ast_lock);
  3010. }
  3011. dp_tx_nawds_handler(soc, vdev, &msdu_info, nbuf,
  3012. sa_peer_id);
  3013. }
  3014. peer_id = DP_INVALID_PEER;
  3015. DP_STATS_INC_PKT(vdev, tx_i.nawds_mcast,
  3016. 1, qdf_nbuf_len(nbuf));
  3017. }
  3018. /* Single linear frame */
  3019. /*
  3020. * If nbuf is a simple linear frame, use send_single function to
  3021. * prepare direct-buffer type TCL descriptor and enqueue to TCL
  3022. * SRNG. There is no need to setup a MSDU extension descriptor.
  3023. */
  3024. dp_tx_prefetch_nbuf_data(nbuf);
  3025. nbuf = dp_tx_send_msdu_single(vdev, nbuf, &msdu_info, peer_id, NULL);
  3026. return nbuf;
  3027. send_multiple:
  3028. nbuf = dp_tx_send_msdu_multiple(vdev, nbuf, &msdu_info);
  3029. if (qdf_unlikely(nbuf && msdu_info.frm_type == dp_tx_frm_raw))
  3030. dp_tx_raw_prepare_unset(vdev->pdev->soc, nbuf);
  3031. return nbuf;
  3032. }
  3033. /**
  3034. * dp_tx_send_vdev_id_check() - Transmit a frame on a given VAP in special
  3035. * case to vaoid check in perpkt path.
  3036. * @soc: DP soc handle
  3037. * @vdev_id: id of DP vdev handle
  3038. * @nbuf: skb
  3039. *
  3040. * Entry point for Core Tx layer (DP_TX) invoked from
  3041. * hard_start_xmit in OSIF/HDD to transmit packet through dp_tx_send
  3042. * with special condition to avoid per pkt check in dp_tx_send
  3043. *
  3044. * Return: NULL on success,
  3045. * nbuf when it fails to send
  3046. */
  3047. qdf_nbuf_t dp_tx_send_vdev_id_check(struct cdp_soc_t *soc_hdl,
  3048. uint8_t vdev_id, qdf_nbuf_t nbuf)
  3049. {
  3050. struct dp_soc *soc = cdp_soc_t_to_dp_soc(soc_hdl);
  3051. struct dp_vdev *vdev = NULL;
  3052. if (qdf_unlikely(vdev_id >= MAX_VDEV_CNT))
  3053. return nbuf;
  3054. /*
  3055. * dp_vdev_get_ref_by_id does does a atomic operation avoid using
  3056. * this in per packet path.
  3057. *
  3058. * As in this path vdev memory is already protected with netdev
  3059. * tx lock
  3060. */
  3061. vdev = soc->vdev_id_map[vdev_id];
  3062. if (qdf_unlikely(!vdev))
  3063. return nbuf;
  3064. if (qdf_unlikely(dp_tx_per_pkt_vdev_id_check(nbuf, vdev)
  3065. == QDF_STATUS_E_FAILURE)) {
  3066. DP_STATS_INC(vdev, tx_i.dropped.fail_per_pkt_vdev_id_check, 1);
  3067. return nbuf;
  3068. }
  3069. return dp_tx_send(soc_hdl, vdev_id, nbuf);
  3070. }
  3071. #ifdef UMAC_SUPPORT_PROXY_ARP
  3072. /**
  3073. * dp_tx_proxy_arp() - Tx proxy arp handler
  3074. * @vdev: datapath vdev handle
  3075. * @buf: sk buffer
  3076. *
  3077. * Return: status
  3078. */
  3079. static inline
  3080. int dp_tx_proxy_arp(struct dp_vdev *vdev, qdf_nbuf_t nbuf)
  3081. {
  3082. if (vdev->osif_proxy_arp)
  3083. return vdev->osif_proxy_arp(vdev->osif_vdev, nbuf);
  3084. /*
  3085. * when UMAC_SUPPORT_PROXY_ARP is defined, we expect
  3086. * osif_proxy_arp has a valid function pointer assigned
  3087. * to it
  3088. */
  3089. dp_tx_err("valid function pointer for osif_proxy_arp is expected!!\n");
  3090. return QDF_STATUS_NOT_INITIALIZED;
  3091. }
  3092. #else
  3093. /**
  3094. * dp_tx_proxy_arp() - Tx proxy arp handler
  3095. * @vdev: datapath vdev handle
  3096. * @buf: sk buffer
  3097. *
  3098. * This function always return 0 when UMAC_SUPPORT_PROXY_ARP
  3099. * is not defined.
  3100. *
  3101. * Return: status
  3102. */
  3103. static inline
  3104. int dp_tx_proxy_arp(struct dp_vdev *vdev, qdf_nbuf_t nbuf)
  3105. {
  3106. return QDF_STATUS_SUCCESS;
  3107. }
  3108. #endif
  3109. /**
  3110. * dp_tx_reinject_handler() - Tx Reinject Handler
  3111. * @soc: datapath soc handle
  3112. * @vdev: datapath vdev handle
  3113. * @tx_desc: software descriptor head pointer
  3114. * @status : Tx completion status from HTT descriptor
  3115. * @reinject_reason : reinject reason from HTT descriptor
  3116. *
  3117. * This function reinjects frames back to Target.
  3118. * Todo - Host queue needs to be added
  3119. *
  3120. * Return: none
  3121. */
  3122. void dp_tx_reinject_handler(struct dp_soc *soc,
  3123. struct dp_vdev *vdev,
  3124. struct dp_tx_desc_s *tx_desc,
  3125. uint8_t *status,
  3126. uint8_t reinject_reason)
  3127. {
  3128. struct dp_peer *peer = NULL;
  3129. uint32_t peer_id = HTT_INVALID_PEER;
  3130. qdf_nbuf_t nbuf = tx_desc->nbuf;
  3131. qdf_nbuf_t nbuf_copy = NULL;
  3132. struct dp_tx_msdu_info_s msdu_info;
  3133. #ifdef WDS_VENDOR_EXTENSION
  3134. int is_mcast = 0, is_ucast = 0;
  3135. int num_peers_3addr = 0;
  3136. qdf_ether_header_t *eth_hdr = (qdf_ether_header_t *)(qdf_nbuf_data(nbuf));
  3137. struct ieee80211_frame_addr4 *wh = (struct ieee80211_frame_addr4 *)(qdf_nbuf_data(nbuf));
  3138. #endif
  3139. struct dp_txrx_peer *txrx_peer;
  3140. qdf_assert(vdev);
  3141. dp_tx_debug("Tx reinject path");
  3142. DP_STATS_INC_PKT(vdev, tx_i.reinject_pkts, 1,
  3143. qdf_nbuf_len(tx_desc->nbuf));
  3144. #if defined(WLAN_FEATURE_11BE_MLO) && defined(WLAN_MLO_MULTI_CHIP)
  3145. #ifdef WLAN_MCAST_MLO
  3146. if (reinject_reason == HTT_TX_FW2WBM_REINJECT_REASON_MLO_MCAST) {
  3147. if (soc->arch_ops.dp_tx_mcast_handler)
  3148. soc->arch_ops.dp_tx_mcast_handler(soc, vdev, nbuf);
  3149. dp_tx_desc_release(tx_desc, tx_desc->pool_id);
  3150. return;
  3151. }
  3152. #endif
  3153. #endif
  3154. #ifdef WDS_VENDOR_EXTENSION
  3155. if (qdf_unlikely(vdev->tx_encap_type != htt_cmn_pkt_type_raw)) {
  3156. is_mcast = (IS_MULTICAST(wh->i_addr1)) ? 1 : 0;
  3157. } else {
  3158. is_mcast = (IS_MULTICAST(eth_hdr->ether_dhost)) ? 1 : 0;
  3159. }
  3160. is_ucast = !is_mcast;
  3161. qdf_spin_lock_bh(&vdev->peer_list_lock);
  3162. TAILQ_FOREACH(peer, &vdev->peer_list, peer_list_elem) {
  3163. txrx_peer = dp_get_txrx_peer(peer);
  3164. if (!txrx_peer || txrx_peer->bss_peer)
  3165. continue;
  3166. /* Detect wds peers that use 3-addr framing for mcast.
  3167. * if there are any, the bss_peer is used to send the
  3168. * the mcast frame using 3-addr format. all wds enabled
  3169. * peers that use 4-addr framing for mcast frames will
  3170. * be duplicated and sent as 4-addr frames below.
  3171. */
  3172. if (!txrx_peer->wds_enabled ||
  3173. !txrx_peer->wds_ecm.wds_tx_mcast_4addr) {
  3174. num_peers_3addr = 1;
  3175. break;
  3176. }
  3177. }
  3178. qdf_spin_unlock_bh(&vdev->peer_list_lock);
  3179. #endif
  3180. if (qdf_unlikely(vdev->mesh_vdev)) {
  3181. DP_TX_FREE_SINGLE_BUF(vdev->pdev->soc, tx_desc->nbuf);
  3182. } else {
  3183. qdf_spin_lock_bh(&vdev->peer_list_lock);
  3184. TAILQ_FOREACH(peer, &vdev->peer_list, peer_list_elem) {
  3185. txrx_peer = dp_get_txrx_peer(peer);
  3186. if (!txrx_peer)
  3187. continue;
  3188. if ((txrx_peer->peer_id != HTT_INVALID_PEER) &&
  3189. #ifdef WDS_VENDOR_EXTENSION
  3190. /*
  3191. * . if 3-addr STA, then send on BSS Peer
  3192. * . if Peer WDS enabled and accept 4-addr mcast,
  3193. * send mcast on that peer only
  3194. * . if Peer WDS enabled and accept 4-addr ucast,
  3195. * send ucast on that peer only
  3196. */
  3197. ((txrx_peer->bss_peer && num_peers_3addr && is_mcast) ||
  3198. (txrx_peer->wds_enabled &&
  3199. ((is_mcast && txrx_peer->wds_ecm.wds_tx_mcast_4addr) ||
  3200. (is_ucast &&
  3201. txrx_peer->wds_ecm.wds_tx_ucast_4addr))))) {
  3202. #else
  3203. (txrx_peer->bss_peer &&
  3204. (dp_tx_proxy_arp(vdev, nbuf) == QDF_STATUS_SUCCESS))) {
  3205. #endif
  3206. peer_id = DP_INVALID_PEER;
  3207. nbuf_copy = qdf_nbuf_copy(nbuf);
  3208. if (!nbuf_copy) {
  3209. dp_tx_debug("nbuf copy failed");
  3210. break;
  3211. }
  3212. qdf_mem_zero(&msdu_info, sizeof(msdu_info));
  3213. dp_tx_get_queue(vdev, nbuf,
  3214. &msdu_info.tx_queue);
  3215. nbuf_copy = dp_tx_send_msdu_single(vdev,
  3216. nbuf_copy,
  3217. &msdu_info,
  3218. peer_id,
  3219. NULL);
  3220. if (nbuf_copy) {
  3221. dp_tx_debug("pkt send failed");
  3222. qdf_nbuf_free(nbuf_copy);
  3223. }
  3224. }
  3225. }
  3226. qdf_spin_unlock_bh(&vdev->peer_list_lock);
  3227. }
  3228. qdf_nbuf_free(nbuf);
  3229. dp_tx_desc_release(tx_desc, tx_desc->pool_id);
  3230. }
  3231. /**
  3232. * dp_tx_inspect_handler() - Tx Inspect Handler
  3233. * @soc: datapath soc handle
  3234. * @vdev: datapath vdev handle
  3235. * @tx_desc: software descriptor head pointer
  3236. * @status : Tx completion status from HTT descriptor
  3237. *
  3238. * Handles Tx frames sent back to Host for inspection
  3239. * (ProxyARP)
  3240. *
  3241. * Return: none
  3242. */
  3243. void dp_tx_inspect_handler(struct dp_soc *soc,
  3244. struct dp_vdev *vdev,
  3245. struct dp_tx_desc_s *tx_desc,
  3246. uint8_t *status)
  3247. {
  3248. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  3249. "%s Tx inspect path",
  3250. __func__);
  3251. DP_STATS_INC_PKT(vdev, tx_i.inspect_pkts, 1,
  3252. qdf_nbuf_len(tx_desc->nbuf));
  3253. DP_TX_FREE_SINGLE_BUF(soc, tx_desc->nbuf);
  3254. dp_tx_desc_release(tx_desc, tx_desc->pool_id);
  3255. }
  3256. #ifdef MESH_MODE_SUPPORT
  3257. /**
  3258. * dp_tx_comp_fill_tx_completion_stats() - Fill per packet Tx completion stats
  3259. * in mesh meta header
  3260. * @tx_desc: software descriptor head pointer
  3261. * @ts: pointer to tx completion stats
  3262. * Return: none
  3263. */
  3264. static
  3265. void dp_tx_comp_fill_tx_completion_stats(struct dp_tx_desc_s *tx_desc,
  3266. struct hal_tx_completion_status *ts)
  3267. {
  3268. qdf_nbuf_t netbuf = tx_desc->nbuf;
  3269. if (!tx_desc->msdu_ext_desc) {
  3270. if (qdf_nbuf_pull_head(netbuf, tx_desc->pkt_offset) == NULL) {
  3271. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  3272. "netbuf %pK offset %d",
  3273. netbuf, tx_desc->pkt_offset);
  3274. return;
  3275. }
  3276. }
  3277. }
  3278. #else
  3279. static
  3280. void dp_tx_comp_fill_tx_completion_stats(struct dp_tx_desc_s *tx_desc,
  3281. struct hal_tx_completion_status *ts)
  3282. {
  3283. }
  3284. #endif
  3285. #ifdef CONFIG_SAWF
  3286. static void dp_tx_update_peer_sawf_stats(struct dp_soc *soc,
  3287. struct dp_vdev *vdev,
  3288. struct dp_txrx_peer *txrx_peer,
  3289. struct dp_tx_desc_s *tx_desc,
  3290. struct hal_tx_completion_status *ts,
  3291. uint8_t tid)
  3292. {
  3293. dp_sawf_tx_compl_update_peer_stats(soc, vdev, txrx_peer, tx_desc,
  3294. ts, tid);
  3295. }
  3296. #else
  3297. static void dp_tx_update_peer_sawf_stats(struct dp_soc *soc,
  3298. struct dp_vdev *vdev,
  3299. struct dp_txrx_peer *txrx_peer,
  3300. struct dp_tx_desc_s *tx_desc,
  3301. struct hal_tx_completion_status *ts,
  3302. uint8_t tid)
  3303. {
  3304. }
  3305. #endif
  3306. #ifdef QCA_PEER_EXT_STATS
  3307. /*
  3308. * dp_tx_compute_tid_delay() - Compute per TID delay
  3309. * @stats: Per TID delay stats
  3310. * @tx_desc: Software Tx descriptor
  3311. *
  3312. * Compute the software enqueue and hw enqueue delays and
  3313. * update the respective histograms
  3314. *
  3315. * Return: void
  3316. */
  3317. static void dp_tx_compute_tid_delay(struct cdp_delay_tid_stats *stats,
  3318. struct dp_tx_desc_s *tx_desc)
  3319. {
  3320. struct cdp_delay_tx_stats *tx_delay = &stats->tx_delay;
  3321. int64_t current_timestamp, timestamp_ingress, timestamp_hw_enqueue;
  3322. uint32_t sw_enqueue_delay, fwhw_transmit_delay;
  3323. current_timestamp = qdf_ktime_to_ms(qdf_ktime_real_get());
  3324. timestamp_ingress = qdf_nbuf_get_timestamp(tx_desc->nbuf);
  3325. timestamp_hw_enqueue = tx_desc->timestamp;
  3326. sw_enqueue_delay = (uint32_t)(timestamp_hw_enqueue - timestamp_ingress);
  3327. fwhw_transmit_delay = (uint32_t)(current_timestamp -
  3328. timestamp_hw_enqueue);
  3329. /*
  3330. * Update the Tx software enqueue delay and HW enque-Completion delay.
  3331. */
  3332. dp_hist_update_stats(&tx_delay->tx_swq_delay, sw_enqueue_delay);
  3333. dp_hist_update_stats(&tx_delay->hwtx_delay, fwhw_transmit_delay);
  3334. }
  3335. /*
  3336. * dp_tx_update_peer_delay_stats() - Update the peer delay stats
  3337. * @txrx_peer: DP peer context
  3338. * @tx_desc: Tx software descriptor
  3339. * @tid: Transmission ID
  3340. * @ring_id: Rx CPU context ID/CPU_ID
  3341. *
  3342. * Update the peer extended stats. These are enhanced other
  3343. * delay stats per msdu level.
  3344. *
  3345. * Return: void
  3346. */
  3347. static void dp_tx_update_peer_delay_stats(struct dp_txrx_peer *txrx_peer,
  3348. struct dp_tx_desc_s *tx_desc,
  3349. uint8_t tid, uint8_t ring_id)
  3350. {
  3351. struct dp_pdev *pdev = txrx_peer->vdev->pdev;
  3352. struct dp_soc *soc = NULL;
  3353. struct dp_peer_delay_stats *delay_stats = NULL;
  3354. soc = pdev->soc;
  3355. if (qdf_likely(!wlan_cfg_is_peer_ext_stats_enabled(soc->wlan_cfg_ctx)))
  3356. return;
  3357. delay_stats = txrx_peer->delay_stats;
  3358. qdf_assert(delay_stats);
  3359. qdf_assert(ring < CDP_MAX_TXRX_CTX);
  3360. /*
  3361. * For non-TID packets use the TID 9
  3362. */
  3363. if (qdf_unlikely(tid >= CDP_MAX_DATA_TIDS))
  3364. tid = CDP_MAX_DATA_TIDS - 1;
  3365. dp_tx_compute_tid_delay(&delay_stats->delay_tid_stats[tid][ring_id],
  3366. tx_desc);
  3367. }
  3368. #else
  3369. static inline void dp_tx_update_peer_delay_stats(struct dp_txrx_peer *txrx_peer,
  3370. struct dp_tx_desc_s *tx_desc,
  3371. uint8_t tid, uint8_t ring_id)
  3372. {
  3373. }
  3374. #endif
  3375. /**
  3376. * dp_tx_compute_delay() - Compute and fill in all timestamps
  3377. * to pass in correct fields
  3378. *
  3379. * @vdev: pdev handle
  3380. * @tx_desc: tx descriptor
  3381. * @tid: tid value
  3382. * @ring_id: TCL or WBM ring number for transmit path
  3383. * Return: none
  3384. */
  3385. void dp_tx_compute_delay(struct dp_vdev *vdev, struct dp_tx_desc_s *tx_desc,
  3386. uint8_t tid, uint8_t ring_id)
  3387. {
  3388. int64_t current_timestamp, timestamp_ingress, timestamp_hw_enqueue;
  3389. uint32_t sw_enqueue_delay, fwhw_transmit_delay, interframe_delay;
  3390. if (qdf_likely(!vdev->pdev->delay_stats_flag))
  3391. return;
  3392. current_timestamp = qdf_ktime_to_ms(qdf_ktime_real_get());
  3393. timestamp_ingress = qdf_nbuf_get_timestamp(tx_desc->nbuf);
  3394. timestamp_hw_enqueue = tx_desc->timestamp;
  3395. sw_enqueue_delay = (uint32_t)(timestamp_hw_enqueue - timestamp_ingress);
  3396. fwhw_transmit_delay = (uint32_t)(current_timestamp -
  3397. timestamp_hw_enqueue);
  3398. interframe_delay = (uint32_t)(timestamp_ingress -
  3399. vdev->prev_tx_enq_tstamp);
  3400. /*
  3401. * Delay in software enqueue
  3402. */
  3403. dp_update_delay_stats(vdev->pdev, sw_enqueue_delay, tid,
  3404. CDP_DELAY_STATS_SW_ENQ, ring_id);
  3405. /*
  3406. * Delay between packet enqueued to HW and Tx completion
  3407. */
  3408. dp_update_delay_stats(vdev->pdev, fwhw_transmit_delay, tid,
  3409. CDP_DELAY_STATS_FW_HW_TRANSMIT, ring_id);
  3410. /*
  3411. * Update interframe delay stats calculated at hardstart receive point.
  3412. * Value of vdev->prev_tx_enq_tstamp will be 0 for 1st frame, so
  3413. * interframe delay will not be calculate correctly for 1st frame.
  3414. * On the other side, this will help in avoiding extra per packet check
  3415. * of !vdev->prev_tx_enq_tstamp.
  3416. */
  3417. dp_update_delay_stats(vdev->pdev, interframe_delay, tid,
  3418. CDP_DELAY_STATS_TX_INTERFRAME, ring_id);
  3419. vdev->prev_tx_enq_tstamp = timestamp_ingress;
  3420. }
  3421. #ifdef DISABLE_DP_STATS
  3422. static
  3423. inline void dp_update_no_ack_stats(qdf_nbuf_t nbuf,
  3424. struct dp_txrx_peer *txrx_peer)
  3425. {
  3426. }
  3427. #else
  3428. static inline void
  3429. dp_update_no_ack_stats(qdf_nbuf_t nbuf, struct dp_txrx_peer *txrx_peer)
  3430. {
  3431. enum qdf_proto_subtype subtype = QDF_PROTO_INVALID;
  3432. DPTRACE(qdf_dp_track_noack_check(nbuf, &subtype));
  3433. if (subtype != QDF_PROTO_INVALID)
  3434. DP_PEER_PER_PKT_STATS_INC(txrx_peer, tx.no_ack_count[subtype],
  3435. 1);
  3436. }
  3437. #endif
  3438. #ifndef QCA_ENHANCED_STATS_SUPPORT
  3439. /**
  3440. * dp_tx_update_peer_extd_stats()- Update Tx extended path stats for peer
  3441. *
  3442. * @ts: Tx compltion status
  3443. * @txrx_peer: datapath txrx_peer handle
  3444. *
  3445. * Return: void
  3446. */
  3447. static inline void
  3448. dp_tx_update_peer_extd_stats(struct hal_tx_completion_status *ts,
  3449. struct dp_txrx_peer *txrx_peer)
  3450. {
  3451. uint8_t mcs, pkt_type;
  3452. mcs = ts->mcs;
  3453. pkt_type = ts->pkt_type;
  3454. DP_PEER_EXTD_STATS_INCC(txrx_peer,
  3455. tx.pkt_type[pkt_type].mcs_count[MAX_MCS - 1], 1,
  3456. ((mcs >= MAX_MCS_11A) && (pkt_type == DOT11_A)));
  3457. DP_PEER_EXTD_STATS_INCC(txrx_peer,
  3458. tx.pkt_type[pkt_type].mcs_count[mcs], 1,
  3459. ((mcs < (MAX_MCS_11A)) && (pkt_type == DOT11_A)));
  3460. DP_PEER_EXTD_STATS_INCC(txrx_peer,
  3461. tx.pkt_type[pkt_type].mcs_count[MAX_MCS - 1], 1,
  3462. ((mcs >= MAX_MCS_11B) && (pkt_type == DOT11_B)));
  3463. DP_PEER_EXTD_STATS_INCC(txrx_peer,
  3464. tx.pkt_type[pkt_type].mcs_count[mcs], 1,
  3465. ((mcs < MAX_MCS_11B) && (pkt_type == DOT11_B)));
  3466. DP_PEER_EXTD_STATS_INCC(txrx_peer,
  3467. tx.pkt_type[pkt_type].mcs_count[MAX_MCS - 1], 1,
  3468. ((mcs >= MAX_MCS_11A) && (pkt_type == DOT11_N)));
  3469. DP_PEER_EXTD_STATS_INCC(txrx_peer,
  3470. tx.pkt_type[pkt_type].mcs_count[mcs], 1,
  3471. ((mcs < MAX_MCS_11A) && (pkt_type == DOT11_N)));
  3472. DP_PEER_EXTD_STATS_INCC(txrx_peer,
  3473. tx.pkt_type[pkt_type].mcs_count[MAX_MCS - 1], 1,
  3474. ((mcs >= MAX_MCS_11AC) && (pkt_type == DOT11_AC)));
  3475. DP_PEER_EXTD_STATS_INCC(txrx_peer,
  3476. tx.pkt_type[pkt_type].mcs_count[mcs], 1,
  3477. ((mcs < MAX_MCS_11AC) && (pkt_type == DOT11_AC)));
  3478. DP_PEER_EXTD_STATS_INCC(txrx_peer,
  3479. tx.pkt_type[pkt_type].mcs_count[MAX_MCS - 1], 1,
  3480. ((mcs >= (MAX_MCS - 1)) && (pkt_type == DOT11_AX)));
  3481. DP_PEER_EXTD_STATS_INCC(txrx_peer,
  3482. tx.pkt_type[pkt_type].mcs_count[mcs], 1,
  3483. ((mcs < (MAX_MCS - 1)) && (pkt_type == DOT11_AX)));
  3484. DP_PEER_EXTD_STATS_INC(txrx_peer, tx.sgi_count[ts->sgi], 1);
  3485. DP_PEER_EXTD_STATS_INC(txrx_peer, tx.bw[ts->bw], 1);
  3486. DP_PEER_EXTD_STATS_UPD(txrx_peer, tx.last_ack_rssi, ts->ack_frame_rssi);
  3487. DP_PEER_EXTD_STATS_INC(txrx_peer,
  3488. tx.wme_ac_type[TID_TO_WME_AC(ts->tid)], 1);
  3489. DP_PEER_EXTD_STATS_INCC(txrx_peer, tx.stbc, 1, ts->stbc);
  3490. DP_PEER_EXTD_STATS_INCC(txrx_peer, tx.ldpc, 1, ts->ldpc);
  3491. DP_PEER_EXTD_STATS_INCC(txrx_peer, tx.retries, 1, ts->transmit_cnt > 1);
  3492. if (ts->first_msdu) {
  3493. DP_PEER_EXTD_STATS_INCC(txrx_peer, tx.retries_mpdu, 1,
  3494. ts->transmit_cnt > 1);
  3495. DP_PEER_EXTD_STATS_INCC(txrx_peer, tx.mpdu_success_with_retries,
  3496. qdf_do_div(ts->transmit_cnt, DP_RETRY_COUNT),
  3497. ts->transmit_cnt > DP_RETRY_COUNT);
  3498. }
  3499. }
  3500. #else
  3501. static inline void
  3502. dp_tx_update_peer_extd_stats(struct hal_tx_completion_status *ts,
  3503. struct dp_txrx_peer *txrx_peer)
  3504. {
  3505. }
  3506. #endif
  3507. /**
  3508. * dp_tx_update_peer_stats() - Update peer stats from Tx completion indications
  3509. * per wbm ring
  3510. *
  3511. * @tx_desc: software descriptor head pointer
  3512. * @ts: Tx completion status
  3513. * @peer: peer handle
  3514. * @ring_id: ring number
  3515. *
  3516. * Return: None
  3517. */
  3518. static inline void
  3519. dp_tx_update_peer_stats(struct dp_tx_desc_s *tx_desc,
  3520. struct hal_tx_completion_status *ts,
  3521. struct dp_txrx_peer *txrx_peer, uint8_t ring_id)
  3522. {
  3523. struct dp_pdev *pdev = txrx_peer->vdev->pdev;
  3524. uint8_t tid = ts->tid;
  3525. uint32_t length;
  3526. struct cdp_tid_tx_stats *tid_stats;
  3527. if (!pdev)
  3528. return;
  3529. if (qdf_unlikely(tid >= CDP_MAX_DATA_TIDS))
  3530. tid = CDP_MAX_DATA_TIDS - 1;
  3531. tid_stats = &pdev->stats.tid_stats.tid_tx_stats[ring_id][tid];
  3532. if (ts->release_src != HAL_TX_COMP_RELEASE_SOURCE_TQM) {
  3533. dp_err("Release source is not from TQM");
  3534. return;
  3535. }
  3536. length = qdf_nbuf_len(tx_desc->nbuf);
  3537. DP_PEER_STATS_FLAT_INC_PKT(txrx_peer, comp_pkt, 1, length);
  3538. if (qdf_unlikely(pdev->delay_stats_flag))
  3539. dp_tx_compute_delay(txrx_peer->vdev, tx_desc, tid, ring_id);
  3540. if (ts->status < CDP_MAX_TX_TQM_STATUS) {
  3541. tid_stats->tqm_status_cnt[ts->status]++;
  3542. }
  3543. if (qdf_likely(ts->status == HAL_TX_TQM_RR_FRAME_ACKED)) {
  3544. DP_PEER_PER_PKT_STATS_INCC(txrx_peer, tx.retry_count, 1,
  3545. ts->transmit_cnt > 1);
  3546. DP_PEER_PER_PKT_STATS_INCC(txrx_peer, tx.multiple_retry_count,
  3547. 1, ts->transmit_cnt > 2);
  3548. DP_PEER_PER_PKT_STATS_INCC(txrx_peer, tx.ofdma, 1, ts->ofdma);
  3549. DP_PEER_PER_PKT_STATS_INCC(txrx_peer, tx.amsdu_cnt, 1,
  3550. ts->msdu_part_of_amsdu);
  3551. DP_PEER_PER_PKT_STATS_INCC(txrx_peer, tx.non_amsdu_cnt, 1,
  3552. !ts->msdu_part_of_amsdu);
  3553. txrx_peer->stats.per_pkt_stats.tx.last_tx_ts =
  3554. qdf_system_ticks();
  3555. dp_tx_update_peer_extd_stats(ts, txrx_peer);
  3556. return;
  3557. }
  3558. /*
  3559. * tx_failed is ideally supposed to be updated from HTT ppdu
  3560. * completion stats. But in IPQ807X/IPQ6018 chipsets owing to
  3561. * hw limitation there are no completions for failed cases.
  3562. * Hence updating tx_failed from data path. Please note that
  3563. * if tx_failed is fixed to be from ppdu, then this has to be
  3564. * removed
  3565. */
  3566. DP_PEER_STATS_FLAT_INC(txrx_peer, tx_failed, 1);
  3567. DP_PEER_PER_PKT_STATS_INCC(txrx_peer, tx.failed_retry_count, 1,
  3568. ts->transmit_cnt > DP_RETRY_COUNT);
  3569. dp_update_no_ack_stats(tx_desc->nbuf, txrx_peer);
  3570. if (ts->status == HAL_TX_TQM_RR_REM_CMD_AGED) {
  3571. DP_PEER_PER_PKT_STATS_INC(txrx_peer, tx.dropped.age_out, 1);
  3572. } else if (ts->status == HAL_TX_TQM_RR_REM_CMD_REM) {
  3573. DP_PEER_PER_PKT_STATS_INC_PKT(txrx_peer, tx.dropped.fw_rem, 1,
  3574. length);
  3575. } else if (ts->status == HAL_TX_TQM_RR_REM_CMD_NOTX) {
  3576. DP_PEER_PER_PKT_STATS_INC(txrx_peer, tx.dropped.fw_rem_notx, 1);
  3577. } else if (ts->status == HAL_TX_TQM_RR_REM_CMD_TX) {
  3578. DP_PEER_PER_PKT_STATS_INC(txrx_peer, tx.dropped.fw_rem_tx, 1);
  3579. } else if (ts->status == HAL_TX_TQM_RR_FW_REASON1) {
  3580. DP_PEER_PER_PKT_STATS_INC(txrx_peer, tx.dropped.fw_reason1, 1);
  3581. } else if (ts->status == HAL_TX_TQM_RR_FW_REASON2) {
  3582. DP_PEER_PER_PKT_STATS_INC(txrx_peer, tx.dropped.fw_reason2, 1);
  3583. } else if (ts->status == HAL_TX_TQM_RR_FW_REASON3) {
  3584. DP_PEER_PER_PKT_STATS_INC(txrx_peer, tx.dropped.fw_reason3, 1);
  3585. } else if (ts->status == HAL_TX_TQM_RR_REM_CMD_DISABLE_QUEUE) {
  3586. DP_PEER_PER_PKT_STATS_INC(txrx_peer,
  3587. tx.dropped.fw_rem_queue_disable, 1);
  3588. } else if (ts->status == HAL_TX_TQM_RR_REM_CMD_TILL_NONMATCHING) {
  3589. DP_PEER_PER_PKT_STATS_INC(txrx_peer,
  3590. tx.dropped.fw_rem_no_match, 1);
  3591. } else if (ts->status == HAL_TX_TQM_RR_DROP_THRESHOLD) {
  3592. DP_PEER_PER_PKT_STATS_INC(txrx_peer,
  3593. tx.dropped.drop_threshold, 1);
  3594. } else if (ts->status == HAL_TX_TQM_RR_LINK_DESC_UNAVAILABLE) {
  3595. DP_PEER_PER_PKT_STATS_INC(txrx_peer,
  3596. tx.dropped.drop_link_desc_na, 1);
  3597. } else if (ts->status == HAL_TX_TQM_RR_DROP_OR_INVALID_MSDU) {
  3598. DP_PEER_PER_PKT_STATS_INC(txrx_peer,
  3599. tx.dropped.invalid_drop, 1);
  3600. } else if (ts->status == HAL_TX_TQM_RR_MULTICAST_DROP) {
  3601. DP_PEER_PER_PKT_STATS_INC(txrx_peer,
  3602. tx.dropped.mcast_vdev_drop, 1);
  3603. } else {
  3604. DP_PEER_PER_PKT_STATS_INC(txrx_peer, tx.dropped.invalid_rr, 1);
  3605. }
  3606. }
  3607. #ifdef QCA_LL_TX_FLOW_CONTROL_V2
  3608. /**
  3609. * dp_tx_flow_pool_lock() - take flow pool lock
  3610. * @soc: core txrx main context
  3611. * @tx_desc: tx desc
  3612. *
  3613. * Return: None
  3614. */
  3615. static inline
  3616. void dp_tx_flow_pool_lock(struct dp_soc *soc,
  3617. struct dp_tx_desc_s *tx_desc)
  3618. {
  3619. struct dp_tx_desc_pool_s *pool;
  3620. uint8_t desc_pool_id;
  3621. desc_pool_id = tx_desc->pool_id;
  3622. pool = &soc->tx_desc[desc_pool_id];
  3623. qdf_spin_lock_bh(&pool->flow_pool_lock);
  3624. }
  3625. /**
  3626. * dp_tx_flow_pool_unlock() - release flow pool lock
  3627. * @soc: core txrx main context
  3628. * @tx_desc: tx desc
  3629. *
  3630. * Return: None
  3631. */
  3632. static inline
  3633. void dp_tx_flow_pool_unlock(struct dp_soc *soc,
  3634. struct dp_tx_desc_s *tx_desc)
  3635. {
  3636. struct dp_tx_desc_pool_s *pool;
  3637. uint8_t desc_pool_id;
  3638. desc_pool_id = tx_desc->pool_id;
  3639. pool = &soc->tx_desc[desc_pool_id];
  3640. qdf_spin_unlock_bh(&pool->flow_pool_lock);
  3641. }
  3642. #else
  3643. static inline
  3644. void dp_tx_flow_pool_lock(struct dp_soc *soc, struct dp_tx_desc_s *tx_desc)
  3645. {
  3646. }
  3647. static inline
  3648. void dp_tx_flow_pool_unlock(struct dp_soc *soc, struct dp_tx_desc_s *tx_desc)
  3649. {
  3650. }
  3651. #endif
  3652. /**
  3653. * dp_tx_notify_completion() - Notify tx completion for this desc
  3654. * @soc: core txrx main context
  3655. * @vdev: datapath vdev handle
  3656. * @tx_desc: tx desc
  3657. * @netbuf: buffer
  3658. * @status: tx status
  3659. *
  3660. * Return: none
  3661. */
  3662. static inline void dp_tx_notify_completion(struct dp_soc *soc,
  3663. struct dp_vdev *vdev,
  3664. struct dp_tx_desc_s *tx_desc,
  3665. qdf_nbuf_t netbuf,
  3666. uint8_t status)
  3667. {
  3668. void *osif_dev;
  3669. ol_txrx_completion_fp tx_compl_cbk = NULL;
  3670. uint16_t flag = BIT(QDF_TX_RX_STATUS_DOWNLOAD_SUCC);
  3671. qdf_assert(tx_desc);
  3672. dp_tx_flow_pool_lock(soc, tx_desc);
  3673. if (!vdev ||
  3674. !vdev->osif_vdev) {
  3675. dp_tx_flow_pool_unlock(soc, tx_desc);
  3676. return;
  3677. }
  3678. osif_dev = vdev->osif_vdev;
  3679. tx_compl_cbk = vdev->tx_comp;
  3680. dp_tx_flow_pool_unlock(soc, tx_desc);
  3681. if (status == HAL_TX_TQM_RR_FRAME_ACKED)
  3682. flag |= BIT(QDF_TX_RX_STATUS_OK);
  3683. if (tx_compl_cbk)
  3684. tx_compl_cbk(netbuf, osif_dev, flag);
  3685. }
  3686. /** dp_tx_sojourn_stats_process() - Collect sojourn stats
  3687. * @pdev: pdev handle
  3688. * @tid: tid value
  3689. * @txdesc_ts: timestamp from txdesc
  3690. * @ppdu_id: ppdu id
  3691. *
  3692. * Return: none
  3693. */
  3694. #ifdef FEATURE_PERPKT_INFO
  3695. static inline void dp_tx_sojourn_stats_process(struct dp_pdev *pdev,
  3696. struct dp_txrx_peer *txrx_peer,
  3697. uint8_t tid,
  3698. uint64_t txdesc_ts,
  3699. uint32_t ppdu_id)
  3700. {
  3701. uint64_t delta_ms;
  3702. struct cdp_tx_sojourn_stats *sojourn_stats;
  3703. struct dp_peer *primary_link_peer = NULL;
  3704. struct dp_soc *link_peer_soc = NULL;
  3705. if (qdf_unlikely(!pdev->enhanced_stats_en))
  3706. return;
  3707. if (qdf_unlikely(tid == HTT_INVALID_TID ||
  3708. tid >= CDP_DATA_TID_MAX))
  3709. return;
  3710. if (qdf_unlikely(!pdev->sojourn_buf))
  3711. return;
  3712. primary_link_peer = dp_get_primary_link_peer_by_id(pdev->soc,
  3713. txrx_peer->peer_id,
  3714. DP_MOD_ID_TX_COMP);
  3715. if (qdf_unlikely(!primary_link_peer))
  3716. return;
  3717. sojourn_stats = (struct cdp_tx_sojourn_stats *)
  3718. qdf_nbuf_data(pdev->sojourn_buf);
  3719. link_peer_soc = primary_link_peer->vdev->pdev->soc;
  3720. sojourn_stats->cookie = (void *)
  3721. dp_monitor_peer_get_rdkstats_ctx(link_peer_soc,
  3722. primary_link_peer);
  3723. delta_ms = qdf_ktime_to_ms(qdf_ktime_real_get()) -
  3724. txdesc_ts;
  3725. qdf_ewma_tx_lag_add(&txrx_peer->stats.per_pkt_stats.tx.avg_sojourn_msdu[tid],
  3726. delta_ms);
  3727. sojourn_stats->sum_sojourn_msdu[tid] = delta_ms;
  3728. sojourn_stats->num_msdus[tid] = 1;
  3729. sojourn_stats->avg_sojourn_msdu[tid].internal =
  3730. txrx_peer->stats.per_pkt_stats.tx.avg_sojourn_msdu[tid].internal;
  3731. dp_wdi_event_handler(WDI_EVENT_TX_SOJOURN_STAT, pdev->soc,
  3732. pdev->sojourn_buf, HTT_INVALID_PEER,
  3733. WDI_NO_VAL, pdev->pdev_id);
  3734. sojourn_stats->sum_sojourn_msdu[tid] = 0;
  3735. sojourn_stats->num_msdus[tid] = 0;
  3736. sojourn_stats->avg_sojourn_msdu[tid].internal = 0;
  3737. dp_peer_unref_delete(primary_link_peer, DP_MOD_ID_TX_COMP);
  3738. }
  3739. #else
  3740. static inline void dp_tx_sojourn_stats_process(struct dp_pdev *pdev,
  3741. struct dp_txrx_peer *txrx_peer,
  3742. uint8_t tid,
  3743. uint64_t txdesc_ts,
  3744. uint32_t ppdu_id)
  3745. {
  3746. }
  3747. #endif
  3748. #ifdef WLAN_FEATURE_PKT_CAPTURE_V2
  3749. /**
  3750. * dp_send_completion_to_pkt_capture() - send tx completion to packet capture
  3751. * @soc: dp_soc handle
  3752. * @desc: Tx Descriptor
  3753. * @ts: HAL Tx completion descriptor contents
  3754. *
  3755. * This function is used to send tx completion to packet capture
  3756. */
  3757. void dp_send_completion_to_pkt_capture(struct dp_soc *soc,
  3758. struct dp_tx_desc_s *desc,
  3759. struct hal_tx_completion_status *ts)
  3760. {
  3761. dp_wdi_event_handler(WDI_EVENT_PKT_CAPTURE_TX_DATA, soc,
  3762. desc, ts->peer_id,
  3763. WDI_NO_VAL, desc->pdev->pdev_id);
  3764. }
  3765. #endif
  3766. /**
  3767. * dp_tx_comp_process_desc() - Process tx descriptor and free associated nbuf
  3768. * @soc: DP Soc handle
  3769. * @tx_desc: software Tx descriptor
  3770. * @ts : Tx completion status from HAL/HTT descriptor
  3771. *
  3772. * Return: none
  3773. */
  3774. void
  3775. dp_tx_comp_process_desc(struct dp_soc *soc,
  3776. struct dp_tx_desc_s *desc,
  3777. struct hal_tx_completion_status *ts,
  3778. struct dp_txrx_peer *txrx_peer)
  3779. {
  3780. uint64_t time_latency = 0;
  3781. uint16_t peer_id = DP_INVALID_PEER_ID;
  3782. /*
  3783. * m_copy/tx_capture modes are not supported for
  3784. * scatter gather packets
  3785. */
  3786. if (qdf_unlikely(!!desc->pdev->latency_capture_enable)) {
  3787. time_latency = (qdf_ktime_to_ms(qdf_ktime_real_get()) -
  3788. desc->timestamp);
  3789. }
  3790. dp_send_completion_to_pkt_capture(soc, desc, ts);
  3791. if (dp_tx_pkt_tracepoints_enabled())
  3792. qdf_trace_dp_packet(desc->nbuf, QDF_TX,
  3793. desc->msdu_ext_desc ?
  3794. desc->msdu_ext_desc->tso_desc : NULL,
  3795. desc->timestamp);
  3796. if (!(desc->msdu_ext_desc)) {
  3797. dp_tx_enh_unmap(soc, desc);
  3798. if (txrx_peer)
  3799. peer_id = txrx_peer->peer_id;
  3800. if (QDF_STATUS_SUCCESS ==
  3801. dp_monitor_tx_add_to_comp_queue(soc, desc, ts, peer_id)) {
  3802. return;
  3803. }
  3804. if (QDF_STATUS_SUCCESS ==
  3805. dp_get_completion_indication_for_stack(soc,
  3806. desc->pdev,
  3807. txrx_peer, ts,
  3808. desc->nbuf,
  3809. time_latency)) {
  3810. dp_send_completion_to_stack(soc,
  3811. desc->pdev,
  3812. ts->peer_id,
  3813. ts->ppdu_id,
  3814. desc->nbuf);
  3815. return;
  3816. }
  3817. }
  3818. desc->flags |= DP_TX_DESC_FLAG_COMPLETED_TX;
  3819. dp_tx_comp_free_buf(soc, desc);
  3820. }
  3821. #ifdef DISABLE_DP_STATS
  3822. /**
  3823. * dp_tx_update_connectivity_stats() - update tx connectivity stats
  3824. * @soc: core txrx main context
  3825. * @tx_desc: tx desc
  3826. * @status: tx status
  3827. *
  3828. * Return: none
  3829. */
  3830. static inline
  3831. void dp_tx_update_connectivity_stats(struct dp_soc *soc,
  3832. struct dp_vdev *vdev,
  3833. struct dp_tx_desc_s *tx_desc,
  3834. uint8_t status)
  3835. {
  3836. }
  3837. #else
  3838. static inline
  3839. void dp_tx_update_connectivity_stats(struct dp_soc *soc,
  3840. struct dp_vdev *vdev,
  3841. struct dp_tx_desc_s *tx_desc,
  3842. uint8_t status)
  3843. {
  3844. void *osif_dev;
  3845. ol_txrx_stats_rx_fp stats_cbk;
  3846. uint8_t pkt_type;
  3847. qdf_assert(tx_desc);
  3848. if (!vdev ||
  3849. !vdev->osif_vdev ||
  3850. !vdev->stats_cb)
  3851. return;
  3852. osif_dev = vdev->osif_vdev;
  3853. stats_cbk = vdev->stats_cb;
  3854. stats_cbk(tx_desc->nbuf, osif_dev, PKT_TYPE_TX_HOST_FW_SENT, &pkt_type);
  3855. if (status == HAL_TX_TQM_RR_FRAME_ACKED)
  3856. stats_cbk(tx_desc->nbuf, osif_dev, PKT_TYPE_TX_ACK_CNT,
  3857. &pkt_type);
  3858. }
  3859. #endif
  3860. #if defined(WLAN_FEATURE_TSF_UPLINK_DELAY) || defined(CONFIG_SAWF)
  3861. void dp_set_delta_tsf(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  3862. uint32_t delta_tsf)
  3863. {
  3864. struct dp_soc *soc = cdp_soc_t_to_dp_soc(soc_hdl);
  3865. struct dp_vdev *vdev = dp_vdev_get_ref_by_id(soc, vdev_id,
  3866. DP_MOD_ID_CDP);
  3867. if (!vdev) {
  3868. dp_err_rl("vdev %d does not exist", vdev_id);
  3869. return;
  3870. }
  3871. vdev->delta_tsf = delta_tsf;
  3872. dp_debug("vdev id %u delta_tsf %u", vdev_id, delta_tsf);
  3873. dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_CDP);
  3874. }
  3875. #endif
  3876. #ifdef WLAN_FEATURE_TSF_UPLINK_DELAY
  3877. QDF_STATUS dp_set_tsf_ul_delay_report(struct cdp_soc_t *soc_hdl,
  3878. uint8_t vdev_id, bool enable)
  3879. {
  3880. struct dp_soc *soc = cdp_soc_t_to_dp_soc(soc_hdl);
  3881. struct dp_vdev *vdev = dp_vdev_get_ref_by_id(soc, vdev_id,
  3882. DP_MOD_ID_CDP);
  3883. if (!vdev) {
  3884. dp_err_rl("vdev %d does not exist", vdev_id);
  3885. return QDF_STATUS_E_FAILURE;
  3886. }
  3887. qdf_atomic_set(&vdev->ul_delay_report, enable);
  3888. dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_CDP);
  3889. return QDF_STATUS_SUCCESS;
  3890. }
  3891. QDF_STATUS dp_get_uplink_delay(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  3892. uint32_t *val)
  3893. {
  3894. struct dp_soc *soc = cdp_soc_t_to_dp_soc(soc_hdl);
  3895. struct dp_vdev *vdev;
  3896. uint32_t delay_accum;
  3897. uint32_t pkts_accum;
  3898. vdev = dp_vdev_get_ref_by_id(soc, vdev_id, DP_MOD_ID_CDP);
  3899. if (!vdev) {
  3900. dp_err_rl("vdev %d does not exist", vdev_id);
  3901. return QDF_STATUS_E_FAILURE;
  3902. }
  3903. if (!qdf_atomic_read(&vdev->ul_delay_report)) {
  3904. dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_CDP);
  3905. return QDF_STATUS_E_FAILURE;
  3906. }
  3907. /* Average uplink delay based on current accumulated values */
  3908. delay_accum = qdf_atomic_read(&vdev->ul_delay_accum);
  3909. pkts_accum = qdf_atomic_read(&vdev->ul_pkts_accum);
  3910. *val = delay_accum / pkts_accum;
  3911. dp_debug("uplink_delay %u delay_accum %u pkts_accum %u", *val,
  3912. delay_accum, pkts_accum);
  3913. /* Reset accumulated values to 0 */
  3914. qdf_atomic_set(&vdev->ul_delay_accum, 0);
  3915. qdf_atomic_set(&vdev->ul_pkts_accum, 0);
  3916. dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_CDP);
  3917. return QDF_STATUS_SUCCESS;
  3918. }
  3919. static void dp_tx_update_uplink_delay(struct dp_soc *soc, struct dp_vdev *vdev,
  3920. struct hal_tx_completion_status *ts)
  3921. {
  3922. uint32_t buffer_ts;
  3923. uint32_t delta_tsf;
  3924. uint32_t ul_delay;
  3925. /* Tx_rate_stats_info_valid is 0 and tsf is invalid then */
  3926. if (!ts->valid)
  3927. return;
  3928. if (qdf_unlikely(!vdev)) {
  3929. dp_info_rl("vdev is null or delete in progrss");
  3930. return;
  3931. }
  3932. if (!qdf_atomic_read(&vdev->ul_delay_report))
  3933. return;
  3934. delta_tsf = vdev->delta_tsf;
  3935. /* buffer_timestamp is in units of 1024 us and is [31:13] of
  3936. * WBM_RELEASE_RING_4. After left shift 10 bits, it's
  3937. * valid up to 29 bits.
  3938. */
  3939. buffer_ts = ts->buffer_timestamp << 10;
  3940. ul_delay = ts->tsf - buffer_ts - delta_tsf;
  3941. ul_delay &= 0x1FFFFFFF; /* mask 29 BITS */
  3942. if (ul_delay > 0x1000000) {
  3943. dp_info_rl("----------------------\n"
  3944. "Tx completion status:\n"
  3945. "----------------------\n"
  3946. "release_src = %d\n"
  3947. "ppdu_id = 0x%x\n"
  3948. "release_reason = %d\n"
  3949. "tsf = %u (0x%x)\n"
  3950. "buffer_timestamp = %u (0x%x)\n"
  3951. "delta_tsf = %u (0x%x)\n",
  3952. ts->release_src, ts->ppdu_id, ts->status,
  3953. ts->tsf, ts->tsf, ts->buffer_timestamp,
  3954. ts->buffer_timestamp, delta_tsf, delta_tsf);
  3955. return;
  3956. }
  3957. ul_delay /= 1000; /* in unit of ms */
  3958. qdf_atomic_add(ul_delay, &vdev->ul_delay_accum);
  3959. qdf_atomic_inc(&vdev->ul_pkts_accum);
  3960. }
  3961. #else /* !WLAN_FEATURE_TSF_UPLINK_DELAY */
  3962. static inline
  3963. void dp_tx_update_uplink_delay(struct dp_soc *soc, struct dp_vdev *vdev,
  3964. struct hal_tx_completion_status *ts)
  3965. {
  3966. }
  3967. #endif /* WLAN_FEATURE_TSF_UPLINK_DELAY */
  3968. /**
  3969. * dp_tx_comp_process_tx_status() - Parse and Dump Tx completion status info
  3970. * @soc: DP soc handle
  3971. * @tx_desc: software descriptor head pointer
  3972. * @ts: Tx completion status
  3973. * @txrx_peer: txrx peer handle
  3974. * @ring_id: ring number
  3975. *
  3976. * Return: none
  3977. */
  3978. void dp_tx_comp_process_tx_status(struct dp_soc *soc,
  3979. struct dp_tx_desc_s *tx_desc,
  3980. struct hal_tx_completion_status *ts,
  3981. struct dp_txrx_peer *txrx_peer,
  3982. uint8_t ring_id)
  3983. {
  3984. uint32_t length;
  3985. qdf_ether_header_t *eh;
  3986. struct dp_vdev *vdev = NULL;
  3987. qdf_nbuf_t nbuf = tx_desc->nbuf;
  3988. enum qdf_dp_tx_rx_status dp_status;
  3989. if (!nbuf) {
  3990. dp_info_rl("invalid tx descriptor. nbuf NULL");
  3991. goto out;
  3992. }
  3993. eh = (qdf_ether_header_t *)qdf_nbuf_data(nbuf);
  3994. length = qdf_nbuf_len(nbuf);
  3995. dp_status = dp_tx_hw_to_qdf(ts->status);
  3996. DPTRACE(qdf_dp_trace_ptr(tx_desc->nbuf,
  3997. QDF_DP_TRACE_LI_DP_FREE_PACKET_PTR_RECORD,
  3998. QDF_TRACE_DEFAULT_PDEV_ID,
  3999. qdf_nbuf_data_addr(nbuf),
  4000. sizeof(qdf_nbuf_data(nbuf)),
  4001. tx_desc->id, ts->status, dp_status));
  4002. dp_tx_comp_debug("-------------------- \n"
  4003. "Tx Completion Stats: \n"
  4004. "-------------------- \n"
  4005. "ack_frame_rssi = %d \n"
  4006. "first_msdu = %d \n"
  4007. "last_msdu = %d \n"
  4008. "msdu_part_of_amsdu = %d \n"
  4009. "rate_stats valid = %d \n"
  4010. "bw = %d \n"
  4011. "pkt_type = %d \n"
  4012. "stbc = %d \n"
  4013. "ldpc = %d \n"
  4014. "sgi = %d \n"
  4015. "mcs = %d \n"
  4016. "ofdma = %d \n"
  4017. "tones_in_ru = %d \n"
  4018. "tsf = %d \n"
  4019. "ppdu_id = %d \n"
  4020. "transmit_cnt = %d \n"
  4021. "tid = %d \n"
  4022. "peer_id = %d\n"
  4023. "tx_status = %d\n",
  4024. ts->ack_frame_rssi, ts->first_msdu,
  4025. ts->last_msdu, ts->msdu_part_of_amsdu,
  4026. ts->valid, ts->bw, ts->pkt_type, ts->stbc,
  4027. ts->ldpc, ts->sgi, ts->mcs, ts->ofdma,
  4028. ts->tones_in_ru, ts->tsf, ts->ppdu_id,
  4029. ts->transmit_cnt, ts->tid, ts->peer_id,
  4030. ts->status);
  4031. /* Update SoC level stats */
  4032. DP_STATS_INCC(soc, tx.dropped_fw_removed, 1,
  4033. (ts->status == HAL_TX_TQM_RR_REM_CMD_REM));
  4034. if (!txrx_peer) {
  4035. dp_info_rl("peer is null or deletion in progress");
  4036. DP_STATS_INC_PKT(soc, tx.tx_invalid_peer, 1, length);
  4037. goto out;
  4038. }
  4039. vdev = txrx_peer->vdev;
  4040. dp_tx_update_connectivity_stats(soc, vdev, tx_desc, ts->status);
  4041. dp_tx_update_uplink_delay(soc, vdev, ts);
  4042. /* Update per-packet stats for mesh mode */
  4043. if (qdf_unlikely(vdev->mesh_vdev) &&
  4044. !(tx_desc->flags & DP_TX_DESC_FLAG_TO_FW))
  4045. dp_tx_comp_fill_tx_completion_stats(tx_desc, ts);
  4046. /* Update peer level stats */
  4047. if (qdf_unlikely(txrx_peer->bss_peer &&
  4048. vdev->opmode == wlan_op_mode_ap)) {
  4049. if (ts->status != HAL_TX_TQM_RR_REM_CMD_REM) {
  4050. DP_PEER_PER_PKT_STATS_INC_PKT(txrx_peer, tx.mcast, 1,
  4051. length);
  4052. if (txrx_peer->vdev->tx_encap_type ==
  4053. htt_cmn_pkt_type_ethernet &&
  4054. QDF_IS_ADDR_BROADCAST(eh->ether_dhost)) {
  4055. DP_PEER_PER_PKT_STATS_INC_PKT(txrx_peer,
  4056. tx.bcast, 1,
  4057. length);
  4058. }
  4059. }
  4060. } else {
  4061. DP_PEER_PER_PKT_STATS_INC_PKT(txrx_peer, tx.ucast, 1, length);
  4062. if (ts->status == HAL_TX_TQM_RR_FRAME_ACKED) {
  4063. DP_PEER_PER_PKT_STATS_INC_PKT(txrx_peer, tx.tx_success,
  4064. 1, length);
  4065. if (qdf_unlikely(txrx_peer->in_twt)) {
  4066. DP_PEER_PER_PKT_STATS_INC_PKT(txrx_peer,
  4067. tx.tx_success_twt,
  4068. 1, length);
  4069. }
  4070. }
  4071. }
  4072. dp_tx_update_peer_stats(tx_desc, ts, txrx_peer, ring_id);
  4073. dp_tx_update_peer_delay_stats(txrx_peer, tx_desc, ts->tid, ring_id);
  4074. dp_tx_update_peer_sawf_stats(soc, vdev, txrx_peer, tx_desc,
  4075. ts, ts->tid);
  4076. #ifdef QCA_SUPPORT_RDK_STATS
  4077. if (soc->rdkstats_enabled)
  4078. dp_tx_sojourn_stats_process(vdev->pdev, txrx_peer, ts->tid,
  4079. tx_desc->timestamp,
  4080. ts->ppdu_id);
  4081. #endif
  4082. out:
  4083. return;
  4084. }
  4085. #if defined(QCA_VDEV_STATS_HW_OFFLOAD_SUPPORT) && \
  4086. defined(QCA_ENHANCED_STATS_SUPPORT)
  4087. /*
  4088. * dp_tx_update_peer_basic_stats(): Update peer basic stats
  4089. * @txrx_peer: Datapath txrx_peer handle
  4090. * @length: Length of the packet
  4091. * @tx_status: Tx status from TQM/FW
  4092. * @update: enhanced flag value present in dp_pdev
  4093. *
  4094. * Return: none
  4095. */
  4096. void dp_tx_update_peer_basic_stats(struct dp_txrx_peer *txrx_peer,
  4097. uint32_t length, uint8_t tx_status,
  4098. bool update)
  4099. {
  4100. if ((!txrx_peer->hw_txrx_stats_en) || update) {
  4101. DP_PEER_STATS_FLAT_INC_PKT(txrx_peer, comp_pkt, 1, length);
  4102. if (tx_status != HAL_TX_TQM_RR_FRAME_ACKED)
  4103. DP_PEER_STATS_FLAT_INC(txrx_peer, tx_failed, 1);
  4104. }
  4105. }
  4106. #elif defined(QCA_VDEV_STATS_HW_OFFLOAD_SUPPORT)
  4107. void dp_tx_update_peer_basic_stats(struct dp_txrx_peer *txrx_peer,
  4108. uint32_t length, uint8_t tx_status,
  4109. bool update)
  4110. {
  4111. if (!peer->hw_txrx_stats_en) {
  4112. DP_PEER_STATS_FLAT_INC_PKT(txrx_peer, comp_pkt, 1, length);
  4113. if (tx_status != HAL_TX_TQM_RR_FRAME_ACKED)
  4114. DP_PEER_STATS_FLAT_INC(txrx_peer, tx_failed, 1);
  4115. }
  4116. }
  4117. #else
  4118. void dp_tx_update_peer_basic_stats(struct dp_txrx_peer *txrx_peer,
  4119. uint32_t length, uint8_t tx_status,
  4120. bool update)
  4121. {
  4122. DP_PEER_STATS_FLAT_INC_PKT(txrx_peer, comp_pkt, 1, length);
  4123. if (tx_status != HAL_TX_TQM_RR_FRAME_ACKED)
  4124. DP_PEER_STATS_FLAT_INC(txrx_peer, tx_failed, 1);
  4125. }
  4126. #endif
  4127. /*
  4128. * dp_tx_prefetch_next_nbuf_data(): Prefetch nbuf and nbuf data
  4129. * @nbuf: skb buffer
  4130. *
  4131. * Return: none
  4132. */
  4133. #ifdef QCA_DP_RX_NBUF_AND_NBUF_DATA_PREFETCH
  4134. static inline
  4135. void dp_tx_prefetch_next_nbuf_data(struct dp_tx_desc_s *next)
  4136. {
  4137. qdf_nbuf_t nbuf = NULL;
  4138. if (next)
  4139. nbuf = next->nbuf;
  4140. if (nbuf) {
  4141. /* prefetch skb->next and first few bytes of skb->cb */
  4142. qdf_prefetch(nbuf);
  4143. /* prefetch skb fields present in different cachelines */
  4144. qdf_prefetch(&nbuf->len);
  4145. qdf_prefetch(&nbuf->users);
  4146. }
  4147. }
  4148. #else
  4149. static inline
  4150. void dp_tx_prefetch_next_nbuf_data(struct dp_tx_desc_s *next)
  4151. {
  4152. }
  4153. #endif
  4154. /**
  4155. * dp_tx_comp_process_desc_list() - Tx complete software descriptor handler
  4156. * @soc: core txrx main context
  4157. * @comp_head: software descriptor head pointer
  4158. * @ring_id: ring number
  4159. *
  4160. * This function will process batch of descriptors reaped by dp_tx_comp_handler
  4161. * and release the software descriptors after processing is complete
  4162. *
  4163. * Return: none
  4164. */
  4165. static void
  4166. dp_tx_comp_process_desc_list(struct dp_soc *soc,
  4167. struct dp_tx_desc_s *comp_head, uint8_t ring_id)
  4168. {
  4169. struct dp_tx_desc_s *desc;
  4170. struct dp_tx_desc_s *next;
  4171. struct hal_tx_completion_status ts;
  4172. struct dp_txrx_peer *txrx_peer = NULL;
  4173. uint16_t peer_id = DP_INVALID_PEER;
  4174. qdf_nbuf_t netbuf;
  4175. dp_txrx_ref_handle txrx_ref_handle = NULL;
  4176. desc = comp_head;
  4177. while (desc) {
  4178. next = desc->next;
  4179. dp_tx_prefetch_next_nbuf_data(next);
  4180. if (peer_id != desc->peer_id) {
  4181. if (txrx_peer)
  4182. dp_txrx_peer_unref_delete(txrx_ref_handle,
  4183. DP_MOD_ID_TX_COMP);
  4184. peer_id = desc->peer_id;
  4185. txrx_peer =
  4186. dp_txrx_peer_get_ref_by_id(soc, peer_id,
  4187. &txrx_ref_handle,
  4188. DP_MOD_ID_TX_COMP);
  4189. }
  4190. if (qdf_likely(desc->flags & DP_TX_DESC_FLAG_SIMPLE)) {
  4191. struct dp_pdev *pdev = desc->pdev;
  4192. if (qdf_likely(txrx_peer))
  4193. dp_tx_update_peer_basic_stats(txrx_peer,
  4194. desc->length,
  4195. desc->tx_status,
  4196. false);
  4197. qdf_assert(pdev);
  4198. dp_tx_outstanding_dec(pdev);
  4199. /*
  4200. * Calling a QDF WRAPPER here is creating signifcant
  4201. * performance impact so avoided the wrapper call here
  4202. */
  4203. dp_tx_desc_history_add(soc, desc->dma_addr, desc->nbuf,
  4204. desc->id, DP_TX_COMP_UNMAP);
  4205. dp_tx_nbuf_unmap(soc, desc);
  4206. qdf_nbuf_free(desc->nbuf);
  4207. dp_tx_desc_free(soc, desc, desc->pool_id);
  4208. desc = next;
  4209. continue;
  4210. }
  4211. hal_tx_comp_get_status(&desc->comp, &ts, soc->hal_soc);
  4212. dp_tx_comp_process_tx_status(soc, desc, &ts, txrx_peer,
  4213. ring_id);
  4214. netbuf = desc->nbuf;
  4215. /* check tx complete notification */
  4216. if (txrx_peer && qdf_nbuf_tx_notify_comp_get(netbuf))
  4217. dp_tx_notify_completion(soc, txrx_peer->vdev, desc,
  4218. netbuf, ts.status);
  4219. dp_tx_comp_process_desc(soc, desc, &ts, txrx_peer);
  4220. dp_tx_desc_release(desc, desc->pool_id);
  4221. desc = next;
  4222. }
  4223. if (txrx_peer)
  4224. dp_txrx_peer_unref_delete(txrx_ref_handle, DP_MOD_ID_TX_COMP);
  4225. }
  4226. #ifdef WLAN_FEATURE_RX_SOFTIRQ_TIME_LIMIT
  4227. static inline
  4228. bool dp_tx_comp_loop_pkt_limit_hit(struct dp_soc *soc, int num_reaped,
  4229. int max_reap_limit)
  4230. {
  4231. bool limit_hit = false;
  4232. limit_hit =
  4233. (num_reaped >= max_reap_limit) ? true : false;
  4234. if (limit_hit)
  4235. DP_STATS_INC(soc, tx.tx_comp_loop_pkt_limit_hit, 1);
  4236. return limit_hit;
  4237. }
  4238. static inline bool dp_tx_comp_enable_eol_data_check(struct dp_soc *soc)
  4239. {
  4240. return soc->wlan_cfg_ctx->tx_comp_enable_eol_data_check;
  4241. }
  4242. static inline int dp_tx_comp_get_loop_pkt_limit(struct dp_soc *soc)
  4243. {
  4244. struct wlan_cfg_dp_soc_ctxt *cfg = soc->wlan_cfg_ctx;
  4245. return cfg->tx_comp_loop_pkt_limit;
  4246. }
  4247. #else
  4248. static inline
  4249. bool dp_tx_comp_loop_pkt_limit_hit(struct dp_soc *soc, int num_reaped,
  4250. int max_reap_limit)
  4251. {
  4252. return false;
  4253. }
  4254. static inline bool dp_tx_comp_enable_eol_data_check(struct dp_soc *soc)
  4255. {
  4256. return false;
  4257. }
  4258. static inline int dp_tx_comp_get_loop_pkt_limit(struct dp_soc *soc)
  4259. {
  4260. return 0;
  4261. }
  4262. #endif
  4263. #ifdef WLAN_FEATURE_NEAR_FULL_IRQ
  4264. static inline int
  4265. dp_srng_test_and_update_nf_params(struct dp_soc *soc, struct dp_srng *dp_srng,
  4266. int *max_reap_limit)
  4267. {
  4268. return soc->arch_ops.dp_srng_test_and_update_nf_params(soc, dp_srng,
  4269. max_reap_limit);
  4270. }
  4271. #else
  4272. static inline int
  4273. dp_srng_test_and_update_nf_params(struct dp_soc *soc, struct dp_srng *dp_srng,
  4274. int *max_reap_limit)
  4275. {
  4276. return 0;
  4277. }
  4278. #endif
  4279. #ifdef DP_TX_TRACKING
  4280. void dp_tx_desc_check_corruption(struct dp_tx_desc_s *tx_desc)
  4281. {
  4282. if ((tx_desc->magic != DP_TX_MAGIC_PATTERN_INUSE) &&
  4283. (tx_desc->magic != DP_TX_MAGIC_PATTERN_FREE)) {
  4284. dp_err_rl("tx_desc %u is corrupted", tx_desc->id);
  4285. qdf_trigger_self_recovery(NULL, QDF_TX_DESC_LEAK);
  4286. }
  4287. }
  4288. #endif
  4289. uint32_t dp_tx_comp_handler(struct dp_intr *int_ctx, struct dp_soc *soc,
  4290. hal_ring_handle_t hal_ring_hdl, uint8_t ring_id,
  4291. uint32_t quota)
  4292. {
  4293. void *tx_comp_hal_desc;
  4294. void *last_prefetched_hw_desc = NULL;
  4295. struct dp_tx_desc_s *last_prefetched_sw_desc = NULL;
  4296. hal_soc_handle_t hal_soc;
  4297. uint8_t buffer_src;
  4298. struct dp_tx_desc_s *tx_desc = NULL;
  4299. struct dp_tx_desc_s *head_desc = NULL;
  4300. struct dp_tx_desc_s *tail_desc = NULL;
  4301. uint32_t num_processed = 0;
  4302. uint32_t count;
  4303. uint32_t num_avail_for_reap = 0;
  4304. bool force_break = false;
  4305. struct dp_srng *tx_comp_ring = &soc->tx_comp_ring[ring_id];
  4306. int max_reap_limit, ring_near_full;
  4307. DP_HIST_INIT();
  4308. more_data:
  4309. hal_soc = soc->hal_soc;
  4310. /* Re-initialize local variables to be re-used */
  4311. head_desc = NULL;
  4312. tail_desc = NULL;
  4313. count = 0;
  4314. max_reap_limit = dp_tx_comp_get_loop_pkt_limit(soc);
  4315. ring_near_full = dp_srng_test_and_update_nf_params(soc, tx_comp_ring,
  4316. &max_reap_limit);
  4317. if (qdf_unlikely(dp_srng_access_start(int_ctx, soc, hal_ring_hdl))) {
  4318. dp_err("HAL RING Access Failed -- %pK", hal_ring_hdl);
  4319. return 0;
  4320. }
  4321. num_avail_for_reap = hal_srng_dst_num_valid(hal_soc, hal_ring_hdl, 0);
  4322. if (num_avail_for_reap >= quota)
  4323. num_avail_for_reap = quota;
  4324. dp_srng_dst_inv_cached_descs(soc, hal_ring_hdl, num_avail_for_reap);
  4325. last_prefetched_hw_desc = dp_srng_dst_prefetch(hal_soc, hal_ring_hdl,
  4326. num_avail_for_reap);
  4327. /* Find head descriptor from completion ring */
  4328. while (qdf_likely(num_avail_for_reap--)) {
  4329. tx_comp_hal_desc = dp_srng_dst_get_next(soc, hal_ring_hdl);
  4330. if (qdf_unlikely(!tx_comp_hal_desc))
  4331. break;
  4332. buffer_src = hal_tx_comp_get_buffer_source(hal_soc,
  4333. tx_comp_hal_desc);
  4334. /* If this buffer was not released by TQM or FW, then it is not
  4335. * Tx completion indication, assert */
  4336. if (qdf_unlikely(buffer_src !=
  4337. HAL_TX_COMP_RELEASE_SOURCE_TQM) &&
  4338. (qdf_unlikely(buffer_src !=
  4339. HAL_TX_COMP_RELEASE_SOURCE_FW))) {
  4340. uint8_t wbm_internal_error;
  4341. dp_err_rl(
  4342. "Tx comp release_src != TQM | FW but from %d",
  4343. buffer_src);
  4344. hal_dump_comp_desc(tx_comp_hal_desc);
  4345. DP_STATS_INC(soc, tx.invalid_release_source, 1);
  4346. /* When WBM sees NULL buffer_addr_info in any of
  4347. * ingress rings it sends an error indication,
  4348. * with wbm_internal_error=1, to a specific ring.
  4349. * The WBM2SW ring used to indicate these errors is
  4350. * fixed in HW, and that ring is being used as Tx
  4351. * completion ring. These errors are not related to
  4352. * Tx completions, and should just be ignored
  4353. */
  4354. wbm_internal_error = hal_get_wbm_internal_error(
  4355. hal_soc,
  4356. tx_comp_hal_desc);
  4357. if (wbm_internal_error) {
  4358. dp_err_rl("Tx comp wbm_internal_error!!");
  4359. DP_STATS_INC(soc, tx.wbm_internal_error[WBM_INT_ERROR_ALL], 1);
  4360. if (HAL_TX_COMP_RELEASE_SOURCE_REO ==
  4361. buffer_src)
  4362. dp_handle_wbm_internal_error(
  4363. soc,
  4364. tx_comp_hal_desc,
  4365. hal_tx_comp_get_buffer_type(
  4366. tx_comp_hal_desc));
  4367. } else {
  4368. dp_err_rl("Tx comp wbm_internal_error false");
  4369. DP_STATS_INC(soc, tx.non_wbm_internal_err, 1);
  4370. }
  4371. continue;
  4372. }
  4373. soc->arch_ops.tx_comp_get_params_from_hal_desc(soc,
  4374. tx_comp_hal_desc,
  4375. &tx_desc);
  4376. if (!tx_desc) {
  4377. dp_err("unable to retrieve tx_desc!");
  4378. QDF_BUG(0);
  4379. continue;
  4380. }
  4381. tx_desc->buffer_src = buffer_src;
  4382. /*
  4383. * If the release source is FW, process the HTT status
  4384. */
  4385. if (qdf_unlikely(buffer_src ==
  4386. HAL_TX_COMP_RELEASE_SOURCE_FW)) {
  4387. uint8_t htt_tx_status[HAL_TX_COMP_HTT_STATUS_LEN];
  4388. hal_tx_comp_get_htt_desc(tx_comp_hal_desc,
  4389. htt_tx_status);
  4390. /* Collect hw completion contents */
  4391. hal_tx_comp_desc_sync(tx_comp_hal_desc,
  4392. &tx_desc->comp, 1);
  4393. soc->arch_ops.dp_tx_process_htt_completion(
  4394. soc,
  4395. tx_desc,
  4396. htt_tx_status,
  4397. ring_id);
  4398. } else {
  4399. tx_desc->tx_status =
  4400. hal_tx_comp_get_tx_status(tx_comp_hal_desc);
  4401. tx_desc->buffer_src = buffer_src;
  4402. /*
  4403. * If the fast completion mode is enabled extended
  4404. * metadata from descriptor is not copied
  4405. */
  4406. if (qdf_likely(tx_desc->flags &
  4407. DP_TX_DESC_FLAG_SIMPLE))
  4408. goto add_to_pool;
  4409. /*
  4410. * If the descriptor is already freed in vdev_detach,
  4411. * continue to next descriptor
  4412. */
  4413. if (qdf_unlikely
  4414. ((tx_desc->vdev_id == DP_INVALID_VDEV_ID) &&
  4415. !tx_desc->flags)) {
  4416. dp_tx_comp_info_rl("Descriptor freed in vdev_detach %d",
  4417. tx_desc->id);
  4418. DP_STATS_INC(soc, tx.tx_comp_exception, 1);
  4419. dp_tx_desc_check_corruption(tx_desc);
  4420. continue;
  4421. }
  4422. if (qdf_unlikely(tx_desc->pdev->is_pdev_down)) {
  4423. dp_tx_comp_info_rl("pdev in down state %d",
  4424. tx_desc->id);
  4425. tx_desc->flags |= DP_TX_DESC_FLAG_TX_COMP_ERR;
  4426. dp_tx_comp_free_buf(soc, tx_desc);
  4427. dp_tx_desc_release(tx_desc, tx_desc->pool_id);
  4428. goto next_desc;
  4429. }
  4430. if (!(tx_desc->flags & DP_TX_DESC_FLAG_ALLOCATED) ||
  4431. !(tx_desc->flags & DP_TX_DESC_FLAG_QUEUED_TX)) {
  4432. dp_tx_comp_alert("Txdesc invalid, flgs = %x,id = %d",
  4433. tx_desc->flags, tx_desc->id);
  4434. qdf_assert_always(0);
  4435. }
  4436. /* Collect hw completion contents */
  4437. hal_tx_comp_desc_sync(tx_comp_hal_desc,
  4438. &tx_desc->comp, 1);
  4439. add_to_pool:
  4440. DP_HIST_PACKET_COUNT_INC(tx_desc->pdev->pdev_id);
  4441. /* First ring descriptor on the cycle */
  4442. if (!head_desc) {
  4443. head_desc = tx_desc;
  4444. tail_desc = tx_desc;
  4445. }
  4446. tail_desc->next = tx_desc;
  4447. tx_desc->next = NULL;
  4448. tail_desc = tx_desc;
  4449. }
  4450. next_desc:
  4451. num_processed += !(count & DP_TX_NAPI_BUDGET_DIV_MASK);
  4452. /*
  4453. * Processed packet count is more than given quota
  4454. * stop to processing
  4455. */
  4456. count++;
  4457. dp_tx_prefetch_hw_sw_nbuf_desc(soc, hal_soc,
  4458. num_avail_for_reap,
  4459. hal_ring_hdl,
  4460. &last_prefetched_hw_desc,
  4461. &last_prefetched_sw_desc);
  4462. if (dp_tx_comp_loop_pkt_limit_hit(soc, count, max_reap_limit))
  4463. break;
  4464. }
  4465. dp_srng_access_end(int_ctx, soc, hal_ring_hdl);
  4466. /* Process the reaped descriptors */
  4467. if (head_desc)
  4468. dp_tx_comp_process_desc_list(soc, head_desc, ring_id);
  4469. /*
  4470. * If we are processing in near-full condition, there are 3 scenario
  4471. * 1) Ring entries has reached critical state
  4472. * 2) Ring entries are still near high threshold
  4473. * 3) Ring entries are below the safe level
  4474. *
  4475. * One more loop will move te state to normal processing and yield
  4476. */
  4477. if (ring_near_full)
  4478. goto more_data;
  4479. if (dp_tx_comp_enable_eol_data_check(soc)) {
  4480. if (num_processed >= quota)
  4481. force_break = true;
  4482. if (!force_break &&
  4483. hal_srng_dst_peek_sync_locked(soc->hal_soc,
  4484. hal_ring_hdl)) {
  4485. DP_STATS_INC(soc, tx.hp_oos2, 1);
  4486. if (!hif_exec_should_yield(soc->hif_handle,
  4487. int_ctx->dp_intr_id))
  4488. goto more_data;
  4489. }
  4490. }
  4491. DP_TX_HIST_STATS_PER_PDEV();
  4492. return num_processed;
  4493. }
  4494. #ifdef FEATURE_WLAN_TDLS
  4495. qdf_nbuf_t dp_tx_non_std(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
  4496. enum ol_tx_spec tx_spec, qdf_nbuf_t msdu_list)
  4497. {
  4498. struct dp_soc *soc = cdp_soc_t_to_dp_soc(soc_hdl);
  4499. struct dp_vdev *vdev = dp_vdev_get_ref_by_id(soc, vdev_id,
  4500. DP_MOD_ID_TDLS);
  4501. if (!vdev) {
  4502. dp_err("vdev handle for id %d is NULL", vdev_id);
  4503. return NULL;
  4504. }
  4505. if (tx_spec & OL_TX_SPEC_NO_FREE)
  4506. vdev->is_tdls_frame = true;
  4507. dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_TDLS);
  4508. return dp_tx_send(soc_hdl, vdev_id, msdu_list);
  4509. }
  4510. #endif
  4511. /**
  4512. * dp_tx_vdev_attach() - attach vdev to dp tx
  4513. * @vdev: virtual device instance
  4514. *
  4515. * Return: QDF_STATUS_SUCCESS: success
  4516. * QDF_STATUS_E_RESOURCES: Error return
  4517. */
  4518. QDF_STATUS dp_tx_vdev_attach(struct dp_vdev *vdev)
  4519. {
  4520. int pdev_id;
  4521. /*
  4522. * Fill HTT TCL Metadata with Vdev ID and MAC ID
  4523. */
  4524. DP_TX_TCL_METADATA_TYPE_SET(vdev->htt_tcl_metadata,
  4525. DP_TCL_METADATA_TYPE_VDEV_BASED);
  4526. DP_TX_TCL_METADATA_VDEV_ID_SET(vdev->htt_tcl_metadata,
  4527. vdev->vdev_id);
  4528. pdev_id =
  4529. dp_get_target_pdev_id_for_host_pdev_id(vdev->pdev->soc,
  4530. vdev->pdev->pdev_id);
  4531. DP_TX_TCL_METADATA_PDEV_ID_SET(vdev->htt_tcl_metadata, pdev_id);
  4532. /*
  4533. * Set HTT Extension Valid bit to 0 by default
  4534. */
  4535. DP_TX_TCL_METADATA_VALID_HTT_SET(vdev->htt_tcl_metadata, 0);
  4536. dp_tx_vdev_update_search_flags(vdev);
  4537. return QDF_STATUS_SUCCESS;
  4538. }
  4539. #ifndef FEATURE_WDS
  4540. static inline bool dp_tx_da_search_override(struct dp_vdev *vdev)
  4541. {
  4542. return false;
  4543. }
  4544. #endif
  4545. /**
  4546. * dp_tx_vdev_update_search_flags() - Update vdev flags as per opmode
  4547. * @vdev: virtual device instance
  4548. *
  4549. * Return: void
  4550. *
  4551. */
  4552. void dp_tx_vdev_update_search_flags(struct dp_vdev *vdev)
  4553. {
  4554. struct dp_soc *soc = vdev->pdev->soc;
  4555. /*
  4556. * Enable both AddrY (SA based search) and AddrX (Da based search)
  4557. * for TDLS link
  4558. *
  4559. * Enable AddrY (SA based search) only for non-WDS STA and
  4560. * ProxySTA VAP (in HKv1) modes.
  4561. *
  4562. * In all other VAP modes, only DA based search should be
  4563. * enabled
  4564. */
  4565. if (vdev->opmode == wlan_op_mode_sta &&
  4566. vdev->tdls_link_connected)
  4567. vdev->hal_desc_addr_search_flags =
  4568. (HAL_TX_DESC_ADDRX_EN | HAL_TX_DESC_ADDRY_EN);
  4569. else if ((vdev->opmode == wlan_op_mode_sta) &&
  4570. !dp_tx_da_search_override(vdev))
  4571. vdev->hal_desc_addr_search_flags = HAL_TX_DESC_ADDRY_EN;
  4572. else
  4573. vdev->hal_desc_addr_search_flags = HAL_TX_DESC_ADDRX_EN;
  4574. if (vdev->opmode == wlan_op_mode_sta)
  4575. vdev->search_type = soc->sta_mode_search_policy;
  4576. else
  4577. vdev->search_type = HAL_TX_ADDR_SEARCH_DEFAULT;
  4578. }
  4579. static inline bool
  4580. dp_is_tx_desc_flush_match(struct dp_pdev *pdev,
  4581. struct dp_vdev *vdev,
  4582. struct dp_tx_desc_s *tx_desc)
  4583. {
  4584. if (!(tx_desc && (tx_desc->flags & DP_TX_DESC_FLAG_ALLOCATED)))
  4585. return false;
  4586. /*
  4587. * if vdev is given, then only check whether desc
  4588. * vdev match. if vdev is NULL, then check whether
  4589. * desc pdev match.
  4590. */
  4591. return vdev ? (tx_desc->vdev_id == vdev->vdev_id) :
  4592. (tx_desc->pdev == pdev);
  4593. }
  4594. #ifdef QCA_LL_TX_FLOW_CONTROL_V2
  4595. /**
  4596. * dp_tx_desc_flush() - release resources associated
  4597. * to TX Desc
  4598. *
  4599. * @dp_pdev: Handle to DP pdev structure
  4600. * @vdev: virtual device instance
  4601. * NULL: no specific Vdev is required and check all allcated TX desc
  4602. * on this pdev.
  4603. * Non-NULL: only check the allocated TX Desc associated to this Vdev.
  4604. *
  4605. * @force_free:
  4606. * true: flush the TX desc.
  4607. * false: only reset the Vdev in each allocated TX desc
  4608. * that associated to current Vdev.
  4609. *
  4610. * This function will go through the TX desc pool to flush
  4611. * the outstanding TX data or reset Vdev to NULL in associated TX
  4612. * Desc.
  4613. */
  4614. void dp_tx_desc_flush(struct dp_pdev *pdev, struct dp_vdev *vdev,
  4615. bool force_free)
  4616. {
  4617. uint8_t i;
  4618. uint32_t j;
  4619. uint32_t num_desc, page_id, offset;
  4620. uint16_t num_desc_per_page;
  4621. struct dp_soc *soc = pdev->soc;
  4622. struct dp_tx_desc_s *tx_desc = NULL;
  4623. struct dp_tx_desc_pool_s *tx_desc_pool = NULL;
  4624. if (!vdev && !force_free) {
  4625. dp_err("Reset TX desc vdev, Vdev param is required!");
  4626. return;
  4627. }
  4628. for (i = 0; i < MAX_TXDESC_POOLS; i++) {
  4629. tx_desc_pool = &soc->tx_desc[i];
  4630. if (!(tx_desc_pool->pool_size) ||
  4631. IS_TX_DESC_POOL_STATUS_INACTIVE(tx_desc_pool) ||
  4632. !(tx_desc_pool->desc_pages.cacheable_pages))
  4633. continue;
  4634. /*
  4635. * Add flow pool lock protection in case pool is freed
  4636. * due to all tx_desc is recycled when handle TX completion.
  4637. * this is not necessary when do force flush as:
  4638. * a. double lock will happen if dp_tx_desc_release is
  4639. * also trying to acquire it.
  4640. * b. dp interrupt has been disabled before do force TX desc
  4641. * flush in dp_pdev_deinit().
  4642. */
  4643. if (!force_free)
  4644. qdf_spin_lock_bh(&tx_desc_pool->flow_pool_lock);
  4645. num_desc = tx_desc_pool->pool_size;
  4646. num_desc_per_page =
  4647. tx_desc_pool->desc_pages.num_element_per_page;
  4648. for (j = 0; j < num_desc; j++) {
  4649. page_id = j / num_desc_per_page;
  4650. offset = j % num_desc_per_page;
  4651. if (qdf_unlikely(!(tx_desc_pool->
  4652. desc_pages.cacheable_pages)))
  4653. break;
  4654. tx_desc = dp_tx_desc_find(soc, i, page_id, offset);
  4655. if (dp_is_tx_desc_flush_match(pdev, vdev, tx_desc)) {
  4656. /*
  4657. * Free TX desc if force free is
  4658. * required, otherwise only reset vdev
  4659. * in this TX desc.
  4660. */
  4661. if (force_free) {
  4662. tx_desc->flags |= DP_TX_DESC_FLAG_FLUSH;
  4663. dp_tx_comp_free_buf(soc, tx_desc);
  4664. dp_tx_desc_release(tx_desc, i);
  4665. } else {
  4666. tx_desc->vdev_id = DP_INVALID_VDEV_ID;
  4667. }
  4668. }
  4669. }
  4670. if (!force_free)
  4671. qdf_spin_unlock_bh(&tx_desc_pool->flow_pool_lock);
  4672. }
  4673. }
  4674. #else /* QCA_LL_TX_FLOW_CONTROL_V2! */
  4675. /**
  4676. * dp_tx_desc_reset_vdev() - reset vdev to NULL in TX Desc
  4677. *
  4678. * @soc: Handle to DP soc structure
  4679. * @tx_desc: pointer of one TX desc
  4680. * @desc_pool_id: TX Desc pool id
  4681. */
  4682. static inline void
  4683. dp_tx_desc_reset_vdev(struct dp_soc *soc, struct dp_tx_desc_s *tx_desc,
  4684. uint8_t desc_pool_id)
  4685. {
  4686. TX_DESC_LOCK_LOCK(&soc->tx_desc[desc_pool_id].lock);
  4687. tx_desc->vdev_id = DP_INVALID_VDEV_ID;
  4688. TX_DESC_LOCK_UNLOCK(&soc->tx_desc[desc_pool_id].lock);
  4689. }
  4690. void dp_tx_desc_flush(struct dp_pdev *pdev, struct dp_vdev *vdev,
  4691. bool force_free)
  4692. {
  4693. uint8_t i, num_pool;
  4694. uint32_t j;
  4695. uint32_t num_desc, page_id, offset;
  4696. uint16_t num_desc_per_page;
  4697. struct dp_soc *soc = pdev->soc;
  4698. struct dp_tx_desc_s *tx_desc = NULL;
  4699. struct dp_tx_desc_pool_s *tx_desc_pool = NULL;
  4700. if (!vdev && !force_free) {
  4701. dp_err("Reset TX desc vdev, Vdev param is required!");
  4702. return;
  4703. }
  4704. num_desc = wlan_cfg_get_num_tx_desc(soc->wlan_cfg_ctx);
  4705. num_pool = wlan_cfg_get_num_tx_desc_pool(soc->wlan_cfg_ctx);
  4706. for (i = 0; i < num_pool; i++) {
  4707. tx_desc_pool = &soc->tx_desc[i];
  4708. if (!tx_desc_pool->desc_pages.cacheable_pages)
  4709. continue;
  4710. num_desc_per_page =
  4711. tx_desc_pool->desc_pages.num_element_per_page;
  4712. for (j = 0; j < num_desc; j++) {
  4713. page_id = j / num_desc_per_page;
  4714. offset = j % num_desc_per_page;
  4715. tx_desc = dp_tx_desc_find(soc, i, page_id, offset);
  4716. if (dp_is_tx_desc_flush_match(pdev, vdev, tx_desc)) {
  4717. if (force_free) {
  4718. tx_desc->flags |= DP_TX_DESC_FLAG_FLUSH;
  4719. dp_tx_comp_free_buf(soc, tx_desc);
  4720. dp_tx_desc_release(tx_desc, i);
  4721. } else {
  4722. dp_tx_desc_reset_vdev(soc, tx_desc,
  4723. i);
  4724. }
  4725. }
  4726. }
  4727. }
  4728. }
  4729. #endif /* !QCA_LL_TX_FLOW_CONTROL_V2 */
  4730. /**
  4731. * dp_tx_vdev_detach() - detach vdev from dp tx
  4732. * @vdev: virtual device instance
  4733. *
  4734. * Return: QDF_STATUS_SUCCESS: success
  4735. * QDF_STATUS_E_RESOURCES: Error return
  4736. */
  4737. QDF_STATUS dp_tx_vdev_detach(struct dp_vdev *vdev)
  4738. {
  4739. struct dp_pdev *pdev = vdev->pdev;
  4740. /* Reset TX desc associated to this Vdev as NULL */
  4741. dp_tx_desc_flush(pdev, vdev, false);
  4742. return QDF_STATUS_SUCCESS;
  4743. }
  4744. #ifdef QCA_LL_TX_FLOW_CONTROL_V2
  4745. /* Pools will be allocated dynamically */
  4746. static QDF_STATUS dp_tx_alloc_static_pools(struct dp_soc *soc, int num_pool,
  4747. int num_desc)
  4748. {
  4749. uint8_t i;
  4750. for (i = 0; i < num_pool; i++) {
  4751. qdf_spinlock_create(&soc->tx_desc[i].flow_pool_lock);
  4752. soc->tx_desc[i].status = FLOW_POOL_INACTIVE;
  4753. }
  4754. return QDF_STATUS_SUCCESS;
  4755. }
  4756. static QDF_STATUS dp_tx_init_static_pools(struct dp_soc *soc, int num_pool,
  4757. int num_desc)
  4758. {
  4759. return QDF_STATUS_SUCCESS;
  4760. }
  4761. static void dp_tx_deinit_static_pools(struct dp_soc *soc, int num_pool)
  4762. {
  4763. }
  4764. static void dp_tx_delete_static_pools(struct dp_soc *soc, int num_pool)
  4765. {
  4766. uint8_t i;
  4767. for (i = 0; i < num_pool; i++)
  4768. qdf_spinlock_destroy(&soc->tx_desc[i].flow_pool_lock);
  4769. }
  4770. #else /* QCA_LL_TX_FLOW_CONTROL_V2! */
  4771. static QDF_STATUS dp_tx_alloc_static_pools(struct dp_soc *soc, int num_pool,
  4772. int num_desc)
  4773. {
  4774. uint8_t i, count;
  4775. /* Allocate software Tx descriptor pools */
  4776. for (i = 0; i < num_pool; i++) {
  4777. if (dp_tx_desc_pool_alloc(soc, i, num_desc)) {
  4778. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  4779. FL("Tx Desc Pool alloc %d failed %pK"),
  4780. i, soc);
  4781. goto fail;
  4782. }
  4783. }
  4784. return QDF_STATUS_SUCCESS;
  4785. fail:
  4786. for (count = 0; count < i; count++)
  4787. dp_tx_desc_pool_free(soc, count);
  4788. return QDF_STATUS_E_NOMEM;
  4789. }
  4790. static QDF_STATUS dp_tx_init_static_pools(struct dp_soc *soc, int num_pool,
  4791. int num_desc)
  4792. {
  4793. uint8_t i;
  4794. for (i = 0; i < num_pool; i++) {
  4795. if (dp_tx_desc_pool_init(soc, i, num_desc)) {
  4796. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  4797. FL("Tx Desc Pool init %d failed %pK"),
  4798. i, soc);
  4799. return QDF_STATUS_E_NOMEM;
  4800. }
  4801. }
  4802. return QDF_STATUS_SUCCESS;
  4803. }
  4804. static void dp_tx_deinit_static_pools(struct dp_soc *soc, int num_pool)
  4805. {
  4806. uint8_t i;
  4807. for (i = 0; i < num_pool; i++)
  4808. dp_tx_desc_pool_deinit(soc, i);
  4809. }
  4810. static void dp_tx_delete_static_pools(struct dp_soc *soc, int num_pool)
  4811. {
  4812. uint8_t i;
  4813. for (i = 0; i < num_pool; i++)
  4814. dp_tx_desc_pool_free(soc, i);
  4815. }
  4816. #endif /* !QCA_LL_TX_FLOW_CONTROL_V2 */
  4817. /**
  4818. * dp_tx_tso_cmn_desc_pool_deinit() - de-initialize TSO descriptors
  4819. * @soc: core txrx main context
  4820. * @num_pool: number of pools
  4821. *
  4822. */
  4823. void dp_tx_tso_cmn_desc_pool_deinit(struct dp_soc *soc, uint8_t num_pool)
  4824. {
  4825. dp_tx_tso_desc_pool_deinit(soc, num_pool);
  4826. dp_tx_tso_num_seg_pool_deinit(soc, num_pool);
  4827. }
  4828. /**
  4829. * dp_tx_tso_cmn_desc_pool_free() - free TSO descriptors
  4830. * @soc: core txrx main context
  4831. * @num_pool: number of pools
  4832. *
  4833. */
  4834. void dp_tx_tso_cmn_desc_pool_free(struct dp_soc *soc, uint8_t num_pool)
  4835. {
  4836. dp_tx_tso_desc_pool_free(soc, num_pool);
  4837. dp_tx_tso_num_seg_pool_free(soc, num_pool);
  4838. }
  4839. /**
  4840. * dp_soc_tx_desc_sw_pools_free() - free all TX descriptors
  4841. * @soc: core txrx main context
  4842. *
  4843. * This function frees all tx related descriptors as below
  4844. * 1. Regular TX descriptors (static pools)
  4845. * 2. extension TX descriptors (used for ME, RAW, TSO etc...)
  4846. * 3. TSO descriptors
  4847. *
  4848. */
  4849. void dp_soc_tx_desc_sw_pools_free(struct dp_soc *soc)
  4850. {
  4851. uint8_t num_pool;
  4852. num_pool = wlan_cfg_get_num_tx_desc_pool(soc->wlan_cfg_ctx);
  4853. dp_tx_tso_cmn_desc_pool_free(soc, num_pool);
  4854. dp_tx_ext_desc_pool_free(soc, num_pool);
  4855. dp_tx_delete_static_pools(soc, num_pool);
  4856. }
  4857. /**
  4858. * dp_soc_tx_desc_sw_pools_deinit() - de-initialize all TX descriptors
  4859. * @soc: core txrx main context
  4860. *
  4861. * This function de-initializes all tx related descriptors as below
  4862. * 1. Regular TX descriptors (static pools)
  4863. * 2. extension TX descriptors (used for ME, RAW, TSO etc...)
  4864. * 3. TSO descriptors
  4865. *
  4866. */
  4867. void dp_soc_tx_desc_sw_pools_deinit(struct dp_soc *soc)
  4868. {
  4869. uint8_t num_pool;
  4870. num_pool = wlan_cfg_get_num_tx_desc_pool(soc->wlan_cfg_ctx);
  4871. dp_tx_flow_control_deinit(soc);
  4872. dp_tx_tso_cmn_desc_pool_deinit(soc, num_pool);
  4873. dp_tx_ext_desc_pool_deinit(soc, num_pool);
  4874. dp_tx_deinit_static_pools(soc, num_pool);
  4875. }
  4876. /**
  4877. * dp_tso_attach() - TSO attach handler
  4878. * @txrx_soc: Opaque Dp handle
  4879. *
  4880. * Reserve TSO descriptor buffers
  4881. *
  4882. * Return: QDF_STATUS_E_FAILURE on failure or
  4883. * QDF_STATUS_SUCCESS on success
  4884. */
  4885. QDF_STATUS dp_tx_tso_cmn_desc_pool_alloc(struct dp_soc *soc,
  4886. uint8_t num_pool,
  4887. uint16_t num_desc)
  4888. {
  4889. if (dp_tx_tso_desc_pool_alloc(soc, num_pool, num_desc)) {
  4890. dp_err("TSO Desc Pool alloc %d failed %pK", num_pool, soc);
  4891. return QDF_STATUS_E_FAILURE;
  4892. }
  4893. if (dp_tx_tso_num_seg_pool_alloc(soc, num_pool, num_desc)) {
  4894. dp_err("TSO Num of seg Pool alloc %d failed %pK",
  4895. num_pool, soc);
  4896. return QDF_STATUS_E_FAILURE;
  4897. }
  4898. return QDF_STATUS_SUCCESS;
  4899. }
  4900. /**
  4901. * dp_tx_tso_cmn_desc_pool_init() - TSO cmn desc pool init
  4902. * @soc: DP soc handle
  4903. * @num_pool: Number of pools
  4904. * @num_desc: Number of descriptors
  4905. *
  4906. * Initialize TSO descriptor pools
  4907. *
  4908. * Return: QDF_STATUS_E_FAILURE on failure or
  4909. * QDF_STATUS_SUCCESS on success
  4910. */
  4911. QDF_STATUS dp_tx_tso_cmn_desc_pool_init(struct dp_soc *soc,
  4912. uint8_t num_pool,
  4913. uint16_t num_desc)
  4914. {
  4915. if (dp_tx_tso_desc_pool_init(soc, num_pool, num_desc)) {
  4916. dp_err("TSO Desc Pool alloc %d failed %pK", num_pool, soc);
  4917. return QDF_STATUS_E_FAILURE;
  4918. }
  4919. if (dp_tx_tso_num_seg_pool_init(soc, num_pool, num_desc)) {
  4920. dp_err("TSO Num of seg Pool alloc %d failed %pK",
  4921. num_pool, soc);
  4922. return QDF_STATUS_E_FAILURE;
  4923. }
  4924. return QDF_STATUS_SUCCESS;
  4925. }
  4926. /**
  4927. * dp_soc_tx_desc_sw_pools_alloc() - Allocate tx descriptor pool memory
  4928. * @soc: core txrx main context
  4929. *
  4930. * This function allocates memory for following descriptor pools
  4931. * 1. regular sw tx descriptor pools (static pools)
  4932. * 2. TX extension descriptor pools (ME, RAW, TSO etc...)
  4933. * 3. TSO descriptor pools
  4934. *
  4935. * Return: QDF_STATUS_SUCCESS: success
  4936. * QDF_STATUS_E_RESOURCES: Error return
  4937. */
  4938. QDF_STATUS dp_soc_tx_desc_sw_pools_alloc(struct dp_soc *soc)
  4939. {
  4940. uint8_t num_pool;
  4941. uint32_t num_desc;
  4942. uint32_t num_ext_desc;
  4943. num_pool = wlan_cfg_get_num_tx_desc_pool(soc->wlan_cfg_ctx);
  4944. num_desc = wlan_cfg_get_num_tx_desc(soc->wlan_cfg_ctx);
  4945. num_ext_desc = wlan_cfg_get_num_tx_ext_desc(soc->wlan_cfg_ctx);
  4946. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  4947. "%s Tx Desc Alloc num_pool = %d, descs = %d",
  4948. __func__, num_pool, num_desc);
  4949. if ((num_pool > MAX_TXDESC_POOLS) ||
  4950. (num_desc > WLAN_CFG_NUM_TX_DESC_MAX))
  4951. goto fail1;
  4952. if (dp_tx_alloc_static_pools(soc, num_pool, num_desc))
  4953. goto fail1;
  4954. if (dp_tx_ext_desc_pool_alloc(soc, num_pool, num_ext_desc))
  4955. goto fail2;
  4956. if (wlan_cfg_is_tso_desc_attach_defer(soc->wlan_cfg_ctx))
  4957. return QDF_STATUS_SUCCESS;
  4958. if (dp_tx_tso_cmn_desc_pool_alloc(soc, num_pool, num_ext_desc))
  4959. goto fail3;
  4960. return QDF_STATUS_SUCCESS;
  4961. fail3:
  4962. dp_tx_ext_desc_pool_free(soc, num_pool);
  4963. fail2:
  4964. dp_tx_delete_static_pools(soc, num_pool);
  4965. fail1:
  4966. return QDF_STATUS_E_RESOURCES;
  4967. }
  4968. /**
  4969. * dp_soc_tx_desc_sw_pools_init() - Initialise TX descriptor pools
  4970. * @soc: core txrx main context
  4971. *
  4972. * This function initializes the following TX descriptor pools
  4973. * 1. regular sw tx descriptor pools (static pools)
  4974. * 2. TX extension descriptor pools (ME, RAW, TSO etc...)
  4975. * 3. TSO descriptor pools
  4976. *
  4977. * Return: QDF_STATUS_SUCCESS: success
  4978. * QDF_STATUS_E_RESOURCES: Error return
  4979. */
  4980. QDF_STATUS dp_soc_tx_desc_sw_pools_init(struct dp_soc *soc)
  4981. {
  4982. uint8_t num_pool;
  4983. uint32_t num_desc;
  4984. uint32_t num_ext_desc;
  4985. num_pool = wlan_cfg_get_num_tx_desc_pool(soc->wlan_cfg_ctx);
  4986. num_desc = wlan_cfg_get_num_tx_desc(soc->wlan_cfg_ctx);
  4987. num_ext_desc = wlan_cfg_get_num_tx_ext_desc(soc->wlan_cfg_ctx);
  4988. if (dp_tx_init_static_pools(soc, num_pool, num_desc))
  4989. goto fail1;
  4990. if (dp_tx_ext_desc_pool_init(soc, num_pool, num_ext_desc))
  4991. goto fail2;
  4992. if (wlan_cfg_is_tso_desc_attach_defer(soc->wlan_cfg_ctx))
  4993. return QDF_STATUS_SUCCESS;
  4994. if (dp_tx_tso_cmn_desc_pool_init(soc, num_pool, num_ext_desc))
  4995. goto fail3;
  4996. dp_tx_flow_control_init(soc);
  4997. soc->process_tx_status = CONFIG_PROCESS_TX_STATUS;
  4998. return QDF_STATUS_SUCCESS;
  4999. fail3:
  5000. dp_tx_ext_desc_pool_deinit(soc, num_pool);
  5001. fail2:
  5002. dp_tx_deinit_static_pools(soc, num_pool);
  5003. fail1:
  5004. return QDF_STATUS_E_RESOURCES;
  5005. }
  5006. /**
  5007. * dp_tso_soc_attach() - Allocate and initialize TSO descriptors
  5008. * @txrx_soc: dp soc handle
  5009. *
  5010. * Return: QDF_STATUS - QDF_STATUS_SUCCESS
  5011. * QDF_STATUS_E_FAILURE
  5012. */
  5013. QDF_STATUS dp_tso_soc_attach(struct cdp_soc_t *txrx_soc)
  5014. {
  5015. struct dp_soc *soc = (struct dp_soc *)txrx_soc;
  5016. uint8_t num_pool;
  5017. uint32_t num_desc;
  5018. uint32_t num_ext_desc;
  5019. num_pool = wlan_cfg_get_num_tx_desc_pool(soc->wlan_cfg_ctx);
  5020. num_desc = wlan_cfg_get_num_tx_desc(soc->wlan_cfg_ctx);
  5021. num_ext_desc = wlan_cfg_get_num_tx_ext_desc(soc->wlan_cfg_ctx);
  5022. if (dp_tx_tso_cmn_desc_pool_alloc(soc, num_pool, num_ext_desc))
  5023. return QDF_STATUS_E_FAILURE;
  5024. if (dp_tx_tso_cmn_desc_pool_init(soc, num_pool, num_ext_desc))
  5025. return QDF_STATUS_E_FAILURE;
  5026. return QDF_STATUS_SUCCESS;
  5027. }
  5028. /**
  5029. * dp_tso_soc_detach() - de-initialize and free the TSO descriptors
  5030. * @txrx_soc: dp soc handle
  5031. *
  5032. * Return: QDF_STATUS - QDF_STATUS_SUCCESS
  5033. */
  5034. QDF_STATUS dp_tso_soc_detach(struct cdp_soc_t *txrx_soc)
  5035. {
  5036. struct dp_soc *soc = (struct dp_soc *)txrx_soc;
  5037. uint8_t num_pool = wlan_cfg_get_num_tx_desc_pool(soc->wlan_cfg_ctx);
  5038. dp_tx_tso_cmn_desc_pool_deinit(soc, num_pool);
  5039. dp_tx_tso_cmn_desc_pool_free(soc, num_pool);
  5040. return QDF_STATUS_SUCCESS;
  5041. }