qdf_nbuf.h 147 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692
  1. /*
  2. * Copyright (c) 2014-2021 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2021-2023 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. /**
  20. * DOC: qdf_nbuf_public network buffer API
  21. * This file defines the network buffer abstraction.
  22. */
  23. #ifndef _QDF_NBUF_H
  24. #define _QDF_NBUF_H
  25. #include <qdf_util.h>
  26. #include <qdf_types.h>
  27. #include <qdf_lock.h>
  28. #include <i_qdf_trace.h>
  29. #include <i_qdf_nbuf.h>
  30. #include <qdf_net_types.h>
  31. #define IPA_NBUF_OWNER_ID 0xaa55aa55
  32. #define QDF_NBUF_PKT_TRAC_TYPE_DNS 0x01
  33. #define QDF_NBUF_PKT_TRAC_TYPE_EAPOL 0x02
  34. #define QDF_NBUF_PKT_TRAC_TYPE_DHCP 0x04
  35. #define QDF_NBUF_PKT_TRAC_TYPE_MGMT_ACTION 0x08
  36. #define QDF_NBUF_PKT_TRAC_TYPE_ARP 0x10
  37. #define QDF_NBUF_PKT_TRAC_TYPE_ICMP 0x20
  38. #define QDF_NBUF_PKT_TRAC_TYPE_ICMPv6 0x40
  39. #define QDF_HL_CREDIT_TRACKING 0x80
  40. #define QDF_NBUF_PKT_TRAC_MAX_STRING 12
  41. #define QDF_NBUF_PKT_TRAC_PROTO_STRING 4
  42. #define QDF_NBUF_PKT_ERROR 1
  43. #define QDF_NBUF_TRAC_IPV4_OFFSET 14
  44. #define QDF_NBUF_TRAC_IPV4_HEADER_MASK 0xF
  45. #define QDF_NBUF_TRAC_IPV4_HEADER_SIZE 20
  46. #define QDF_NBUF_TRAC_DHCP_SRV_PORT 67
  47. #define QDF_NBUF_TRAC_DHCP_CLI_PORT 68
  48. #define QDF_NBUF_TRAC_ETH_TYPE_OFFSET 12
  49. #define QDF_NBUF_TRAC_VLAN_ETH_TYPE_OFFSET 16
  50. #define QDF_NBUF_TRAC_DOUBLE_VLAN_ETH_TYPE_OFFSET 20
  51. #define QDF_NBUF_TRAC_EAPOL_ETH_TYPE 0x888E
  52. #define QDF_NBUF_TRAC_WAPI_ETH_TYPE 0x88b4
  53. #define QDF_NBUF_TRAC_ARP_ETH_TYPE 0x0806
  54. #define QDF_NBUF_PKT_IPV4_DSCP_MASK 0xFC
  55. #define QDF_NBUF_PKT_IPV4_DSCP_SHIFT 0x02
  56. #define QDF_NBUF_TRAC_TDLS_ETH_TYPE 0x890D
  57. #define QDF_NBUF_TRAC_IPV4_ETH_TYPE 0x0800
  58. #define QDF_NBUF_TRAC_IPV6_ETH_TYPE 0x86dd
  59. #define QDF_NBUF_DEST_MAC_OFFSET 0
  60. #define QDF_NBUF_SRC_MAC_OFFSET 6
  61. #define QDF_NBUF_TRAC_IPV4_TOS_OFFSET 15
  62. #define QDF_NBUF_TRAC_IPV4_PROTO_TYPE_OFFSET 23
  63. #define QDF_NBUF_TRAC_VLAN_IPV4_PROTO_TYPE_OFFSET 27
  64. #define QDF_NBUF_TRAC_IPV4_DEST_ADDR_OFFSET 30
  65. #define QDF_NBUF_TRAC_IPV4_SRC_ADDR_OFFSET 26
  66. #define QDF_NBUF_TRAC_IPV6_PROTO_TYPE_OFFSET 20
  67. #define QDF_NBUF_TRAC_VLAN_IPV6_PROTO_TYPE_OFFSET 24
  68. #define QDF_NBUF_TRAC_IPV4_ADDR_MCAST_MASK 0xE0000000
  69. #define QDF_NBUF_TRAC_IPV4_ADDR_BCAST_MASK 0xF0000000
  70. #define QDF_NBUF_TRAC_IPV6_DEST_ADDR_OFFSET 38
  71. #define QDF_NBUF_TRAC_IPV6_DEST_ADDR 0xFF00
  72. #define QDF_NBUF_TRAC_IPV6_OFFSET 14
  73. #define QDF_NBUF_TRAC_VLAN_IPV6_OFFSET 18
  74. #define QDF_NBUF_TRAC_IPV6_HEADER_SIZE 40
  75. #define QDF_NBUF_TRAC_ICMP_TYPE 1
  76. #define QDF_NBUF_TRAC_IGMP_TYPE 2
  77. #define QDF_NBUF_TRAC_TCP_TYPE 6
  78. #define QDF_NBUF_TRAC_TCP_FLAGS_OFFSET (47 - 34)
  79. #define QDF_NBUF_TRAC_TCP_ACK_OFFSET (42 - 34)
  80. #define QDF_NBUF_TRAC_TCP_HEADER_LEN_OFFSET (46 - 34)
  81. #define QDF_NBUF_TRAC_TCP_ACK_MASK 0x10
  82. #define QDF_NBUF_TRAC_TCP_SPORT_OFFSET (34 - 34)
  83. #define QDF_NBUF_TRAC_TCP_DPORT_OFFSET (36 - 34)
  84. #define QDF_NBUF_TRAC_UDP_TYPE 17
  85. #define QDF_NBUF_TRAC_ICMPV6_TYPE 0x3a
  86. #define QDF_NBUF_TRAC_HOPOPTS_TYPE 0
  87. #define QDF_NBUF_TRAC_DHCP6_SRV_PORT 547
  88. #define QDF_NBUF_TRAC_DHCP6_CLI_PORT 546
  89. #define QDF_NBUF_TRAC_MDNS_SRC_N_DST_PORT 5353
  90. #define QDF_NBUF_TRAC_IP_OFFSET 14
  91. #define QDF_NBUF_TRAC_VLAN_IP_OFFSET 18
  92. #define QDF_NBUF_TRAC_DOUBLE_VLAN_IP_OFFSET 22
  93. /* One dword for IPv4 header size unit */
  94. #define QDF_NBUF_IPV4_HDR_SIZE_UNIT 4
  95. #define QDF_NBUF_TRAC_IPV4_TOTAL_LEN_OFFSET 16
  96. #define QDF_NBUF_TRAC_IPV6_PAYLOAD_LEN_OFFSET 18
  97. /* EAPOL Related MASK */
  98. #define EAPOL_PACKET_TYPE_OFFSET 15
  99. #define EAPOL_KEY_INFO_OFFSET 19
  100. #define EAPOL_PKT_LEN_OFFSET 16
  101. #define EAPOL_KEY_LEN_OFFSET 21
  102. #define EAPOL_KEY_DATA_LENGTH_OFFSET 111
  103. #define EAPOL_WPA_KEY_NONCE_OFFSET 31
  104. #define EAPOL_PACKET_TYPE_EAP 0
  105. #define EAPOL_PACKET_TYPE_START 1
  106. #define EAPOL_PACKET_TYPE_LOGOFF 2
  107. #define EAPOL_PACKET_TYPE_KEY 3
  108. #define EAPOL_PACKET_TYPE_ASF 4
  109. #define EAPOL_KEY_TYPE_MASK 0x0800
  110. #define EAPOL_KEY_ENCRYPTED_MASK 0x0010
  111. /* EAP Related Mask */
  112. #define EAP_CODE_OFFSET 18
  113. #define EAP_LENGTH_OFFSET 20
  114. #define EAP_TYPE_OFFSET 22
  115. #define QDF_EAP_REQUEST 1
  116. #define QDF_EAP_RESPONSE 2
  117. #define QDF_EAP_SUCCESS 3
  118. #define QDF_EAP_FAILURE 4
  119. #define QDF_EAP_INITIATE 5
  120. #define QDF_EAP_FINISH 6
  121. #define EAP_PACKET_TYPE_ID 0x01
  122. #define EAP_PACKET_TYPE_EXP 0xFE
  123. #define EAP_EXP_TYPE_WSC_START 0x01
  124. #define EAP_EXP_TYPE_M1 0x04
  125. #define EAP_EXP_TYPE_M2 0x05
  126. #define EAP_EXP_TYPE_M3 0x07
  127. #define EAP_EXP_TYPE_M4 0x08
  128. #define EAP_EXP_TYPE_M5 0x09
  129. #define EAP_EXP_TYPE_M6 0x0A
  130. #define EAP_EXP_TYPE_M7 0x0B
  131. #define EAP_EXP_TYPE_M8 0x0C
  132. #define EAP_EXP_TYPE_WSC_DONE 0x0F
  133. #define EAP_EXP_MSG_OPCODE_OFFSET 0x1E
  134. #define EAP_EXP_MSG_TYPE_OFFSET 0x29
  135. enum wsc_op_code {
  136. WSC_UPNP = 0, /* No OP Code in UPnP transport */
  137. WSC_START = 0x01,
  138. WSC_ACK = 0x02,
  139. WSC_NACK = 0x03,
  140. WSC_MSG = 0x04,
  141. WSC_DONE = 0x05,
  142. WSC_FRAG_ACK = 0x06
  143. };
  144. /* ARP Related MASK */
  145. #define QDF_NBUF_PKT_ARP_OPCODE_OFFSET 20
  146. #define QDF_NBUF_PKT_ARPOP_REQ 1
  147. #define QDF_NBUF_PKT_ARPOP_REPLY 2
  148. #define QDF_NBUF_PKT_ARP_SRC_IP_OFFSET 28
  149. #define QDF_NBUF_PKT_ARP_TGT_IP_OFFSET 38
  150. /* ICMPv4 Related MASK */
  151. #define QDF_NBUF_PKT_ICMPv4_OPCODE_OFFSET 34
  152. #define QDF_NBUF_PKT_ICMPv4OP_REQ 0x08
  153. #define QDF_NBUF_PKT_ICMPv4OP_REPLY 0x00
  154. #define QDF_NBUF_PKT_ICMPv4_SRC_IP_OFFSET 26
  155. #define QDF_NBUF_PKT_ICMPv4_TGT_IP_OFFSET 30
  156. #define QDF_NBUF_PKT_ICMPV4_REDIRECT 0x05
  157. /* TCP Related MASK */
  158. #define QDF_NBUF_PKT_TCP_OPCODE_OFFSET 47
  159. #define QDF_NBUF_PKT_TCPOP_SYN 0x02
  160. #define QDF_NBUF_PKT_TCPOP_SYN_ACK 0x12
  161. #define QDF_NBUF_PKT_TCPOP_ACK 0x10
  162. #define QDF_NBUF_PKT_TCP_SRC_PORT_OFFSET 34
  163. #define QDF_NBUF_PKT_TCP_DST_PORT_OFFSET 36
  164. #define QDF_NBUF_PKT_IPV4_TCP_HDR_LEN_OFFSET 46
  165. #define QDF_NBUF_PKT_IPV4_TCP_OPCODE_OFFSET 47
  166. #define QDF_NBUF_PKT_IPV6_TCP_HDR_LEN_OFFSET 66
  167. #define QDF_NBUF_PKT_IPV6_TCP_OPCODE_OFFSET 67
  168. #define QDF_NBUF_PKT_TCP_HDR_LEN_MASK 0xF0
  169. #define QDF_NBUF_PKT_TCP_HDR_LEN_LSB 4
  170. #define QDF_NBUF_PKT_TCP_HDR_LEN_UNIT 4
  171. #define QDF_NBUF_PKT_TCP_ACK_MAX_LEN 100
  172. /* DNS Related MASK */
  173. #define QDF_NBUF_PKT_DNS_OVER_UDP_OPCODE_OFFSET 44
  174. #define QDF_NBUF_PKT_DNSOP_BITMAP 0xF800
  175. #define QDF_NBUF_PKT_DNSOP_STANDARD_QUERY 0x0000
  176. #define QDF_NBUF_PKT_DNSOP_STANDARD_RESPONSE 0x8000
  177. #define QDF_NBUF_PKT_DNS_SRC_PORT_OFFSET 34
  178. #define QDF_NBUF_PKT_DNS_DST_PORT_OFFSET 36
  179. #define QDF_NBUF_PKT_DNS_NAME_OVER_UDP_OFFSET 54
  180. #define QDF_NBUF_PKT_DNS_STANDARD_PORT 53
  181. /* Tracked Packet types */
  182. #define QDF_NBUF_TX_PKT_INVALID 0
  183. #define QDF_NBUF_TX_PKT_DATA_TRACK 1
  184. #define QDF_NBUF_TX_PKT_MGMT_TRACK 2
  185. #define QDF_NBUF_RX_PKT_DATA_TRACK 3
  186. /* Different Packet states */
  187. #define QDF_NBUF_TX_PKT_HDD 1
  188. #define QDF_NBUF_TX_PKT_TXRX_ENQUEUE 2
  189. #define QDF_NBUF_TX_PKT_TXRX_DEQUEUE 3
  190. #define QDF_NBUF_TX_PKT_TXRX 4
  191. #define QDF_NBUF_TX_PKT_HTT 5
  192. #define QDF_NBUF_TX_PKT_HTC 6
  193. #define QDF_NBUF_TX_PKT_HIF 7
  194. #define QDF_NBUF_TX_PKT_CE 8
  195. #define QDF_NBUF_TX_PKT_FREE 9
  196. #define QDF_NBUF_TX_PKT_LI_DP 10
  197. #define QDF_NBUF_TX_PKT_DP 11
  198. #define QDF_NBUF_TX_PKT_STATE_MAX 12
  199. /* nbuf allocations only come from one domain */
  200. #define QDF_DEBUG_NBUF_DOMAIN 0
  201. /* qdf_nbuf allocate and map max retry threshold when failed */
  202. #define QDF_NBUF_ALLOC_MAP_RETRY_THRESHOLD 20
  203. /* Enable flag to print TSO specific prints in datapath */
  204. #ifdef TSO_DEBUG_LOG_ENABLE
  205. #define TSO_DEBUG(fmt, args ...) \
  206. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_NONE, \
  207. fmt, ## args)
  208. #else
  209. #define TSO_DEBUG(fmt, args ...)
  210. #endif
  211. #define IEEE80211_AMPDU_FLAG 0x01
  212. #ifdef GET_MSDU_AGGREGATION
  213. #define IEEE80211_AMSDU_FLAG 0x02
  214. #endif
  215. #define MAX_CHAIN 8
  216. #define QDF_MON_STATUS_MPDU_FCS_BMAP_NWORDS 8
  217. #define EHT_USER_INFO_LEN 4
  218. /**
  219. * typedef qdf_nbuf_queue_t - Platform independent packet queue abstraction
  220. */
  221. typedef __qdf_nbuf_queue_t qdf_nbuf_queue_t;
  222. /*
  223. * This is the length for radiotap, combined length
  224. * (Mandatory part struct ieee80211_radiotap_header + RADIOTAP_HEADER_LEN)
  225. * cannot be more than available headroom_sz.
  226. * increase this when we add more radiotap elements.
  227. * Number after '+' indicates maximum possible increase due to alignment
  228. */
  229. #define RADIOTAP_TX_FLAGS_LEN (2 + 1)
  230. #define RADIOTAP_VHT_FLAGS_LEN (12 + 1)
  231. #define RADIOTAP_HE_FLAGS_LEN (12 + 1)
  232. #define RADIOTAP_HE_MU_FLAGS_LEN (8 + 1)
  233. #define RADIOTAP_HE_MU_OTHER_FLAGS_LEN (18 + 1)
  234. #define RADIOTAP_U_SIG_FLAGS_LEN (12 + 3)
  235. #define RADIOTAP_EHT_FLAGS_LEN (32 + 3)
  236. #define RADIOTAP_FIXED_HEADER_LEN 17
  237. #define RADIOTAP_HT_FLAGS_LEN 3
  238. #define RADIOTAP_AMPDU_STATUS_LEN (8 + 3)
  239. #define RADIOTAP_VENDOR_NS_LEN \
  240. (sizeof(struct qdf_radiotap_vendor_ns_ath) + 1)
  241. /* This is Radio Tap Header Extension Length.
  242. * 4 Bytes for Extended it_present bit map +
  243. * 4 bytes padding for alignment
  244. */
  245. #define RADIOTAP_HEADER_EXT_LEN (2 * sizeof(uint32_t))
  246. #define RADIOTAP_HEADER_EXT2_LEN \
  247. (sizeof(struct qdf_radiotap_ext2))
  248. #define RADIOTAP_HEADER_LEN (RADIOTAP_BASE_HEADER_LEN + \
  249. RADIOTAP_FIXED_HEADER_LEN + \
  250. RADIOTAP_TX_FLAGS_LEN + \
  251. RADIOTAP_HT_FLAGS_LEN + \
  252. RADIOTAP_VHT_FLAGS_LEN + \
  253. RADIOTAP_AMPDU_STATUS_LEN + \
  254. RADIOTAP_HE_FLAGS_LEN + \
  255. RADIOTAP_HE_MU_FLAGS_LEN + \
  256. RADIOTAP_HE_MU_OTHER_FLAGS_LEN + \
  257. RADIOTAP_VENDOR_NS_LEN + \
  258. RADIOTAP_HEADER_EXT_LEN + \
  259. RADIOTAP_HEADER_EXT2_LEN + \
  260. RADIOTAP_U_SIG_FLAGS_LEN + \
  261. RADIOTAP_EHT_FLAGS_LEN)
  262. /**
  263. * struct mon_rx_status - This will have monitor mode rx_status extracted from
  264. * htt_rx_desc used later to update radiotap information.
  265. * @tsft: Time Synchronization Function timer
  266. * @ppdu_timestamp: Timestamp in the PPDU_START TLV
  267. * @chan_freq: Capture channel frequency
  268. * @chan_num: Capture channel number
  269. * @chan_flags: Bitmap of Channel flags, IEEE80211_CHAN_TURBO,
  270. * IEEE80211_CHAN_CCK...
  271. * @ht_flags: HT flags, only present for HT frames.
  272. * @vht_flags: VHT flags, only present for VHT frames.
  273. * @vht_flag_values1-5: Contains corresponding data for flags field
  274. * @he_flags: HE (11ax) flags, only present in HE frames
  275. * @he_mu_flags: HE-MU (11ax) flags, only present in HE frames
  276. * @he_mu_other_flags: HE-MU-OTHER (11ax) flags, only present in HE frames
  277. * @usig_flags: USIG flags, only present in 802.11BE and subsequent protocol
  278. * @eht_flags: EHT (11be) flags, only present in EHT frames
  279. * @nr_ant: Number of Antennas used for streaming
  280. * @mcs: MCS index of Rx frame
  281. * @nss: Number of spatial streams
  282. * @bw: bandwidth of rx frame
  283. * @is_stbc: Is STBC enabled
  284. * @sgi: Rx frame short guard interval
  285. * @he_re: HE range extension
  286. * @ldpc: ldpc enabled
  287. * @beamformed: Is frame beamformed.
  288. * @dcm: dcm
  289. * @preamble_type: Preamble type in radio header
  290. * @tid: QoS traffic tid number
  291. * @rs_fcs_err: FCS error flag
  292. * @cck_flag: Flag to indicate CCK modulation
  293. * @ofdm_flag: Flag to indicate OFDM modulation
  294. * @ulofdma_flag: Flag to indicate UL OFDMA PPDU
  295. * @monitor_direct_used: monitor direct mode
  296. * @data_sequence_control_info_valid: field to indicate validity of seq control
  297. * @rxpcu_filter_pass: Flag which indicates whether RX packets are received in
  298. * BSS mode(not in promisc mode)
  299. * @add_rtap_ext: add radio tap extension
  300. * @frame_control_info_valid: field indicates if fc value is valid
  301. * @add_rtap_ext2: add radiotap extension2
  302. * @reception_type: PPDU reception type
  303. * @ltf_size: ltf size
  304. * @tx_status: packet tx status
  305. * @mu_dl_ul: MU down or up link, 0 downlink, 1 uplink
  306. * @rx_antenna: rx antenna
  307. * @vht_flag_values6: VHT flag value6
  308. * @he_mu_other_flags: HE MU other flag
  309. * @he_sig_b_common: HE (11ax) sig B common field
  310. * @he_sig_b_common_known: HE (11ax) sig B common known field
  311. * @l_sig_a_info: L_SIG_A value coming in Rx descriptor
  312. * @l_sig_b_info: L_SIG_B value coming in Rx descriptor
  313. * @num_eht_user_info_valid: Number of valid EHT user info
  314. * @rate: Rate in terms 500Kbps
  315. * @rtap_flags: Bit map of available fields in the radiotap
  316. * @ant_signal_db: Rx packet RSSI
  317. * @ht_mcs: MCS index for HT RX frames
  318. * @tcp_msdu_count: TCP MSDU Count
  319. * @udp_msdu_count: UDP MSDU Count
  320. * @other_msdu_count: Other MSDU Count
  321. * @vht_flag_values1: VHT flag value 1
  322. * @vht_flag_values2: VHT flag value 2
  323. * @vht_flag_values3: VHT flag value 3
  324. * @vht_flag_values4: VHT flag value 4
  325. * @vht_flag_values5: VHT flag value 5
  326. * @he_sig_b_common_RU: HE (11ax) common RU assignment index
  327. * @rssi_comb: Combined RSSI
  328. * @rssi: 8 bits RSSI per 20 MHz per chain
  329. * @duration: 802.11 Duration
  330. * @frame_control: frame control field
  331. * @ast_index: AST table hash index
  332. * @rs_flags: Flags to indicate AMPDU or AMSDU aggregation
  333. * @he_per_user_1: HE per user info1
  334. * @he_per_user_2: HE per user info2
  335. * @he_per_user_position: HE per user position info
  336. * @he_per_user_known: HE per user known info
  337. * @he_flags1: HE flags
  338. * @he_flags2: HE flags
  339. * @he_RU: HE RU assignment index
  340. * @he_data1: HE property of received frame
  341. * @he_data2: HE property of received frame
  342. * @he_data3: HE property of received frame
  343. * @he_data4: HE property of received frame
  344. * @he_data5: HE property of received frame
  345. * @he_data6: HE property of received frame
  346. * @ppdu_len: PPDU length
  347. * @prev_ppdu_id: ppdu_id in previously received message
  348. * @ppdu_id: Id of the PLCP protocol data unit
  349. *
  350. * The following variables are not coming from the TLVs.
  351. * These variables are placeholders for passing information to update_radiotap
  352. * function.
  353. * @device_id: Device ID coming from sub-system (PCI, AHB etc..)
  354. * @chan_noise_floor: Channel Noise Floor for the pdev
  355. * @first_data_seq_ctrl: Sequence ctrl field of first data frame
  356. * @rssi_chain: Rssi chain per nss per bw
  357. * @tx_retry_cnt: tx retry count
  358. * @start_seq: starting sequence number
  359. * @ba_bitmap: 256 bit block ack bitmap
  360. * @mpdu_retry_cnt: Rx mpdu retry count
  361. * @punctured_pattern: punctured pattern (0 means the band is punctured)
  362. * @usig_common: U-SIG property of received frame
  363. * @usig_value: U-SIG property of received frame
  364. * @usig_mask: U-SIG property of received frame
  365. * @eht_known: EHT property of received frame
  366. * @eht_data: EHT property of received frame
  367. * @eht_user_info: EHT USER property of received frame
  368. * @phyrx_abort: phy aborted undecoded frame indication
  369. * @phyrx_abort_reason: abort reason in phyrx_abort_request_info
  370. * @vht_crc: vht crc
  371. * @vht_no_txop_ps: TXOP power save mode
  372. * @he_crc: he crc
  373. * @l_sig_length: L SIG A length
  374. * @l_sig_a_parity: L SIG A parity
  375. * @l_sig_a_pkt_type: L SIG A info pkt type
  376. * @l_sig_a_implicit_sounding: L SIG A info captured implicit sounding
  377. * @ht_length: num of bytes in PSDU
  378. * @smoothing: Indicate smoothing
  379. * @not_sounding: Indicate sounding
  380. * @aggregation: Indicate A-MPDU format
  381. * @ht_stbc: Indicate stbc
  382. * @ht_crc: ht crc
  383. * @rx_user_status: pointer to mon_rx_user_status, when set update
  384. * @rssi_offset: This offset value will use for RSSI db to dbm conversion
  385. * @rssi_dbm_conv_support: Rssi dbm conversion support param
  386. * radiotap header will use userinfo from this structure.
  387. */
  388. struct mon_rx_status {
  389. uint64_t tsft;
  390. uint32_t ppdu_timestamp;
  391. qdf_freq_t chan_freq;
  392. uint16_t chan_num;
  393. uint16_t chan_flags;
  394. uint32_t ht_flags : 1,
  395. vht_flags : 1,
  396. he_flags : 1,
  397. he_mu_flags : 1,
  398. usig_flags : 1,
  399. eht_flags : 1,
  400. nr_ant : 3,
  401. mcs : 4,
  402. nss : 3,
  403. bw : 4,
  404. is_stbc : 1,
  405. sgi : 2,
  406. he_re : 1,
  407. ldpc : 1,
  408. beamformed : 1,
  409. dcm : 1,
  410. preamble_type : 4;
  411. uint32_t tid : 5,
  412. rs_fcs_err : 1,
  413. cck_flag : 1,
  414. ofdm_flag : 1,
  415. ulofdma_flag : 1,
  416. monitor_direct_used : 1,
  417. data_sequence_control_info_valid : 1,
  418. rxpcu_filter_pass : 1,
  419. add_rtap_ext : 1,
  420. frame_control_info_valid : 1,
  421. add_rtap_ext2 : 1,
  422. reception_type : 4,
  423. ltf_size : 2,
  424. tx_status : 4,
  425. mu_dl_ul : 1;
  426. uint32_t rx_antenna : 24;
  427. uint16_t vht_flag_values6;
  428. uint16_t he_mu_other_flags;
  429. uint16_t he_sig_b_common;
  430. uint16_t he_sig_b_common_known;
  431. uint32_t l_sig_a_info;
  432. uint32_t l_sig_b_info;
  433. uint8_t num_eht_user_info_valid;
  434. uint8_t rate;
  435. uint8_t rtap_flags;
  436. uint8_t ant_signal_db;
  437. uint8_t ht_mcs;
  438. uint16_t tcp_msdu_count;
  439. uint16_t udp_msdu_count;
  440. uint16_t other_msdu_count;
  441. uint8_t vht_flag_values1;
  442. uint8_t vht_flag_values2;
  443. uint8_t vht_flag_values3[4];
  444. uint8_t vht_flag_values4;
  445. uint8_t vht_flag_values5;
  446. uint8_t he_sig_b_common_RU[4];
  447. int8_t rssi_comb;
  448. int8_t rssi[MAX_CHAIN];
  449. uint16_t duration;
  450. uint16_t frame_control;
  451. uint16_t ast_index;
  452. uint8_t rs_flags;
  453. /* New HE radiotap fields */
  454. uint16_t he_per_user_1;
  455. uint16_t he_per_user_2;
  456. uint8_t he_per_user_position;
  457. uint8_t he_per_user_known;
  458. uint16_t he_flags1;
  459. uint16_t he_flags2;
  460. uint8_t he_RU[8];
  461. uint16_t he_data1;
  462. uint16_t he_data2;
  463. uint16_t he_data3;
  464. uint16_t he_data4;
  465. uint16_t he_data5;
  466. uint16_t he_data6;
  467. uint32_t ppdu_len;
  468. uint16_t prev_ppdu_id;
  469. uint16_t ppdu_id;
  470. uint16_t device_id;
  471. int16_t chan_noise_floor;
  472. uint16_t first_data_seq_ctrl;
  473. int8_t rssi_chain[8][8];
  474. uint8_t tx_retry_cnt;
  475. uint16_t start_seq;
  476. uint32_t ba_bitmap[8];
  477. uint16_t mpdu_retry_cnt;
  478. #ifdef WLAN_FEATURE_11BE
  479. uint16_t punctured_pattern;
  480. #endif
  481. uint32_t usig_common;
  482. uint32_t usig_value;
  483. uint32_t usig_mask;
  484. uint32_t eht_known;
  485. uint32_t eht_data[6];
  486. uint32_t eht_user_info[EHT_USER_INFO_LEN];
  487. #ifdef QCA_UNDECODED_METADATA_SUPPORT
  488. uint32_t phyrx_abort:1,
  489. phyrx_abort_reason:8,
  490. vht_crc:8,
  491. vht_no_txop_ps:1,
  492. he_crc:4;
  493. uint32_t l_sig_length:12,
  494. l_sig_a_parity:1,
  495. l_sig_a_pkt_type:4,
  496. l_sig_a_implicit_sounding:1;
  497. uint32_t ht_length:16,
  498. smoothing:1,
  499. not_sounding:1,
  500. aggregation:1,
  501. ht_stbc:2,
  502. ht_crc:8;
  503. #endif
  504. struct mon_rx_user_status *rx_user_status;
  505. int32_t rssi_offset;
  506. bool rssi_dbm_conv_support;
  507. };
  508. /**
  509. * struct mon_rx_user_status - This will have monitor mode per user rx_status
  510. * extracted from hardware TLV.
  511. * @mcs: MCS index of Rx frame
  512. * @nss: Number of spatial streams
  513. * @mu_ul_info_valid: MU UL info below is valid
  514. * @ofdma_ru_start_index: OFDMA RU start index
  515. * @ofdma_ru_width: OFDMA total RU width
  516. * @ofdma_ru_size: OFDMA RU size index
  517. * @is_ampdu: AMPDU flag
  518. * @mu_ul_user_v0_word0: MU UL user info word 0
  519. * @mu_ul_user_v0_word1: MU UL user info word 1
  520. * @ast_index: AST table hash index
  521. * @sw_peer_id: software peer id
  522. * @tid: QoS traffic tid number
  523. * @preamble_type: Preamble type in radio header
  524. * @ht_flags: HT flags, only present for HT frames.
  525. * @vht_flags: VHT flags, only present for VHT frames.
  526. * @he_flags: HE (11ax) flags, only present in HE frames
  527. * @frame_control_info_valid: field indicates if fc value is valid
  528. * @frame_control: frame control field
  529. * @data_sequence_control_info_valid: field to indicate validity of seq control
  530. * @ba_bitmap_sz: blockack bitmap size
  531. * @filter_category: mpdu filter category
  532. * @tcp_msdu_count: tcp protocol msdu count
  533. * @udp_msdu_count: udp protocol msdu count
  534. * @other_msdu_count: other protocol msdu count
  535. * @first_data_seq_ctrl: Sequence ctrl field of first data frame
  536. * @duration: 802.11 Duration
  537. * @vht_flag_values2: Contains corresponding data for flags field
  538. * @vht_flag_values3: Contains corresponding data for flags field
  539. * @vht_flag_values4: Contains corresponding data for flags field
  540. * @vht_flag_values5: Contains corresponding data for flags field
  541. * @vht_flag_values6: Contains corresponding data for flags field
  542. * @he_flags1: HE flags
  543. * @he_flags2: HE flags
  544. * @he_RU: HE RU assignment index
  545. * @he_data1: HE property of received frame
  546. * @he_data2: HE property of received frame
  547. * @he_data3: HE property of received frame
  548. * @he_data4: HE property of received frame
  549. * @he_data5: HE property of received frame
  550. * @he_data6: HE property of received frame
  551. * @he_per_user_1: HE per user info1
  552. * @he_per_user_2: HE per user info2
  553. * @he_per_user_position: HE per user position info
  554. * @he_per_user_known: HE per user known info
  555. * @rtap_flags: Bit map of available fields in the radiotap
  556. * @rs_flags: Flags to indicate AMPDU or AMSDU aggregation
  557. * @mpdu_cnt_fcs_ok: mpdu count received with fcs ok
  558. * @mpdu_cnt_fcs_err: mpdu count received with fcs ok bitmap
  559. * @mpdu_fcs_ok_bitmap: mpdu with fcs ok bitmap
  560. * @mpdu_ok_byte_count: mpdu byte count with fcs ok
  561. * @mpdu_err_byte_count: mpdu byte count with fcs err
  562. * @retry_mpdu: mpdu retry count
  563. * @start_seq: starting sequence number
  564. * @ba_control: Block ack control
  565. * @ba_bitmap: 256 bit block ack bitmap
  566. * @aid: Association ID
  567. * @mpdu_q: user mpdu_queue used for monitor
  568. */
  569. struct mon_rx_user_status {
  570. uint32_t mcs:4,
  571. nss:3,
  572. mu_ul_info_valid:1,
  573. ofdma_ru_start_index:7,
  574. ofdma_ru_width:7,
  575. ofdma_ru_size:8,
  576. is_ampdu:1;
  577. uint32_t mu_ul_user_v0_word0;
  578. uint32_t mu_ul_user_v0_word1;
  579. uint32_t ast_index : 16,
  580. sw_peer_id : 16;
  581. uint32_t tid : 4,
  582. preamble_type : 4,
  583. ht_flags : 1,
  584. vht_flags : 1,
  585. he_flags : 1,
  586. frame_control_info_valid : 1,
  587. frame_control : 16,
  588. data_sequence_control_info_valid : 1,
  589. ba_bitmap_sz : 2,
  590. filter_category : 2;
  591. uint16_t tcp_msdu_count;
  592. uint16_t udp_msdu_count;
  593. uint16_t other_msdu_count;
  594. uint16_t first_data_seq_ctrl;
  595. uint16_t duration;
  596. uint8_t vht_flag_values2;
  597. uint8_t vht_flag_values3[4];
  598. uint8_t vht_flag_values4;
  599. uint8_t vht_flag_values5;
  600. uint16_t vht_flag_values6;
  601. uint16_t he_flags1;
  602. uint16_t he_flags2;
  603. uint8_t he_RU[8];
  604. uint16_t he_data1;
  605. uint16_t he_data2;
  606. uint16_t he_data3;
  607. uint16_t he_data4;
  608. uint16_t he_data5;
  609. uint16_t he_data6;
  610. uint8_t he_per_user_1;
  611. uint8_t he_per_user_2;
  612. uint8_t he_per_user_position;
  613. uint8_t he_per_user_known;
  614. uint8_t rtap_flags;
  615. uint8_t rs_flags;
  616. uint16_t mpdu_cnt_fcs_ok;
  617. uint8_t mpdu_cnt_fcs_err;
  618. uint32_t mpdu_fcs_ok_bitmap[QDF_MON_STATUS_MPDU_FCS_BMAP_NWORDS];
  619. uint32_t mpdu_ok_byte_count;
  620. uint32_t mpdu_err_byte_count;
  621. uint16_t retry_mpdu;
  622. uint16_t start_seq;
  623. uint16_t ba_control;
  624. uint32_t ba_bitmap[8];
  625. uint16_t aid;
  626. qdf_nbuf_queue_t mpdu_q;
  627. };
  628. /**
  629. * struct qdf_radiotap_vendor_ns - Vendor Namespace header as per
  630. * Radiotap spec: https://www.radiotap.org/fields/Vendor%20Namespace.html
  631. * @oui: Vendor OUI
  632. * @selector: sub_namespace selector
  633. * @skip_length: How many bytes of Vendor Namespace data that follows
  634. */
  635. struct qdf_radiotap_vendor_ns {
  636. uint8_t oui[3];
  637. uint8_t selector;
  638. uint16_t skip_length;
  639. } __attribute__((__packed__));
  640. /**
  641. * struct qdf_radiotap_vendor_ns_ath - Combined QTI Vendor NS
  642. * including the Radiotap specified Vendor Namespace header and
  643. * QTI specific Vendor Namespace data
  644. * @hdr: radiotap vendor namespace header
  645. * @lsig: L_SIG_A (or L_SIG)
  646. * @device_id: Device Identification
  647. * @lsig_b: L_SIG_B
  648. * @ppdu_start_timestamp: Timestamp from RX_PPDU_START TLV
  649. */
  650. struct qdf_radiotap_vendor_ns_ath {
  651. struct qdf_radiotap_vendor_ns hdr;
  652. /* QTI specific data follows */
  653. uint32_t lsig;
  654. uint32_t device_id;
  655. uint32_t lsig_b;
  656. uint32_t ppdu_start_timestamp;
  657. } __attribute__((__packed__));
  658. /**
  659. * struct qdf_radiotap_ext2 - radiotap ext2 fields
  660. * @ppdu_id: ppdu_id of current msdu
  661. * @prev_ppdu_id: ppdu_id of previous msdu
  662. * @tid: tid number of previous msdu
  663. * @reserved: reserved bits
  664. * @start_seq: start sequence of previous msdu
  665. * @ba_bitmap: block ack bitmap of previous msdu
  666. */
  667. struct qdf_radiotap_ext2 {
  668. uint32_t ppdu_id;
  669. uint32_t prev_ppdu_id;
  670. uint16_t tid:8,
  671. reserved:8;
  672. uint16_t start_seq;
  673. uint32_t ba_bitmap[8];
  674. } __attribute__((__packed__));
  675. #define QDF_MEM_FUNC_NAME_SIZE 48
  676. /* Masks for HE SIG known fields in mon_rx_status structure */
  677. #define QDF_MON_STATUS_HE_SIG_B_COMMON_KNOWN_RU0 0x00000001
  678. #define QDF_MON_STATUS_HE_SIG_B_COMMON_KNOWN_RU1 0x00000002
  679. #define QDF_MON_STATUS_HE_SIG_B_COMMON_KNOWN_RU2 0x00000004
  680. #define QDF_MON_STATUS_HE_SIG_B_COMMON_KNOWN_RU3 0x00000008
  681. #define QDF_MON_STATUS_HE_SIG_B_USER_KNOWN_SIG_B_ALL 0x00fe0000
  682. #define QDF_MON_STATUS_HE_SIG_A1_HE_FORMAT_SU 0x00000000
  683. #define QDF_MON_STATUS_HE_SIG_A1_HE_FORMAT_EXT_SU 0x40000000
  684. #define QDF_MON_STATUS_HE_SIG_A1_HE_FORMAT_TRIG 0xc0000000
  685. /* DHCP Related Mask */
  686. #define QDF_DHCP_OPTION53 (0x35)
  687. #define QDF_DHCP_OPTION53_LENGTH (1)
  688. #define QDF_DHCP_OPTION53_OFFSET (0x11A)
  689. #define QDF_DHCP_OPTION53_LENGTH_OFFSET (0x11B)
  690. #define QDF_DHCP_OPTION53_STATUS_OFFSET (0x11C)
  691. #define DHCP_PKT_LEN_OFFSET 16
  692. #define DHCP_TRANSACTION_ID_OFFSET 46
  693. #define QDF_DHCP_DISCOVER (1)
  694. #define QDF_DHCP_OFFER (2)
  695. #define QDF_DHCP_REQUEST (3)
  696. #define QDF_DHCP_DECLINE (4)
  697. #define QDF_DHCP_ACK (5)
  698. #define QDF_DHCP_NAK (6)
  699. #define QDF_DHCP_RELEASE (7)
  700. #define QDF_DHCP_INFORM (8)
  701. /* ARP Related Mask */
  702. #define ARP_SUB_TYPE_OFFSET 20
  703. #define ARP_REQUEST (1)
  704. #define ARP_RESPONSE (2)
  705. /* IPV4 header fields offset values */
  706. #define IPV4_PKT_LEN_OFFSET 16
  707. #define IPV4_TCP_SEQ_NUM_OFFSET 38
  708. #define IPV4_SRC_ADDR_OFFSET 26
  709. #define IPV4_DST_ADDR_OFFSET 30
  710. #define IPV4_SRC_PORT_OFFSET 34
  711. #define IPV4_DST_PORT_OFFSET 36
  712. /* IPV4 ICMP Related Mask */
  713. #define ICMP_ID_OFFSET 38
  714. #define ICMP_SEQ_NUM_OFFSET 40
  715. #define ICMP_SUBTYPE_OFFSET 34
  716. #define ICMP_REQUEST 0x08
  717. #define ICMP_RESPONSE 0x00
  718. #define IPV6_ADDR_STR "%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:"\
  719. "%02x%02x:%02x%02x"
  720. /* IPV6 header fields offset values */
  721. #define IPV6_PKT_LEN_OFFSET 18
  722. #define IPV6_TCP_SEQ_NUM_OFFSET 58
  723. #define IPV6_SRC_ADDR_OFFSET 22
  724. #define IPV6_DST_ADDR_OFFSET 38
  725. #define IPV6_SRC_PORT_OFFSET 54
  726. #define IPV6_DST_PORT_OFFSET 56
  727. /* IPV6 ICMPV6 Related Mask */
  728. #define ICMPV6_REDIRECT 137
  729. #define ICMPV6_SEQ_NUM_OFFSET 60
  730. #define ICMPV6_SUBTYPE_OFFSET 54
  731. #define ICMPV6_REQUEST 0x80
  732. #define ICMPV6_RESPONSE 0x81
  733. #define ICMPV6_RS 0x85
  734. #define ICMPV6_RA 0x86
  735. #define ICMPV6_NS 0x87
  736. #define ICMPV6_NA 0x88
  737. #define QDF_NBUF_IPA_CHECK_MASK 0x80000000
  738. /* HE Radiotap data1 Mask */
  739. #define QDF_MON_STATUS_HE_SU_FORMAT_TYPE 0x0000
  740. #define QDF_MON_STATUS_HE_EXT_SU_FORMAT_TYPE 0x0001
  741. #define QDF_MON_STATUS_HE_MU_FORMAT_TYPE 0x0002
  742. #define QDF_MON_STATUS_HE_TRIG_FORMAT_TYPE 0x0003
  743. #define QDF_MON_STATUS_HE_BEAM_CHANGE_KNOWN 0x0008
  744. #define QDF_MON_STATUS_HE_DL_UL_KNOWN 0x0010
  745. #define QDF_MON_STATUS_HE_MCS_KNOWN 0x0020
  746. #define QDF_MON_STATUS_HE_DCM_KNOWN 0x0040
  747. #define QDF_MON_STATUS_HE_CODING_KNOWN 0x0080
  748. #define QDF_MON_STATUS_HE_LDPC_EXTRA_SYMBOL_KNOWN 0x0100
  749. #define QDF_MON_STATUS_HE_STBC_KNOWN 0x0200
  750. #define QDF_MON_STATUS_HE_SPATIAL_REUSE_1_KNOWN 0x0400
  751. #define QDF_MON_STATUS_HE_SPATIAL_REUSE_2_KNOWN 0x0800
  752. #define QDF_MON_STATUS_HE_SPATIAL_REUSE_3_KNOWN 0x1000
  753. #define QDF_MON_STATUS_HE_SPATIAL_REUSE_4_KNOWN 0x2000
  754. #define QDF_MON_STATUS_HE_DATA_BW_RU_KNOWN 0x4000
  755. #define QDF_MON_STATUS_HE_DOPPLER_KNOWN 0x8000
  756. #define QDF_MON_STATUS_HE_BSS_COLOR_KNOWN 0x0004
  757. /* HE Radiotap data2 Mask */
  758. #define QDF_MON_STATUS_HE_GI_KNOWN 0x0002
  759. #define QDF_MON_STATUS_TXBF_KNOWN 0x0010
  760. #define QDF_MON_STATUS_PE_DISAMBIGUITY_KNOWN 0x0020
  761. #define QDF_MON_STATUS_TXOP_KNOWN 0x0040
  762. #define QDF_MON_STATUS_LTF_SYMBOLS_KNOWN 0x0004
  763. #define QDF_MON_STATUS_PRE_FEC_PADDING_KNOWN 0x0008
  764. #define QDF_MON_STATUS_MIDABLE_PERIODICITY_KNOWN 0x0080
  765. #define QDF_MON_STATUS_RU_ALLOCATION_OFFSET_KNOWN 0x4000
  766. #define QDF_MON_STATUS_RU_ALLOCATION_SHIFT 8
  767. /* HE radiotap data3 shift values */
  768. #define QDF_MON_STATUS_BEAM_CHANGE_SHIFT 6
  769. #define QDF_MON_STATUS_DL_UL_SHIFT 7
  770. #define QDF_MON_STATUS_TRANSMIT_MCS_SHIFT 8
  771. #define QDF_MON_STATUS_DCM_SHIFT 12
  772. #define QDF_MON_STATUS_CODING_SHIFT 13
  773. #define QDF_MON_STATUS_LDPC_EXTRA_SYMBOL_SHIFT 14
  774. #define QDF_MON_STATUS_STBC_SHIFT 15
  775. /* HE radiotap data4 shift values */
  776. #define QDF_MON_STATUS_STA_ID_SHIFT 4
  777. /* HE radiotap data5 */
  778. #define QDF_MON_STATUS_GI_SHIFT 4
  779. #define QDF_MON_STATUS_HE_LTF_SIZE_SHIFT 6
  780. #define QDF_MON_STATUS_HE_LTF_SYM_SHIFT 8
  781. #define QDF_MON_STATUS_TXBF_SHIFT 14
  782. #define QDF_MON_STATUS_PE_DISAMBIGUITY_SHIFT 15
  783. #define QDF_MON_STATUS_PRE_FEC_PAD_SHIFT 12
  784. /* HE radiotap data6 */
  785. #define QDF_MON_STATUS_HE_DATA_6_NSS_SHIFT 0
  786. #define QDF_MON_STATUS_DOPPLER_SHIFT 4
  787. #define QDF_MON_STATUS_TXOP_SHIFT 8
  788. /* HE radiotap HE-MU flags1 */
  789. #define QDF_MON_STATUS_SIG_B_MCS_SHIFT 0x0000
  790. #define QDF_MON_STATUS_SIG_B_MCS_KNOWN 0x0010
  791. #define QDF_MON_STATUS_SIG_B_DCM_SHIFT 5
  792. #define QDF_MON_STATUS_SIG_B_DCM_KNOWN 0x0040
  793. #define QDF_MON_STATUS_CHANNEL_2_CENTER_26_RU_KNOWN 0x0080
  794. #define QDF_MON_STATUS_CHANNEL_1_RU_KNOWN 0x0100
  795. #define QDF_MON_STATUS_CHANNEL_2_RU_KNOWN 0x0200
  796. #define QDF_MON_STATUS_CHANNEL_1_CENTER_26_RU_KNOWN 0x1000
  797. #define QDF_MON_STATUS_CHANNEL_1_CENTER_26_RU_VALUE 0x2000
  798. #define QDF_MON_STATUS_CHANNEL_1_CENTER_26_RU_SHIFT 13
  799. #define QDF_MON_STATUS_SIG_B_SYM_NUM_KNOWN 0x8000
  800. #define QDF_MON_STATUS_RU_0_KNOWN 0x0100
  801. #define QDF_MON_STATUS_RU_1_KNOWN 0x0200
  802. #define QDF_MON_STATUS_RU_2_KNOWN 0x0400
  803. #define QDF_MON_STATUS_RU_3_KNOWN 0x0800
  804. #define QDF_MON_STATUS_DCM_FLAG_1_SHIFT 5
  805. #define QDF_MON_STATUS_SPATIAL_REUSE_MU_KNOWN 0x0100
  806. #define QDF_MON_STATUS_SIG_B_COMPRESSION_FLAG_1_KNOWN 0x4000
  807. #define QDF_MON_STATUS_SIG_B_SYMBOL_USER_KNOWN 0x8000
  808. /* HE radiotap HE-MU flags2 */
  809. #define QDF_MON_STATUS_SIG_A_BANDWIDTH_KNOWN 0x0004
  810. #define QDF_MON_STATUS_SIG_A_BANDWIDTH_SHIFT 0
  811. #define QDF_MON_STATUS_SIG_B_COMPRESSION_FLAG_2_SHIFT 3
  812. #define QDF_MON_STATUS_BW_KNOWN 0x0004
  813. #define QDF_MON_STATUS_NUM_SIG_B_SYMBOLS_SHIFT 4
  814. #define QDF_MON_STATUS_SIG_B_COMPRESSION_FLAG_2_KNOWN 0x0100
  815. #define QDF_MON_STATUS_NUM_SIG_B_FLAG_2_SHIFT 9
  816. #define QDF_MON_STATUS_SIG_A_PUNC_BANDWIDTH_KNOWN 0x0400
  817. #define QDF_MON_STATUS_SIG_A_PUNC_BANDWIDTH_SHIFT 8
  818. #define QDF_MON_STATUS_CHANNEL_2_CENTER_26_RU_VALUE 0x0800
  819. #define QDF_MON_STATUS_CHANNEL_2_CENTER_26_RU_SHIFT 11
  820. #define QDF_MON_STATUS_LTF_FLAG_2_SYMBOLS_SHIFT 12
  821. #define QDF_MON_STATUS_LTF_KNOWN 0x8000
  822. /* HE radiotap per_user_1 */
  823. #define QDF_MON_STATUS_STA_SPATIAL_SHIFT 11
  824. #define QDF_MON_STATUS_TXBF_SHIFT 14
  825. #define QDF_MON_STATUS_RESERVED_SET_TO_1_SHIFT 19
  826. #define QDF_MON_STATUS_STA_CODING_SHIFT 20
  827. /* HE radiotap per_user_2 */
  828. #define QDF_MON_STATUS_STA_MCS_SHIFT 4
  829. #define QDF_MON_STATUS_STA_DCM_SHIFT 5
  830. /* HE radiotap per user known */
  831. #define QDF_MON_STATUS_USER_FIELD_POSITION_KNOWN 0x01
  832. #define QDF_MON_STATUS_STA_ID_PER_USER_KNOWN 0x02
  833. #define QDF_MON_STATUS_STA_NSTS_KNOWN 0x04
  834. #define QDF_MON_STATUS_STA_TX_BF_KNOWN 0x08
  835. #define QDF_MON_STATUS_STA_SPATIAL_CONFIG_KNOWN 0x10
  836. #define QDF_MON_STATUS_STA_MCS_KNOWN 0x20
  837. #define QDF_MON_STATUS_STA_DCM_KNOWN 0x40
  838. #define QDF_MON_STATUS_STA_CODING_KNOWN 0x80
  839. /* U-SIG Common Mask */
  840. #define QDF_MON_STATUS_USIG_PHY_VERSION_KNOWN 0x00000001
  841. #define QDF_MON_STATUS_USIG_BW_KNOWN 0x00000002
  842. #define QDF_MON_STATUS_USIG_UL_DL_KNOWN 0x00000004
  843. #define QDF_MON_STATUS_USIG_BSS_COLOR_KNOWN 0x00000008
  844. #define QDF_MON_STATUS_USIG_TXOP_KNOWN 0x00000010
  845. #define QDF_MON_STATUS_USIG_PHY_VERSION_SHIFT 12
  846. #define QDF_MON_STATUS_USIG_BW_SHIFT 15
  847. #define QDF_MON_STATUS_USIG_UL_DL_SHIFT 18
  848. #define QDF_MON_STATUS_USIG_BSS_COLOR_SHIFT 19
  849. #define QDF_MON_STATUS_USIG_TXOP_SHIFT 25
  850. /* U-SIG MU/TB Value */
  851. #define QDF_MON_STATUS_USIG_DISREGARD_SHIFT 0
  852. #define QDF_MON_STATUS_USIG_PPDU_TYPE_N_COMP_MODE_SHIFT 6
  853. #define QDF_MON_STATUS_USIG_VALIDATE_SHIFT 8
  854. #define QDF_MON_STATUS_USIG_MU_VALIDATE1_SHIFT 5
  855. #define QDF_MON_STATUS_USIG_MU_PUNCTURE_CH_INFO_SHIFT 9
  856. #define QDF_MON_STATUS_USIG_MU_VALIDATE2_SHIFT 14
  857. #define QDF_MON_STATUS_USIG_MU_EHT_SIG_MCS_SHIFT 15
  858. #define QDF_MON_STATUS_USIG_MU_NUM_EHT_SIG_SYM_SHIFT 17
  859. #define QDF_MON_STATUS_USIG_TB_SPATIAL_REUSE_1_SHIFT 9
  860. #define QDF_MON_STATUS_USIG_TB_SPATIAL_REUSE_2_SHIFT 13
  861. #define QDF_MON_STATUS_USIG_TB_DISREGARD1_SHIFT 17
  862. #define QDF_MON_STATUS_USIG_CRC_SHIFT 22
  863. #define QDF_MON_STATUS_USIG_TAIL_SHIFT 26
  864. /* U-SIG MU/TB Mask */
  865. #define QDF_MON_STATUS_USIG_DISREGARD_KNOWN 0x00000001
  866. #define QDF_MON_STATUS_USIG_PPDU_TYPE_N_COMP_MODE_KNOWN 0x00000004
  867. #define QDF_MON_STATUS_USIG_VALIDATE_KNOWN 0x00000008
  868. #define QDF_MON_STATUS_USIG_MU_VALIDATE1_KNOWN 0x00000002
  869. #define QDF_MON_STATUS_USIG_MU_PUNCTURE_CH_INFO_KNOWN 0x00000010
  870. #define QDF_MON_STATUS_USIG_MU_VALIDATE2_KNOWN 0x00000020
  871. #define QDF_MON_STATUS_USIG_MU_EHT_SIG_MCS_KNOWN 0x00000040
  872. #define QDF_MON_STATUS_USIG_MU_NUM_EHT_SIG_SYM_KNOWN 0x00000080
  873. #define QDF_MON_STATUS_USIG_TB_SPATIAL_REUSE_1_KNOWN 0x00000010
  874. #define QDF_MON_STATUS_USIG_TB_SPATIAL_REUSE_2_KNOWN 0x00000020
  875. #define QDF_MON_STATUS_USIG_TB_DISREGARD1_KNOWN 0x00000040
  876. #define QDF_MON_STATUS_USIG_CRC_KNOWN 0x00000100
  877. #define QDF_MON_STATUS_USIG_TAIL_KNOWN 0x00000200
  878. /* EHT known Mask */
  879. #define QDF_MON_STATUS_EHT_CONTENT_CH_INDEX_KNOWN 0x00000001
  880. #define QDF_MON_STATUS_EHT_SPATIAL_REUSE_KNOWN 0x00000002
  881. #define QDF_MON_STATUS_EHT_GUARD_INTERVAL_KNOWN 0x00000004
  882. #define QDF_MON_STATUS_EHT_LTF_KNOWN 0x00000008
  883. #define QDF_MON_STATUS_EHT_EHT_LTF_KNOWN 0x00000010
  884. #define QDF_MON_STATUS_EHT_LDPC_EXTRA_SYMBOL_SEG_KNOWN 0x00000020
  885. #define QDF_MON_STATUS_EHT_PRE_FEC_PADDING_FACTOR_KNOWN 0x00000040
  886. #define QDF_MON_STATUS_EHT_PE_DISAMBIGUITY_KNOWN 0x00000080
  887. #define QDF_MON_STATUS_EHT_DISREARD_KNOWN 0x00000100
  888. #define QDF_MON_STATUS_EHT_CRC1_KNOWN 0x00002000
  889. #define QDF_MON_STATUS_EHT_TAIL1_KNOWN 0x00004000
  890. #define QDF_MON_STATUS_EHT_CRC2_KNOWN 0x00008000
  891. #define QDF_MON_STATUS_EHT_TAIL2_KNOWN 0x00010000
  892. #define QDF_MON_STATUS_EHT_RU_MRU_SIZE_KNOWN 0x00400000
  893. #define QDF_MON_STATUS_EHT_RU_MRU_INDEX_KNOWN 0x00800000
  894. #define QDF_MON_STATUS_EHT_TB_RU_ALLOCATION_KNOWN 0x01000000
  895. #define QDF_MON_STATUS_EHT_NUM_NON_OFDMA_USERS_KNOWN 0x00080000
  896. #define QDF_MON_STATUS_EHT_USER_ENC_BLOCK_CRC_KNOWN 0x00100000
  897. #define QDF_MON_STATUS_EHT_USER_ENC_BLOCK_TAIL_KNOWN 0x00200000
  898. #define QDF_MON_STATUS_EHT_NDP_DISREGARD_KNOWN 0x00000200
  899. #define QDF_MON_STATUS_EHT_NDP_NSS_KNOWN 0x00020000
  900. #define QDF_MON_STATUS_EHT_NDP_BEAMFORMED_KNOWN 0x00040000
  901. #define QDF_MON_STATUS_EHT_NUM_KNOWN_RU_ALLOCATIONS_SHIFT 10
  902. /* EHT data0 Mask/SHIFT */
  903. #define QDF_MON_STATUS_EHT_CONTENT_CH_INDEX_SHIFT 0
  904. #define QDF_MON_STATUS_EHT_SPATIAL_REUSE_SHIFT 3
  905. #define QDF_MON_STATUS_EHT_GI_SHIFT 7
  906. #define QDF_MON_STATUS_EHT_LTF_SHIFT 9
  907. #define QDF_MON_STATUS_EHT_EHT_LTF_SHIFT 11
  908. #define QDF_MON_STATUS_EHT_LDPC_EXTRA_SYMBOL_SEG_SHIFT 14
  909. #define QDF_MON_STATUS_EHT_PRE_FEC_PADDING_FACTOR_SHIFT 15
  910. #define QDF_MON_STATUS_EHT_PE_DISAMBIGUITY_SHIFT 17
  911. #define QDF_MON_STATUS_EHT_NDP_DISREGARD_SHIFT 18
  912. #define QDF_MON_STATUS_EHT_DISREGARD_SHIFT 18
  913. #define QDF_MON_STATUS_EHT_CRC1_SHIFT 22
  914. #define QDF_MON_STATUS_EHT_TAIL1_SHIFT 26
  915. /* EHT data1 Mask/SHIFT */
  916. #define QDF_MON_STATUS_EHT_RU_MRU_SIZE_SHIFT 0
  917. #define QDF_MON_STATUS_EHT_RU_MRU_INDEX_SHIFT 5
  918. #define QDF_MON_STATUS_EHT_RU_ALLOCATION1_1_SHIFT 13
  919. #define QDF_MON_STATUS_EHT_RU_ALLOCATION1_2_SHIFT 22
  920. /* EHT data2 Mask/SHIFT */
  921. #define QDF_MON_STATUS_EHT_RU_ALLOCATION2_1_SHIFT 0
  922. #define QDF_MON_STATUS_EHT_RU_ALLOCATION2_2_SHIFT 9
  923. #define QDF_MON_STATUS_EHT_RU_ALLOCATION2_3_SHIFT 18
  924. /* EHT data3 Mask/SHIFT */
  925. #define QDF_MON_STATUS_EHT_RU_ALLOCATION2_4_SHIFT 0
  926. #define QDF_MON_STATUS_EHT_RU_ALLOCATION2_5_SHIFT 9
  927. #define QDF_MON_STATUS_EHT_RU_ALLOCATION2_6_SHIFT 18
  928. /* EHT data4 Mask/SHIFT */
  929. #define QDF_MON_STATUS_EHT_CRC2_SHIFT 0
  930. #define QDF_MON_STATUS_EHT_TAIL2_SHIFT 4
  931. #define QDF_MON_STATUS_EHT_NDP_NSS_SHIFT 12
  932. #define QDF_MON_STATUS_EHT_NDP_BEAMFORMED_SHIFT 16
  933. #define QDF_MON_STATUS_EHT_NUM_NON_OFDMA_USERS_SHIFT 17
  934. #define QDF_MON_STATUS_EHT_USER_ENC_BLOCK_CRC_SHIFT 20
  935. #define QDF_MON_STATUS_EHT_USER_ENC_BLOCK_TAIL_SHIFT 24
  936. /* EHT data5 Mask/SHIFT */
  937. #define QDF_MON_STATUS_EHT_TB_RU_PS160_SHIFT 0
  938. #define QDF_MON_STATUS_EHT_TB_RU_PS80_SHIFT 1
  939. #define QDF_MON_STATUS_EHT_TB_RU_B7_B1_SHIFT 2
  940. /* EHT user info Mask/SHIFT */
  941. #define QDF_MON_STATUS_EHT_USER_STA_ID_KNOWN 0x00000001
  942. #define QDF_MON_STATUS_EHT_USER_MCS_KNOWN 0x00000002
  943. #define QDF_MON_STATUS_EHT_USER_CODING_KNOWN 0x00000004
  944. #define QDF_MON_STATUS_EHT_USER_RESERVED_KNOWN 0x00000008
  945. #define QDF_MON_STATUS_EHT_USER_NSS_KNOWN 0x00000010
  946. #define QDF_MON_STATUS_EHT_USER_BEAMFORMING_KNOWN 0x00000020
  947. #define QDF_MON_STATUS_EHT_USER_SPATIAL_CONFIG_KNOWN 0x00000040
  948. #define QDF_MON_STATUS_EHT_USER_DATA_FOR_THIS_USER_SHIFT 7
  949. #define QDF_MON_STATUS_EHT_USER_STA_ID_SHIFT 8
  950. #define QDF_MON_STATUS_EHT_USER_CODING_SHIFT 19
  951. #define QDF_MON_STATUS_EHT_USER_MCS_SHIFT 20
  952. #define QDF_MON_STATUS_EHT_USER_NSS_SHIFT 24
  953. #define QDF_MON_STATUS_EHT_USER_RESERVED_SHIFT 28
  954. #define QDF_MON_STATUS_EHT_USER_BEAMFORMING_SHIFT 29
  955. #define QDF_MON_STATUS_EHT_USER_SPATIAL_CONFIG_SHIFT 24
  956. /**
  957. * enum qdf_proto_type - protocol type
  958. * @QDF_PROTO_TYPE_DHCP: DHCP
  959. * @QDF_PROTO_TYPE_EAPOL: EAPOL
  960. * @QDF_PROTO_TYPE_ARP: ARP
  961. * @QDF_PROTO_TYPE_MGMT: MGMT
  962. * @QDF_PROTO_TYPE_ICMP: ICMP
  963. * @QDF_PROTO_TYPE_ICMPv6: ICMPv6
  964. * @QDF_PROTO_TYPE_EVENT: EVENT
  965. * @QDF_PROTO_TYPE_DNS: DNS
  966. * @QDF_PROTO_TYPE_MAX: Max enumeration
  967. */
  968. enum qdf_proto_type {
  969. QDF_PROTO_TYPE_DHCP,
  970. QDF_PROTO_TYPE_EAPOL,
  971. QDF_PROTO_TYPE_ARP,
  972. QDF_PROTO_TYPE_MGMT,
  973. QDF_PROTO_TYPE_ICMP,
  974. QDF_PROTO_TYPE_ICMPv6,
  975. QDF_PROTO_TYPE_EVENT,
  976. QDF_PROTO_TYPE_DNS,
  977. QDF_PROTO_TYPE_MAX
  978. };
  979. /**
  980. * enum qdf_reception_type - reception type used by lithium phy TLV
  981. * @QDF_RECEPTION_TYPE_ULOFMDA: UL OFDMA
  982. * @QDF_RECEPTION_TYPE_ULMIMO: UL MIMO
  983. * @QDF_RECEPTION_TYPE_FRAMELESS: Frame less
  984. * @QDF_RECEPTION_TYPE_OTHER: All the other types
  985. */
  986. enum qdf_reception_type {
  987. QDF_RECEPTION_TYPE_ULOFMDA,
  988. QDF_RECEPTION_TYPE_ULMIMO,
  989. QDF_RECEPTION_TYPE_OTHER,
  990. QDF_RECEPTION_TYPE_FRAMELESS
  991. };
  992. /**
  993. * enum cb_ftype - Frame type information in skb cb
  994. * @CB_FTYPE_INVALID: Invalid
  995. * @CB_FTYPE_MCAST2UCAST: Multicast to Unicast converted packet
  996. * @CB_FTYPE_TSO: TCP Segmentation Offload
  997. * @CB_FTYPE_TSO_SG: TSO Scatter Gather
  998. * @CB_FTYPE_SG: Scatter Gather
  999. * @CB_FTYPE_INTRABSS_FWD: Intra BSS forwarding
  1000. * @CB_FTYPE_RX_INFO: Rx information
  1001. * @CB_FTYPE_MESH_RX_INFO: Mesh Rx information
  1002. * @CB_FTYPE_MESH_TX_INFO: Mesh Tx information
  1003. * @CB_FTYPE_DMS: Directed Multicast Service
  1004. * @CB_FTYPE_SAWF: SAWF information
  1005. * @CB_FTYPE_MLO_MCAST: MLO MCAST enable information
  1006. */
  1007. enum cb_ftype {
  1008. CB_FTYPE_INVALID = 0,
  1009. CB_FTYPE_MCAST2UCAST = 1,
  1010. CB_FTYPE_TSO = 2,
  1011. CB_FTYPE_TSO_SG = 3,
  1012. CB_FTYPE_SG = 4,
  1013. CB_FTYPE_INTRABSS_FWD = 5,
  1014. CB_FTYPE_RX_INFO = 6,
  1015. CB_FTYPE_MESH_RX_INFO = 7,
  1016. CB_FTYPE_MESH_TX_INFO = 8,
  1017. CB_FTYPE_DMS = 9,
  1018. CB_FTYPE_SAWF = 10,
  1019. CB_FTYPE_MLO_MCAST = 11,
  1020. };
  1021. /**
  1022. * typedef qdf_nbuf_t - Platform independent packet abstraction
  1023. */
  1024. typedef __qdf_nbuf_t qdf_nbuf_t;
  1025. /**
  1026. * typedef qdf_nbuf_shared_info_t - Platform independent shared info
  1027. */
  1028. typedef __qdf_nbuf_shared_info_t qdf_nbuf_shared_info_t;
  1029. /**
  1030. * struct qdf_nbuf_track_t - Network buffer track structure
  1031. *
  1032. * @p_next: Pointer to next
  1033. * @net_buf: Pointer to network buffer
  1034. * @func_name: Function name
  1035. * @line_num: Line number
  1036. * @size: Size
  1037. * @map_func_name: nbuf mapping function name
  1038. * @map_line_num: mapping function line number
  1039. * @unmap_func_name: nbuf unmapping function name
  1040. * @unmap_line_num: mapping function line number
  1041. * @is_nbuf_mapped: indicate mapped/unmapped nbuf
  1042. * @time: mapping function timestamp
  1043. * @smmu_map_line_num: smmu mapping line number
  1044. * @smmu_unmap_line_num: smmu unmapping line number
  1045. * @smmu_map_func_name: smmu mapping function name
  1046. * @smmu_unmap_func_name: smmu unmapping function name
  1047. * @is_nbuf_smmu_mapped: nbuf is smmu mapped
  1048. * @smmu_map_iova_addr: nbuf smmu map virtual address
  1049. * @smmu_map_pa_addr: nbuf smmu map physical address
  1050. * @smmu_unmap_iova_addr: nbuf smmu unmap virtual address
  1051. * @smmu_unmap_pa_addr: nbuf smmu unmap physical address
  1052. */
  1053. struct qdf_nbuf_track_t {
  1054. struct qdf_nbuf_track_t *p_next;
  1055. qdf_nbuf_t net_buf;
  1056. char func_name[QDF_MEM_FUNC_NAME_SIZE];
  1057. uint32_t line_num;
  1058. size_t size;
  1059. char map_func_name[QDF_MEM_FUNC_NAME_SIZE];
  1060. uint32_t map_line_num;
  1061. char unmap_func_name[QDF_MEM_FUNC_NAME_SIZE];
  1062. uint32_t unmap_line_num;
  1063. bool is_nbuf_mapped;
  1064. qdf_time_t time;
  1065. #ifdef NBUF_SMMU_MAP_UNMAP_DEBUG
  1066. uint32_t smmu_map_line_num;
  1067. uint32_t smmu_unmap_line_num;
  1068. char smmu_map_func_name[QDF_MEM_FUNC_NAME_SIZE];
  1069. char smmu_unmap_func_name[QDF_MEM_FUNC_NAME_SIZE];
  1070. bool is_nbuf_smmu_mapped;
  1071. unsigned long smmu_map_iova_addr;
  1072. unsigned long smmu_map_pa_addr;
  1073. unsigned long smmu_unmap_iova_addr;
  1074. unsigned long smmu_unmap_pa_addr;
  1075. #endif
  1076. };
  1077. typedef struct qdf_nbuf_track_t QDF_NBUF_TRACK;
  1078. /**
  1079. * typedef qdf_nbuf_queue_head_t - Platform independent nbuf queue head
  1080. */
  1081. typedef __qdf_nbuf_queue_head_t qdf_nbuf_queue_head_t;
  1082. /**
  1083. * typedef qdf_dma_map_cb_t() - Dma map callback prototype
  1084. * @arg: callback context
  1085. * @buf: netbuf
  1086. * @dmap: DMA map
  1087. */
  1088. typedef void (*qdf_dma_map_cb_t)(void *arg, qdf_nbuf_t buf,
  1089. qdf_dma_map_t dmap);
  1090. /* BUS/DMA mapping routines */
  1091. static inline QDF_STATUS
  1092. qdf_nbuf_dmamap_create(qdf_device_t osdev, qdf_dma_map_t *dmap)
  1093. {
  1094. return __qdf_nbuf_dmamap_create(osdev, dmap);
  1095. }
  1096. static inline void
  1097. qdf_nbuf_dmamap_destroy(qdf_device_t osdev, qdf_dma_map_t dmap)
  1098. {
  1099. __qdf_nbuf_dmamap_destroy(osdev, dmap);
  1100. }
  1101. static inline void
  1102. qdf_nbuf_dmamap_set_cb(qdf_dma_map_t dmap, qdf_dma_map_cb_t cb, void *arg)
  1103. {
  1104. __qdf_nbuf_dmamap_set_cb(dmap, cb, arg);
  1105. }
  1106. static inline void
  1107. qdf_nbuf_set_send_complete_flag(qdf_nbuf_t buf, bool flag)
  1108. {
  1109. __qdf_nbuf_set_send_complete_flag(buf, flag);
  1110. }
  1111. #define QDF_NBUF_QUEUE_WALK_SAFE(queue, var, tvar) \
  1112. __qdf_nbuf_queue_walk_safe(queue, var, tvar)
  1113. #ifdef NBUF_MAP_UNMAP_DEBUG
  1114. /**
  1115. * qdf_nbuf_map_check_for_leaks() - check for nbuf map leaks
  1116. *
  1117. * Check for net buffers that have been mapped, but never unmapped.
  1118. *
  1119. * Returns: None
  1120. */
  1121. void qdf_nbuf_map_check_for_leaks(void);
  1122. QDF_STATUS qdf_nbuf_map_debug(qdf_device_t osdev,
  1123. qdf_nbuf_t buf,
  1124. qdf_dma_dir_t dir,
  1125. const char *func,
  1126. uint32_t line);
  1127. #define qdf_nbuf_map(osdev, buf, dir) \
  1128. qdf_nbuf_map_debug(osdev, buf, dir, __func__, __LINE__)
  1129. void qdf_nbuf_unmap_debug(qdf_device_t osdev,
  1130. qdf_nbuf_t buf,
  1131. qdf_dma_dir_t dir,
  1132. const char *func,
  1133. uint32_t line);
  1134. #define qdf_nbuf_unmap(osdev, buf, dir) \
  1135. qdf_nbuf_unmap_debug(osdev, buf, dir, __func__, __LINE__)
  1136. QDF_STATUS qdf_nbuf_map_single_debug(qdf_device_t osdev,
  1137. qdf_nbuf_t buf,
  1138. qdf_dma_dir_t dir,
  1139. const char *func,
  1140. uint32_t line);
  1141. #define qdf_nbuf_map_single(osdev, buf, dir) \
  1142. qdf_nbuf_map_single_debug(osdev, buf, dir, __func__, __LINE__)
  1143. void qdf_nbuf_unmap_single_debug(qdf_device_t osdev,
  1144. qdf_nbuf_t buf,
  1145. qdf_dma_dir_t dir,
  1146. const char *func,
  1147. uint32_t line);
  1148. #define qdf_nbuf_unmap_single(osdev, buf, dir) \
  1149. qdf_nbuf_unmap_single_debug(osdev, buf, dir, __func__, __LINE__)
  1150. QDF_STATUS qdf_nbuf_map_nbytes_debug(qdf_device_t osdev,
  1151. qdf_nbuf_t buf,
  1152. qdf_dma_dir_t dir,
  1153. int nbytes,
  1154. const char *func,
  1155. uint32_t line);
  1156. #define qdf_nbuf_map_nbytes(osdev, buf, dir, nbytes) \
  1157. qdf_nbuf_map_nbytes_debug(osdev, buf, dir, nbytes, __func__, __LINE__)
  1158. void qdf_nbuf_unmap_nbytes_debug(qdf_device_t osdev,
  1159. qdf_nbuf_t buf,
  1160. qdf_dma_dir_t dir,
  1161. int nbytes,
  1162. const char *func,
  1163. uint32_t line);
  1164. #define qdf_nbuf_unmap_nbytes(osdev, buf, dir, nbytes) \
  1165. qdf_nbuf_unmap_nbytes_debug(osdev, buf, dir, nbytes, __func__, __LINE__)
  1166. QDF_STATUS qdf_nbuf_map_nbytes_single_debug(qdf_device_t osdev,
  1167. qdf_nbuf_t buf,
  1168. qdf_dma_dir_t dir,
  1169. int nbytes,
  1170. const char *func,
  1171. uint32_t line);
  1172. #define qdf_nbuf_map_nbytes_single(osdev, buf, dir, nbytes) \
  1173. qdf_nbuf_map_nbytes_single_debug(osdev, buf, dir, nbytes, \
  1174. __func__, __LINE__)
  1175. void qdf_nbuf_unmap_nbytes_single_debug(qdf_device_t osdev,
  1176. qdf_nbuf_t buf,
  1177. qdf_dma_dir_t dir,
  1178. int nbytes,
  1179. const char *func,
  1180. uint32_t line);
  1181. #define qdf_nbuf_unmap_nbytes_single(osdev, buf, dir, nbytes) \
  1182. qdf_nbuf_unmap_nbytes_single_debug(osdev, buf, dir, nbytes, \
  1183. __func__, __LINE__)
  1184. void qdf_nbuf_unmap_nbytes_single_paddr_debug(qdf_device_t osdev,
  1185. qdf_nbuf_t buf,
  1186. qdf_dma_addr_t phy_addr,
  1187. qdf_dma_dir_t dir, int nbytes,
  1188. const char *func, uint32_t line);
  1189. #define qdf_nbuf_unmap_nbytes_single_paddr(osdev, buf, phy_addr, dir, nbytes) \
  1190. qdf_nbuf_unmap_nbytes_single_paddr_debug(osdev, buf, phy_addr, \
  1191. dir, nbytes, __func__, \
  1192. __LINE__)
  1193. #else /* NBUF_MAP_UNMAP_DEBUG */
  1194. static inline void qdf_nbuf_map_check_for_leaks(void) {}
  1195. static inline QDF_STATUS
  1196. qdf_nbuf_map(qdf_device_t osdev, qdf_nbuf_t buf, qdf_dma_dir_t dir)
  1197. {
  1198. return __qdf_nbuf_map(osdev, buf, dir);
  1199. }
  1200. static inline void
  1201. qdf_nbuf_unmap(qdf_device_t osdev, qdf_nbuf_t buf, qdf_dma_dir_t dir)
  1202. {
  1203. __qdf_nbuf_unmap(osdev, buf, dir);
  1204. }
  1205. static inline QDF_STATUS
  1206. qdf_nbuf_map_single(qdf_device_t osdev, qdf_nbuf_t buf, qdf_dma_dir_t dir)
  1207. {
  1208. return __qdf_nbuf_map_single(osdev, buf, dir);
  1209. }
  1210. static inline void
  1211. qdf_nbuf_unmap_single(qdf_device_t osdev, qdf_nbuf_t buf, qdf_dma_dir_t dir)
  1212. {
  1213. __qdf_nbuf_unmap_single(osdev, buf, dir);
  1214. }
  1215. static inline QDF_STATUS
  1216. qdf_nbuf_map_nbytes(qdf_device_t osdev, qdf_nbuf_t buf,
  1217. qdf_dma_dir_t dir, int nbytes)
  1218. {
  1219. return __qdf_nbuf_map_nbytes(osdev, buf, dir, nbytes);
  1220. }
  1221. static inline void
  1222. qdf_nbuf_unmap_nbytes(qdf_device_t osdev,
  1223. qdf_nbuf_t buf, qdf_dma_dir_t dir, int nbytes)
  1224. {
  1225. __qdf_nbuf_unmap_nbytes(osdev, buf, dir, nbytes);
  1226. }
  1227. static inline QDF_STATUS
  1228. qdf_nbuf_map_nbytes_single(
  1229. qdf_device_t osdev, qdf_nbuf_t buf, qdf_dma_dir_t dir, int nbytes)
  1230. {
  1231. return __qdf_nbuf_map_nbytes_single(osdev, buf, dir, nbytes);
  1232. }
  1233. static inline void
  1234. qdf_nbuf_unmap_nbytes_single(
  1235. qdf_device_t osdev, qdf_nbuf_t buf, qdf_dma_dir_t dir, int nbytes)
  1236. {
  1237. return __qdf_nbuf_unmap_nbytes_single(osdev, buf, dir, nbytes);
  1238. }
  1239. static inline void
  1240. qdf_nbuf_unmap_nbytes_single_paddr(qdf_device_t osdev, qdf_nbuf_t buf,
  1241. qdf_dma_addr_t phy_addr, qdf_dma_dir_t dir,
  1242. int nbytes)
  1243. {
  1244. __qdf_record_nbuf_nbytes(__qdf_nbuf_get_end_offset(buf), dir, false);
  1245. __qdf_mem_unmap_nbytes_single(osdev, phy_addr, dir, nbytes);
  1246. }
  1247. #endif /* NBUF_MAP_UNMAP_DEBUG */
  1248. /**
  1249. * qdf_nbuf_queue_head_dequeue() - dequeue nbuf from the head of queue
  1250. * @nbuf_queue_head: pointer to nbuf queue head
  1251. *
  1252. * Return: pointer to network buffer dequeued
  1253. */
  1254. static inline
  1255. qdf_nbuf_t qdf_nbuf_queue_head_dequeue(qdf_nbuf_queue_head_t *nbuf_queue_head)
  1256. {
  1257. return __qdf_nbuf_queue_head_dequeue(nbuf_queue_head);
  1258. }
  1259. /**
  1260. * qdf_nbuf_queue_head_qlen() - length of the queue
  1261. * @nbuf_queue_head: pointer to nbuf queue head
  1262. *
  1263. * Return: length of queue (number of nbufs) pointed by qdf_nbuf_queue_head_t
  1264. */
  1265. static inline
  1266. uint32_t qdf_nbuf_queue_head_qlen(qdf_nbuf_queue_head_t *nbuf_queue_head)
  1267. {
  1268. return __qdf_nbuf_queue_head_qlen(nbuf_queue_head);
  1269. }
  1270. /**
  1271. * qdf_nbuf_queue_head_enqueue_tail() - enqueue nbuf into queue tail
  1272. * @nbuf_queue_head: pointer to nbuf queue head
  1273. * @nbuf: nbuf to be enqueued
  1274. *
  1275. * Return: None
  1276. */
  1277. static inline
  1278. void qdf_nbuf_queue_head_enqueue_tail(qdf_nbuf_queue_head_t *nbuf_queue_head,
  1279. qdf_nbuf_t nbuf)
  1280. {
  1281. return __qdf_nbuf_queue_head_enqueue_tail(nbuf_queue_head, nbuf);
  1282. }
  1283. /**
  1284. * qdf_nbuf_queue_head_init() - initialize qdf_nbuf_queue_head_t
  1285. * @nbuf_queue_head: pointer to nbuf queue head to be initialized
  1286. *
  1287. * Return: None
  1288. */
  1289. static inline
  1290. void qdf_nbuf_queue_head_init(qdf_nbuf_queue_head_t *nbuf_queue_head)
  1291. {
  1292. return __qdf_nbuf_queue_head_init(nbuf_queue_head);
  1293. }
  1294. /**
  1295. * qdf_nbuf_queue_head_purge() - purge qdf_nbuf_queue_head_t
  1296. * @nbuf_queue_head: pointer to nbuf queue head to be purged
  1297. *
  1298. * Return: None
  1299. */
  1300. static inline
  1301. void qdf_nbuf_queue_head_purge(qdf_nbuf_queue_head_t *nbuf_queue_head)
  1302. {
  1303. return __qdf_nbuf_queue_head_purge(nbuf_queue_head);
  1304. }
  1305. /**
  1306. * qdf_nbuf_queue_empty() - dequeue nbuf from the head of queue
  1307. * @nbuf_queue_head: pointer to nbuf queue head
  1308. *
  1309. * Return: true if queue is empty else false
  1310. */
  1311. static inline
  1312. int qdf_nbuf_queue_empty(qdf_nbuf_queue_head_t *nbuf_queue_head)
  1313. {
  1314. return __qdf_nbuf_queue_empty(nbuf_queue_head);
  1315. }
  1316. /**
  1317. * qdf_nbuf_queue_head_lock() - Acquire the nbuf_queue_head lock
  1318. * @head: nbuf_queue_head of the nbuf_list for which lock is to be acquired
  1319. *
  1320. * Return: void
  1321. */
  1322. static inline void qdf_nbuf_queue_head_lock(qdf_nbuf_queue_head_t *head)
  1323. {
  1324. __qdf_nbuf_queue_head_lock(head);
  1325. }
  1326. /**
  1327. * qdf_nbuf_queue_head_unlock() - Release the nbuf queue lock
  1328. * @head: nbuf_queue_head of the nbuf_list for which lock is to be release
  1329. *
  1330. * Return: void
  1331. */
  1332. static inline void qdf_nbuf_queue_head_unlock(qdf_nbuf_queue_head_t *head)
  1333. {
  1334. __qdf_nbuf_queue_head_unlock(head);
  1335. }
  1336. static inline void
  1337. qdf_nbuf_sync_for_cpu(qdf_device_t osdev, qdf_nbuf_t buf, qdf_dma_dir_t dir)
  1338. {
  1339. __qdf_nbuf_sync_for_cpu(osdev, buf, dir);
  1340. }
  1341. /**
  1342. * qdf_nbuf_dma_inv_range() - Invalidate the specified virtual address range
  1343. * @buf_start: start address
  1344. * @buf_end: end address
  1345. *
  1346. * Return: none
  1347. */
  1348. static inline void
  1349. qdf_nbuf_dma_inv_range(const void *buf_start, const void *buf_end)
  1350. {
  1351. __qdf_nbuf_dma_inv_range(buf_start, buf_end);
  1352. }
  1353. /**
  1354. * qdf_nbuf_dma_inv_range_no_dsb() - barrierless Invalidate the specified
  1355. * virtual address range
  1356. * @buf_start: start address
  1357. * @buf_end: end address
  1358. *
  1359. * Return: none
  1360. */
  1361. static inline void
  1362. qdf_nbuf_dma_inv_range_no_dsb(const void *buf_start, const void *buf_end)
  1363. {
  1364. __qdf_nbuf_dma_inv_range_no_dsb(buf_start, buf_end);
  1365. }
  1366. /**
  1367. * qdf_nbuf_dma_clean_range_no_dsb() - barrierless clean the specified
  1368. * virtual address range
  1369. * @buf_start: start address
  1370. * @buf_end: end address
  1371. *
  1372. * Return: none
  1373. */
  1374. static inline void
  1375. qdf_nbuf_dma_clean_range_no_dsb(const void *buf_start, const void *buf_end)
  1376. {
  1377. __qdf_nbuf_dma_clean_range_no_dsb(buf_start, buf_end);
  1378. }
  1379. static inline void
  1380. qdf_dsb(void)
  1381. {
  1382. __qdf_dsb();
  1383. }
  1384. static inline int qdf_nbuf_get_num_frags(qdf_nbuf_t buf)
  1385. {
  1386. return __qdf_nbuf_get_num_frags(buf);
  1387. }
  1388. /**
  1389. * qdf_nbuf_dma_clean_range() - Clean the specified virtual address range
  1390. * @buf_start: start address
  1391. * @buf_end: end address
  1392. *
  1393. * Return: none
  1394. */
  1395. static inline void
  1396. qdf_nbuf_dma_clean_range(const void *buf_start, const void *buf_end)
  1397. {
  1398. __qdf_nbuf_dma_clean_range(buf_start, buf_end);
  1399. }
  1400. /**
  1401. * qdf_nbuf_get_frag_len() - get fragment length
  1402. * @buf: Network buffer
  1403. * @frag_num: Fragment number
  1404. *
  1405. * Return: Fragment length
  1406. */
  1407. static inline int qdf_nbuf_get_frag_len(qdf_nbuf_t buf, int frag_num)
  1408. {
  1409. QDF_BUG(!(frag_num >= QDF_NBUF_CB_TX_MAX_EXTRA_FRAGS));
  1410. return __qdf_nbuf_get_frag_len(buf, frag_num);
  1411. }
  1412. /**
  1413. * qdf_nbuf_get_frag_vaddr() - get fragment virtual address
  1414. * @buf: Network buffer
  1415. * @frag_num: Fragment number
  1416. *
  1417. * Return: Fragment virtual address
  1418. */
  1419. static inline unsigned char *qdf_nbuf_get_frag_vaddr(qdf_nbuf_t buf,
  1420. int frag_num)
  1421. {
  1422. QDF_BUG(!(frag_num >= QDF_NBUF_CB_TX_MAX_EXTRA_FRAGS));
  1423. return __qdf_nbuf_get_frag_vaddr(buf, frag_num);
  1424. }
  1425. /**
  1426. * qdf_nbuf_get_frag_vaddr_always() - get fragment virtual address
  1427. * @buf: Network buffer
  1428. *
  1429. * Return: Fragment virtual address
  1430. */
  1431. static inline unsigned char *
  1432. qdf_nbuf_get_frag_vaddr_always(qdf_nbuf_t buf)
  1433. {
  1434. return __qdf_nbuf_get_frag_vaddr_always(buf);
  1435. }
  1436. /**
  1437. * qdf_nbuf_get_frag_paddr() - get physical address for skb linear buffer
  1438. * or skb fragment, based on frag_num passed
  1439. * @buf: Network buffer
  1440. * @frag_num: Fragment number
  1441. *
  1442. * Return: Fragment physical address
  1443. */
  1444. static inline qdf_dma_addr_t qdf_nbuf_get_frag_paddr(qdf_nbuf_t buf,
  1445. unsigned int frag_num)
  1446. {
  1447. QDF_BUG(!(frag_num >= QDF_NBUF_CB_TX_MAX_EXTRA_FRAGS));
  1448. return __qdf_nbuf_get_frag_paddr(buf, frag_num);
  1449. }
  1450. /**
  1451. * qdf_nbuf_get_tx_frag_paddr() - get physical address for skb fragments only
  1452. * @buf: Network buffer
  1453. *
  1454. * Return: Fragment physical address
  1455. * Usage guideline: Use “qdf_nbuf_frag_map()” to dma map the specific
  1456. * skb fragment , followed by “qdf_nbuf_get_tx_frag_paddr”
  1457. */
  1458. static inline qdf_dma_addr_t qdf_nbuf_get_tx_frag_paddr(qdf_nbuf_t buf)
  1459. {
  1460. return __qdf_nbuf_get_tx_frag_paddr(buf);
  1461. }
  1462. /**
  1463. * qdf_nbuf_get_frag_is_wordstream() - is fragment wordstream
  1464. * @buf: Network buffer
  1465. * @frag_num: Fragment number
  1466. *
  1467. * Return: Fragment wordstream or not
  1468. */
  1469. static inline int qdf_nbuf_get_frag_is_wordstream(qdf_nbuf_t buf, int frag_num)
  1470. {
  1471. QDF_BUG(!(frag_num >= QDF_NBUF_CB_TX_MAX_EXTRA_FRAGS));
  1472. return __qdf_nbuf_get_frag_is_wordstream(buf, frag_num);
  1473. }
  1474. /**
  1475. * qdf_nbuf_set_frag_is_wordstream() - set fragment wordstream
  1476. * @buf: Network buffer
  1477. * @frag_num: Fragment number
  1478. * @is_wordstream: Wordstream
  1479. *
  1480. * Return: none
  1481. */
  1482. static inline void
  1483. qdf_nbuf_set_frag_is_wordstream(qdf_nbuf_t buf,
  1484. int frag_num, int is_wordstream)
  1485. {
  1486. QDF_BUG(!(frag_num >= QDF_NBUF_CB_TX_MAX_EXTRA_FRAGS));
  1487. __qdf_nbuf_set_frag_is_wordstream(buf, frag_num, is_wordstream);
  1488. }
  1489. static inline void
  1490. qdf_nbuf_set_vdev_ctx(qdf_nbuf_t buf, uint8_t vdev_id)
  1491. {
  1492. __qdf_nbuf_set_vdev_ctx(buf, vdev_id);
  1493. }
  1494. static inline void
  1495. qdf_nbuf_set_tx_ftype(qdf_nbuf_t buf, enum cb_ftype type)
  1496. {
  1497. __qdf_nbuf_set_tx_ftype(buf, type);
  1498. }
  1499. static inline void
  1500. qdf_nbuf_set_rx_ftype(qdf_nbuf_t buf, enum cb_ftype type)
  1501. {
  1502. __qdf_nbuf_set_rx_ftype(buf, type);
  1503. }
  1504. static inline uint8_t
  1505. qdf_nbuf_get_vdev_ctx(qdf_nbuf_t buf)
  1506. {
  1507. return __qdf_nbuf_get_vdev_ctx(buf);
  1508. }
  1509. static inline enum cb_ftype qdf_nbuf_get_tx_ftype(qdf_nbuf_t buf)
  1510. {
  1511. return __qdf_nbuf_get_tx_ftype(buf);
  1512. }
  1513. static inline enum cb_ftype qdf_nbuf_get_rx_ftype(qdf_nbuf_t buf)
  1514. {
  1515. return __qdf_nbuf_get_rx_ftype(buf);
  1516. }
  1517. static inline qdf_dma_addr_t
  1518. qdf_nbuf_mapped_paddr_get(qdf_nbuf_t buf)
  1519. {
  1520. return __qdf_nbuf_mapped_paddr_get(buf);
  1521. }
  1522. static inline void
  1523. qdf_nbuf_mapped_paddr_set(qdf_nbuf_t buf, qdf_dma_addr_t paddr)
  1524. {
  1525. __qdf_nbuf_mapped_paddr_set(buf, paddr);
  1526. }
  1527. static inline void
  1528. qdf_nbuf_frag_push_head(qdf_nbuf_t buf,
  1529. int frag_len, unsigned char *frag_vaddr,
  1530. qdf_dma_addr_t frag_paddr)
  1531. {
  1532. __qdf_nbuf_frag_push_head(buf, frag_len, frag_vaddr, frag_paddr);
  1533. }
  1534. #define qdf_nbuf_num_frags_init(_nbuf) __qdf_nbuf_num_frags_init((_nbuf))
  1535. /**
  1536. * qdf_nbuf_set_rx_chfrag_start() - set msdu start bit
  1537. * @buf: Network buffer
  1538. * @val: 0/1
  1539. *
  1540. * Return: void
  1541. */
  1542. static inline void
  1543. qdf_nbuf_set_rx_chfrag_start(qdf_nbuf_t buf, uint8_t val)
  1544. {
  1545. __qdf_nbuf_set_rx_chfrag_start(buf, val);
  1546. }
  1547. /**
  1548. * qdf_nbuf_is_rx_chfrag_start() - get msdu start bit
  1549. * @buf: Network buffer
  1550. *
  1551. * Return: integer value - 0/1
  1552. */
  1553. static inline int qdf_nbuf_is_rx_chfrag_start(qdf_nbuf_t buf)
  1554. {
  1555. return __qdf_nbuf_is_rx_chfrag_start(buf);
  1556. }
  1557. /**
  1558. * qdf_nbuf_set_rx_chfrag_cont() - set msdu continuation bit
  1559. * @buf: Network buffer
  1560. * @val: 0/1
  1561. *
  1562. * Return: void
  1563. */
  1564. static inline void
  1565. qdf_nbuf_set_rx_chfrag_cont(qdf_nbuf_t buf, uint8_t val)
  1566. {
  1567. __qdf_nbuf_set_rx_chfrag_cont(buf, val);
  1568. }
  1569. /**
  1570. * qdf_nbuf_is_rx_chfrag_cont() - get msdu continuation bit
  1571. * @buf: Network buffer
  1572. *
  1573. * Return: integer value - 0/1
  1574. */
  1575. static inline int qdf_nbuf_is_rx_chfrag_cont(qdf_nbuf_t buf)
  1576. {
  1577. return __qdf_nbuf_is_rx_chfrag_cont(buf);
  1578. }
  1579. /**
  1580. * qdf_nbuf_set_rx_chfrag_end() - set msdu end bit
  1581. * @buf: Network buffer
  1582. * @val: 0/1
  1583. *
  1584. * Return: void
  1585. */
  1586. static inline void qdf_nbuf_set_rx_chfrag_end(qdf_nbuf_t buf, uint8_t val)
  1587. {
  1588. __qdf_nbuf_set_rx_chfrag_end(buf, val);
  1589. }
  1590. /**
  1591. * qdf_nbuf_is_rx_chfrag_end() - set msdu end bit
  1592. * @buf: Network buffer
  1593. *
  1594. * Return: integer value - 0/1
  1595. */
  1596. static inline int qdf_nbuf_is_rx_chfrag_end(qdf_nbuf_t buf)
  1597. {
  1598. return __qdf_nbuf_is_rx_chfrag_end(buf);
  1599. }
  1600. /**
  1601. * qdf_nbuf_set_da_mcbc() - set da is mcbc
  1602. * @buf: Network buffer
  1603. * @val: 0/1
  1604. *
  1605. * Return: void
  1606. */
  1607. static inline void
  1608. qdf_nbuf_set_da_mcbc(qdf_nbuf_t buf, uint8_t val)
  1609. {
  1610. __qdf_nbuf_set_da_mcbc(buf, val);
  1611. }
  1612. /**
  1613. * qdf_nbuf_is_da_mcbc() - get da is mcbc bit
  1614. * @buf: Network buffer
  1615. *
  1616. * Return: integer value - 0/1
  1617. */
  1618. static inline int qdf_nbuf_is_da_mcbc(qdf_nbuf_t buf)
  1619. {
  1620. return __qdf_nbuf_is_da_mcbc(buf);
  1621. }
  1622. /**
  1623. * qdf_nbuf_set_da_valid() - set da valid bit
  1624. * @buf: Network buffer
  1625. * @val: 0/1
  1626. *
  1627. * Return: void
  1628. */
  1629. static inline void qdf_nbuf_set_da_valid(qdf_nbuf_t buf, uint8_t val)
  1630. {
  1631. __qdf_nbuf_set_da_valid(buf, val);
  1632. }
  1633. /**
  1634. * qdf_nbuf_is_da_valid() - get da valid bit
  1635. * @buf: Network buffer
  1636. *
  1637. * Return: integer value - 0/1
  1638. */
  1639. static inline int qdf_nbuf_is_da_valid(qdf_nbuf_t buf)
  1640. {
  1641. return __qdf_nbuf_is_da_valid(buf);
  1642. }
  1643. /**
  1644. * qdf_nbuf_set_sa_valid() - set sa valid bit
  1645. * @buf: Network buffer
  1646. * @val: 0/1
  1647. *
  1648. * Return: void
  1649. */
  1650. static inline void qdf_nbuf_set_sa_valid(qdf_nbuf_t buf, uint8_t val)
  1651. {
  1652. __qdf_nbuf_set_sa_valid(buf, val);
  1653. }
  1654. /**
  1655. * qdf_nbuf_is_sa_valid() - get da valid bit
  1656. * @buf: Network buffer
  1657. *
  1658. * Return: integer value - 0/1
  1659. */
  1660. static inline int qdf_nbuf_is_sa_valid(qdf_nbuf_t buf)
  1661. {
  1662. return __qdf_nbuf_is_sa_valid(buf);
  1663. }
  1664. /**
  1665. * qdf_nbuf_set_rx_retry_flag() - set rx retry flag bit
  1666. * @buf: Network buffer
  1667. * @val: 0/1
  1668. *
  1669. * Return: void
  1670. */
  1671. static inline void qdf_nbuf_set_rx_retry_flag(qdf_nbuf_t buf, uint8_t val)
  1672. {
  1673. __qdf_nbuf_set_rx_retry_flag(buf, val);
  1674. }
  1675. /**
  1676. * qdf_nbuf_is_rx_retry_flag() - get rx retry flag bit
  1677. * @buf: Network buffer
  1678. *
  1679. * Return: integer value - 0/1
  1680. */
  1681. static inline int qdf_nbuf_is_rx_retry_flag(qdf_nbuf_t buf)
  1682. {
  1683. return __qdf_nbuf_is_rx_retry_flag(buf);
  1684. }
  1685. /**
  1686. * qdf_nbuf_set_raw_frame() - set raw_frame bit
  1687. * @buf: Network buffer
  1688. * @val: 0/1
  1689. *
  1690. * Return: void
  1691. */
  1692. static inline void qdf_nbuf_set_raw_frame(qdf_nbuf_t buf, uint8_t val)
  1693. {
  1694. __qdf_nbuf_set_raw_frame(buf, val);
  1695. }
  1696. /**
  1697. * qdf_nbuf_is_raw_frame() - get raw_frame bit
  1698. * @buf: Network buffer
  1699. *
  1700. * Return: integer value - 0/1
  1701. */
  1702. static inline int qdf_nbuf_is_raw_frame(qdf_nbuf_t buf)
  1703. {
  1704. return __qdf_nbuf_is_raw_frame(buf);
  1705. }
  1706. /**
  1707. * qdf_nbuf_is_fr_ds_set() - get from DS bit
  1708. * @buf: Network buffer
  1709. *
  1710. * Return: integer value - 0/1
  1711. */
  1712. static inline int qdf_nbuf_is_fr_ds_set(qdf_nbuf_t buf)
  1713. {
  1714. return __qdf_nbuf_is_fr_ds_set(buf);
  1715. }
  1716. /**
  1717. * qdf_nbuf_is_to_ds_set() - get to DS bit
  1718. * @buf: Network buffer
  1719. *
  1720. * Return: integer value - 0/1
  1721. */
  1722. static inline int qdf_nbuf_is_to_ds_set(qdf_nbuf_t buf)
  1723. {
  1724. return __qdf_nbuf_is_to_ds_set(buf);
  1725. }
  1726. /**
  1727. * qdf_nbuf_set_tid_val() - set tid_val
  1728. * @buf: Network buffer
  1729. * @val: 4 bits tid value
  1730. */
  1731. static inline void qdf_nbuf_set_tid_val(qdf_nbuf_t buf, uint8_t val)
  1732. {
  1733. __qdf_nbuf_set_tid_val(buf, val);
  1734. }
  1735. /**
  1736. * qdf_nbuf_get_tid_val() - get tid_val
  1737. * @buf: Network buffer
  1738. *
  1739. * Return: integer value[4 bits tid value]
  1740. */
  1741. static inline uint8_t qdf_nbuf_get_tid_val(qdf_nbuf_t buf)
  1742. {
  1743. return __qdf_nbuf_get_tid_val(buf);
  1744. }
  1745. /**
  1746. * qdf_nbuf_set_is_frag() - set frag list bit
  1747. * @buf: Network buffer
  1748. * @val: 0/1
  1749. *
  1750. * Return: void
  1751. */
  1752. static inline void qdf_nbuf_set_is_frag(qdf_nbuf_t buf, uint8_t val)
  1753. {
  1754. __qdf_nbuf_set_is_frag(buf, val);
  1755. }
  1756. /**
  1757. * qdf_nbuf_is_frag() - get da frag list bit
  1758. * @buf: Network buffer
  1759. *
  1760. * Return: integer value - 0/1
  1761. */
  1762. static inline int qdf_nbuf_is_frag(qdf_nbuf_t buf)
  1763. {
  1764. return __qdf_nbuf_is_frag(buf);
  1765. }
  1766. /**
  1767. * qdf_nbuf_set_tx_chfrag_start() - set msdu start bit
  1768. * @buf: Network buffer
  1769. * @val: 0/1
  1770. *
  1771. * Return: void
  1772. */
  1773. static inline void
  1774. qdf_nbuf_set_tx_chfrag_start(qdf_nbuf_t buf, uint8_t val)
  1775. {
  1776. __qdf_nbuf_set_tx_chfrag_start(buf, val);
  1777. }
  1778. /**
  1779. * qdf_nbuf_is_tx_chfrag_start() - get msdu start bit
  1780. * @buf: Network buffer
  1781. *
  1782. * Return: integer value - 0/1
  1783. */
  1784. static inline int qdf_nbuf_is_tx_chfrag_start(qdf_nbuf_t buf)
  1785. {
  1786. return __qdf_nbuf_is_tx_chfrag_start(buf);
  1787. }
  1788. /**
  1789. * qdf_nbuf_set_tx_chfrag_cont() - set msdu continuation bit
  1790. * @buf: Network buffer
  1791. * @val: 0/1
  1792. *
  1793. * Return: void
  1794. */
  1795. static inline void
  1796. qdf_nbuf_set_tx_chfrag_cont(qdf_nbuf_t buf, uint8_t val)
  1797. {
  1798. __qdf_nbuf_set_tx_chfrag_cont(buf, val);
  1799. }
  1800. /**
  1801. * qdf_nbuf_is_tx_chfrag_cont() - get msdu continuation bit
  1802. * @buf: Network buffer
  1803. *
  1804. * Return: integer value - 0/1
  1805. */
  1806. static inline int qdf_nbuf_is_tx_chfrag_cont(qdf_nbuf_t buf)
  1807. {
  1808. return __qdf_nbuf_is_tx_chfrag_cont(buf);
  1809. }
  1810. /**
  1811. * qdf_nbuf_set_tx_chfrag_end() - set msdu end bit
  1812. * @buf: Network buffer
  1813. * @val: 0/1
  1814. *
  1815. * Return: void
  1816. */
  1817. static inline void qdf_nbuf_set_tx_chfrag_end(qdf_nbuf_t buf, uint8_t val)
  1818. {
  1819. __qdf_nbuf_set_tx_chfrag_end(buf, val);
  1820. }
  1821. /**
  1822. * qdf_nbuf_is_tx_chfrag_end() - set msdu end bit
  1823. * @buf: Network buffer
  1824. *
  1825. * Return: integer value - 0/1
  1826. */
  1827. static inline int qdf_nbuf_is_tx_chfrag_end(qdf_nbuf_t buf)
  1828. {
  1829. return __qdf_nbuf_is_tx_chfrag_end(buf);
  1830. }
  1831. static inline void
  1832. qdf_nbuf_dma_map_info(qdf_dma_map_t bmap, qdf_dmamap_info_t *sg)
  1833. {
  1834. __qdf_nbuf_dma_map_info(bmap, sg);
  1835. }
  1836. /**
  1837. * qdf_nbuf_is_tso() - is the network buffer a jumbo packet?
  1838. * @nbuf: Network buffer
  1839. *
  1840. * Return: 1 - this is a jumbo packet 0 - not a jumbo packet
  1841. */
  1842. static inline uint8_t qdf_nbuf_is_tso(qdf_nbuf_t nbuf)
  1843. {
  1844. return __qdf_nbuf_is_tso(nbuf);
  1845. }
  1846. /**
  1847. * qdf_nbuf_get_users() - function to get the number of users referencing this
  1848. * network buffer
  1849. *
  1850. * @nbuf: network buffer
  1851. *
  1852. * Return: number of user references to nbuf.
  1853. */
  1854. static inline int qdf_nbuf_get_users(qdf_nbuf_t nbuf)
  1855. {
  1856. return __qdf_nbuf_get_users(nbuf);
  1857. }
  1858. /**
  1859. * qdf_nbuf_next() - get the next packet in the linked list
  1860. * @buf: Network buffer
  1861. *
  1862. * This function can be used when nbufs are directly linked into a list,
  1863. * rather than using a separate network buffer queue object.
  1864. *
  1865. * Return: next network buffer in the linked list
  1866. */
  1867. static inline qdf_nbuf_t qdf_nbuf_next(qdf_nbuf_t buf)
  1868. {
  1869. return __qdf_nbuf_next(buf);
  1870. }
  1871. #ifdef IPA_OFFLOAD
  1872. /**
  1873. * qdf_nbuf_smmu_map_debug() - map smmu buffer
  1874. * @nbuf: network buffer
  1875. * @hdl: ipa handle
  1876. * @num_buffers: number of buffers
  1877. * @info: memory info
  1878. * @func: function name
  1879. * @line: line number
  1880. *
  1881. * Return: QDF_STATUS
  1882. */
  1883. QDF_STATUS qdf_nbuf_smmu_map_debug(qdf_nbuf_t nbuf,
  1884. uint8_t hdl,
  1885. uint8_t num_buffers,
  1886. qdf_mem_info_t *info,
  1887. const char *func,
  1888. uint32_t line);
  1889. /**
  1890. * qdf_nbuf_smmu_unmap_debug() - unmap smmu buffer
  1891. * @nbuf: network buffer
  1892. * @hdl: ipa handle
  1893. * @num_buffers: number of buffers
  1894. * @info: memory info
  1895. * @func: function name
  1896. * @line: line number
  1897. *
  1898. * Return: QDF_STATUS
  1899. */
  1900. QDF_STATUS qdf_nbuf_smmu_unmap_debug(qdf_nbuf_t nbuf,
  1901. uint8_t hdl,
  1902. uint8_t num_buffers,
  1903. qdf_mem_info_t *info,
  1904. const char *func,
  1905. uint32_t line);
  1906. #endif /* IPA_OFFLOAD */
  1907. #ifdef NBUF_MEMORY_DEBUG
  1908. #define QDF_NET_BUF_TRACK_MAX_SIZE (1024)
  1909. enum qdf_nbuf_event_type {
  1910. QDF_NBUF_ALLOC,
  1911. QDF_NBUF_ALLOC_CLONE,
  1912. QDF_NBUF_ALLOC_COPY,
  1913. QDF_NBUF_ALLOC_FAILURE,
  1914. QDF_NBUF_FREE,
  1915. QDF_NBUF_MAP,
  1916. QDF_NBUF_UNMAP,
  1917. QDF_NBUF_ALLOC_COPY_EXPAND,
  1918. QDF_NBUF_SMMU_MAP,
  1919. QDF_NBUF_SMMU_UNMAP,
  1920. };
  1921. /**
  1922. * qdf_net_buf_debug_init() - initialize network buffer debug functionality
  1923. *
  1924. * QDF network buffer debug feature tracks all SKBs allocated by WLAN driver
  1925. * in a hash table and when driver is unloaded it reports about leaked SKBs.
  1926. * WLAN driver module whose allocated SKB is freed by network stack are
  1927. * suppose to call qdf_net_buf_debug_release_skb() such that the SKB is not
  1928. * reported as memory leak.
  1929. *
  1930. * Return: none
  1931. */
  1932. void qdf_net_buf_debug_init(void);
  1933. /**
  1934. * qdf_net_buf_debug_exit() - exit network buffer debug functionality
  1935. *
  1936. * Exit network buffer tracking debug functionality and log SKB memory leaks
  1937. * As part of exiting the functionality, free the leaked memory and
  1938. * cleanup the tracking buffers.
  1939. *
  1940. * Return: none
  1941. */
  1942. void qdf_net_buf_debug_exit(void);
  1943. void qdf_net_buf_debug_clean(void);
  1944. void qdf_nbuf_history_add(qdf_nbuf_t nbuf, const char *func, uint32_t line,
  1945. enum qdf_nbuf_event_type type);
  1946. /**
  1947. * qdf_net_buf_debug_add_node() - store skb in debug hash table
  1948. * @net_buf: network buffer
  1949. * @size: buffer size
  1950. * @func_name: function name that requests for mapping the nbuf
  1951. * @line_num: function line number
  1952. *
  1953. * Return: none
  1954. */
  1955. void qdf_net_buf_debug_add_node(qdf_nbuf_t net_buf, size_t size,
  1956. const char *func_name, uint32_t line_num);
  1957. /**
  1958. * qdf_net_buf_debug_update_node() - update nbuf in debug hash table
  1959. * @net_buf: network buffer
  1960. * @func_name: function name that requests for mapping the nbuf
  1961. * @line_num: function line number
  1962. *
  1963. * Return: none
  1964. */
  1965. void qdf_net_buf_debug_update_node(qdf_nbuf_t net_buf, const char *func_name,
  1966. uint32_t line_num);
  1967. /**
  1968. * qdf_net_buf_debug_delete_node() - remove skb from debug hash table
  1969. * @net_buf: network buffer
  1970. *
  1971. * Return: none
  1972. */
  1973. void qdf_net_buf_debug_delete_node(qdf_nbuf_t net_buf);
  1974. /**
  1975. * qdf_net_buf_debug_update_map_node() - update nbuf in debug
  1976. * hash table with the mapping function info
  1977. * @net_buf: network buffer
  1978. * @func_name: function name that requests for mapping the nbuf
  1979. * @line_num: function line number
  1980. *
  1981. * Return: none
  1982. */
  1983. void qdf_net_buf_debug_update_map_node(qdf_nbuf_t net_buf,
  1984. const char *func_name,
  1985. uint32_t line_num);
  1986. #ifdef NBUF_SMMU_MAP_UNMAP_DEBUG
  1987. /**
  1988. * qdf_nbuf_map_check_for_smmu_leaks() - check for nbuf smmu map leaks
  1989. *
  1990. * Check for net buffers that have been smmu mapped, but never smmu unmapped.
  1991. *
  1992. * Returns: None
  1993. */
  1994. void qdf_nbuf_map_check_for_smmu_leaks(void);
  1995. /**
  1996. * qdf_net_buf_debug_update_smmu_map_node() - update nbuf in debug
  1997. * hash table with the mapping function info
  1998. * @nbuf: network buffer
  1999. * @iova: Virtual address of buffer
  2000. * @pa: Physical address of buffer
  2001. * @func: function name that requests for mapping the nbuf
  2002. * @line: function line number
  2003. *
  2004. * Return: none
  2005. */
  2006. void qdf_net_buf_debug_update_smmu_map_node(qdf_nbuf_t nbuf,
  2007. unsigned long iova,
  2008. unsigned long pa,
  2009. const char *func,
  2010. uint32_t line);
  2011. /**
  2012. * qdf_net_buf_debug_update_smmu_unmap_node() - update nbuf in debug
  2013. * hash table with the unmapping function info
  2014. * @nbuf: network buffer
  2015. * @iova: Virtual address of buffer
  2016. * @pa: Physical address of buffer
  2017. * @func: function name that requests for unmapping the nbuf
  2018. * @line: function line number
  2019. *
  2020. * Return: none
  2021. */
  2022. void qdf_net_buf_debug_update_smmu_unmap_node(qdf_nbuf_t nbuf,
  2023. unsigned long iova,
  2024. unsigned long pa,
  2025. const char *func,
  2026. uint32_t line);
  2027. #endif /* NBUF_SMMU_MAP_UNMAP_DEBUG */
  2028. /**
  2029. * qdf_net_buf_debug_update_unmap_node() - update nbuf in debug
  2030. * hash table with the unmap function info
  2031. * @net_buf: network buffer
  2032. * @func_name: function name that requests for unmapping the nbuf
  2033. * @line_num: function line number
  2034. *
  2035. * Return: none
  2036. */
  2037. void qdf_net_buf_debug_update_unmap_node(qdf_nbuf_t net_buf,
  2038. const char *func_name,
  2039. uint32_t line_num);
  2040. /**
  2041. * qdf_net_buf_debug_acquire_skb() - acquire skb to avoid memory leak
  2042. * @net_buf: Network buf holding head segment (single)
  2043. * @func_name: pointer to function name
  2044. * @line_num: line number
  2045. *
  2046. * WLAN driver module's SKB which are allocated by network stack are
  2047. * suppose to call this API before freeing it such that the SKB
  2048. * is not reported as memory leak.
  2049. *
  2050. * Return: none
  2051. */
  2052. void qdf_net_buf_debug_acquire_skb(qdf_nbuf_t net_buf,
  2053. const char *func_name,
  2054. uint32_t line_num);
  2055. /**
  2056. * qdf_net_buf_debug_release_skb() - release skb to avoid memory leak
  2057. * @net_buf: Network buf holding head segment (single)
  2058. *
  2059. * WLAN driver module whose allocated SKB is freed by network stack are
  2060. * suppose to call this API before returning SKB to network stack such
  2061. * that the SKB is not reported as memory leak.
  2062. *
  2063. * Return: none
  2064. */
  2065. void qdf_net_buf_debug_release_skb(qdf_nbuf_t net_buf);
  2066. /* nbuf allocation routines */
  2067. #define qdf_nbuf_alloc_simple(d, s, r, a, p) \
  2068. __qdf_nbuf_alloc_simple(d, s, __func__, __LINE__)
  2069. #define qdf_nbuf_alloc(d, s, r, a, p) \
  2070. qdf_nbuf_alloc_debug(d, s, r, a, p, __func__, __LINE__)
  2071. qdf_nbuf_t qdf_nbuf_alloc_debug(qdf_device_t osdev, qdf_size_t size,
  2072. int reserve, int align, int prio,
  2073. const char *func, uint32_t line);
  2074. #define qdf_nbuf_frag_alloc(d, s, r, a, p) \
  2075. qdf_nbuf_frag_alloc_debug(d, s, r, a, p, __func__, __LINE__)
  2076. qdf_nbuf_t qdf_nbuf_frag_alloc_debug(qdf_device_t osdev, qdf_size_t size,
  2077. int reserve, int align, int prio,
  2078. const char *func, uint32_t line);
  2079. /**
  2080. * qdf_nbuf_alloc_no_recycler() - Allocates skb
  2081. * @size: Size to be allocated for skb
  2082. * @reserve: Reserved headroom size
  2083. * @align: Align
  2084. *
  2085. * This API allocates skb of required size and aligns if needed and reserves
  2086. * some space in the front. This skb allocation is not from skb recycler pool.
  2087. *
  2088. * Return: Allocated nbuf pointer
  2089. */
  2090. #define qdf_nbuf_alloc_no_recycler(size, reserve, align) \
  2091. qdf_nbuf_alloc_no_recycler_debug(size, reserve, align, __func__, __LINE__)
  2092. /**
  2093. * qdf_nbuf_alloc_no_recycler_debug() - Allocates skb
  2094. * @size: Size to be allocated for skb
  2095. * @reserve: Reserved headroom size
  2096. * @align: Align
  2097. * @func: Function name of the call site
  2098. * @line: Line number of the callsite
  2099. *
  2100. * This API allocates skb of required size and aligns if needed and reserves
  2101. * some space in the front. This skb allocation is not from skb recycler pool.
  2102. *
  2103. * Return: Allocated nbuf pointer
  2104. */
  2105. qdf_nbuf_t qdf_nbuf_alloc_no_recycler_debug(size_t size, int reserve, int align,
  2106. const char *func, uint32_t line);
  2107. #define qdf_nbuf_free(d) \
  2108. qdf_nbuf_free_debug(d, __func__, __LINE__)
  2109. void qdf_nbuf_free_debug(qdf_nbuf_t nbuf, const char *func, uint32_t line);
  2110. #define qdf_nbuf_free_simple(d) \
  2111. qdf_nbuf_free_debug_simple(d, __func__, __LINE__)
  2112. void qdf_nbuf_free_debug_simple(qdf_nbuf_t nbuf, const char *func,
  2113. uint32_t line);
  2114. #define qdf_nbuf_clone(buf) \
  2115. qdf_nbuf_clone_debug(buf, __func__, __LINE__)
  2116. /**
  2117. * qdf_nbuf_clone_debug() - clone the nbuf (copy is readonly)
  2118. * @buf: nbuf to clone from
  2119. * @func: name of the calling function
  2120. * @line: line number of the callsite
  2121. *
  2122. * This function clones the nbuf and creates a memory tracking
  2123. * node corresponding to that cloned skbuff structure.
  2124. *
  2125. * Return: cloned buffer
  2126. */
  2127. qdf_nbuf_t qdf_nbuf_clone_debug(qdf_nbuf_t buf, const char *func,
  2128. uint32_t line);
  2129. #define qdf_nbuf_copy(buf) \
  2130. qdf_nbuf_copy_debug(buf, __func__, __LINE__)
  2131. /**
  2132. * qdf_nbuf_copy_debug() - returns a private copy of the buf
  2133. * @buf: nbuf to copy from
  2134. * @func: name of the calling function
  2135. * @line: line number of the callsite
  2136. *
  2137. * This API returns a private copy of the buf, the buf returned is completely
  2138. * modifiable by callers. It also creates a memory tracking node corresponding
  2139. * to that new skbuff structure.
  2140. *
  2141. * Return: copied buffer
  2142. */
  2143. qdf_nbuf_t qdf_nbuf_copy_debug(qdf_nbuf_t buf, const char *func, uint32_t line);
  2144. #define qdf_nbuf_copy_expand(buf, headroom, tailroom) \
  2145. qdf_nbuf_copy_expand_debug(buf, headroom, tailroom, __func__, __LINE__)
  2146. /**
  2147. * qdf_nbuf_copy_expand_debug() - copy and expand nbuf
  2148. * @buf: Network buf instance
  2149. * @headroom: Additional headroom to be added
  2150. * @tailroom: Additional tailroom to be added
  2151. * @func: name of the calling function
  2152. * @line: line number of the callsite
  2153. *
  2154. * Return: New nbuf that is a copy of buf, with additional head and tailroom
  2155. * or NULL if there is no memory
  2156. */
  2157. qdf_nbuf_t
  2158. qdf_nbuf_copy_expand_debug(qdf_nbuf_t buf, int headroom, int tailroom,
  2159. const char *func, uint32_t line);
  2160. /**
  2161. * qdf_nbuf_unshare() - make a copy of the shared nbuf
  2162. * @buf: Network buf instance
  2163. *
  2164. * Return: New nbuf which is a copy of the received nbuf if it is cloned,
  2165. * else, return the original nbuf
  2166. */
  2167. #define qdf_nbuf_unshare(buf) \
  2168. qdf_nbuf_unshare_debug(buf, __func__, __LINE__)
  2169. qdf_nbuf_t
  2170. qdf_nbuf_unshare_debug(qdf_nbuf_t buf, const char *func_name,
  2171. uint32_t line_num);
  2172. /**
  2173. * qdf_nbuf_dev_kfree_list() - Free nbuf list using kfree
  2174. * @buf: Pointer to network buffer head
  2175. *
  2176. * This function is called to free the nbuf list on failure cases
  2177. *
  2178. * Return: None
  2179. */
  2180. #define qdf_nbuf_dev_kfree_list(buf) \
  2181. qdf_nbuf_dev_kfree_list_debug(buf, __func__, __LINE__)
  2182. void
  2183. qdf_nbuf_dev_kfree_list_debug(qdf_nbuf_queue_head_t *nbuf_queue_head,
  2184. const char *func_name,
  2185. uint32_t line_num);
  2186. #define qdf_nbuf_page_frag_alloc(d, s, r, a, p) \
  2187. qdf_nbuf_page_frag_alloc_debug(d, s, r, a, p, __func__, __LINE__)
  2188. qdf_nbuf_t
  2189. qdf_nbuf_page_frag_alloc_debug(qdf_device_t osdev, qdf_size_t size, int reserve,
  2190. int align, qdf_frag_cache_t *pf_cache,
  2191. const char *func, uint32_t line);
  2192. #else /* NBUF_MEMORY_DEBUG */
  2193. static inline void qdf_net_buf_debug_init(void) {}
  2194. static inline void qdf_net_buf_debug_exit(void) {}
  2195. static inline void qdf_net_buf_debug_acquire_skb(qdf_nbuf_t net_buf,
  2196. const char *func_name,
  2197. uint32_t line_num)
  2198. {
  2199. }
  2200. static inline void qdf_net_buf_debug_release_skb(qdf_nbuf_t net_buf)
  2201. {
  2202. }
  2203. static inline void
  2204. qdf_net_buf_debug_update_node(qdf_nbuf_t net_buf, const char *func_name,
  2205. uint32_t line_num)
  2206. {
  2207. }
  2208. static inline void
  2209. qdf_net_buf_debug_update_map_node(qdf_nbuf_t net_buf,
  2210. const char *func_name,
  2211. uint32_t line_num)
  2212. {
  2213. }
  2214. static inline void
  2215. qdf_net_buf_debug_update_unmap_node(qdf_nbuf_t net_buf,
  2216. const char *func_name,
  2217. uint32_t line_num)
  2218. {
  2219. }
  2220. /* Nbuf allocation routines */
  2221. #define qdf_nbuf_alloc_simple(osdev, size, reserve, align, prio) \
  2222. qdf_nbuf_alloc_fl(osdev, size, reserve, align, prio, \
  2223. __func__, __LINE__)
  2224. #define qdf_nbuf_alloc(osdev, size, reserve, align, prio) \
  2225. qdf_nbuf_alloc_fl(osdev, size, reserve, align, prio, \
  2226. __func__, __LINE__)
  2227. #define qdf_nbuf_alloc_no_recycler(size, reserve, align) \
  2228. qdf_nbuf_alloc_no_recycler_fl(size, reserve, align, __func__, __LINE__)
  2229. static inline qdf_nbuf_t
  2230. qdf_nbuf_alloc_fl(qdf_device_t osdev, qdf_size_t size, int reserve, int align,
  2231. int prio, const char *func, uint32_t line)
  2232. {
  2233. return __qdf_nbuf_alloc(osdev, size, reserve, align, prio, func, line);
  2234. }
  2235. #define qdf_nbuf_frag_alloc(osdev, size, reserve, align, prio) \
  2236. qdf_nbuf_frag_alloc_fl(osdev, size, reserve, align, prio, \
  2237. __func__, __LINE__)
  2238. static inline qdf_nbuf_t
  2239. qdf_nbuf_frag_alloc_fl(qdf_device_t osdev, qdf_size_t size, int reserve,
  2240. int align, int prio, const char *func, uint32_t line)
  2241. {
  2242. return __qdf_nbuf_frag_alloc(osdev, size, reserve, align, prio,
  2243. func, line);
  2244. }
  2245. /**
  2246. * qdf_nbuf_alloc_no_recycler_fl() - Allocate SKB
  2247. * @size: Size to be allocated for skb
  2248. * @reserve: Reserved headroom size
  2249. * @align: Align
  2250. * @func: Function name of the call site
  2251. * @line: Line number of the callsite
  2252. *
  2253. * This API allocates skb of required size and aligns if needed and reserves
  2254. * some space in the front. This skb allocation is not from skb recycler pool.
  2255. *
  2256. * Return: Allocated nbuf pointer
  2257. */
  2258. static inline qdf_nbuf_t
  2259. qdf_nbuf_alloc_no_recycler_fl(size_t size, int reserve, int align,
  2260. const char *func, uint32_t line)
  2261. {
  2262. return __qdf_nbuf_alloc_no_recycler(size, reserve, align, func, line);
  2263. }
  2264. #define qdf_nbuf_free_simple(d) qdf_nbuf_free(d)
  2265. static inline void qdf_nbuf_free(qdf_nbuf_t buf)
  2266. {
  2267. if (qdf_likely(buf))
  2268. __qdf_nbuf_free(buf);
  2269. }
  2270. /**
  2271. * qdf_nbuf_clone() - clone the nbuf (copy is readonly)
  2272. * @buf: Pointer to network buffer
  2273. *
  2274. * This function clones the nbuf and returns new sk_buff
  2275. * structure.
  2276. *
  2277. * Return: cloned skb
  2278. */
  2279. static inline qdf_nbuf_t qdf_nbuf_clone(qdf_nbuf_t buf)
  2280. {
  2281. return __qdf_nbuf_clone(buf);
  2282. }
  2283. /**
  2284. * qdf_nbuf_copy() - returns a private copy of the buf
  2285. * @buf: Pointer to network buffer
  2286. *
  2287. * This API returns a private copy of the buf, the buf returned is completely
  2288. * modifiable by callers
  2289. *
  2290. * Return: skb or NULL
  2291. */
  2292. static inline qdf_nbuf_t qdf_nbuf_copy(qdf_nbuf_t buf)
  2293. {
  2294. return __qdf_nbuf_copy(buf);
  2295. }
  2296. /**
  2297. * qdf_nbuf_copy_expand() - copy and expand nbuf
  2298. * @buf: Network buf instance
  2299. * @headroom: Additional headroom to be added
  2300. * @tailroom: Additional tailroom to be added
  2301. *
  2302. * Return: New nbuf that is a copy of buf, with additional head and tailroom
  2303. * or NULL if there is no memory
  2304. */
  2305. static inline qdf_nbuf_t qdf_nbuf_copy_expand(qdf_nbuf_t buf, int headroom,
  2306. int tailroom)
  2307. {
  2308. return __qdf_nbuf_copy_expand(buf, headroom, tailroom);
  2309. }
  2310. static inline qdf_nbuf_t qdf_nbuf_unshare(qdf_nbuf_t buf)
  2311. {
  2312. return __qdf_nbuf_unshare(buf);
  2313. }
  2314. /**
  2315. * qdf_nbuf_dev_kfree_list() - Free nbuf list using kfree
  2316. * @nbuf_queue_head: Pointer to buffer list head
  2317. *
  2318. * This function is called to free the nbuf list on failure cases
  2319. *
  2320. * Return: None
  2321. */
  2322. static inline void
  2323. qdf_nbuf_dev_kfree_list(qdf_nbuf_queue_head_t *nbuf_queue_head)
  2324. {
  2325. __qdf_nbuf_dev_kfree_list(nbuf_queue_head);
  2326. }
  2327. #define qdf_nbuf_page_frag_alloc(osdev, size, reserve, align, pf_cache) \
  2328. qdf_nbuf_page_frag_alloc_fl(osdev, size, reserve, align, pf_cache, \
  2329. __func__, __LINE__)
  2330. static inline qdf_nbuf_t
  2331. qdf_nbuf_page_frag_alloc_fl(qdf_device_t osdev, qdf_size_t size, int reserve,
  2332. int align, qdf_frag_cache_t *pf_cache,
  2333. const char *func, uint32_t line)
  2334. {
  2335. return __qdf_nbuf_page_frag_alloc(osdev, size, reserve, align, pf_cache,
  2336. func, line);
  2337. }
  2338. #endif /* NBUF_MEMORY_DEBUG */
  2339. #if defined(QCA_DP_NBUF_FAST_PPEDS)
  2340. #define qdf_nbuf_alloc_ppe_ds(d, s, r, a, p) \
  2341. __qdf_nbuf_alloc_ppe_ds(d, s, __func__, __LINE__)
  2342. #endif /* QCA_DP_NBUF_FAST_PPEDS */
  2343. /**
  2344. * qdf_nbuf_dev_queue_head() - Queue a buffer at the list head
  2345. * @nbuf_queue_head: Pointer to buffer list head
  2346. * @buf: Pointer to network buffer head
  2347. *
  2348. * This function is called to queue a buffer at the list head
  2349. *
  2350. * Return: None
  2351. */
  2352. static inline void
  2353. qdf_nbuf_dev_queue_head(qdf_nbuf_queue_head_t *nbuf_queue_head,
  2354. qdf_nbuf_t buf)
  2355. {
  2356. __qdf_nbuf_dev_queue_head(nbuf_queue_head, buf);
  2357. }
  2358. /**
  2359. * qdf_nbuf_kfree() - Free nbuf using kfree
  2360. * @buf: Pointer to network buffer
  2361. *
  2362. * This function is called to free the skb on failure cases
  2363. *
  2364. * Return: None
  2365. */
  2366. static inline void qdf_nbuf_kfree(qdf_nbuf_t buf)
  2367. {
  2368. __qdf_nbuf_kfree(buf);
  2369. }
  2370. /**
  2371. * qdf_nbuf_dev_kfree() - Free nbuf using dev based os call
  2372. * @buf: Pointer to network buffer
  2373. *
  2374. * This function is called to free the skb on failure cases
  2375. *
  2376. * Return: None
  2377. */
  2378. static inline void qdf_nbuf_dev_kfree(qdf_nbuf_t buf)
  2379. {
  2380. __qdf_nbuf_dev_kfree(buf);
  2381. }
  2382. /**
  2383. * qdf_nbuf_copy_expand_fraglist() - copy and expand nbuf and
  2384. * get reference of the fraglist.
  2385. * @buf: Network buf instance
  2386. * @headroom: Additional headroom to be added
  2387. * @tailroom: Additional tailroom to be added
  2388. *
  2389. * Return: New nbuf that is a copy of buf, with additional head and tailroom
  2390. * or NULL if there is no memory
  2391. */
  2392. static inline qdf_nbuf_t
  2393. qdf_nbuf_copy_expand_fraglist(qdf_nbuf_t buf, int headroom,
  2394. int tailroom)
  2395. {
  2396. buf = qdf_nbuf_copy_expand(buf, headroom, tailroom);
  2397. /* get fraglist reference */
  2398. if (buf)
  2399. __qdf_nbuf_get_ref_fraglist(buf);
  2400. return buf;
  2401. }
  2402. #ifdef WLAN_FEATURE_FASTPATH
  2403. /**
  2404. * qdf_nbuf_init_fast() - before put buf into pool,turn it to init state
  2405. * @nbuf: buf instance
  2406. *
  2407. * Return: data pointer of this buf where new data has to be
  2408. * put, or NULL if there is not enough room in this buf.
  2409. */
  2410. void qdf_nbuf_init_fast(qdf_nbuf_t nbuf);
  2411. #endif /* WLAN_FEATURE_FASTPATH */
  2412. /**
  2413. * qdf_nbuf_list_free() - free a list of nbufs
  2414. * @buf_list: A list of nbufs to be freed
  2415. *
  2416. * Return: none
  2417. */
  2418. static inline void qdf_nbuf_list_free(qdf_nbuf_t buf_list)
  2419. {
  2420. while (buf_list) {
  2421. qdf_nbuf_t next = qdf_nbuf_next(buf_list);
  2422. qdf_nbuf_free(buf_list);
  2423. buf_list = next;
  2424. }
  2425. }
  2426. static inline void qdf_nbuf_tx_free(qdf_nbuf_t buf_list, int tx_err)
  2427. {
  2428. qdf_nbuf_list_free(buf_list);
  2429. }
  2430. static inline void qdf_nbuf_ref(qdf_nbuf_t buf)
  2431. {
  2432. __qdf_nbuf_ref(buf);
  2433. }
  2434. static inline int qdf_nbuf_shared(qdf_nbuf_t buf)
  2435. {
  2436. return __qdf_nbuf_shared(buf);
  2437. }
  2438. static inline QDF_STATUS qdf_nbuf_cat(qdf_nbuf_t dst, qdf_nbuf_t src)
  2439. {
  2440. return __qdf_nbuf_cat(dst, src);
  2441. }
  2442. /**
  2443. * qdf_nbuf_copy_bits() - return the length of the copy bits for skb
  2444. * @nbuf: netbuf
  2445. * @offset: offset
  2446. * @len: Length
  2447. * @to: To
  2448. *
  2449. * Return: int32_t
  2450. */
  2451. static inline int32_t
  2452. qdf_nbuf_copy_bits(qdf_nbuf_t nbuf, uint32_t offset, uint32_t len, void *to)
  2453. {
  2454. return __qdf_nbuf_copy_bits(nbuf, offset, len, to);
  2455. }
  2456. /* nbuf manipulation routines */
  2457. /**
  2458. * qdf_nbuf_head() - return the address of an nbuf's buffer
  2459. * @buf: netbuf
  2460. *
  2461. * Return: head address
  2462. */
  2463. static inline uint8_t *qdf_nbuf_head(qdf_nbuf_t buf)
  2464. {
  2465. return __qdf_nbuf_head(buf);
  2466. }
  2467. /**
  2468. * qdf_nbuf_data() - Return the address of the start of data within an nbuf
  2469. * @buf: Network buffer
  2470. *
  2471. * Return: Data address
  2472. */
  2473. static inline uint8_t *qdf_nbuf_data(qdf_nbuf_t buf)
  2474. {
  2475. return __qdf_nbuf_data(buf);
  2476. }
  2477. /**
  2478. * qdf_nbuf_data_addr() - Return the address of skb->data
  2479. * @buf: Network buffer
  2480. *
  2481. * Return: Data address
  2482. */
  2483. static inline uint8_t *qdf_nbuf_data_addr(qdf_nbuf_t buf)
  2484. {
  2485. return __qdf_nbuf_data_addr(buf);
  2486. }
  2487. /**
  2488. * qdf_nbuf_headroom() - amount of headroom int the current nbuf
  2489. * @buf: Network buffer
  2490. *
  2491. * Return: Amount of head room
  2492. */
  2493. static inline uint32_t qdf_nbuf_headroom(qdf_nbuf_t buf)
  2494. {
  2495. return __qdf_nbuf_headroom(buf);
  2496. }
  2497. /**
  2498. * qdf_nbuf_tailroom() - amount of tail space available
  2499. * @buf: Network buffer
  2500. *
  2501. * Return: amount of tail room
  2502. */
  2503. static inline uint32_t qdf_nbuf_tailroom(qdf_nbuf_t buf)
  2504. {
  2505. return __qdf_nbuf_tailroom(buf);
  2506. }
  2507. /**
  2508. * qdf_nbuf_push_head() - push data in the front
  2509. * @buf: Network buf instance
  2510. * @size: Size to be pushed
  2511. *
  2512. * Return: New data pointer of this buf after data has been pushed,
  2513. * or NULL if there is not enough room in this buf.
  2514. */
  2515. static inline uint8_t *qdf_nbuf_push_head(qdf_nbuf_t buf, qdf_size_t size)
  2516. {
  2517. return __qdf_nbuf_push_head(buf, size);
  2518. }
  2519. /**
  2520. * qdf_nbuf_put_tail() - puts data in the end
  2521. * @buf: Network buf instance
  2522. * @size: Size to be pushed
  2523. *
  2524. * Return: Data pointer of this buf where new data has to be
  2525. * put, or NULL if there is not enough room in this buf.
  2526. */
  2527. static inline uint8_t *qdf_nbuf_put_tail(qdf_nbuf_t buf, qdf_size_t size)
  2528. {
  2529. return __qdf_nbuf_put_tail(buf, size);
  2530. }
  2531. /**
  2532. * qdf_nbuf_pull_head() - pull data out from the front
  2533. * @buf: Network buf instance
  2534. * @size: Size to be popped
  2535. *
  2536. * Return: New data pointer of this buf after data has been popped,
  2537. * or NULL if there is not sufficient data to pull.
  2538. */
  2539. static inline uint8_t *qdf_nbuf_pull_head(qdf_nbuf_t buf, qdf_size_t size)
  2540. {
  2541. return __qdf_nbuf_pull_head(buf, size);
  2542. }
  2543. /**
  2544. * qdf_nbuf_trim_tail() - trim data out from the end
  2545. * @buf: Network buf instance
  2546. * @size: Size to be popped
  2547. *
  2548. * Return: none
  2549. */
  2550. static inline void qdf_nbuf_trim_tail(qdf_nbuf_t buf, qdf_size_t size)
  2551. {
  2552. __qdf_nbuf_trim_tail(buf, size);
  2553. }
  2554. /**
  2555. * qdf_nbuf_len() - get the length of the buf
  2556. * @buf: Network buf instance
  2557. *
  2558. * Return: total length of this buf.
  2559. */
  2560. static inline qdf_size_t qdf_nbuf_len(qdf_nbuf_t buf)
  2561. {
  2562. return __qdf_nbuf_len(buf);
  2563. }
  2564. /**
  2565. * qdf_nbuf_set_pktlen() - set the length of the buf
  2566. * @buf: Network buf instance
  2567. * @len: Size to be set
  2568. *
  2569. * Return: none
  2570. */
  2571. static inline void qdf_nbuf_set_pktlen(qdf_nbuf_t buf, uint32_t len)
  2572. {
  2573. __qdf_nbuf_set_pktlen(buf, len);
  2574. }
  2575. /**
  2576. * qdf_nbuf_reserve() - trim data out from the end
  2577. * @buf: Network buf instance
  2578. * @size: Size to be popped
  2579. *
  2580. * Return: none
  2581. */
  2582. static inline void qdf_nbuf_reserve(qdf_nbuf_t buf, qdf_size_t size)
  2583. {
  2584. __qdf_nbuf_reserve(buf, size);
  2585. }
  2586. /**
  2587. * qdf_nbuf_set_data_pointer() - set data pointer
  2588. * @buf: Network buf instance
  2589. * @data: data pointer
  2590. *
  2591. * Return: none
  2592. */
  2593. static inline void qdf_nbuf_set_data_pointer(qdf_nbuf_t buf, uint8_t *data)
  2594. {
  2595. __qdf_nbuf_set_data_pointer(buf, data);
  2596. }
  2597. /**
  2598. * qdf_nbuf_set_len() - set data length
  2599. * @buf: Network buf instance
  2600. * @len: data length
  2601. * Return: none
  2602. */
  2603. static inline void qdf_nbuf_set_len(qdf_nbuf_t buf, uint32_t len)
  2604. {
  2605. __qdf_nbuf_set_len(buf, len);
  2606. }
  2607. /**
  2608. * qdf_nbuf_set_tail_pointer() - set data tail pointer
  2609. * @buf: Network buf instance
  2610. * @len: length of data
  2611. *
  2612. * Return: none
  2613. */
  2614. static inline void qdf_nbuf_set_tail_pointer(qdf_nbuf_t buf, int len)
  2615. {
  2616. __qdf_nbuf_set_tail_pointer(buf, len);
  2617. }
  2618. /**
  2619. * qdf_nbuf_unlink_no_lock() - unlink a nbuf from nbuf list
  2620. * @buf: Network buf instance
  2621. * @list: list to use
  2622. *
  2623. * This is a lockless version, driver must acquire locks if it
  2624. * needs to synchronize
  2625. *
  2626. * Return: none
  2627. */
  2628. static inline void
  2629. qdf_nbuf_unlink_no_lock(qdf_nbuf_t buf, qdf_nbuf_queue_head_t *list)
  2630. {
  2631. __qdf_nbuf_unlink_no_lock(buf, list);
  2632. }
  2633. /**
  2634. * qdf_nbuf_reset() - reset the buffer data and pointer
  2635. * @buf: Network buf instance
  2636. * @reserve: reserve
  2637. * @align: align
  2638. *
  2639. * Return: none
  2640. */
  2641. static inline void qdf_nbuf_reset(qdf_nbuf_t buf, int reserve, int align)
  2642. {
  2643. __qdf_nbuf_reset(buf, reserve, align);
  2644. }
  2645. /**
  2646. * qdf_nbuf_is_dev_scratch_supported() - dev_scratch support for network buffer
  2647. * in kernel
  2648. *
  2649. * Return: true if dev_scratch is supported
  2650. * false if dev_scratch is not supported
  2651. */
  2652. static inline bool qdf_nbuf_is_dev_scratch_supported(void)
  2653. {
  2654. return __qdf_nbuf_is_dev_scratch_supported();
  2655. }
  2656. /**
  2657. * qdf_nbuf_get_dev_scratch() - get dev_scratch of network buffer
  2658. * @buf: Pointer to network buffer
  2659. *
  2660. * Return: dev_scratch if dev_scratch supported
  2661. * 0 if dev_scratch not supported
  2662. */
  2663. static inline unsigned long qdf_nbuf_get_dev_scratch(qdf_nbuf_t buf)
  2664. {
  2665. return __qdf_nbuf_get_dev_scratch(buf);
  2666. }
  2667. /**
  2668. * qdf_nbuf_set_dev_scratch() - set dev_scratch of network buffer
  2669. * @buf: Pointer to network buffer
  2670. * @value: value to be set in dev_scratch of network buffer
  2671. *
  2672. * Return: void
  2673. */
  2674. static inline void qdf_nbuf_set_dev_scratch(qdf_nbuf_t buf, unsigned long value)
  2675. {
  2676. __qdf_nbuf_set_dev_scratch(buf, value);
  2677. }
  2678. /**
  2679. * qdf_nbuf_set_dev() - set dev in network buffer
  2680. * @nbuf: Pointer to network buffer
  2681. * @dev: netdev to be set in network buffer
  2682. *
  2683. * Return: void
  2684. */
  2685. static inline
  2686. void qdf_nbuf_set_dev(qdf_nbuf_t nbuf, qdf_netdev_t dev)
  2687. {
  2688. __qdf_nbuf_set_dev(nbuf, dev);
  2689. }
  2690. /**
  2691. * qdf_nbuf_get_dev_mtu() - get dev mtu in n/w buffer
  2692. * @nbuf: Pointer to network buffer
  2693. *
  2694. * Return: dev mtu value in nbuf
  2695. */
  2696. static inline
  2697. unsigned int qdf_nbuf_get_dev_mtu(qdf_nbuf_t nbuf)
  2698. {
  2699. return __qdf_nbuf_get_dev_mtu(nbuf);
  2700. }
  2701. /**
  2702. * qdf_nbuf_set_protocol_eth_tye_trans() - set protocol using eth trans os API
  2703. * @nbuf: Pointer to network buffer
  2704. *
  2705. * Return: None
  2706. */
  2707. static inline
  2708. void qdf_nbuf_set_protocol_eth_tye_trans(qdf_nbuf_t nbuf)
  2709. {
  2710. __qdf_nbuf_set_protocol_eth_type_trans(nbuf);
  2711. }
  2712. /**
  2713. * qdf_nbuf_peek_header() - return the data pointer & length of the header
  2714. * @buf: Network nbuf
  2715. * @addr: Data pointer
  2716. * @len: Length of the data
  2717. *
  2718. * Return: none
  2719. */
  2720. static inline void
  2721. qdf_nbuf_peek_header(qdf_nbuf_t buf, uint8_t **addr, uint32_t *len)
  2722. {
  2723. __qdf_nbuf_peek_header(buf, addr, len);
  2724. }
  2725. /* nbuf queue routines */
  2726. /**
  2727. * qdf_nbuf_queue_init() - initialize buf queue
  2728. * @head: Network buf queue head
  2729. *
  2730. * Return: none
  2731. */
  2732. static inline void qdf_nbuf_queue_init(qdf_nbuf_queue_t *head)
  2733. {
  2734. __qdf_nbuf_queue_init(head);
  2735. }
  2736. /**
  2737. * qdf_nbuf_queue_add() - append a nbuf to the tail of the buf queue
  2738. * @head: Network buf queue head
  2739. * @buf: Network buf
  2740. *
  2741. * Return: none
  2742. */
  2743. static inline void qdf_nbuf_queue_add(qdf_nbuf_queue_t *head, qdf_nbuf_t buf)
  2744. {
  2745. __qdf_nbuf_queue_add(head, buf);
  2746. }
  2747. /**
  2748. * qdf_nbuf_queue_insert_head() - insert nbuf at the head of queue
  2749. * @head: Network buf queue head
  2750. * @buf: Network buf
  2751. *
  2752. * Return: none
  2753. */
  2754. static inline void
  2755. qdf_nbuf_queue_insert_head(qdf_nbuf_queue_t *head, qdf_nbuf_t buf)
  2756. {
  2757. __qdf_nbuf_queue_insert_head(head, buf);
  2758. }
  2759. /**
  2760. * qdf_nbuf_queue_remove_last() - remove last nbuf from queue
  2761. * @head: Network buf queue head
  2762. *
  2763. * Return: none
  2764. */
  2765. static inline qdf_nbuf_t qdf_nbuf_queue_remove_last(qdf_nbuf_queue_t *head)
  2766. {
  2767. return __qdf_nbuf_queue_remove_last(head);
  2768. }
  2769. /**
  2770. * qdf_nbuf_queue_remove() - retrieve a buf from the head of the buf queue
  2771. * @head: Network buf queue head
  2772. *
  2773. * Return: The head buf in the buf queue.
  2774. */
  2775. static inline qdf_nbuf_t qdf_nbuf_queue_remove(qdf_nbuf_queue_t *head)
  2776. {
  2777. return __qdf_nbuf_queue_remove(head);
  2778. }
  2779. /**
  2780. * qdf_nbuf_queue_len() - get the length of the queue
  2781. * @head: Network buf queue head
  2782. *
  2783. * Return: length of the queue
  2784. */
  2785. static inline uint32_t qdf_nbuf_queue_len(qdf_nbuf_queue_t *head)
  2786. {
  2787. return __qdf_nbuf_queue_len(head);
  2788. }
  2789. /**
  2790. * qdf_nbuf_queue_next() - get the next guy/packet of the given buffer
  2791. * @buf: Network buffer
  2792. *
  2793. * Return: next buffer/packet
  2794. */
  2795. static inline qdf_nbuf_t qdf_nbuf_queue_next(qdf_nbuf_t buf)
  2796. {
  2797. return __qdf_nbuf_queue_next(buf);
  2798. }
  2799. /**
  2800. * qdf_nbuf_is_queue_empty() - check if the buf queue is empty
  2801. * @nbq: Network buf queue handle
  2802. *
  2803. * Return: true if queue is empty
  2804. * false if queue is not empty
  2805. */
  2806. static inline bool qdf_nbuf_is_queue_empty(qdf_nbuf_queue_t *nbq)
  2807. {
  2808. return __qdf_nbuf_is_queue_empty(nbq);
  2809. }
  2810. static inline qdf_nbuf_queue_t *
  2811. qdf_nbuf_queue_append(qdf_nbuf_queue_t *dest, qdf_nbuf_queue_t *src)
  2812. {
  2813. return __qdf_nbuf_queue_append(dest, src);
  2814. }
  2815. static inline void
  2816. qdf_nbuf_queue_free(qdf_nbuf_queue_t *head)
  2817. {
  2818. qdf_nbuf_t buf = NULL;
  2819. while ((buf = qdf_nbuf_queue_remove(head)) != NULL)
  2820. qdf_nbuf_free(buf);
  2821. }
  2822. static inline qdf_nbuf_t
  2823. qdf_nbuf_queue_first(qdf_nbuf_queue_t *head)
  2824. {
  2825. return __qdf_nbuf_queue_first(head);
  2826. }
  2827. static inline qdf_nbuf_t
  2828. qdf_nbuf_queue_last(qdf_nbuf_queue_t *head)
  2829. {
  2830. return __qdf_nbuf_queue_last(head);
  2831. }
  2832. /**
  2833. * qdf_nbuf_get_protocol() - return the protocol value of the skb
  2834. * @skb: Pointer to network buffer
  2835. *
  2836. * Return: skb protocol
  2837. */
  2838. static inline uint16_t qdf_nbuf_get_protocol(struct sk_buff *skb)
  2839. {
  2840. return __qdf_nbuf_get_protocol(skb);
  2841. }
  2842. /**
  2843. * qdf_nbuf_get_ip_summed() - return the ip checksum value of the skb
  2844. * @skb: Pointer to network buffer
  2845. *
  2846. * Return: skb ip_summed
  2847. */
  2848. static inline uint8_t qdf_nbuf_get_ip_summed(struct sk_buff *skb)
  2849. {
  2850. return __qdf_nbuf_get_ip_summed(skb);
  2851. }
  2852. /**
  2853. * qdf_nbuf_set_ip_summed() - sets the ip_summed value of the skb
  2854. * @skb: Pointer to network buffer
  2855. * @ip_summed: ip checksum
  2856. *
  2857. * Return: none
  2858. */
  2859. static inline void qdf_nbuf_set_ip_summed(struct sk_buff *skb,
  2860. uint8_t ip_summed)
  2861. {
  2862. __qdf_nbuf_set_ip_summed(skb, ip_summed);
  2863. }
  2864. /**
  2865. * qdf_nbuf_set_next() - add a packet to a linked list
  2866. * @this_buf: Predecessor buffer
  2867. * @next_buf: Successor buffer
  2868. *
  2869. * This function can be used to directly link nbufs, rather than using
  2870. * a separate network buffer queue object.
  2871. *
  2872. * Return: none
  2873. */
  2874. static inline void qdf_nbuf_set_next(qdf_nbuf_t this_buf, qdf_nbuf_t next_buf)
  2875. {
  2876. __qdf_nbuf_set_next(this_buf, next_buf);
  2877. }
  2878. /* nbuf extension routines */
  2879. /**
  2880. * qdf_nbuf_set_next_ext() - link extension of this packet contained in a new
  2881. * nbuf
  2882. * @this_buf: predecessor buffer
  2883. * @next_buf: successor buffer
  2884. *
  2885. * This function is used to link up many nbufs containing a single logical
  2886. * packet - not a collection of packets. Do not use for linking the first
  2887. * extension to the head
  2888. *
  2889. * Return: none
  2890. */
  2891. static inline void
  2892. qdf_nbuf_set_next_ext(qdf_nbuf_t this_buf, qdf_nbuf_t next_buf)
  2893. {
  2894. __qdf_nbuf_set_next_ext(this_buf, next_buf);
  2895. }
  2896. /**
  2897. * qdf_nbuf_next_ext() - get the next packet extension in the linked list
  2898. * @buf: Network buffer
  2899. *
  2900. * Return: Next network buffer in the linked list
  2901. */
  2902. static inline qdf_nbuf_t qdf_nbuf_next_ext(qdf_nbuf_t buf)
  2903. {
  2904. return __qdf_nbuf_next_ext(buf);
  2905. }
  2906. /**
  2907. * qdf_nbuf_append_ext_list() - link list of packet extensions to the head
  2908. * segment
  2909. * @head_buf: Network buf holding head segment (single)
  2910. * @ext_list: Network buf list holding linked extensions to the head
  2911. * @ext_len: Total length of all buffers in the extension list
  2912. *
  2913. * This function is used to link up a list of packet extensions (seg1, 2,
  2914. * ...) to the nbuf holding the head segment (seg0)
  2915. *
  2916. * Return: none
  2917. */
  2918. static inline void
  2919. qdf_nbuf_append_ext_list(qdf_nbuf_t head_buf, qdf_nbuf_t ext_list,
  2920. qdf_size_t ext_len)
  2921. {
  2922. __qdf_nbuf_append_ext_list(head_buf, ext_list, ext_len);
  2923. }
  2924. /**
  2925. * qdf_nbuf_get_ext_list() - Get the link to extended nbuf list.
  2926. * @head_buf: Network buf holding head segment (single)
  2927. *
  2928. * This ext_list is populated when we have Jumbo packet, for example in case of
  2929. * monitor mode amsdu packet reception, and are stiched using frags_list.
  2930. *
  2931. * Return: Network buf list holding linked extensions from head buf.
  2932. */
  2933. static inline qdf_nbuf_t qdf_nbuf_get_ext_list(qdf_nbuf_t head_buf)
  2934. {
  2935. return (qdf_nbuf_t)__qdf_nbuf_get_ext_list(head_buf);
  2936. }
  2937. /**
  2938. * qdf_nbuf_get_shinfo() - gets the shared info of head buf
  2939. * @head_buf: Network buffer
  2940. *
  2941. * Return: shared info of head buf
  2942. */
  2943. static inline qdf_nbuf_shared_info_t qdf_nbuf_get_shinfo(qdf_nbuf_t head_buf)
  2944. {
  2945. return (qdf_nbuf_shared_info_t)__qdf_nbuf_get_shinfo(head_buf);
  2946. }
  2947. /**
  2948. * qdf_nbuf_get_tx_cksum() - gets the tx checksum offload demand
  2949. * @buf: Network buffer
  2950. *
  2951. * Return: qdf_nbuf_tx_cksum_t checksum offload demand for the frame
  2952. */
  2953. static inline qdf_nbuf_tx_cksum_t qdf_nbuf_get_tx_cksum(qdf_nbuf_t buf)
  2954. {
  2955. return __qdf_nbuf_get_tx_cksum(buf);
  2956. }
  2957. /**
  2958. * qdf_nbuf_set_rx_cksum() - drivers that support hw checksumming use this to
  2959. * indicate checksum info to the stack.
  2960. * @buf: Network buffer
  2961. * @cksum: Checksum
  2962. *
  2963. * Return: none
  2964. */
  2965. static inline void
  2966. qdf_nbuf_set_rx_cksum(qdf_nbuf_t buf, qdf_nbuf_rx_cksum_t *cksum)
  2967. {
  2968. __qdf_nbuf_set_rx_cksum(buf, cksum);
  2969. }
  2970. /**
  2971. * qdf_nbuf_get_tid() - this function extracts the TID value from nbuf
  2972. * @buf: Network buffer
  2973. *
  2974. * Return: TID value
  2975. */
  2976. static inline uint8_t qdf_nbuf_get_tid(qdf_nbuf_t buf)
  2977. {
  2978. return __qdf_nbuf_get_tid(buf);
  2979. }
  2980. /**
  2981. * qdf_nbuf_set_tid() - this function sets the TID value in nbuf
  2982. * @buf: Network buffer
  2983. * @tid: TID value
  2984. *
  2985. * Return: none
  2986. */
  2987. static inline void qdf_nbuf_set_tid(qdf_nbuf_t buf, uint8_t tid)
  2988. {
  2989. __qdf_nbuf_set_tid(buf, tid);
  2990. }
  2991. /**
  2992. * qdf_nbuf_get_exemption_type() - this function extracts the exemption type
  2993. * from nbuf
  2994. * @buf: Network buffer
  2995. *
  2996. * Return: Exemption type
  2997. */
  2998. static inline uint8_t qdf_nbuf_get_exemption_type(qdf_nbuf_t buf)
  2999. {
  3000. return __qdf_nbuf_get_exemption_type(buf);
  3001. }
  3002. /**
  3003. * qdf_nbuf_set_protocol() - this function peeks data into the buffer at given
  3004. * offset
  3005. * @buf: Network buffer
  3006. * @proto: Protocol
  3007. *
  3008. * Return: none
  3009. */
  3010. static inline void qdf_nbuf_set_protocol(qdf_nbuf_t buf, uint16_t proto)
  3011. {
  3012. __qdf_nbuf_set_protocol(buf, proto);
  3013. }
  3014. /**
  3015. * qdf_nbuf_trace_get_proto_type() - this function return packet proto type
  3016. * @buf: Network buffer
  3017. *
  3018. * Return: Packet protocol type
  3019. */
  3020. static inline uint8_t qdf_nbuf_trace_get_proto_type(qdf_nbuf_t buf)
  3021. {
  3022. return __qdf_nbuf_trace_get_proto_type(buf);
  3023. }
  3024. /**
  3025. * qdf_nbuf_reg_trace_cb() - this function registers protocol trace callback
  3026. * @cb_func_ptr: Callback pointer
  3027. *
  3028. * Return: none
  3029. */
  3030. static inline void qdf_nbuf_reg_trace_cb(qdf_nbuf_trace_update_t cb_func_ptr)
  3031. {
  3032. __qdf_nbuf_reg_trace_cb(cb_func_ptr);
  3033. }
  3034. /**
  3035. * qdf_nbuf_set_tx_parallel_dnload_frm() - set tx parallel download
  3036. * @buf: Network buffer
  3037. * @candi: Candidate of parallel download frame
  3038. *
  3039. * This function stores a flag specifying this TX frame is suitable for
  3040. * downloading though a 2nd TX data pipe that is used for short frames for
  3041. * protocols that can accept out-of-order delivery.
  3042. *
  3043. * Return: none
  3044. */
  3045. static inline void
  3046. qdf_nbuf_set_tx_parallel_dnload_frm(qdf_nbuf_t buf, uint8_t candi)
  3047. {
  3048. __qdf_nbuf_set_tx_htt2_frm(buf, candi);
  3049. }
  3050. /**
  3051. * qdf_nbuf_get_tx_parallel_dnload_frm() - get tx parallel download
  3052. * @buf: Network buffer
  3053. *
  3054. * This function return whether this TX frame is allow to download though a 2nd
  3055. * TX data pipe or not.
  3056. *
  3057. * Return: none
  3058. */
  3059. static inline uint8_t qdf_nbuf_get_tx_parallel_dnload_frm(qdf_nbuf_t buf)
  3060. {
  3061. return __qdf_nbuf_get_tx_htt2_frm(buf);
  3062. }
  3063. /**
  3064. * qdf_nbuf_get_dhcp_subtype() - get the subtype
  3065. * of DHCP packet.
  3066. * @buf: Pointer to DHCP packet buffer
  3067. *
  3068. * This func. returns the subtype of DHCP packet.
  3069. *
  3070. * Return: subtype of the DHCP packet.
  3071. */
  3072. static inline enum qdf_proto_subtype
  3073. qdf_nbuf_get_dhcp_subtype(qdf_nbuf_t buf)
  3074. {
  3075. return __qdf_nbuf_data_get_dhcp_subtype(qdf_nbuf_data(buf));
  3076. }
  3077. /**
  3078. * qdf_nbuf_data_get_dhcp_subtype() - get the subtype
  3079. * of DHCP packet.
  3080. * @data: Pointer to DHCP packet data buffer
  3081. *
  3082. * This func. returns the subtype of DHCP packet.
  3083. *
  3084. * Return: subtype of the DHCP packet.
  3085. */
  3086. static inline enum qdf_proto_subtype
  3087. qdf_nbuf_data_get_dhcp_subtype(uint8_t *data)
  3088. {
  3089. return __qdf_nbuf_data_get_dhcp_subtype(data);
  3090. }
  3091. /**
  3092. * qdf_nbuf_get_eapol_subtype() - get the subtype
  3093. * of EAPOL packet.
  3094. * @buf: Pointer to EAPOL packet buffer
  3095. *
  3096. * This func. returns the subtype of EAPOL packet.
  3097. *
  3098. * Return: subtype of the EAPOL packet.
  3099. */
  3100. static inline enum qdf_proto_subtype
  3101. qdf_nbuf_get_eapol_subtype(qdf_nbuf_t buf)
  3102. {
  3103. return __qdf_nbuf_data_get_eapol_subtype(qdf_nbuf_data(buf));
  3104. }
  3105. /**
  3106. * qdf_nbuf_data_get_eapol_subtype() - get the subtype
  3107. * of EAPOL packet.
  3108. * @data: Pointer to EAPOL packet data buffer
  3109. *
  3110. * This func. returns the subtype of EAPOL packet.
  3111. *
  3112. * Return: subtype of the EAPOL packet.
  3113. */
  3114. static inline enum qdf_proto_subtype
  3115. qdf_nbuf_data_get_eapol_subtype(uint8_t *data)
  3116. {
  3117. return __qdf_nbuf_data_get_eapol_subtype(data);
  3118. }
  3119. /**
  3120. * qdf_nbuf_get_arp_subtype() - get the subtype
  3121. * of ARP packet.
  3122. * @buf: Pointer to ARP packet buffer
  3123. *
  3124. * This func. returns the subtype of ARP packet.
  3125. *
  3126. * Return: subtype of the ARP packet.
  3127. */
  3128. static inline enum qdf_proto_subtype
  3129. qdf_nbuf_get_arp_subtype(qdf_nbuf_t buf)
  3130. {
  3131. return __qdf_nbuf_data_get_arp_subtype(qdf_nbuf_data(buf));
  3132. }
  3133. /**
  3134. * qdf_nbuf_data_get_arp_subtype() - get the subtype
  3135. * of ARP packet.
  3136. * @data: Pointer to ARP packet data buffer
  3137. *
  3138. * This func. returns the subtype of ARP packet.
  3139. *
  3140. * Return: subtype of the ARP packet.
  3141. */
  3142. static inline enum qdf_proto_subtype
  3143. qdf_nbuf_data_get_arp_subtype(uint8_t *data)
  3144. {
  3145. return __qdf_nbuf_data_get_arp_subtype(data);
  3146. }
  3147. /**
  3148. * qdf_nbuf_get_icmp_subtype() - get the subtype
  3149. * of IPV4 ICMP packet.
  3150. * @buf: Pointer to IPV4 ICMP packet buffer
  3151. *
  3152. * This func. returns the subtype of ICMP packet.
  3153. *
  3154. * Return: subtype of the ICMP packet.
  3155. */
  3156. static inline enum qdf_proto_subtype
  3157. qdf_nbuf_get_icmp_subtype(qdf_nbuf_t buf)
  3158. {
  3159. return __qdf_nbuf_data_get_icmp_subtype(qdf_nbuf_data(buf));
  3160. }
  3161. /**
  3162. * qdf_nbuf_data_get_icmp_subtype() - get the subtype
  3163. * of IPV4 ICMP packet.
  3164. * @data: Pointer to IPV4 ICMP packet data buffer
  3165. *
  3166. * This func. returns the subtype of ICMP packet.
  3167. *
  3168. * Return: subtype of the ICMP packet.
  3169. */
  3170. static inline enum qdf_proto_subtype
  3171. qdf_nbuf_data_get_icmp_subtype(uint8_t *data)
  3172. {
  3173. return __qdf_nbuf_data_get_icmp_subtype(data);
  3174. }
  3175. /**
  3176. * qdf_nbuf_get_icmpv6_subtype() - get the subtype
  3177. * of IPV6 ICMPV6 packet.
  3178. * @buf: Pointer to IPV6 ICMPV6 packet buffer
  3179. *
  3180. * This func. returns the subtype of ICMPV6 packet.
  3181. *
  3182. * Return: subtype of the ICMPV6 packet.
  3183. */
  3184. static inline enum qdf_proto_subtype
  3185. qdf_nbuf_get_icmpv6_subtype(qdf_nbuf_t buf)
  3186. {
  3187. return __qdf_nbuf_data_get_icmpv6_subtype(qdf_nbuf_data(buf));
  3188. }
  3189. /**
  3190. * qdf_nbuf_data_get_icmpv6_subtype() - get the subtype
  3191. * of IPV6 ICMPV6 packet.
  3192. * @data: Pointer to IPV6 ICMPV6 packet data buffer
  3193. *
  3194. * This func. returns the subtype of ICMPV6 packet.
  3195. *
  3196. * Return: subtype of the ICMPV6 packet.
  3197. */
  3198. static inline enum qdf_proto_subtype
  3199. qdf_nbuf_data_get_icmpv6_subtype(uint8_t *data)
  3200. {
  3201. return __qdf_nbuf_data_get_icmpv6_subtype(data);
  3202. }
  3203. /**
  3204. * qdf_nbuf_is_ipv4_last_fragment() - Check if IPV4 packet is last fragment
  3205. * @nbuf: Network buffer
  3206. *
  3207. * This function check if IPV4 packet is last fragment or not.
  3208. * Caller has to call this function for ipv4 packets only.
  3209. *
  3210. * Return: True if ipv4 packet is last fragment otherwise false
  3211. */
  3212. static inline bool
  3213. qdf_nbuf_is_ipv4_last_fragment(qdf_nbuf_t nbuf)
  3214. {
  3215. return __qdf_nbuf_is_ipv4_last_fragment(nbuf);
  3216. }
  3217. /**
  3218. * qdf_nbuf_data_set_ipv4_tos() - set the TOS field of IPV4 packet.
  3219. *
  3220. * @data: Pointer to IPV4 packet data buffer
  3221. * @tos: TOS value to be set in IPV4 packet
  3222. *
  3223. * This func. set the TOS field of IPV4 packet.
  3224. *
  3225. * Return: None
  3226. */
  3227. static inline void
  3228. qdf_nbuf_data_set_ipv4_tos(uint8_t *data, uint8_t tos)
  3229. {
  3230. __qdf_nbuf_data_set_ipv4_tos(data, tos);
  3231. }
  3232. /**
  3233. * qdf_nbuf_data_get_ipv4_tos() - get the TOS field of IPV4 packet.
  3234. *
  3235. * @data: Pointer to IPV4 packet data buffer
  3236. *
  3237. * This func. returns the TOS field of IPV4 packet.
  3238. *
  3239. * Return: TOS of IPV4 packet.
  3240. */
  3241. static inline uint8_t
  3242. qdf_nbuf_data_get_ipv4_tos(uint8_t *data)
  3243. {
  3244. return __qdf_nbuf_data_get_ipv4_tos(data);
  3245. }
  3246. /**
  3247. * qdf_nbuf_data_get_ipv4_proto() - get the proto type
  3248. * of IPV4 packet.
  3249. * @data: Pointer to IPV4 packet data buffer
  3250. *
  3251. * This func. returns the proto type of IPV4 packet.
  3252. *
  3253. * Return: proto type of IPV4 packet.
  3254. */
  3255. static inline uint8_t
  3256. qdf_nbuf_data_get_ipv4_proto(uint8_t *data)
  3257. {
  3258. return __qdf_nbuf_data_get_ipv4_proto(data);
  3259. }
  3260. /**
  3261. * qdf_nbuf_data_set_ipv6_tc() - set the TC field
  3262. * of IPV6 packet.
  3263. * @data: Pointer to IPV6 packet data buffer
  3264. * @tc: Value to IPV6 packet TC field
  3265. *
  3266. * This func. set the TC field of IPV6 packet.
  3267. *
  3268. * Return: None
  3269. */
  3270. static inline void
  3271. qdf_nbuf_data_set_ipv6_tc(uint8_t *data, uint8_t tc)
  3272. {
  3273. __qdf_nbuf_data_set_ipv6_tc(data, tc);
  3274. }
  3275. /**
  3276. * qdf_nbuf_data_get_ipv6_tc() - get the TC field
  3277. * of IPV6 packet.
  3278. * @data: Pointer to IPV6 packet data buffer
  3279. *
  3280. * This func. returns the TC field of IPV6 packet.
  3281. *
  3282. * Return: Traffic classification field of IPV6 packet.
  3283. */
  3284. static inline uint8_t
  3285. qdf_nbuf_data_get_ipv6_tc(uint8_t *data)
  3286. {
  3287. return __qdf_nbuf_data_get_ipv6_tc(data);
  3288. }
  3289. /**
  3290. * qdf_nbuf_data_get_ipv6_proto() - get the proto type
  3291. * of IPV6 packet.
  3292. * @data: Pointer to IPV6 packet data buffer
  3293. *
  3294. * This func. returns the proto type of IPV6 packet.
  3295. *
  3296. * Return: proto type of IPV6 packet.
  3297. */
  3298. static inline uint8_t
  3299. qdf_nbuf_data_get_ipv6_proto(uint8_t *data)
  3300. {
  3301. return __qdf_nbuf_data_get_ipv6_proto(data);
  3302. }
  3303. /**
  3304. * qdf_nbuf_is_ipv4_pkt() - check if packet is a ipv4 packet or not
  3305. * @buf: buffer
  3306. *
  3307. * This api is for Tx packets.
  3308. *
  3309. * Return: true if packet is ipv4 packet
  3310. */
  3311. static inline
  3312. bool qdf_nbuf_is_ipv4_pkt(qdf_nbuf_t buf)
  3313. {
  3314. return __qdf_nbuf_data_is_ipv4_pkt(qdf_nbuf_data(buf));
  3315. }
  3316. /**
  3317. * qdf_nbuf_data_is_ipv4_pkt() - check if packet is a ipv4 packet or not
  3318. * @data: data
  3319. *
  3320. * This api is for Tx packets.
  3321. *
  3322. * Return: true if packet is ipv4 packet
  3323. */
  3324. static inline
  3325. bool qdf_nbuf_data_is_ipv4_pkt(uint8_t *data)
  3326. {
  3327. return __qdf_nbuf_data_is_ipv4_pkt(data);
  3328. }
  3329. /**
  3330. * qdf_nbuf_is_ipv4_dhcp_pkt() - check if packet is a dhcp packet or not
  3331. * @buf: buffer
  3332. *
  3333. * This api is for ipv4 packet.
  3334. *
  3335. * Return: true if packet is DHCP packet
  3336. */
  3337. static inline
  3338. bool qdf_nbuf_is_ipv4_dhcp_pkt(qdf_nbuf_t buf)
  3339. {
  3340. return __qdf_nbuf_data_is_ipv4_dhcp_pkt(qdf_nbuf_data(buf));
  3341. }
  3342. /**
  3343. * qdf_nbuf_data_is_ipv4_dhcp_pkt() - check if it is DHCP packet.
  3344. * @data: Pointer to DHCP packet data buffer
  3345. *
  3346. * This func. checks whether it is a DHCP packet or not.
  3347. *
  3348. * Return: true if it is a DHCP packet
  3349. * false if not
  3350. */
  3351. static inline
  3352. bool qdf_nbuf_data_is_ipv4_dhcp_pkt(uint8_t *data)
  3353. {
  3354. return __qdf_nbuf_data_is_ipv4_dhcp_pkt(data);
  3355. }
  3356. /**
  3357. * qdf_nbuf_is_ipv6_mdns_pkt() - check if it is MDNS packet.
  3358. * @buf: Pointer to packet data buffer
  3359. *
  3360. * This func. checks whether it is a MDNS packet or not.
  3361. *
  3362. * Return: true if it is a MDNS packet, false if not
  3363. */
  3364. static inline
  3365. bool qdf_nbuf_is_ipv6_mdns_pkt(qdf_nbuf_t buf)
  3366. {
  3367. return __qdf_nbuf_data_is_ipv6_mdns_pkt(qdf_nbuf_data(buf));
  3368. }
  3369. /**
  3370. * qdf_nbuf_is_ipv6_dhcp_pkt() - check if it is DHCP packet.
  3371. * @buf: Pointer to DHCP packet data buffer
  3372. *
  3373. * This func. checks whether it is a DHCP packet or not.
  3374. *
  3375. * Return: true if it is a DHCP packet
  3376. * false if not
  3377. */
  3378. static inline
  3379. bool qdf_nbuf_is_ipv6_dhcp_pkt(qdf_nbuf_t buf)
  3380. {
  3381. return __qdf_nbuf_data_is_ipv6_dhcp_pkt(qdf_nbuf_data(buf));
  3382. }
  3383. /**
  3384. * qdf_nbuf_is_ipv4_eapol_pkt() - check if packet is a eapol packet or not
  3385. * @buf: buffer
  3386. *
  3387. * This api is for ipv4 packet.
  3388. *
  3389. * Return: true if packet is EAPOL packet
  3390. */
  3391. static inline
  3392. bool qdf_nbuf_is_ipv4_eapol_pkt(qdf_nbuf_t buf)
  3393. {
  3394. return __qdf_nbuf_data_is_ipv4_eapol_pkt(qdf_nbuf_data(buf));
  3395. }
  3396. /**
  3397. * qdf_nbuf_data_is_ipv4_eapol_pkt() - check if it is EAPOL packet.
  3398. * @data: Pointer to EAPOL packet data buffer
  3399. *
  3400. * This func. checks whether it is a EAPOL packet or not.
  3401. *
  3402. * Return: true if it is a EAPOL packet
  3403. * false if not
  3404. */
  3405. static inline
  3406. bool qdf_nbuf_data_is_ipv4_eapol_pkt(uint8_t *data)
  3407. {
  3408. return __qdf_nbuf_data_is_ipv4_eapol_pkt(data);
  3409. }
  3410. /**
  3411. * qdf_nbuf_is_ipv4_wapi_pkt() - check if packet is a wapi packet or not
  3412. * @buf: buffer
  3413. *
  3414. * This api is for ipv4 packet.
  3415. *
  3416. * Return: true if packet is WAPI packet
  3417. */
  3418. static inline
  3419. bool qdf_nbuf_is_ipv4_wapi_pkt(qdf_nbuf_t buf)
  3420. {
  3421. return __qdf_nbuf_is_ipv4_wapi_pkt(buf);
  3422. }
  3423. /**
  3424. * qdf_nbuf_is_ipv4_igmp_pkt() - check if packet is a igmp packet or not
  3425. * @buf: buffer
  3426. *
  3427. * This api is for ipv4 packet.
  3428. *
  3429. * Return: true if packet is igmp packet
  3430. */
  3431. static inline
  3432. bool qdf_nbuf_is_ipv4_igmp_pkt(qdf_nbuf_t buf)
  3433. {
  3434. return __qdf_nbuf_data_is_ipv4_igmp_pkt(qdf_nbuf_data(buf));
  3435. }
  3436. /**
  3437. * qdf_nbuf_is_ipv6_igmp_pkt() - check if packet is a igmp packet or not
  3438. * @buf: buffer
  3439. *
  3440. * This api is for ipv6 packet.
  3441. *
  3442. * Return: true if packet is igmp packet
  3443. */
  3444. static inline
  3445. bool qdf_nbuf_is_ipv6_igmp_pkt(qdf_nbuf_t buf)
  3446. {
  3447. return __qdf_nbuf_data_is_ipv6_igmp_pkt(qdf_nbuf_data(buf));
  3448. }
  3449. /**
  3450. * qdf_nbuf_is_ipv4_igmp_leave_pkt() - check if it is a igmp leave packet or not
  3451. * @buf: buffer
  3452. *
  3453. * This api is for ipv4 packet.
  3454. *
  3455. * Return: true if packet is igmp packet
  3456. */
  3457. static inline
  3458. bool qdf_nbuf_is_ipv4_igmp_leave_pkt(qdf_nbuf_t buf)
  3459. {
  3460. return __qdf_nbuf_is_ipv4_igmp_leave_pkt(buf);
  3461. }
  3462. /**
  3463. * qdf_nbuf_is_ipv6_igmp_leave_pkt() - check if it is a igmp leave packet or not
  3464. * @buf: buffer
  3465. *
  3466. * This api is for ipv6 packet.
  3467. *
  3468. * Return: true if packet is igmp packet
  3469. */
  3470. static inline
  3471. bool qdf_nbuf_is_ipv6_igmp_leave_pkt(qdf_nbuf_t buf)
  3472. {
  3473. return __qdf_nbuf_is_ipv6_igmp_leave_pkt(buf);
  3474. }
  3475. /**
  3476. * qdf_nbuf_is_ipv4_tdls_pkt() - check if packet is a tdls packet or not
  3477. * @buf: buffer
  3478. *
  3479. * This api is for ipv4 packet.
  3480. *
  3481. * Return: true if packet is TDLS packet
  3482. */
  3483. static inline
  3484. bool qdf_nbuf_is_ipv4_tdls_pkt(qdf_nbuf_t buf)
  3485. {
  3486. return __qdf_nbuf_is_ipv4_tdls_pkt(buf);
  3487. }
  3488. /**
  3489. * qdf_nbuf_is_ipv4_arp_pkt() - check if packet is a arp packet or not
  3490. * @buf: buffer
  3491. *
  3492. * This api is for ipv4 packet.
  3493. *
  3494. * Return: true if packet is ARP packet
  3495. */
  3496. static inline
  3497. bool qdf_nbuf_is_ipv4_arp_pkt(qdf_nbuf_t buf)
  3498. {
  3499. return __qdf_nbuf_data_is_ipv4_arp_pkt(qdf_nbuf_data(buf));
  3500. }
  3501. /**
  3502. * qdf_nbuf_data_is_ipv4_arp_pkt() - check if it is ARP packet.
  3503. * @data: Pointer to ARP packet data buffer
  3504. *
  3505. * This func. checks whether it is a ARP packet or not.
  3506. *
  3507. * Return: TRUE if it is a ARP packet
  3508. * FALSE if not
  3509. */
  3510. static inline
  3511. bool qdf_nbuf_data_is_ipv4_arp_pkt(uint8_t *data)
  3512. {
  3513. return __qdf_nbuf_data_is_ipv4_arp_pkt(data);
  3514. }
  3515. /**
  3516. * qdf_nbuf_data_is_arp_req() - check if ARP packet is request.
  3517. * @buf: buffer
  3518. *
  3519. * This func. checks whether it is a ARP request or not.
  3520. *
  3521. * Return: true if it is a ARP request or FALSE if not
  3522. */
  3523. static inline
  3524. bool qdf_nbuf_data_is_arp_req(qdf_nbuf_t buf)
  3525. {
  3526. return __qdf_nbuf_data_is_arp_req(qdf_nbuf_data(buf));
  3527. }
  3528. /**
  3529. * qdf_nbuf_data_is_arp_rsp() - check if ARP packet is response.
  3530. * @buf: buffer
  3531. *
  3532. * This func. checks whether it is a ARP response or not.
  3533. *
  3534. * Return: true if it is a ARP response or FALSE if not
  3535. */
  3536. static inline
  3537. bool qdf_nbuf_data_is_arp_rsp(qdf_nbuf_t buf)
  3538. {
  3539. return __qdf_nbuf_data_is_arp_rsp(qdf_nbuf_data(buf));
  3540. }
  3541. /**
  3542. * qdf_nbuf_get_arp_src_ip() - get ARP packet source IP gateway.
  3543. * @buf: buffer
  3544. *
  3545. * Return: ARP packet source IP value.
  3546. */
  3547. static inline
  3548. uint32_t qdf_nbuf_get_arp_src_ip(qdf_nbuf_t buf)
  3549. {
  3550. return __qdf_nbuf_get_arp_src_ip(qdf_nbuf_data(buf));
  3551. }
  3552. /**
  3553. * qdf_nbuf_get_arp_tgt_ip() - get ARP packet target IP gateway.
  3554. * @buf: buffer
  3555. *
  3556. * Return: ARP packet target IP value.
  3557. */
  3558. static inline
  3559. uint32_t qdf_nbuf_get_arp_tgt_ip(qdf_nbuf_t buf)
  3560. {
  3561. return __qdf_nbuf_get_arp_tgt_ip(qdf_nbuf_data(buf));
  3562. }
  3563. /**
  3564. * qdf_nbuf_get_dns_domain_name() - get dns domain name of required length
  3565. * @buf: buffer
  3566. * @len: length to copy
  3567. *
  3568. * Return: dns domain name
  3569. */
  3570. static inline
  3571. uint8_t *qdf_nbuf_get_dns_domain_name(qdf_nbuf_t buf, uint32_t len)
  3572. {
  3573. return __qdf_nbuf_get_dns_domain_name(qdf_nbuf_data(buf), len);
  3574. }
  3575. /**
  3576. * qdf_nbuf_data_is_dns_query() - check if skb data is a dns query
  3577. * @buf: buffer
  3578. *
  3579. * Return: true if packet is dns query packet.
  3580. * false otherwise.
  3581. */
  3582. static inline
  3583. bool qdf_nbuf_data_is_dns_query(qdf_nbuf_t buf)
  3584. {
  3585. return __qdf_nbuf_data_is_dns_query(qdf_nbuf_data(buf));
  3586. }
  3587. /**
  3588. * qdf_nbuf_data_is_dns_response() - check if skb data is a dns response
  3589. * @buf: buffer
  3590. *
  3591. * Return: true if packet is dns response packet.
  3592. * false otherwise.
  3593. */
  3594. static inline
  3595. bool qdf_nbuf_data_is_dns_response(qdf_nbuf_t buf)
  3596. {
  3597. return __qdf_nbuf_data_is_dns_response(qdf_nbuf_data(buf));
  3598. }
  3599. /**
  3600. * qdf_nbuf_data_is_tcp_fin() - check if skb data is a tcp fin
  3601. * @buf: buffer
  3602. *
  3603. * Return: true if packet is tcp fin packet.
  3604. * false otherwise.
  3605. */
  3606. static inline
  3607. bool qdf_nbuf_data_is_tcp_fin(qdf_nbuf_t buf)
  3608. {
  3609. return __qdf_nbuf_data_is_tcp_fin(qdf_nbuf_data(buf));
  3610. }
  3611. /**
  3612. * qdf_nbuf_data_is_tcp_fin_ack() - check if skb data is a tcp fin ack
  3613. * @buf: buffer
  3614. *
  3615. * Return: true if packet is tcp fin ack packet.
  3616. * false otherwise.
  3617. */
  3618. static inline
  3619. bool qdf_nbuf_data_is_tcp_fin_ack(qdf_nbuf_t buf)
  3620. {
  3621. return __qdf_nbuf_data_is_tcp_fin_ack(qdf_nbuf_data(buf));
  3622. }
  3623. /**
  3624. * qdf_nbuf_data_is_tcp_syn() - check if skb data is a tcp syn
  3625. * @buf: buffer
  3626. *
  3627. * Return: true if packet is tcp syn packet.
  3628. * false otherwise.
  3629. */
  3630. static inline
  3631. bool qdf_nbuf_data_is_tcp_syn(qdf_nbuf_t buf)
  3632. {
  3633. return __qdf_nbuf_data_is_tcp_syn(qdf_nbuf_data(buf));
  3634. }
  3635. /**
  3636. * qdf_nbuf_data_is_tcp_syn_ack() - check if skb data is a tcp syn ack
  3637. * @buf: buffer
  3638. *
  3639. * Return: true if packet is tcp syn ack packet.
  3640. * false otherwise.
  3641. */
  3642. static inline
  3643. bool qdf_nbuf_data_is_tcp_syn_ack(qdf_nbuf_t buf)
  3644. {
  3645. return __qdf_nbuf_data_is_tcp_syn_ack(qdf_nbuf_data(buf));
  3646. }
  3647. /**
  3648. * qdf_nbuf_data_is_tcp_rst() - check if skb data is a tcp rst
  3649. * @buf: buffer
  3650. *
  3651. * Return: true if packet is tcp rst packet.
  3652. * false otherwise.
  3653. */
  3654. static inline
  3655. bool qdf_nbuf_data_is_tcp_rst(qdf_nbuf_t buf)
  3656. {
  3657. return __qdf_nbuf_data_is_tcp_rst(qdf_nbuf_data(buf));
  3658. }
  3659. /**
  3660. * qdf_nbuf_data_is_tcp_ack() - check if skb data is a tcp ack
  3661. * @buf: buffer
  3662. *
  3663. * Return: true if packet is tcp ack packet.
  3664. * false otherwise.
  3665. */
  3666. static inline
  3667. bool qdf_nbuf_data_is_tcp_ack(qdf_nbuf_t buf)
  3668. {
  3669. return __qdf_nbuf_data_is_tcp_ack(qdf_nbuf_data(buf));
  3670. }
  3671. /**
  3672. * qdf_nbuf_data_get_tcp_src_port() - get tcp src port
  3673. * @buf: buffer
  3674. *
  3675. * Return: tcp source port value.
  3676. */
  3677. static inline
  3678. uint16_t qdf_nbuf_data_get_tcp_src_port(qdf_nbuf_t buf)
  3679. {
  3680. return __qdf_nbuf_data_get_tcp_src_port(qdf_nbuf_data(buf));
  3681. }
  3682. /**
  3683. * qdf_nbuf_data_get_tcp_dst_port() - get tcp dst port
  3684. * @buf: buffer
  3685. *
  3686. * Return: tcp destination port value.
  3687. */
  3688. static inline
  3689. uint16_t qdf_nbuf_data_get_tcp_dst_port(qdf_nbuf_t buf)
  3690. {
  3691. return __qdf_nbuf_data_get_tcp_dst_port(qdf_nbuf_data(buf));
  3692. }
  3693. /**
  3694. * qdf_nbuf_data_is_icmpv4_req() - check if ICMPv4 packet is request.
  3695. * @buf: buffer
  3696. *
  3697. * This func. checks whether it is a ICMPv4 request or not.
  3698. *
  3699. * Return: true if it is a ICMPv4 request or fALSE if not
  3700. */
  3701. static inline
  3702. bool qdf_nbuf_data_is_icmpv4_req(qdf_nbuf_t buf)
  3703. {
  3704. return __qdf_nbuf_data_is_icmpv4_req(qdf_nbuf_data(buf));
  3705. }
  3706. /**
  3707. * qdf_nbuf_data_is_icmpv4_rsp() - check if ICMPv4 packet is res
  3708. * @buf: buffer
  3709. *
  3710. * Return: true if packet is icmpv4 response
  3711. * false otherwise.
  3712. */
  3713. static inline
  3714. bool qdf_nbuf_data_is_icmpv4_rsp(qdf_nbuf_t buf)
  3715. {
  3716. return __qdf_nbuf_data_is_icmpv4_rsp(qdf_nbuf_data(buf));
  3717. }
  3718. static inline
  3719. bool qdf_nbuf_is_icmpv4_redirect(qdf_nbuf_t buf)
  3720. {
  3721. return __qdf_nbuf_data_is_icmpv4_redirect(qdf_nbuf_data(buf));
  3722. }
  3723. /**
  3724. * qdf_nbuf_get_icmpv4_src_ip() - get icmpv4 src IP
  3725. * @buf: buffer
  3726. *
  3727. * Return: icmpv4 packet source IP value.
  3728. */
  3729. static inline
  3730. uint32_t qdf_nbuf_get_icmpv4_src_ip(qdf_nbuf_t buf)
  3731. {
  3732. return __qdf_nbuf_get_icmpv4_src_ip(qdf_nbuf_data(buf));
  3733. }
  3734. /**
  3735. * qdf_nbuf_get_icmpv4_tgt_ip() - get icmpv4 target IP
  3736. * @buf: buffer
  3737. *
  3738. * Return: icmpv4 packet target IP value.
  3739. */
  3740. static inline
  3741. uint32_t qdf_nbuf_get_icmpv4_tgt_ip(qdf_nbuf_t buf)
  3742. {
  3743. return __qdf_nbuf_get_icmpv4_tgt_ip(qdf_nbuf_data(buf));
  3744. }
  3745. /**
  3746. * qdf_nbuf_is_ipv6_pkt() - check if it is IPV6 packet.
  3747. * @buf: Pointer to IPV6 packet buffer
  3748. *
  3749. * This func. checks whether it is a IPV6 packet or not.
  3750. *
  3751. * Return: TRUE if it is a IPV6 packet
  3752. * FALSE if not
  3753. */
  3754. static inline
  3755. bool qdf_nbuf_is_ipv6_pkt(qdf_nbuf_t buf)
  3756. {
  3757. return __qdf_nbuf_data_is_ipv6_pkt(qdf_nbuf_data(buf));
  3758. }
  3759. static inline
  3760. bool qdf_nbuf_is_icmpv6_redirect(qdf_nbuf_t buf)
  3761. {
  3762. return __qdf_nbuf_data_is_icmpv6_redirect(qdf_nbuf_data(buf));
  3763. }
  3764. /**
  3765. * qdf_nbuf_data_is_ipv6_pkt() - check if it is IPV6 packet.
  3766. * @data: Pointer to IPV6 packet data buffer
  3767. *
  3768. * This func. checks whether it is a IPV6 packet or not.
  3769. *
  3770. * Return: TRUE if it is a IPV6 packet
  3771. * FALSE if not
  3772. */
  3773. static inline
  3774. bool qdf_nbuf_data_is_ipv6_pkt(uint8_t *data)
  3775. {
  3776. return __qdf_nbuf_data_is_ipv6_pkt(data);
  3777. }
  3778. /**
  3779. * qdf_nbuf_data_is_ipv4_mcast_pkt() - check if it is IPV4 multicast packet.
  3780. * @data: Pointer to IPV4 packet data buffer
  3781. *
  3782. * This func. checks whether it is a IPV4 multicast packet or not.
  3783. *
  3784. * Return: TRUE if it is a IPV4 multicast packet
  3785. * FALSE if not
  3786. */
  3787. static inline
  3788. bool qdf_nbuf_data_is_ipv4_mcast_pkt(uint8_t *data)
  3789. {
  3790. return __qdf_nbuf_data_is_ipv4_mcast_pkt(data);
  3791. }
  3792. /**
  3793. * qdf_nbuf_data_is_ipv6_mcast_pkt() - check if it is IPV6 multicast packet.
  3794. * @data: Pointer to IPV6 packet data buffer
  3795. *
  3796. * This func. checks whether it is a IPV6 multicast packet or not.
  3797. *
  3798. * Return: TRUE if it is a IPV6 multicast packet
  3799. * FALSE if not
  3800. */
  3801. static inline
  3802. bool qdf_nbuf_data_is_ipv6_mcast_pkt(uint8_t *data)
  3803. {
  3804. return __qdf_nbuf_data_is_ipv6_mcast_pkt(data);
  3805. }
  3806. /**
  3807. * qdf_nbuf_is_icmp_pkt() - check if it is IPV4 ICMP packet.
  3808. * @buf: Pointer to IPV4 ICMP packet buffer
  3809. *
  3810. * This func. checks whether it is a ICMP packet or not.
  3811. *
  3812. * Return: TRUE if it is a ICMP packet
  3813. * FALSE if not
  3814. */
  3815. static inline
  3816. bool qdf_nbuf_is_icmp_pkt(qdf_nbuf_t buf)
  3817. {
  3818. return __qdf_nbuf_data_is_icmp_pkt(qdf_nbuf_data(buf));
  3819. }
  3820. /**
  3821. * qdf_nbuf_data_is_icmp_pkt() - check if it is IPV4 ICMP packet.
  3822. * @data: Pointer to IPV4 ICMP packet data buffer
  3823. *
  3824. * This func. checks whether it is a ICMP packet or not.
  3825. *
  3826. * Return: TRUE if it is a ICMP packet
  3827. * FALSE if not
  3828. */
  3829. static inline
  3830. bool qdf_nbuf_data_is_icmp_pkt(uint8_t *data)
  3831. {
  3832. return __qdf_nbuf_data_is_icmp_pkt(data);
  3833. }
  3834. /**
  3835. * qdf_nbuf_is_icmpv6_pkt() - check if it is IPV6 ICMPV6 packet.
  3836. * @buf: Pointer to IPV6 ICMPV6 packet buffer
  3837. *
  3838. * This func. checks whether it is a ICMPV6 packet or not.
  3839. *
  3840. * Return: TRUE if it is a ICMPV6 packet
  3841. * FALSE if not
  3842. */
  3843. static inline
  3844. bool qdf_nbuf_is_icmpv6_pkt(qdf_nbuf_t buf)
  3845. {
  3846. return __qdf_nbuf_data_is_icmpv6_pkt(qdf_nbuf_data(buf));
  3847. }
  3848. /**
  3849. * qdf_nbuf_data_is_icmpv6_pkt() - check if it is IPV6 ICMPV6 packet.
  3850. * @data: Pointer to IPV6 ICMPV6 packet data buffer
  3851. *
  3852. * This func. checks whether it is a ICMPV6 packet or not.
  3853. *
  3854. * Return: TRUE if it is a ICMPV6 packet
  3855. * FALSE if not
  3856. */
  3857. static inline
  3858. bool qdf_nbuf_data_is_icmpv6_pkt(uint8_t *data)
  3859. {
  3860. return __qdf_nbuf_data_is_icmpv6_pkt(data);
  3861. }
  3862. /**
  3863. * qdf_nbuf_is_ipv4_udp_pkt() - check if it is IPV4 UDP packet.
  3864. * @buf: Pointer to IPV4 UDP packet buffer
  3865. *
  3866. * This func. checks whether it is a IPV4 UDP packet or not.
  3867. *
  3868. * Return: TRUE if it is a IPV4 UDP packet
  3869. * FALSE if not
  3870. */
  3871. static inline
  3872. bool qdf_nbuf_is_ipv4_udp_pkt(qdf_nbuf_t buf)
  3873. {
  3874. return __qdf_nbuf_data_is_ipv4_udp_pkt(qdf_nbuf_data(buf));
  3875. }
  3876. /**
  3877. * qdf_nbuf_data_is_ipv4_udp_pkt() - check if it is IPV4 UDP packet.
  3878. * @data: Pointer to IPV4 UDP packet data buffer
  3879. *
  3880. * This func. checks whether it is a IPV4 UDP packet or not.
  3881. *
  3882. * Return: TRUE if it is a IPV4 UDP packet
  3883. * FALSE if not
  3884. */
  3885. static inline
  3886. bool qdf_nbuf_data_is_ipv4_udp_pkt(uint8_t *data)
  3887. {
  3888. return __qdf_nbuf_data_is_ipv4_udp_pkt(data);
  3889. }
  3890. /**
  3891. * qdf_nbuf_is_ipv4_tcp_pkt() - check if it is IPV4 TCP packet.
  3892. * @buf: Pointer to IPV4 TCP packet buffer
  3893. *
  3894. * This func. checks whether it is a IPV4 TCP packet or not.
  3895. *
  3896. * Return: TRUE if it is a IPV4 TCP packet
  3897. * FALSE if not
  3898. */
  3899. static inline
  3900. bool qdf_nbuf_is_ipv4_tcp_pkt(qdf_nbuf_t buf)
  3901. {
  3902. return __qdf_nbuf_data_is_ipv4_tcp_pkt(qdf_nbuf_data(buf));
  3903. }
  3904. /**
  3905. * qdf_nbuf_data_is_ipv4_tcp_pkt() - check if it is IPV4 TCP packet.
  3906. * @data: Pointer to IPV4 TCP packet data buffer
  3907. *
  3908. * This func. checks whether it is a IPV4 TCP packet or not.
  3909. *
  3910. * Return: TRUE if it is a IPV4 TCP packet
  3911. * FALSE if not
  3912. */
  3913. static inline
  3914. bool qdf_nbuf_data_is_ipv4_tcp_pkt(uint8_t *data)
  3915. {
  3916. return __qdf_nbuf_data_is_ipv4_tcp_pkt(data);
  3917. }
  3918. /**
  3919. * qdf_nbuf_is_ipv6_udp_pkt() - check if it is IPV6 UDP packet.
  3920. * @buf: Pointer to IPV6 UDP packet buffer
  3921. *
  3922. * This func. checks whether it is a IPV6 UDP packet or not.
  3923. *
  3924. * Return: TRUE if it is a IPV6 UDP packet
  3925. * FALSE if not
  3926. */
  3927. static inline
  3928. bool qdf_nbuf_is_ipv6_udp_pkt(qdf_nbuf_t buf)
  3929. {
  3930. return __qdf_nbuf_data_is_ipv6_udp_pkt(qdf_nbuf_data(buf));
  3931. }
  3932. /**
  3933. * qdf_nbuf_data_is_ipv6_udp_pkt() - check if it is IPV6 UDP packet.
  3934. * @data: Pointer to IPV6 UDP packet data buffer
  3935. *
  3936. * This func. checks whether it is a IPV6 UDP packet or not.
  3937. *
  3938. * Return: TRUE if it is a IPV6 UDP packet
  3939. * FALSE if not
  3940. */
  3941. static inline
  3942. bool qdf_nbuf_data_is_ipv6_udp_pkt(uint8_t *data)
  3943. {
  3944. return __qdf_nbuf_data_is_ipv6_udp_pkt(data);
  3945. }
  3946. /**
  3947. * qdf_nbuf_is_ipv6_tcp_pkt() - check if it is IPV6 TCP packet.
  3948. * @buf: Pointer to IPV6 TCP packet buffer
  3949. *
  3950. * This func. checks whether it is a IPV6 TCP packet or not.
  3951. *
  3952. * Return: TRUE if it is a IPV6 TCP packet
  3953. * FALSE if not
  3954. */
  3955. static inline
  3956. bool qdf_nbuf_is_ipv6_tcp_pkt(qdf_nbuf_t buf)
  3957. {
  3958. return __qdf_nbuf_data_is_ipv6_tcp_pkt(qdf_nbuf_data(buf));
  3959. }
  3960. /**
  3961. * qdf_nbuf_data_is_ipv6_tcp_pkt() - check if it is IPV6 TCP packet.
  3962. * @data: Pointer to IPV6 TCP packet data buffer
  3963. *
  3964. * This func. checks whether it is a IPV6 TCP packet or not.
  3965. *
  3966. * Return: TRUE if it is a IPV6 TCP packet
  3967. * FALSE if not
  3968. */
  3969. static inline
  3970. bool qdf_nbuf_data_is_ipv6_tcp_pkt(uint8_t *data)
  3971. {
  3972. return __qdf_nbuf_data_is_ipv6_tcp_pkt(data);
  3973. }
  3974. /**
  3975. * qdf_nbuf_is_bcast_pkt() - check if it is broadcast packet.
  3976. * @buf: Network buffer
  3977. *
  3978. * This func. checks whether packet is broadcast or not.
  3979. *
  3980. * Return: TRUE if it is broadcast packet
  3981. * FALSE if not
  3982. */
  3983. static inline
  3984. bool qdf_nbuf_is_bcast_pkt(qdf_nbuf_t buf)
  3985. {
  3986. return __qdf_nbuf_is_bcast_pkt(buf);
  3987. }
  3988. /**
  3989. * qdf_nbuf_pkt_type_is_mcast() - check if skb pkt type is mcast
  3990. * @buf: Network buffer
  3991. *
  3992. * Return: TRUE if skb pkt type is mcast
  3993. * FALSE if not
  3994. */
  3995. static inline
  3996. bool qdf_nbuf_pkt_type_is_mcast(qdf_nbuf_t buf)
  3997. {
  3998. return __qdf_nbuf_pkt_type_is_mcast(buf);
  3999. }
  4000. /**
  4001. * qdf_nbuf_pkt_type_is_bcast() - check if skb pkt type is bcast
  4002. * @buf: Network buffer
  4003. *
  4004. * Return: TRUE if skb pkt type is mcast
  4005. * FALSE if not
  4006. */
  4007. static inline
  4008. bool qdf_nbuf_pkt_type_is_bcast(qdf_nbuf_t buf)
  4009. {
  4010. return __qdf_nbuf_pkt_type_is_bcast(buf);
  4011. }
  4012. /**
  4013. * qdf_nbuf_is_mcast_replay() - check if it is multicast replay packet.
  4014. * @buf: Network buffer
  4015. *
  4016. * This func. checks whether packet is multicast replay packet or not.
  4017. *
  4018. * Return: TRUE if it is multicast packet
  4019. * FALSE if not
  4020. */
  4021. static inline
  4022. bool qdf_nbuf_is_mcast_replay(qdf_nbuf_t buf)
  4023. {
  4024. return __qdf_nbuf_is_mcast_replay(buf);
  4025. }
  4026. #ifdef DP_TX_PACKET_INSPECT_FOR_ILP
  4027. /* Reuse bit24~31 in skb->priority for packet type */
  4028. #define QDF_NBUF_PRIORITY_PKT_TYPE_MASK 0xFF000000
  4029. #define QDF_NBUF_PRIORITY_PKT_TYPE_LSB 24
  4030. /* TCP ACK */
  4031. #define QDF_NBUF_PRIORITY_PKT_TCP_ACK 0x1
  4032. #define QDF_NBUF_GET_PRIORITY_PKT_TYPE(_pri) \
  4033. (((_pri) & QDF_NBUF_PRIORITY_PKT_TYPE_MASK) >> \
  4034. QDF_NBUF_PRIORITY_PKT_TYPE_LSB)
  4035. #define QDF_NBUF_PRIORITY_PKT_TYPE(_pkt_type) \
  4036. (((_pkt_type) << QDF_NBUF_PRIORITY_PKT_TYPE_LSB) & \
  4037. QDF_NBUF_PRIORITY_PKT_TYPE_MASK)
  4038. /**
  4039. * qdf_nbuf_get_priority_pkt_type() - Get packet type from priority
  4040. * @nbuf: pointer to network buffer
  4041. *
  4042. * Return: packet type
  4043. */
  4044. static inline
  4045. uint8_t qdf_nbuf_get_priority_pkt_type(qdf_nbuf_t nbuf)
  4046. {
  4047. return QDF_NBUF_GET_PRIORITY_PKT_TYPE(nbuf->priority);
  4048. }
  4049. /**
  4050. * qdf_nbuf_set_priority_pkt_type() - Set packet type to priority
  4051. * @nbuf: pointer to network buffer
  4052. * @pkt_type: packet type to be set
  4053. *
  4054. * Return: none
  4055. */
  4056. static inline
  4057. void qdf_nbuf_set_priority_pkt_type(qdf_nbuf_t nbuf, uint8_t pkt_type)
  4058. {
  4059. nbuf->priority |= QDF_NBUF_PRIORITY_PKT_TYPE(pkt_type);
  4060. }
  4061. /**
  4062. * qdf_nbuf_remove_priority_pkt_type() - Remove the packet type bits
  4063. * from priority
  4064. * @nbuf: pointer to network buffer
  4065. *
  4066. * Return: none
  4067. */
  4068. static inline
  4069. void qdf_nbuf_remove_priority_pkt_type(qdf_nbuf_t nbuf)
  4070. {
  4071. nbuf->priority &= ~QDF_NBUF_PRIORITY_PKT_TYPE_MASK;
  4072. }
  4073. #endif
  4074. /**
  4075. * qdf_nbuf_is_ipv4_v6_pure_tcp_ack() - check if it is pure tcp ack
  4076. * without data payload
  4077. * @buf: Network buffer
  4078. *
  4079. * Check whether the packet is pure TCP ack without data payload.
  4080. *
  4081. * Return : true if TCP ack, else return false
  4082. */
  4083. static inline
  4084. bool qdf_nbuf_is_ipv4_v6_pure_tcp_ack(qdf_nbuf_t buf)
  4085. {
  4086. return __qdf_nbuf_is_ipv4_v6_pure_tcp_ack(buf);
  4087. }
  4088. /**
  4089. * qdf_nbuf_is_arp_local() - check if it is local or no local arp
  4090. * @buf: Network buffer
  4091. *
  4092. * This func. checks whether packet is local or no local arp.
  4093. *
  4094. * Return: TRUE if it is broadcast packet
  4095. * FALSE if not
  4096. */
  4097. static inline
  4098. bool qdf_nbuf_is_arp_local(qdf_nbuf_t buf)
  4099. {
  4100. return __qdf_nbuf_is_arp_local(buf);
  4101. }
  4102. /**
  4103. * qdf_nbuf_reset_num_frags() - decrement the number of fragments
  4104. * @buf: Network buffer
  4105. *
  4106. * Return: Number of fragments
  4107. */
  4108. static inline void qdf_nbuf_reset_num_frags(qdf_nbuf_t buf)
  4109. {
  4110. __qdf_nbuf_reset_num_frags(buf);
  4111. }
  4112. /**
  4113. * qdf_dmaaddr_to_32s - return high and low parts of dma_addr
  4114. * @dmaaddr: DMA address
  4115. * @lo: low 32-bits of @dmaaddr
  4116. * @hi: high 32-bits of @dmaaddr
  4117. *
  4118. * Returns the high and low 32-bits of the DMA addr in the provided ptrs
  4119. *
  4120. * Return: N/A
  4121. */
  4122. static inline void qdf_dmaaddr_to_32s(qdf_dma_addr_t dmaaddr,
  4123. uint32_t *lo, uint32_t *hi)
  4124. {
  4125. return __qdf_dmaaddr_to_32s(dmaaddr, lo, hi);
  4126. }
  4127. /**
  4128. * qdf_nbuf_get_tso_info() - function to divide a jumbo TSO
  4129. * network buffer into segments
  4130. * @osdev: qdf device handle
  4131. * @nbuf: network buffer to be segmented
  4132. * @tso_info: This is the output. The information about the
  4133. * TSO segments will be populated within this.
  4134. *
  4135. * This function fragments a TCP jumbo packet into smaller
  4136. * segments to be transmitted by the driver. It chains the TSO
  4137. * segments created into a list.
  4138. *
  4139. * Return: number of TSO segments
  4140. */
  4141. static inline uint32_t qdf_nbuf_get_tso_info(qdf_device_t osdev,
  4142. qdf_nbuf_t nbuf, struct qdf_tso_info_t *tso_info)
  4143. {
  4144. return __qdf_nbuf_get_tso_info(osdev, nbuf, tso_info);
  4145. }
  4146. /**
  4147. * qdf_nbuf_unmap_tso_segment() - function to dma unmap TSO segment element
  4148. *
  4149. * @osdev: qdf device handle
  4150. * @tso_seg: TSO segment element to be unmapped
  4151. * @is_last_seg: whether this is last tso seg or not
  4152. *
  4153. * Return: none
  4154. */
  4155. static inline void qdf_nbuf_unmap_tso_segment(qdf_device_t osdev,
  4156. struct qdf_tso_seg_elem_t *tso_seg,
  4157. bool is_last_seg)
  4158. {
  4159. return __qdf_nbuf_unmap_tso_segment(osdev, tso_seg, is_last_seg);
  4160. }
  4161. /**
  4162. * qdf_nbuf_get_tcp_payload_len() - function to return the tso payload len
  4163. * @nbuf: network buffer
  4164. *
  4165. * Return: size of the tso packet
  4166. */
  4167. static inline size_t qdf_nbuf_get_tcp_payload_len(qdf_nbuf_t nbuf)
  4168. {
  4169. return __qdf_nbuf_get_tcp_payload_len(nbuf);
  4170. }
  4171. /**
  4172. * qdf_nbuf_get_tso_num_seg() - function to calculate the number
  4173. * of TCP segments within the TSO jumbo packet
  4174. * @nbuf: TSO jumbo network buffer to be segmented
  4175. *
  4176. * This function calculates the number of TCP segments that the
  4177. * network buffer can be divided into.
  4178. *
  4179. * Return: number of TCP segments
  4180. */
  4181. static inline uint32_t qdf_nbuf_get_tso_num_seg(qdf_nbuf_t nbuf)
  4182. {
  4183. return __qdf_nbuf_get_tso_num_seg(nbuf);
  4184. }
  4185. /**
  4186. * qdf_nbuf_get_gso_segs() - Return the number of gso segments in nbuf
  4187. * @nbuf: Network buffer
  4188. *
  4189. * Return: number of gso segments in nbuf
  4190. */
  4191. static inline uint16_t qdf_nbuf_get_gso_segs(qdf_nbuf_t nbuf)
  4192. {
  4193. return __qdf_nbuf_get_gso_segs(nbuf);
  4194. }
  4195. /**
  4196. * qdf_nbuf_set_gso_segs() - set the number of gso segments in nbuf
  4197. * @nbuf: Network buffer
  4198. * @val: val to be set
  4199. *
  4200. * Return: None
  4201. */
  4202. static inline void qdf_nbuf_set_gso_segs(qdf_nbuf_t nbuf, uint16_t val)
  4203. {
  4204. __qdf_nbuf_set_gso_segs(nbuf, val);
  4205. }
  4206. /**
  4207. * qdf_nbuf_set_gso_type_udp_l4() - set the gso type to GSO UDP L4
  4208. * @nbuf: Network buffer
  4209. *
  4210. * Return: None
  4211. */
  4212. static inline void qdf_nbuf_set_gso_type_udp_l4(qdf_nbuf_t nbuf)
  4213. {
  4214. __qdf_nbuf_set_gso_type_udp_l4(nbuf);
  4215. }
  4216. /**
  4217. * qdf_nbuf_set_ip_summed_partial() - set the ip summed to CHECKSUM_PARTIAL
  4218. * @nbuf: Network buffer
  4219. *
  4220. * Return: None
  4221. */
  4222. static inline void qdf_nbuf_set_ip_summed_partial(qdf_nbuf_t nbuf)
  4223. {
  4224. __qdf_nbuf_set_ip_summed_partial(nbuf);
  4225. }
  4226. /**
  4227. * qdf_nbuf_get_gso_size() - Return the number of gso size in nbuf
  4228. * @nbuf: Network buffer
  4229. *
  4230. * Return: number of gso segments in nbuf
  4231. */
  4232. static inline unsigned int qdf_nbuf_get_gso_size(qdf_nbuf_t nbuf)
  4233. {
  4234. return __qdf_nbuf_get_gso_size(nbuf);
  4235. }
  4236. /**
  4237. * qdf_nbuf_set_gso_size() - Set the gso size in nbuf
  4238. * @nbuf: Pointer to network buffer
  4239. * @val: number of gso segments in nbuf
  4240. *
  4241. * Return: None
  4242. */
  4243. static inline void qdf_nbuf_set_gso_size(qdf_nbuf_t nbuf, unsigned int val)
  4244. {
  4245. __qdf_nbuf_set_gso_size(nbuf, val);
  4246. }
  4247. /**
  4248. * qdf_nbuf_inc_users() - function to increment the number of
  4249. * users referencing this network buffer
  4250. * @nbuf: network buffer
  4251. *
  4252. * This function increments the number of users referencing this
  4253. * network buffer
  4254. *
  4255. * Return: the network buffer
  4256. */
  4257. static inline qdf_nbuf_t qdf_nbuf_inc_users(qdf_nbuf_t nbuf)
  4258. {
  4259. return __qdf_nbuf_inc_users(nbuf);
  4260. }
  4261. /**
  4262. * qdf_nbuf_data_attr_get() - Get data_attr field from cvg_nbuf_cb
  4263. * @buf: Network buffer (skb on linux)
  4264. *
  4265. * This function returns the values of data_attr field
  4266. * in struct cvg_nbuf_cb{}, to which skb->cb is typecast.
  4267. * This value is actually the value programmed in CE descriptor.
  4268. *
  4269. * Return: Value of data_attr
  4270. */
  4271. static inline uint32_t qdf_nbuf_data_attr_get(qdf_nbuf_t buf)
  4272. {
  4273. return __qdf_nbuf_data_attr_get(buf);
  4274. }
  4275. /**
  4276. * qdf_nbuf_data_attr_set() - Sets data_attr field in cvg_nbuf_cb
  4277. * @buf: Network buffer (skb on linux)
  4278. * @data_attr: Value to be stored cvg_nbuf_cb->data_attr
  4279. *
  4280. * This function stores the value to be programmed in CE
  4281. * descriptor as part skb->cb which is typecast to struct cvg_nbuf_cb{}
  4282. *
  4283. * Return: void
  4284. */
  4285. static inline
  4286. void qdf_nbuf_data_attr_set(qdf_nbuf_t buf, uint32_t data_attr)
  4287. {
  4288. __qdf_nbuf_data_attr_set(buf, data_attr);
  4289. }
  4290. /**
  4291. * qdf_nbuf_tx_info_get() - Parse skb and get Tx metadata
  4292. * @nbuf: Network buffer
  4293. * @pkt_type: Pkt type (from enum htt_pkt_type)
  4294. * @pkt_subtype: Bit 4 of this field in HTT descriptor
  4295. * needs to be set in case of CE classification support
  4296. * Is set by this macro.
  4297. * @hw_classify: This is a flag which is set to indicate
  4298. * CE classification is enabled.
  4299. * Do not set this bit for VLAN packets
  4300. * OR for mcast / bcast frames.
  4301. *
  4302. * This function parses the payload to figure out relevant
  4303. * Tx meta-data e.g. whether to enable tx_classify bit
  4304. * in CE.
  4305. *
  4306. * Return: void
  4307. */
  4308. #define qdf_nbuf_tx_info_get(nbuf, pkt_type, pkt_subtype, hw_classify) \
  4309. __qdf_nbuf_tx_info_get(nbuf, pkt_type, \
  4310. pkt_subtype, hw_classify)
  4311. /**
  4312. * qdf_nbuf_set_state() - Updates the packet state
  4313. * @nbuf: network buffer
  4314. * @current_state : layer at which the packet currently is
  4315. *
  4316. * This function updates the packet state to the layer at which the packet
  4317. * currently is
  4318. *
  4319. * Return: none
  4320. */
  4321. void qdf_nbuf_set_state(qdf_nbuf_t nbuf, uint8_t current_state);
  4322. /**
  4323. * qdf_nbuf_tx_desc_count_display() - Displays the packet counter
  4324. *
  4325. * Return: none
  4326. */
  4327. void qdf_nbuf_tx_desc_count_display(void);
  4328. /**
  4329. * qdf_nbuf_tx_desc_count_clear() - Clears packet counter for both data, mgmt
  4330. *
  4331. * Return: none
  4332. */
  4333. void qdf_nbuf_tx_desc_count_clear(void);
  4334. static inline qdf_nbuf_t
  4335. qdf_nbuf_realloc_headroom(qdf_nbuf_t buf, uint32_t headroom)
  4336. {
  4337. return __qdf_nbuf_realloc_headroom(buf, headroom);
  4338. }
  4339. static inline qdf_nbuf_t
  4340. qdf_nbuf_realloc_tailroom(qdf_nbuf_t buf, uint32_t tailroom)
  4341. {
  4342. return __qdf_nbuf_realloc_tailroom(buf, tailroom);
  4343. }
  4344. static inline qdf_nbuf_t
  4345. qdf_nbuf_expand(qdf_nbuf_t buf, uint32_t headroom, uint32_t tailroom)
  4346. {
  4347. return __qdf_nbuf_expand(buf, headroom, tailroom);
  4348. }
  4349. static inline int
  4350. qdf_nbuf_linearize(qdf_nbuf_t buf)
  4351. {
  4352. return __qdf_nbuf_linearize(buf);
  4353. }
  4354. static inline bool
  4355. qdf_nbuf_is_cloned(qdf_nbuf_t buf)
  4356. {
  4357. return __qdf_nbuf_is_cloned(buf);
  4358. }
  4359. static inline void
  4360. qdf_nbuf_frag_info(qdf_nbuf_t buf, qdf_sglist_t *sg)
  4361. {
  4362. __qdf_nbuf_frag_info(buf, sg);
  4363. }
  4364. static inline qdf_nbuf_tx_cksum_t
  4365. qdf_nbuf_tx_cksum_info(qdf_nbuf_t buf, uint8_t **hdr_off, uint8_t **where)
  4366. {
  4367. return __qdf_nbuf_tx_cksum_info(buf, hdr_off, where);
  4368. }
  4369. static inline void qdf_nbuf_reset_ctxt(__qdf_nbuf_t nbuf)
  4370. {
  4371. __qdf_nbuf_reset_ctxt(nbuf);
  4372. }
  4373. static inline void qdf_nbuf_init(qdf_nbuf_t buf)
  4374. {
  4375. __qdf_nbuf_init(buf);
  4376. }
  4377. static inline void *qdf_nbuf_network_header(qdf_nbuf_t buf)
  4378. {
  4379. return __qdf_nbuf_network_header(buf);
  4380. }
  4381. static inline void *qdf_nbuf_transport_header(qdf_nbuf_t buf)
  4382. {
  4383. return __qdf_nbuf_transport_header(buf);
  4384. }
  4385. static inline qdf_size_t qdf_nbuf_tcp_tso_size(qdf_nbuf_t buf)
  4386. {
  4387. return __qdf_nbuf_tcp_tso_size(buf);
  4388. }
  4389. static inline void *qdf_nbuf_get_cb(qdf_nbuf_t nbuf)
  4390. {
  4391. return __qdf_nbuf_get_cb(nbuf);
  4392. }
  4393. static inline uint32_t qdf_nbuf_get_nr_frags(qdf_nbuf_t nbuf)
  4394. {
  4395. return __qdf_nbuf_get_nr_frags(nbuf);
  4396. }
  4397. static inline uint32_t qdf_nbuf_get_nr_frags_in_fraglist(qdf_nbuf_t nbuf)
  4398. {
  4399. return __qdf_nbuf_get_nr_frags_in_fraglist(nbuf);
  4400. }
  4401. static inline qdf_size_t qdf_nbuf_headlen(qdf_nbuf_t buf)
  4402. {
  4403. return __qdf_nbuf_headlen(buf);
  4404. }
  4405. static inline QDF_STATUS qdf_nbuf_frag_map(qdf_device_t osdev,
  4406. qdf_nbuf_t buf, int offset,
  4407. qdf_dma_dir_t dir, int cur_frag)
  4408. {
  4409. return __qdf_nbuf_frag_map(osdev, buf, offset, dir, cur_frag);
  4410. }
  4411. static inline bool qdf_nbuf_tso_tcp_v4(qdf_nbuf_t buf)
  4412. {
  4413. return __qdf_nbuf_tso_tcp_v4(buf);
  4414. }
  4415. static inline bool qdf_nbuf_tso_tcp_v6(qdf_nbuf_t buf)
  4416. {
  4417. return __qdf_nbuf_tso_tcp_v6(buf);
  4418. }
  4419. static inline uint32_t qdf_nbuf_tcp_seq(qdf_nbuf_t buf)
  4420. {
  4421. return __qdf_nbuf_tcp_seq(buf);
  4422. }
  4423. static inline qdf_size_t qdf_nbuf_l2l3l4_hdr_len(qdf_nbuf_t buf)
  4424. {
  4425. return __qdf_nbuf_l2l3l4_hdr_len(buf);
  4426. }
  4427. /**
  4428. * qdf_nbuf_get_tcp_hdr_len() - return TCP header length of the skb
  4429. * @nbuf: sk buff
  4430. *
  4431. * Return: size of TCP header length
  4432. */
  4433. static inline size_t qdf_nbuf_get_tcp_hdr_len(qdf_nbuf_t nbuf)
  4434. {
  4435. return __qdf_nbuf_get_tcp_hdr_len(nbuf);
  4436. }
  4437. static inline bool qdf_nbuf_is_nonlinear(qdf_nbuf_t buf)
  4438. {
  4439. return __qdf_nbuf_is_nonlinear(buf);
  4440. }
  4441. static inline uint32_t
  4442. qdf_nbuf_get_frag_size(qdf_nbuf_t buf, uint32_t frag_num)
  4443. {
  4444. return __qdf_nbuf_get_frag_size(buf, frag_num);
  4445. }
  4446. static inline uint32_t qdf_nbuf_get_priority(qdf_nbuf_t buf)
  4447. {
  4448. return __qdf_nbuf_get_priority(buf);
  4449. }
  4450. static inline void qdf_nbuf_set_priority(qdf_nbuf_t buf, uint32_t p)
  4451. {
  4452. __qdf_nbuf_set_priority(buf, p);
  4453. }
  4454. static inline void qdf_nbuf_record_rx_queue(qdf_nbuf_t buf, uint32_t queue_id)
  4455. {
  4456. __qdf_nbuf_record_rx_queue(buf, queue_id);
  4457. }
  4458. static inline uint16_t
  4459. qdf_nbuf_get_queue_mapping(qdf_nbuf_t buf)
  4460. {
  4461. return __qdf_nbuf_get_queue_mapping(buf);
  4462. }
  4463. static inline void
  4464. qdf_nbuf_set_queue_mapping(qdf_nbuf_t buf, uint16_t val)
  4465. {
  4466. __qdf_nbuf_set_queue_mapping(buf, val);
  4467. }
  4468. static inline char *
  4469. qdf_nbuf_get_priv_ptr(qdf_nbuf_t buf)
  4470. {
  4471. return __qdf_nbuf_get_priv_ptr(buf);
  4472. }
  4473. /**
  4474. * qdf_nbuf_has_fraglist() - check if nbuf has attached frag list
  4475. * @nbuf: Pointer to nbuf
  4476. *
  4477. * Return: bool
  4478. */
  4479. static inline bool
  4480. qdf_nbuf_has_fraglist(qdf_nbuf_t nbuf)
  4481. {
  4482. return __qdf_nbuf_has_fraglist(nbuf);
  4483. }
  4484. /**
  4485. * qdf_nbuf_get_last_frag_list_nbuf() - Fetch pointer to last nbuf in frag list
  4486. * @nbuf: Pointer to nbuf
  4487. *
  4488. * Return: Pointer to last nbuf in frag list if parent nbuf has extended frag
  4489. * list or else return NULL
  4490. */
  4491. static inline qdf_nbuf_t
  4492. qdf_nbuf_get_last_frag_list_nbuf(qdf_nbuf_t nbuf)
  4493. {
  4494. return __qdf_nbuf_get_last_frag_list_nbuf(nbuf);
  4495. }
  4496. /**
  4497. * qdf_nbuf_update_radiotap() - update radiotap at head of nbuf.
  4498. * @rx_status: rx_status containing required info to update radiotap
  4499. * @nbuf: Pointer to nbuf
  4500. * @headroom_sz: Available headroom size
  4501. *
  4502. * Return: radiotap length.
  4503. */
  4504. unsigned int qdf_nbuf_update_radiotap(struct mon_rx_status *rx_status,
  4505. qdf_nbuf_t nbuf, uint32_t headroom_sz);
  4506. /**
  4507. * qdf_nbuf_mark_wakeup_frame() - mark wakeup frame.
  4508. * @buf: Pointer to nbuf
  4509. *
  4510. * Return: None
  4511. */
  4512. static inline void
  4513. qdf_nbuf_mark_wakeup_frame(qdf_nbuf_t buf)
  4514. {
  4515. __qdf_nbuf_mark_wakeup_frame(buf);
  4516. }
  4517. /**
  4518. * qdf_nbuf_reg_free_cb - Registers nbuf free callback
  4519. * @cb_func_ptr: Callback pointer
  4520. *
  4521. * This function registers nbuf free callback
  4522. *
  4523. * Return: void
  4524. */
  4525. static inline void
  4526. qdf_nbuf_reg_free_cb(qdf_nbuf_free_t cb_func_ptr)
  4527. {
  4528. __qdf_nbuf_reg_free_cb(cb_func_ptr);
  4529. }
  4530. /**
  4531. * qdf_nbuf_count_get() - get global nbuf gauge
  4532. *
  4533. * Return: global nbuf gauge
  4534. */
  4535. static inline int qdf_nbuf_count_get(void)
  4536. {
  4537. return __qdf_nbuf_count_get();
  4538. }
  4539. /**
  4540. * qdf_nbuf_count_inc() - increment nbuf global count
  4541. *
  4542. * @buf: sk buff
  4543. *
  4544. * Return: void
  4545. */
  4546. static inline void qdf_nbuf_count_inc(qdf_nbuf_t buf)
  4547. {
  4548. return __qdf_nbuf_count_inc(buf);
  4549. }
  4550. /**
  4551. * qdf_nbuf_count_dec() - decrement nbuf global count
  4552. *
  4553. * @buf: sk buff
  4554. *
  4555. * Return: void
  4556. */
  4557. static inline void qdf_nbuf_count_dec(qdf_nbuf_t buf)
  4558. {
  4559. return __qdf_nbuf_count_dec(buf);
  4560. }
  4561. /**
  4562. * qdf_nbuf_mod_init() - Initialization routine for qdf_nbuf
  4563. *
  4564. * Return void
  4565. */
  4566. static inline void qdf_nbuf_mod_init(void)
  4567. {
  4568. return __qdf_nbuf_mod_init();
  4569. }
  4570. /**
  4571. * qdf_nbuf_mod_exit() - Unintialization routine for qdf_nbuf
  4572. *
  4573. * Return void
  4574. */
  4575. static inline void qdf_nbuf_mod_exit(void)
  4576. {
  4577. return __qdf_nbuf_mod_exit();
  4578. }
  4579. /**
  4580. * qdf_nbuf_orphan() - orphan a nbuf
  4581. * @buf: Pointer to network buffer
  4582. *
  4583. * If a buffer currently has an owner then we call the
  4584. * owner's destructor function
  4585. *
  4586. * Return: void
  4587. */
  4588. static inline void qdf_nbuf_orphan(qdf_nbuf_t buf)
  4589. {
  4590. return __qdf_nbuf_orphan(buf);
  4591. }
  4592. /**
  4593. * qdf_nbuf_get_frag_size_by_idx() - Get size of nbuf frag at index idx
  4594. * @nbuf: qdf_nbuf_t
  4595. * @idx: Frag index for which frag size is requested
  4596. *
  4597. * Return: Frag size
  4598. */
  4599. static inline unsigned int qdf_nbuf_get_frag_size_by_idx(qdf_nbuf_t nbuf,
  4600. uint8_t idx)
  4601. {
  4602. return __qdf_nbuf_get_frag_size_by_idx(nbuf, idx);
  4603. }
  4604. /**
  4605. * qdf_nbuf_get_frag_addr() - Get nbuf frag address at index idx
  4606. * @nbuf: qdf_nbuf_t
  4607. * @idx: Frag index for which frag address is requested
  4608. *
  4609. * Return: Frag address
  4610. */
  4611. static inline qdf_frag_t qdf_nbuf_get_frag_addr(qdf_nbuf_t nbuf, uint8_t idx)
  4612. {
  4613. return __qdf_nbuf_get_frag_addr(nbuf, idx);
  4614. }
  4615. /**
  4616. * qdf_nbuf_trim_add_frag_size() - Increase/Decrease frag_size by size
  4617. * @nbuf: qdf_nbuf_t
  4618. * @idx: Frag index
  4619. * @size: Size by which frag_size needs to be increased/decreased
  4620. * +Ve means increase, -Ve means decrease
  4621. * @truesize: truesize
  4622. */
  4623. static inline void qdf_nbuf_trim_add_frag_size(qdf_nbuf_t nbuf, uint8_t idx,
  4624. int size, unsigned int truesize)
  4625. {
  4626. __qdf_nbuf_trim_add_frag_size(nbuf, idx, size, truesize);
  4627. }
  4628. /**
  4629. * qdf_nbuf_set_mark() - Set nbuf mark
  4630. * @nbuf: qdf_nbuf_t
  4631. * @mark: Value to set mark
  4632. *
  4633. * Return: none
  4634. */
  4635. static inline void qdf_nbuf_set_mark(qdf_nbuf_t nbuf, uint32_t mark)
  4636. {
  4637. __qdf_nbuf_set_mark(nbuf, mark);
  4638. }
  4639. /**
  4640. * qdf_nbuf_get_mark() - Get nbuf mark
  4641. * @nbuf: qdf_nbuf_t
  4642. *
  4643. * Return: mark value
  4644. */
  4645. static inline uint32_t qdf_nbuf_get_mark(qdf_nbuf_t nbuf)
  4646. {
  4647. return __qdf_nbuf_get_mark(nbuf);
  4648. }
  4649. /**
  4650. * qdf_nbuf_get_data_len() - Return the size of the nbuf from
  4651. * data pointer to end pointer
  4652. * @nbuf: qdf_nbuf_t
  4653. *
  4654. * Return: size of network buffer from data pointer to end
  4655. * pointer
  4656. */
  4657. static inline qdf_size_t qdf_nbuf_get_data_len(qdf_nbuf_t nbuf)
  4658. {
  4659. return __qdf_nbuf_get_data_len(nbuf);
  4660. }
  4661. /**
  4662. * qdf_nbuf_set_data_len() - Return the data_len of the nbuf
  4663. * @nbuf: qdf_nbuf_t
  4664. * @len: data_len to be set
  4665. *
  4666. * Return: set data_len value
  4667. */
  4668. static inline qdf_size_t qdf_nbuf_set_data_len(qdf_nbuf_t nbuf, uint32_t len)
  4669. {
  4670. return __qdf_nbuf_set_data_len(nbuf, len);
  4671. }
  4672. /**
  4673. * qdf_nbuf_get_only_data_len() - Return the data_len of the nbuf
  4674. * @nbuf: qdf_nbuf_t
  4675. *
  4676. * Return: data_len value
  4677. */
  4678. static inline qdf_size_t qdf_nbuf_get_only_data_len(qdf_nbuf_t nbuf)
  4679. {
  4680. return __qdf_nbuf_get_only_data_len(nbuf);
  4681. }
  4682. /**
  4683. * qdf_nbuf_set_hash() - set the hash of the buf
  4684. * @buf: Network buf instance
  4685. * @len: len to be set
  4686. *
  4687. * Return: none
  4688. */
  4689. static inline void qdf_nbuf_set_hash(qdf_nbuf_t buf, uint32_t len)
  4690. {
  4691. __qdf_nbuf_set_hash(buf, len);
  4692. }
  4693. /**
  4694. * qdf_nbuf_set_sw_hash() - set the sw hash of the buf
  4695. * @buf: Network buf instance
  4696. * @len: len to be set
  4697. *
  4698. * Return: none
  4699. */
  4700. static inline void qdf_nbuf_set_sw_hash(qdf_nbuf_t buf, uint32_t len)
  4701. {
  4702. __qdf_nbuf_set_sw_hash(buf, len);
  4703. }
  4704. /**
  4705. * qdf_nbuf_set_csum_start() - set the csum start of the buf
  4706. * @buf: Network buf instance
  4707. * @len: len to be set
  4708. *
  4709. * Return: none
  4710. */
  4711. static inline void qdf_nbuf_set_csum_start(qdf_nbuf_t buf, uint16_t len)
  4712. {
  4713. __qdf_nbuf_set_csum_start(buf, len);
  4714. }
  4715. /**
  4716. * qdf_nbuf_set_csum_offset() - set the csum offset of the buf
  4717. * @buf: Network buf instance
  4718. * @len: len to be set
  4719. *
  4720. * Return: none
  4721. */
  4722. static inline void qdf_nbuf_set_csum_offset(qdf_nbuf_t buf, uint16_t len)
  4723. {
  4724. __qdf_nbuf_set_csum_offset(buf, len);
  4725. }
  4726. /**
  4727. * qdf_nbuf_get_end_offset() - Return the size of the nbuf from
  4728. * head pointer to end pointer
  4729. * @nbuf: qdf_nbuf_t
  4730. *
  4731. * Return: size of network buffer from head pointer to end
  4732. * pointer
  4733. */
  4734. static inline qdf_size_t qdf_nbuf_get_end_offset(qdf_nbuf_t nbuf)
  4735. {
  4736. return __qdf_nbuf_get_end_offset(nbuf);
  4737. }
  4738. /**
  4739. * qdf_nbuf_get_truesize() - Return the true size of the nbuf
  4740. * including the header and variable data area
  4741. * @nbuf: qdf_nbuf_t
  4742. *
  4743. * Return: size of network buffer
  4744. */
  4745. static inline qdf_size_t qdf_nbuf_get_truesize(qdf_nbuf_t nbuf)
  4746. {
  4747. return __qdf_nbuf_get_truesize(nbuf);
  4748. }
  4749. /**
  4750. * qdf_nbuf_get_allocsize() - Return the actual size of the skb->head
  4751. * excluding the header and variable data area
  4752. * @nbuf: qdf_nbuf_t
  4753. *
  4754. * Return: actual allocated size of network buffer
  4755. */
  4756. static inline qdf_size_t qdf_nbuf_get_allocsize(qdf_nbuf_t nbuf)
  4757. {
  4758. return __qdf_nbuf_get_allocsize(nbuf);
  4759. }
  4760. #ifdef NBUF_FRAG_MEMORY_DEBUG
  4761. #define qdf_nbuf_move_frag_page_offset(f, i, o) \
  4762. qdf_nbuf_move_frag_page_offset_debug(f, i, o, __func__, __LINE__)
  4763. /**
  4764. * qdf_nbuf_move_frag_page_offset_debug() - Move frag page_offset by size
  4765. * and adjust length by size.
  4766. * @nbuf: qdf_nbuf_t
  4767. * @idx: Frag index
  4768. * @offset: Frag page offset should be moved by offset.
  4769. * +Ve - Move offset forward.
  4770. * -Ve - Move offset backward.
  4771. * @func: Caller function name
  4772. * @line: Caller function line no.
  4773. *
  4774. * Return: QDF_STATUS
  4775. */
  4776. QDF_STATUS qdf_nbuf_move_frag_page_offset_debug(qdf_nbuf_t nbuf, uint8_t idx,
  4777. int offset, const char *func,
  4778. uint32_t line);
  4779. #define qdf_nbuf_remove_frag(n, i, t) \
  4780. qdf_nbuf_remove_frag_debug(n, i, t, __func__, __LINE__)
  4781. /**
  4782. * qdf_nbuf_remove_frag_debug - Remove frag from nbuf
  4783. * @nbuf: nbuf where frag will be removed
  4784. * @idx: frag index
  4785. * @truesize: truesize of frag
  4786. * @func: Caller function name
  4787. * @line: Caller function line no.
  4788. *
  4789. * Return: QDF_STATUS
  4790. *
  4791. */
  4792. QDF_STATUS
  4793. qdf_nbuf_remove_frag_debug(qdf_nbuf_t nbuf,
  4794. uint16_t idx,
  4795. uint16_t truesize,
  4796. const char *func,
  4797. uint32_t line);
  4798. #define qdf_nbuf_add_rx_frag(f, b, o, l, s, r) \
  4799. qdf_nbuf_add_rx_frag_debug(f, b, o, l, s, r, __func__, __LINE__)
  4800. /**
  4801. * qdf_nbuf_add_rx_frag_debug() - Add frag to nbuf at index frag_idx
  4802. * @buf: Frag pointer needs to be added in nbuf
  4803. * @nbuf: qdf_nbuf_t where frag will be added
  4804. * @offset: Offset in frag to be added to nbuf_frags
  4805. * @frag_len: Frag length
  4806. * @truesize: truesize
  4807. * @take_frag_ref: Whether to take ref for frag or not
  4808. * This bool must be set as per below comdition:
  4809. * 1. False: If this frag is being added in any nbuf
  4810. * for the first time after allocation
  4811. * 2. True: If frag is already attached part of any
  4812. * nbuf
  4813. * @func: Caller function name
  4814. * @line: Caller function line no.
  4815. *
  4816. * Return: none
  4817. */
  4818. void qdf_nbuf_add_rx_frag_debug(qdf_frag_t buf, qdf_nbuf_t nbuf,
  4819. int offset, int frag_len,
  4820. unsigned int truesize, bool take_frag_ref,
  4821. const char *func, uint32_t line);
  4822. #define qdf_nbuf_ref_frag(f) \
  4823. qdf_nbuf_ref_frag_debug(f, __func__, __LINE__)
  4824. /**
  4825. * qdf_nbuf_ref_frag_debug() - get frag reference
  4826. * @buf: Frag pointer needs to be taken reference.
  4827. * @func: Caller function name
  4828. * @line: Caller function line no.
  4829. *
  4830. * Return: none
  4831. */
  4832. void qdf_nbuf_ref_frag_debug(qdf_frag_t buf, const char *func, uint32_t line);
  4833. /**
  4834. * qdf_net_buf_debug_acquire_frag() - Add frag nodes to frag debug tracker
  4835. * when nbuf is received from network stack
  4836. * @buf: qdf_nbuf_t
  4837. * @func: Caller function name
  4838. * @line: Caller function line no.
  4839. *
  4840. * Return: none
  4841. */
  4842. void qdf_net_buf_debug_acquire_frag(qdf_nbuf_t buf, const char *func,
  4843. uint32_t line);
  4844. /**
  4845. * qdf_net_buf_debug_release_frag() - Update frag nodes in frag debug tracker
  4846. * when nbuf is sent to network stack
  4847. * @buf: qdf_nbuf_t
  4848. * @func: Caller function name
  4849. * @line: Caller function line no.
  4850. *
  4851. * Return: none
  4852. */
  4853. void qdf_net_buf_debug_release_frag(qdf_nbuf_t buf, const char *func,
  4854. uint32_t line);
  4855. /**
  4856. * qdf_nbuf_frag_count_inc() - Increment global frag counter
  4857. * @buf: qdf_nbuf_t
  4858. *
  4859. * Return: none
  4860. */
  4861. void qdf_nbuf_frag_count_inc(qdf_nbuf_t buf);
  4862. /**
  4863. * qdf_nbuf_frag_count_dec() - Decrement global frag counter
  4864. * @buf: qdf_nbuf_t
  4865. *
  4866. * Return: none
  4867. */
  4868. void qdf_nbuf_frag_count_dec(qdf_nbuf_t buf);
  4869. #else /* NBUF_FRAG_MEMORY_DEBUG */
  4870. /**
  4871. * qdf_nbuf_move_frag_page_offset() - Move frag page_offset by size
  4872. * and adjust length by size.
  4873. * @nbuf: qdf_nbuf_t
  4874. * @idx: Frag index
  4875. * @offset: Frag page offset should be moved by offset.
  4876. * +Ve - Move offset forward.
  4877. * -Ve - Move offset backward.
  4878. */
  4879. static inline QDF_STATUS qdf_nbuf_move_frag_page_offset(qdf_nbuf_t nbuf,
  4880. uint8_t idx,
  4881. int offset)
  4882. {
  4883. return __qdf_nbuf_move_frag_page_offset(nbuf, idx, offset);
  4884. }
  4885. /**
  4886. * qdf_nbuf_remove_frag() - Remove frag from nbuf
  4887. *
  4888. * @nbuf: nbuf pointer
  4889. * @idx: idx at which frag need to be removed
  4890. * @truesize: truesize of frag
  4891. *
  4892. * Return: void
  4893. */
  4894. static inline void qdf_nbuf_remove_frag(qdf_nbuf_t nbuf,
  4895. uint16_t idx,
  4896. uint16_t truesize)
  4897. {
  4898. return __qdf_nbuf_remove_frag(nbuf, idx, truesize);
  4899. }
  4900. /**
  4901. * qdf_nbuf_add_rx_frag() - Add frag to nbuf at index frag_idx
  4902. * @buf: Frag pointer needs to be added in nbuf frag
  4903. * @nbuf: qdf_nbuf_t where frag will be added
  4904. * @offset: Offset in frag to be added to nbuf_frags
  4905. * @frag_len: Frag length
  4906. * @truesize: truesize
  4907. * @take_frag_ref: Whether to take ref for frag or not
  4908. * This bool must be set as per below comdition:
  4909. * 1. False: If this frag is being added in any nbuf
  4910. * for the first time after allocation
  4911. * 2. True: If frag is already attached part of any
  4912. * nbuf
  4913. *
  4914. * qdf_nbuf_add_rx_frag takes ref_count based on boolean flag take_frag_ref
  4915. */
  4916. static inline void qdf_nbuf_add_rx_frag(qdf_frag_t buf, qdf_nbuf_t nbuf,
  4917. int offset, int frag_len,
  4918. unsigned int truesize,
  4919. bool take_frag_ref)
  4920. {
  4921. __qdf_nbuf_add_rx_frag(buf, nbuf, offset,
  4922. frag_len, truesize, take_frag_ref);
  4923. }
  4924. /**
  4925. * qdf_nbuf_ref_frag() - get frag reference
  4926. * @buf: Frag pointer needs to be taken reference.
  4927. *
  4928. * Return: void
  4929. */
  4930. static inline void qdf_nbuf_ref_frag(qdf_frag_t buf)
  4931. {
  4932. __qdf_nbuf_ref_frag(buf);
  4933. }
  4934. static inline void qdf_net_buf_debug_acquire_frag(qdf_nbuf_t buf,
  4935. const char *func,
  4936. uint32_t line)
  4937. {
  4938. }
  4939. static inline void qdf_net_buf_debug_release_frag(qdf_nbuf_t buf,
  4940. const char *func,
  4941. uint32_t line)
  4942. {
  4943. }
  4944. static inline void qdf_nbuf_frag_count_inc(qdf_nbuf_t buf)
  4945. {
  4946. }
  4947. static inline void qdf_nbuf_frag_count_dec(qdf_nbuf_t buf)
  4948. {
  4949. }
  4950. #endif /* NBUF_FRAG_MEMORY_DEBUG */
  4951. #define qdf_nbuf_add_frag(dev, f, n, o, f_l, t_sz, f_r, sz) \
  4952. qdf_nbuf_add_frag_debug(dev, f, n, o, f_l, t_sz, \
  4953. f_r, sz, __func__, __LINE__)
  4954. /**
  4955. * qdf_nbuf_add_frag_debug() - Add frag to nbuf
  4956. * @osdev: Device handle
  4957. * @buf: Frag pointer needs to be added in nbuf frag
  4958. * @nbuf: qdf_nbuf_t where frag will be added
  4959. * @offset: Offset in frag to be added to nbuf_frags
  4960. * @frag_len: Frag length
  4961. * @truesize: truesize
  4962. * @take_frag_ref: Whether to take ref for frag or not
  4963. * This bool must be set as per below comdition:
  4964. * 1. False: If this frag is being added in any nbuf
  4965. * for the first time after allocation
  4966. * 2. True: If frag is already attached part of any
  4967. * nbuf
  4968. * @minsize: Minimum size to allocate
  4969. * @func: Caller function name
  4970. * @line: Caller function line no.
  4971. *
  4972. * if number of frag exceed maximum frag array. A new nbuf is allocated
  4973. * with minimum headroom and frag it added to that nbuf.
  4974. * new nbuf is added as frag_list to the master nbuf.
  4975. *
  4976. * Return: QDF_STATUS
  4977. */
  4978. QDF_STATUS
  4979. qdf_nbuf_add_frag_debug(qdf_device_t osdev, qdf_frag_t buf,
  4980. qdf_nbuf_t nbuf, int offset,
  4981. int frag_len, unsigned int truesize,
  4982. bool take_frag_ref, unsigned int minsize,
  4983. const char *func, uint32_t line);
  4984. #ifdef MEMORY_DEBUG
  4985. /**
  4986. * qdf_nbuf_acquire_track_lock - acquire the nbuf spinlock at the
  4987. * specified index
  4988. * @index: index to get the lock
  4989. * @irq_flag: lock flag for using nbuf lock
  4990. *
  4991. * Return: none
  4992. */
  4993. void qdf_nbuf_acquire_track_lock(uint32_t index,
  4994. unsigned long irq_flag);
  4995. /**
  4996. * qdf_nbuf_release_track_lock - release the nbuf spinlock at the
  4997. * specified index
  4998. * @index: index of the lock to be released
  4999. * @irq_flag: lock flag for using nbuf lock
  5000. *
  5001. * Return: none
  5002. */
  5003. void qdf_nbuf_release_track_lock(uint32_t index,
  5004. unsigned long irq_flag);
  5005. /**
  5006. * qdf_nbuf_get_track_tbl - get the QDF_NBUF_TRACK entry from the track
  5007. * table at the specified index
  5008. * @index: index to get the table entry
  5009. *
  5010. * Return: the QDF_NBUF_TRACK entry at the specified index in the table
  5011. */
  5012. QDF_NBUF_TRACK *qdf_nbuf_get_track_tbl(uint32_t index);
  5013. #endif /* MEMORY_DEBUG */
  5014. #ifdef CONFIG_WLAN_SYSFS_MEM_STATS
  5015. /**
  5016. * qdf_record_nbuf_nbytes() - add or subtract the size of the nbuf
  5017. * from the total skb mem and DP tx/rx skb mem
  5018. * @nbytes: number of bytes
  5019. * @dir: direction
  5020. * @is_mapped: is mapped or unmapped memory
  5021. *
  5022. * Return: none
  5023. */
  5024. void qdf_record_nbuf_nbytes(
  5025. uint32_t nbytes, qdf_dma_dir_t dir, bool is_mapped);
  5026. #else /* CONFIG_WLAN_SYSFS_MEM_STATS */
  5027. static inline void qdf_record_nbuf_nbytes(
  5028. int nbytes, qdf_dma_dir_t dir, bool is_mapped)
  5029. {
  5030. }
  5031. #endif /* CONFIG_WLAN_SYSFS_MEM_STATS */
  5032. #ifdef ENHANCED_OS_ABSTRACTION
  5033. /**
  5034. * qdf_nbuf_set_timestamp() - set the timestamp for frame
  5035. * @buf: pointer to network buffer
  5036. *
  5037. * Return: none
  5038. */
  5039. void qdf_nbuf_set_timestamp(qdf_nbuf_t buf);
  5040. /**
  5041. * qdf_nbuf_get_timestamp() - get the timestamp for frame
  5042. * @buf: pointer to network buffer
  5043. *
  5044. * Return: timestamp stored in skb in ms
  5045. */
  5046. uint64_t qdf_nbuf_get_timestamp(qdf_nbuf_t buf);
  5047. /**
  5048. * qdf_nbuf_get_timestamp_us() - get the timestamp for frame
  5049. * @buf: pointer to network buffer
  5050. *
  5051. * Return: timestamp stored in nbuf in us
  5052. */
  5053. uint64_t qdf_nbuf_get_timestamp_us(qdf_nbuf_t buf);
  5054. /**
  5055. * qdf_nbuf_get_timedelta_ms() - get time difference in ms
  5056. * @buf: pointer to network buffer
  5057. *
  5058. * Return: time difference ms
  5059. */
  5060. uint64_t qdf_nbuf_get_timedelta_ms(qdf_nbuf_t buf);
  5061. /**
  5062. * qdf_nbuf_get_timedelta_us() - get time difference in micro seconds
  5063. * @buf: pointer to network buffer
  5064. *
  5065. * Return: time difference in micro seconds
  5066. */
  5067. uint64_t qdf_nbuf_get_timedelta_us(qdf_nbuf_t buf);
  5068. /**
  5069. * qdf_nbuf_net_timedelta() - get time delta
  5070. * @t: time as qdf_ktime_t object
  5071. *
  5072. * Return: time delta as ktime_t object
  5073. */
  5074. qdf_ktime_t qdf_nbuf_net_timedelta(qdf_ktime_t t);
  5075. #else
  5076. static inline void
  5077. qdf_nbuf_set_timestamp(struct sk_buff *skb)
  5078. {
  5079. __qdf_nbuf_set_timestamp(skb);
  5080. }
  5081. static inline uint64_t
  5082. qdf_nbuf_get_timestamp(struct sk_buff *skb)
  5083. {
  5084. return __qdf_nbuf_get_timestamp(skb);
  5085. }
  5086. static inline uint64_t
  5087. qdf_nbuf_get_timestamp_us(qdf_nbuf_t buf)
  5088. {
  5089. return __qdf_nbuf_get_timestamp_us(buf);
  5090. }
  5091. static inline uint64_t
  5092. qdf_nbuf_get_timedelta_ms(struct sk_buff *skb)
  5093. {
  5094. return __qdf_nbuf_get_timedelta_ms(skb);
  5095. }
  5096. static inline uint64_t
  5097. qdf_nbuf_get_timedelta_us(struct sk_buff *skb)
  5098. {
  5099. return __qdf_nbuf_get_timedelta_us(skb);
  5100. }
  5101. static inline qdf_ktime_t qdf_nbuf_net_timedelta(qdf_ktime_t t)
  5102. {
  5103. return __qdf_nbuf_net_timedelta(t);
  5104. }
  5105. #endif /* ENHANCED_OS_ABSTRACTION */
  5106. #ifdef NBUF_MEMORY_DEBUG
  5107. /**
  5108. * qdf_set_smmu_fault_state() - Set smmu fault state
  5109. * @smmu_fault_state: state of the wlan smmu
  5110. *
  5111. * Return: void
  5112. */
  5113. void qdf_set_smmu_fault_state(bool smmu_fault_state);
  5114. #else
  5115. static inline void qdf_set_smmu_fault_state(bool smmu_fault_state)
  5116. {
  5117. }
  5118. #endif
  5119. #ifdef CONFIG_NBUF_AP_PLATFORM
  5120. #include <i_qdf_nbuf_api_w.h>
  5121. #else
  5122. #include <i_qdf_nbuf_api_m.h>
  5123. #endif
  5124. /**
  5125. * qdf_nbuf_stop_replenish_timer - Stop alloc fail replenish timer
  5126. *
  5127. * This function stops the alloc fail replenish timer.
  5128. *
  5129. * Return: void
  5130. */
  5131. void qdf_nbuf_stop_replenish_timer(void);
  5132. /**
  5133. * qdf_get_nbuf_valid_frag() - Get nbuf to store frag
  5134. * @nbuf: qdf_nbuf_t master nbuf
  5135. *
  5136. * Return: qdf_nbuf_t
  5137. */
  5138. qdf_nbuf_t qdf_get_nbuf_valid_frag(qdf_nbuf_t nbuf);
  5139. /**
  5140. * qdf_nbuf_fast_xmit() - Check if packet has fast_xmit support
  5141. * @nbuf: qdf_nbuf_t master nbuf
  5142. *
  5143. * This function checks if skb has fast_xmit or not.
  5144. *
  5145. * Return: True if skb support fast_xmit otherwise false
  5146. */
  5147. bool qdf_nbuf_fast_xmit(qdf_nbuf_t nbuf);
  5148. /**
  5149. * qdf_nbuf_set_fast_xmit() - Set fast_xmit in SKB
  5150. * @nbuf: qdf_nbuf_t master nbuf
  5151. * @value: value to set in fast_xmit
  5152. *
  5153. * This function set fast_xmit in SKB if it exist.
  5154. *
  5155. * Return: void
  5156. */
  5157. void qdf_nbuf_set_fast_xmit(qdf_nbuf_t nbuf, int value);
  5158. #endif /* _QDF_NBUF_H */