qdf_nbuf.h 129 KB

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