qdf_nbuf.h 141 KB

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