qdf_nbuf.h 140 KB

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