qdf_nbuf.h 100 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997
  1. /*
  2. * Copyright (c) 2014-2020 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. /**
  19. * DOC: qdf_nbuf_public network buffer API
  20. * This file defines the network buffer abstraction.
  21. */
  22. #ifndef _QDF_NBUF_H
  23. #define _QDF_NBUF_H
  24. #include <qdf_util.h>
  25. #include <qdf_types.h>
  26. #include <qdf_lock.h>
  27. #include <i_qdf_trace.h>
  28. #include <i_qdf_nbuf.h>
  29. #include <qdf_net_types.h>
  30. #define IPA_NBUF_OWNER_ID 0xaa55aa55
  31. #define QDF_NBUF_PKT_TRAC_TYPE_DNS 0x01
  32. #define QDF_NBUF_PKT_TRAC_TYPE_EAPOL 0x02
  33. #define QDF_NBUF_PKT_TRAC_TYPE_DHCP 0x04
  34. #define QDF_NBUF_PKT_TRAC_TYPE_MGMT_ACTION 0x08
  35. #define QDF_NBUF_PKT_TRAC_TYPE_ARP 0x10
  36. #define QDF_NBUF_PKT_TRAC_TYPE_ICMP 0x20
  37. #define QDF_NBUF_PKT_TRAC_TYPE_ICMPv6 0x40
  38. #define QDF_HL_CREDIT_TRACKING 0x80
  39. #define QDF_NBUF_PKT_TRAC_MAX_STRING 12
  40. #define QDF_NBUF_PKT_TRAC_PROTO_STRING 4
  41. #define QDF_NBUF_PKT_ERROR 1
  42. #define QDF_NBUF_TRAC_IPV4_OFFSET 14
  43. #define QDF_NBUF_TRAC_IPV4_HEADER_MASK 0xF
  44. #define QDF_NBUF_TRAC_IPV4_HEADER_SIZE 20
  45. #define QDF_NBUF_TRAC_DHCP_SRV_PORT 67
  46. #define QDF_NBUF_TRAC_DHCP_CLI_PORT 68
  47. #define QDF_NBUF_TRAC_ETH_TYPE_OFFSET 12
  48. #define QDF_NBUF_TRAC_VLAN_ETH_TYPE_OFFSET 16
  49. #define QDF_NBUF_TRAC_DOUBLE_VLAN_ETH_TYPE_OFFSET 20
  50. #define QDF_NBUF_TRAC_EAPOL_ETH_TYPE 0x888E
  51. #define QDF_NBUF_TRAC_WAPI_ETH_TYPE 0x88b4
  52. #define QDF_NBUF_TRAC_ARP_ETH_TYPE 0x0806
  53. #define QDF_NBUF_PKT_IPV4_DSCP_MASK 0xFC
  54. #define QDF_NBUF_PKT_IPV4_DSCP_SHIFT 0x02
  55. #define QDF_NBUF_TRAC_TDLS_ETH_TYPE 0x890D
  56. #define QDF_NBUF_TRAC_IPV4_ETH_TYPE 0x0800
  57. #define QDF_NBUF_TRAC_IPV6_ETH_TYPE 0x86dd
  58. #define QDF_NBUF_DEST_MAC_OFFSET 0
  59. #define QDF_NBUF_SRC_MAC_OFFSET 6
  60. #define QDF_NBUF_TRAC_IPV4_PROTO_TYPE_OFFSET 23
  61. #define QDF_NBUF_TRAC_IPV4_DEST_ADDR_OFFSET 30
  62. #define QDF_NBUF_TRAC_IPV4_SRC_ADDR_OFFSET 26
  63. #define QDF_NBUF_TRAC_IPV6_PROTO_TYPE_OFFSET 20
  64. #define QDF_NBUF_TRAC_IPV4_ADDR_MCAST_MASK 0xE0000000
  65. #define QDF_NBUF_TRAC_IPV4_ADDR_BCAST_MASK 0xF0000000
  66. #define QDF_NBUF_TRAC_IPV6_DEST_ADDR_OFFSET 38
  67. #define QDF_NBUF_TRAC_IPV6_DEST_ADDR 0xFF00
  68. #define QDF_NBUF_TRAC_IPV6_OFFSET 14
  69. #define QDF_NBUF_TRAC_IPV6_HEADER_SIZE 40
  70. #define QDF_NBUF_TRAC_ICMP_TYPE 1
  71. #define QDF_NBUF_TRAC_TCP_TYPE 6
  72. #define QDF_NBUF_TRAC_TCP_FLAGS_OFFSET (47 - 34)
  73. #define QDF_NBUF_TRAC_TCP_ACK_OFFSET (42 - 34)
  74. #define QDF_NBUF_TRAC_TCP_HEADER_LEN_OFFSET (46 - 34)
  75. #define QDF_NBUF_TRAC_TCP_ACK_MASK 0x10
  76. #define QDF_NBUF_TRAC_TCP_SPORT_OFFSET (34 - 34)
  77. #define QDF_NBUF_TRAC_TCP_DPORT_OFFSET (36 - 34)
  78. #define QDF_NBUF_TRAC_UDP_TYPE 17
  79. #define QDF_NBUF_TRAC_ICMPV6_TYPE 0x3a
  80. #define QDF_NBUF_TRAC_DHCP6_SRV_PORT 547
  81. #define QDF_NBUF_TRAC_DHCP6_CLI_PORT 546
  82. #define QDF_NBUF_TRAC_MDNS_SRC_N_DST_PORT 5353
  83. #define QDF_NBUF_TRAC_IP_OFFSET 14
  84. #define QDF_NBUF_TRAC_VLAN_IP_OFFSET 18
  85. #define QDF_NBUF_TRAC_DOUBLE_VLAN_IP_OFFSET 22
  86. /* One dword for IPv4 header size unit */
  87. #define QDF_NBUF_IPV4_HDR_SIZE_UNIT 4
  88. /* EAPOL Related MASK */
  89. #define EAPOL_PACKET_TYPE_OFFSET 15
  90. #define EAPOL_KEY_INFO_OFFSET 19
  91. #define EAPOL_PKT_LEN_OFFSET 16
  92. #define EAPOL_KEY_LEN_OFFSET 21
  93. #define EAPOL_MASK 0x8013
  94. #define EAPOL_M1_BIT_MASK 0x8000
  95. #define EAPOL_M2_BIT_MASK 0x0001
  96. #define EAPOL_M3_BIT_MASK 0x8013
  97. #define EAPOL_M4_BIT_MASK 0x0003
  98. /* ARP Related MASK */
  99. #define QDF_NBUF_PKT_ARP_OPCODE_OFFSET 20
  100. #define QDF_NBUF_PKT_ARPOP_REQ 1
  101. #define QDF_NBUF_PKT_ARPOP_REPLY 2
  102. #define QDF_NBUF_PKT_ARP_SRC_IP_OFFSET 28
  103. #define QDF_NBUF_PKT_ARP_TGT_IP_OFFSET 38
  104. /* ICMPv4 Related MASK */
  105. #define QDF_NBUF_PKT_ICMPv4_OPCODE_OFFSET 34
  106. #define QDF_NBUF_PKT_ICMPv4OP_REQ 0x08
  107. #define QDF_NBUF_PKT_ICMPv4OP_REPLY 0x00
  108. #define QDF_NBUF_PKT_ICMPv4_SRC_IP_OFFSET 26
  109. #define QDF_NBUF_PKT_ICMPv4_TGT_IP_OFFSET 30
  110. /* TCP Related MASK */
  111. #define QDF_NBUF_PKT_TCP_OPCODE_OFFSET 47
  112. #define QDF_NBUF_PKT_TCPOP_SYN 0x02
  113. #define QDF_NBUF_PKT_TCPOP_SYN_ACK 0x12
  114. #define QDF_NBUF_PKT_TCPOP_ACK 0x10
  115. #define QDF_NBUF_PKT_TCP_SRC_PORT_OFFSET 34
  116. #define QDF_NBUF_PKT_TCP_DST_PORT_OFFSET 36
  117. /* DNS Related MASK */
  118. #define QDF_NBUF_PKT_DNS_OVER_UDP_OPCODE_OFFSET 44
  119. #define QDF_NBUF_PKT_DNSOP_BITMAP 0xF800
  120. #define QDF_NBUF_PKT_DNSOP_STANDARD_QUERY 0x0000
  121. #define QDF_NBUF_PKT_DNSOP_STANDARD_RESPONSE 0x8000
  122. #define QDF_NBUF_PKT_DNS_SRC_PORT_OFFSET 34
  123. #define QDF_NBUF_PKT_DNS_DST_PORT_OFFSET 36
  124. #define QDF_NBUF_PKT_DNS_NAME_OVER_UDP_OFFSET 54
  125. #define QDF_NBUF_PKT_DNS_STANDARD_PORT 53
  126. /* Tracked Packet types */
  127. #define QDF_NBUF_TX_PKT_INVALID 0
  128. #define QDF_NBUF_TX_PKT_DATA_TRACK 1
  129. #define QDF_NBUF_TX_PKT_MGMT_TRACK 2
  130. #define QDF_NBUF_RX_PKT_DATA_TRACK 3
  131. /* Different Packet states */
  132. #define QDF_NBUF_TX_PKT_HDD 1
  133. #define QDF_NBUF_TX_PKT_TXRX_ENQUEUE 2
  134. #define QDF_NBUF_TX_PKT_TXRX_DEQUEUE 3
  135. #define QDF_NBUF_TX_PKT_TXRX 4
  136. #define QDF_NBUF_TX_PKT_HTT 5
  137. #define QDF_NBUF_TX_PKT_HTC 6
  138. #define QDF_NBUF_TX_PKT_HIF 7
  139. #define QDF_NBUF_TX_PKT_CE 8
  140. #define QDF_NBUF_TX_PKT_FREE 9
  141. #define QDF_NBUF_TX_PKT_STATE_MAX 10
  142. #define QDF_NBUF_TX_PKT_LI_DP 11
  143. /* nbuf allocations only come from one domain */
  144. #define QDF_DEBUG_NBUF_DOMAIN 0
  145. /* qdf_nbuf allocate and map max retry threshold when failed */
  146. #define QDF_NBUF_ALLOC_MAP_RETRY_THRESHOLD 20
  147. /* Enable flag to print TSO specific prints in datapath */
  148. #ifdef TSO_DEBUG_LOG_ENABLE
  149. #define TSO_DEBUG(fmt, args ...) \
  150. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_NONE, \
  151. fmt, ## args)
  152. #else
  153. #define TSO_DEBUG(fmt, args ...)
  154. #endif
  155. #define IEEE80211_AMPDU_FLAG 0x01
  156. #ifdef GET_MSDU_AGGREGATION
  157. #define IEEE80211_AMSDU_FLAG 0x02
  158. #endif
  159. #define MAX_CHAIN 8
  160. #define QDF_MON_STATUS_MPDU_FCS_BMAP_NWORDS 8
  161. /**
  162. * struct mon_rx_status - This will have monitor mode rx_status extracted from
  163. * htt_rx_desc used later to update radiotap information.
  164. * @tsft: Time Synchronization Function timer
  165. * @ppdu_timestamp: Timestamp in the PPDU_START TLV
  166. * @preamble_type: Preamble type in radio header
  167. * @chan_freq: Capture channel frequency
  168. * @chan_num: Capture channel number
  169. * @chan_flags: Bitmap of Channel flags, IEEE80211_CHAN_TURBO,
  170. * IEEE80211_CHAN_CCK...
  171. * @ht_flags: HT flags, only present for HT frames.
  172. * @vht_flags: VHT flags, only present for VHT frames.
  173. * @vht_flag_values1-5: Contains corresponding data for flags field
  174. * @he_flags: HE (11ax) flags, only present in HE frames
  175. * @he_mu_flags: HE-MU (11ax) flags, only present in HE frames
  176. * @he_mu_other_flags: HE-MU-OTHER (11ax) flags, only present in HE frames
  177. * @he_sig_A1_known: HE (11ax) sig A1 known field
  178. * @he_sig_A2_known: HE (11ax) sig A2 known field
  179. * @he_sig_b_common: HE (11ax) sig B common field
  180. * @he_sig_b_common_known: HE (11ax) sig B common known field
  181. * @l_sig_a_info: L_SIG_A value coming in Rx descriptor
  182. * @l_sig_b_info: L_SIG_B value coming in Rx descriptor
  183. * @rate: Rate in terms 500Kbps
  184. * @rtap_flags: Bit map of available fields in the radiotap
  185. * @ant_signal_db: Rx packet RSSI
  186. * @nr_ant: Number of Antennas used for streaming
  187. * @mcs: MCS index of Rx frame
  188. * @ht_mcs: MCS index for HT RX frames
  189. * @nss: Number of spatial streams
  190. * @bw: bandwidth of rx frame
  191. * @is_stbc: Is STBC enabled
  192. * @sgi: Rx frame short guard interval
  193. * @he_re: HE range extension
  194. * @ldpc: ldpc enabled
  195. * @beamformed: Is frame beamformed.
  196. * @he_sig_b_common_RU[4]: HE (11ax) common RU assignment index
  197. * @rssi_comb: Combined RSSI
  198. * @rssi[MAX_CHAIN]: 8 bits RSSI per 20Mhz per chain
  199. * @duration: 802.11 Duration
  200. * @frame_control_info_valid: field indicates if fc value is valid
  201. * @frame_control: frame control field
  202. * @ast_index: AST table hash index
  203. * @tid: QoS traffic tid number
  204. * @rs_fcs_err: FCS error flag
  205. * @rs_flags: Flags to indicate AMPDU or AMSDU aggregation
  206. * @cck_flag: Flag to indicate CCK modulation
  207. * @ofdm_flag: Flag to indicate OFDM modulation
  208. * @ulofdma_flag: Flag to indicate UL OFDMA PPDU
  209. * @he_per_user_1: HE per user info1
  210. * @he_per_user_2: HE per user info2
  211. * @he_per_user_position: HE per user position info
  212. * @he_per_user_known: HE per user known info
  213. * @he_flags1: HE flags
  214. * @he_flags2: HE flags
  215. * @he_RU[4]: HE RU assignment index
  216. * @he_data1: HE property of received frame
  217. * @he_data2: HE property of received frame
  218. * @he_data3: HE property of received frame
  219. * @he_data4: HE property of received frame
  220. * @he_data5: HE property of received frame
  221. * @prev_ppdu_id: ppdu_id in previously received message
  222. * @ppdu_id: Id of the PLCP protocol data unit
  223. *
  224. * The following variables are not coming from the TLVs.
  225. * These variables are placeholders for passing information to update_radiotap
  226. * function.
  227. * @device_id: Device ID coming from sub-system (PCI, AHB etc..)
  228. * @chan_noise_floor: Channel Noise Floor for the pdev
  229. * @data_sequence_control_info_valid: field to indicate validity of seq control
  230. * @first_data_seq_ctrl: Sequence ctrl field of first data frame
  231. * @rxpcu_filter_pass: Flag which indicates whether RX packets are received in
  232. * BSS mode(not in promisc mode)
  233. * @rssi_chain: Rssi chain per nss per bw
  234. * @tx_status: packet tx status
  235. * @tx_retry_cnt: tx retry count
  236. * @add_rtap_ext: add radio tap extension
  237. */
  238. struct mon_rx_status {
  239. uint64_t tsft;
  240. uint32_t ppdu_timestamp;
  241. uint32_t preamble_type;
  242. qdf_freq_t chan_freq;
  243. uint16_t chan_num;
  244. uint16_t chan_flags;
  245. uint16_t ht_flags;
  246. uint16_t vht_flags;
  247. uint16_t vht_flag_values6;
  248. uint16_t he_flags;
  249. uint16_t he_mu_flags;
  250. uint16_t he_mu_other_flags;
  251. uint16_t he_sig_A1_known;
  252. uint16_t he_sig_A2_known;
  253. uint16_t he_sig_b_common;
  254. uint16_t he_sig_b_common_known;
  255. uint32_t l_sig_a_info;
  256. uint32_t l_sig_b_info;
  257. uint8_t rate;
  258. uint8_t rtap_flags;
  259. uint8_t ant_signal_db;
  260. uint8_t nr_ant;
  261. uint8_t mcs;
  262. uint8_t ht_mcs;
  263. uint8_t nss;
  264. uint16_t tcp_msdu_count;
  265. uint16_t udp_msdu_count;
  266. uint16_t other_msdu_count;
  267. uint8_t bw;
  268. uint8_t vht_flag_values1;
  269. uint8_t vht_flag_values2;
  270. uint8_t vht_flag_values3[4];
  271. uint8_t vht_flag_values4;
  272. uint8_t vht_flag_values5;
  273. uint8_t is_stbc;
  274. uint8_t sgi;
  275. uint8_t he_re;
  276. uint8_t ldpc;
  277. uint8_t beamformed;
  278. uint8_t he_sig_b_common_RU[4];
  279. int8_t rssi_comb;
  280. uint64_t rssi[MAX_CHAIN];
  281. uint8_t reception_type;
  282. uint16_t duration;
  283. uint8_t frame_control_info_valid;
  284. uint16_t frame_control;
  285. uint32_t ast_index;
  286. uint32_t tid;
  287. uint8_t rs_fcs_err;
  288. uint8_t rs_flags;
  289. uint8_t cck_flag;
  290. uint8_t ofdm_flag;
  291. uint8_t ulofdma_flag;
  292. /* New HE radiotap fields */
  293. uint16_t he_per_user_1;
  294. uint16_t he_per_user_2;
  295. uint8_t he_per_user_position;
  296. uint8_t he_per_user_known;
  297. uint16_t he_flags1;
  298. uint16_t he_flags2;
  299. uint8_t he_RU[4];
  300. uint16_t he_data1;
  301. uint16_t he_data2;
  302. uint16_t he_data3;
  303. uint16_t he_data4;
  304. uint16_t he_data5;
  305. uint16_t he_data6;
  306. uint32_t ppdu_len;
  307. uint32_t prev_ppdu_id;
  308. uint32_t ppdu_id;
  309. uint32_t device_id;
  310. int16_t chan_noise_floor;
  311. uint8_t monitor_direct_used;
  312. uint8_t data_sequence_control_info_valid;
  313. uint16_t first_data_seq_ctrl;
  314. uint8_t ltf_size;
  315. uint8_t rxpcu_filter_pass;
  316. int8_t rssi_chain[8][8];
  317. uint32_t rx_antenna;
  318. uint8_t tx_status;
  319. uint8_t tx_retry_cnt;
  320. bool add_rtap_ext;
  321. };
  322. /**
  323. * struct mon_rx_user_status - This will have monitor mode per user rx_status
  324. * extracted from hardware TLV.
  325. * @mcs: MCS index of Rx frame
  326. * @nss: Number of spatial streams
  327. * @mu_ul_info_valid: MU UL info below is valid
  328. * @ofdma_ru_start_index: OFDMA RU start index
  329. * @ofdma_ru_width: OFDMA total RU width
  330. * @ofdma_ru_size: OFDMA RU size index
  331. * @mu_ul_user_v0_word0: MU UL user info word 0
  332. * @mu_ul_user_v0_word1: MU UL user info word 1
  333. * @ast_index: AST table hash index
  334. * @tid: QoS traffic tid number
  335. * @tcp_msdu_count: tcp protocol msdu count
  336. * @udp_msdu_count: udp protocol msdu count
  337. * @other_msdu_count: other protocol msdu count
  338. * @frame_control: frame control field
  339. * @frame_control_info_valid: field indicates if fc value is valid
  340. * @data_sequence_control_info_valid: field to indicate validity of seq control
  341. * @first_data_seq_ctrl: Sequence ctrl field of first data frame
  342. * @preamble_type: Preamble type in radio header
  343. * @ht_flags: HT flags, only present for HT frames.
  344. * @vht_flags: VHT flags, only present for VHT frames.
  345. * @he_flags: HE (11ax) flags, only present in HE frames
  346. * @rtap_flags: Bit map of available fields in the radiotap
  347. * @rs_flags: Flags to indicate AMPDU or AMSDU aggregation
  348. * @mpdu_cnt_fcs_ok: mpdu count received with fcs ok
  349. * @mpdu_cnt_fcs_err: mpdu count received with fcs ok bitmap
  350. * @mpdu_fcs_ok_bitmap: mpdu with fcs ok bitmap
  351. * @mpdu_ok_byte_count: mpdu byte count with fcs ok
  352. * @mpdu_err_byte_count: mpdu byte count with fcs err
  353. */
  354. struct mon_rx_user_status {
  355. uint32_t mcs:4,
  356. nss:3,
  357. mu_ul_info_valid:1,
  358. ofdma_ru_start_index:7,
  359. ofdma_ru_width:7,
  360. ofdma_ru_size:8;
  361. uint32_t mu_ul_user_v0_word0;
  362. uint32_t mu_ul_user_v0_word1;
  363. uint32_t ast_index;
  364. uint32_t tid;
  365. uint16_t tcp_msdu_count;
  366. uint16_t udp_msdu_count;
  367. uint16_t other_msdu_count;
  368. uint16_t frame_control;
  369. uint8_t frame_control_info_valid;
  370. uint8_t data_sequence_control_info_valid;
  371. uint16_t first_data_seq_ctrl;
  372. uint32_t preamble_type;
  373. uint16_t ht_flags;
  374. uint16_t vht_flags;
  375. uint16_t he_flags;
  376. uint8_t rtap_flags;
  377. uint8_t rs_flags;
  378. uint32_t mpdu_cnt_fcs_ok;
  379. uint32_t mpdu_cnt_fcs_err;
  380. uint32_t mpdu_fcs_ok_bitmap[QDF_MON_STATUS_MPDU_FCS_BMAP_NWORDS];
  381. uint32_t mpdu_ok_byte_count;
  382. uint32_t mpdu_err_byte_count;
  383. };
  384. /**
  385. * struct qdf_radiotap_vendor_ns - Vendor Namespace header as per
  386. * Radiotap spec: https://www.radiotap.org/fields/Vendor%20Namespace.html
  387. * @oui: Vendor OUI
  388. * @selector: sub_namespace selector
  389. * @skip_length: How many bytes of Vendor Namespace data that follows
  390. */
  391. struct qdf_radiotap_vendor_ns {
  392. uint8_t oui[3];
  393. uint8_t selector;
  394. uint16_t skip_length;
  395. } __attribute__((__packed__));
  396. /**
  397. * struct qdf_radiotap_vendor_ns_ath - Combined QTI Vendor NS
  398. * including the Radiotap specified Vendor Namespace header and
  399. * QTI specific Vendor Namespace data
  400. * @lsig: L_SIG_A (or L_SIG)
  401. * @device_id: Device Identification
  402. * @lsig_b: L_SIG_B
  403. * @ppdu_start_timestamp: Timestamp from RX_PPDU_START TLV
  404. */
  405. struct qdf_radiotap_vendor_ns_ath {
  406. struct qdf_radiotap_vendor_ns hdr;
  407. /* QTI specific data follows */
  408. uint32_t lsig;
  409. uint32_t device_id;
  410. uint32_t lsig_b;
  411. uint32_t ppdu_start_timestamp;
  412. } __attribute__((__packed__));
  413. #define QDF_MEM_FUNC_NAME_SIZE 48
  414. /* Masks for HE SIG known fields in mon_rx_status structure */
  415. #define QDF_MON_STATUS_HE_SIG_B_COMMON_KNOWN_RU0 0x00000001
  416. #define QDF_MON_STATUS_HE_SIG_B_COMMON_KNOWN_RU1 0x00000002
  417. #define QDF_MON_STATUS_HE_SIG_B_COMMON_KNOWN_RU2 0x00000004
  418. #define QDF_MON_STATUS_HE_SIG_B_COMMON_KNOWN_RU3 0x00000008
  419. #define QDF_MON_STATUS_HE_SIG_B_USER_KNOWN_SIG_B_ALL 0x00fe0000
  420. #define QDF_MON_STATUS_HE_SIG_A1_HE_FORMAT_SU 0x00000000
  421. #define QDF_MON_STATUS_HE_SIG_A1_HE_FORMAT_EXT_SU 0x40000000
  422. #define QDF_MON_STATUS_HE_SIG_A1_HE_FORMAT_TRIG 0xc0000000
  423. /* DHCP Related Mask */
  424. #define QDF_DHCP_OPTION53 (0x35)
  425. #define QDF_DHCP_OPTION53_LENGTH (1)
  426. #define QDF_DHCP_OPTION53_OFFSET (0x11A)
  427. #define QDF_DHCP_OPTION53_LENGTH_OFFSET (0x11B)
  428. #define QDF_DHCP_OPTION53_STATUS_OFFSET (0x11C)
  429. #define DHCP_PKT_LEN_OFFSET 16
  430. #define DHCP_TRANSACTION_ID_OFFSET 46
  431. #define QDF_DHCP_DISCOVER (1)
  432. #define QDF_DHCP_OFFER (2)
  433. #define QDF_DHCP_REQUEST (3)
  434. #define QDF_DHCP_DECLINE (4)
  435. #define QDF_DHCP_ACK (5)
  436. #define QDF_DHCP_NAK (6)
  437. #define QDF_DHCP_RELEASE (7)
  438. #define QDF_DHCP_INFORM (8)
  439. /* ARP Related Mask */
  440. #define ARP_SUB_TYPE_OFFSET 20
  441. #define ARP_REQUEST (1)
  442. #define ARP_RESPONSE (2)
  443. /* IPV4 header fields offset values */
  444. #define IPV4_PKT_LEN_OFFSET 16
  445. #define IPV4_TCP_SEQ_NUM_OFFSET 38
  446. #define IPV4_SRC_ADDR_OFFSET 26
  447. #define IPV4_DST_ADDR_OFFSET 30
  448. #define IPV4_SRC_PORT_OFFSET 34
  449. #define IPV4_DST_PORT_OFFSET 36
  450. /* IPV4 ICMP Related Mask */
  451. #define ICMP_SEQ_NUM_OFFSET 40
  452. #define ICMP_SUBTYPE_OFFSET 34
  453. #define ICMP_REQUEST 0x08
  454. #define ICMP_RESPONSE 0x00
  455. #define IPV6_ADDR_STR "%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:"\
  456. "%02x%02x:%02x%02x"
  457. /* IPV6 header fields offset values */
  458. #define IPV6_PKT_LEN_OFFSET 18
  459. #define IPV6_TCP_SEQ_NUM_OFFSET 58
  460. #define IPV6_SRC_ADDR_OFFSET 22
  461. #define IPV6_DST_ADDR_OFFSET 38
  462. #define IPV6_SRC_PORT_OFFSET 54
  463. #define IPV6_DST_PORT_OFFSET 56
  464. /* IPV6 ICMPV6 Related Mask */
  465. #define ICMPV6_SEQ_NUM_OFFSET 60
  466. #define ICMPV6_SUBTYPE_OFFSET 54
  467. #define ICMPV6_REQUEST 0x80
  468. #define ICMPV6_RESPONSE 0x81
  469. #define ICMPV6_RS 0x85
  470. #define ICMPV6_RA 0x86
  471. #define ICMPV6_NS 0x87
  472. #define ICMPV6_NA 0x88
  473. #define QDF_NBUF_IPA_CHECK_MASK 0x80000000
  474. /* HE Radiotap data1 Mask */
  475. #define QDF_MON_STATUS_HE_SU_FORMAT_TYPE 0x0000
  476. #define QDF_MON_STATUS_HE_EXT_SU_FORMAT_TYPE 0x0001
  477. #define QDF_MON_STATUS_HE_MU_FORMAT_TYPE 0x0002
  478. #define QDF_MON_STATUS_HE_TRIG_FORMAT_TYPE 0x0003
  479. #define QDF_MON_STATUS_HE_BEAM_CHANGE_KNOWN 0x0008
  480. #define QDF_MON_STATUS_HE_DL_UL_KNOWN 0x0010
  481. #define QDF_MON_STATUS_HE_MCS_KNOWN 0x0020
  482. #define QDF_MON_STATUS_HE_DCM_KNOWN 0x0040
  483. #define QDF_MON_STATUS_HE_CODING_KNOWN 0x0080
  484. #define QDF_MON_STATUS_HE_LDPC_EXTRA_SYMBOL_KNOWN 0x0100
  485. #define QDF_MON_STATUS_HE_STBC_KNOWN 0x0200
  486. #define QDF_MON_STATUS_HE_DATA_BW_RU_KNOWN 0x4000
  487. #define QDF_MON_STATUS_HE_DOPPLER_KNOWN 0x8000
  488. #define QDF_MON_STATUS_HE_BSS_COLOR_KNOWN 0x0004
  489. /* HE Radiotap data2 Mask */
  490. #define QDF_MON_STATUS_HE_GI_KNOWN 0x0002
  491. #define QDF_MON_STATUS_TXBF_KNOWN 0x0010
  492. #define QDF_MON_STATUS_PE_DISAMBIGUITY_KNOWN 0x0020
  493. #define QDF_MON_STATUS_TXOP_KNOWN 0x0040
  494. #define QDF_MON_STATUS_LTF_SYMBOLS_KNOWN 0x0004
  495. #define QDF_MON_STATUS_PRE_FEC_PADDING_KNOWN 0x0008
  496. #define QDF_MON_STATUS_MIDABLE_PERIODICITY_KNOWN 0x0080
  497. /* HE radiotap data3 shift values */
  498. #define QDF_MON_STATUS_BEAM_CHANGE_SHIFT 6
  499. #define QDF_MON_STATUS_DL_UL_SHIFT 7
  500. #define QDF_MON_STATUS_TRANSMIT_MCS_SHIFT 8
  501. #define QDF_MON_STATUS_DCM_SHIFT 12
  502. #define QDF_MON_STATUS_CODING_SHIFT 13
  503. #define QDF_MON_STATUS_LDPC_EXTRA_SYMBOL_SHIFT 14
  504. #define QDF_MON_STATUS_STBC_SHIFT 15
  505. /* HE radiotap data4 shift values */
  506. #define QDF_MON_STATUS_STA_ID_SHIFT 4
  507. /* HE radiotap data5 */
  508. #define QDF_MON_STATUS_GI_SHIFT 4
  509. #define QDF_MON_STATUS_HE_LTF_SIZE_SHIFT 6
  510. #define QDF_MON_STATUS_HE_LTF_SYM_SHIFT 8
  511. #define QDF_MON_STATUS_TXBF_SHIFT 14
  512. #define QDF_MON_STATUS_PE_DISAMBIGUITY_SHIFT 15
  513. #define QDF_MON_STATUS_PRE_FEC_PAD_SHIFT 12
  514. /* HE radiotap data6 */
  515. #define QDF_MON_STATUS_DOPPLER_SHIFT 4
  516. #define QDF_MON_STATUS_TXOP_SHIFT 8
  517. /* HE radiotap HE-MU flags1 */
  518. #define QDF_MON_STATUS_SIG_B_MCS_KNOWN 0x0010
  519. #define QDF_MON_STATUS_SIG_B_DCM_KNOWN 0x0040
  520. #define QDF_MON_STATUS_SIG_B_SYM_NUM_KNOWN 0x8000
  521. #define QDF_MON_STATUS_RU_0_KNOWN 0x0100
  522. #define QDF_MON_STATUS_RU_1_KNOWN 0x0200
  523. #define QDF_MON_STATUS_RU_2_KNOWN 0x0400
  524. #define QDF_MON_STATUS_RU_3_KNOWN 0x0800
  525. #define QDF_MON_STATUS_DCM_FLAG_1_SHIFT 5
  526. #define QDF_MON_STATUS_SPATIAL_REUSE_MU_KNOWN 0x0100
  527. #define QDF_MON_STATUS_SIG_B_COMPRESSION_FLAG_1_KNOWN 0x4000
  528. /* HE radiotap HE-MU flags2 */
  529. #define QDF_MON_STATUS_SIG_B_COMPRESSION_FLAG_2_SHIFT 3
  530. #define QDF_MON_STATUS_BW_KNOWN 0x0004
  531. #define QDF_MON_STATUS_NUM_SIG_B_SYMBOLS_SHIFT 4
  532. #define QDF_MON_STATUS_SIG_B_COMPRESSION_FLAG_2_KNOWN 0x0100
  533. #define QDF_MON_STATUS_NUM_SIG_B_FLAG_2_SHIFT 9
  534. #define QDF_MON_STATUS_LTF_FLAG_2_SYMBOLS_SHIFT 12
  535. #define QDF_MON_STATUS_LTF_KNOWN 0x8000
  536. /* HE radiotap per_user_1 */
  537. #define QDF_MON_STATUS_STA_SPATIAL_SHIFT 11
  538. #define QDF_MON_STATUS_TXBF_SHIFT 14
  539. #define QDF_MON_STATUS_RESERVED_SET_TO_1_SHIFT 19
  540. #define QDF_MON_STATUS_STA_CODING_SHIFT 20
  541. /* HE radiotap per_user_2 */
  542. #define QDF_MON_STATUS_STA_MCS_SHIFT 4
  543. #define QDF_MON_STATUS_STA_DCM_SHIFT 5
  544. /* HE radiotap per user known */
  545. #define QDF_MON_STATUS_USER_FIELD_POSITION_KNOWN 0x01
  546. #define QDF_MON_STATUS_STA_ID_PER_USER_KNOWN 0x02
  547. #define QDF_MON_STATUS_STA_NSTS_KNOWN 0x04
  548. #define QDF_MON_STATUS_STA_TX_BF_KNOWN 0x08
  549. #define QDF_MON_STATUS_STA_SPATIAL_CONFIG_KNOWN 0x10
  550. #define QDF_MON_STATUS_STA_MCS_KNOWN 0x20
  551. #define QDF_MON_STATUS_STA_DCM_KNOWN 0x40
  552. #define QDF_MON_STATUS_STA_CODING_KNOWN 0x80
  553. /**
  554. * enum qdf_proto_type - protocol type
  555. * @QDF_PROTO_TYPE_DHCP - DHCP
  556. * @QDF_PROTO_TYPE_EAPOL - EAPOL
  557. * @QDF_PROTO_TYPE_ARP - ARP
  558. * @QDF_PROTO_TYPE_MGMT - MGMT
  559. * @QDF_PROTO_TYPE_ICMP - ICMP
  560. * @QDF_PROTO_TYPE_ICMPv6 - ICMPv6
  561. * @QDF_PROTO_TYPE_EVENT - EVENT
  562. * @QDF_PROTO_TYPE_DNS - DNS
  563. */
  564. enum qdf_proto_type {
  565. QDF_PROTO_TYPE_DHCP,
  566. QDF_PROTO_TYPE_EAPOL,
  567. QDF_PROTO_TYPE_ARP,
  568. QDF_PROTO_TYPE_MGMT,
  569. QDF_PROTO_TYPE_ICMP,
  570. QDF_PROTO_TYPE_ICMPv6,
  571. QDF_PROTO_TYPE_EVENT,
  572. QDF_PROTO_TYPE_DNS,
  573. QDF_PROTO_TYPE_MAX
  574. };
  575. /**
  576. * qdf_reception_type - reception type used by lithium phy TLV
  577. * @QDF_RECEPTION_TYPE_ULOFMDA - UL OFDMA
  578. * @QDF_RECEPTION_TYPE_ULMIMO - UL MIMO
  579. * @QQDF_RECEPTION_TYPE_FRAMELESS - Frame less
  580. * @QDF_RECEPTION_TYPE_OTHER - All the other types
  581. */
  582. enum qdf_reception_type {
  583. QDF_RECEPTION_TYPE_ULOFMDA,
  584. QDF_RECEPTION_TYPE_ULMIMO,
  585. QDF_RECEPTION_TYPE_OTHER,
  586. QDF_RECEPTION_TYPE_FRAMELESS
  587. };
  588. /**
  589. * cb_ftype - Frame type information in skb cb
  590. * @CB_FTYPE_INVALID - Invalid
  591. * @CB_FTYPE_MCAST2UCAST - Multicast to Unicast converted packet
  592. * @CB_FTYPE_TSO - TCP Segmentation Offload
  593. * @CB_FTYPE_TSO_SG - TSO Scatter Gather
  594. * @CB_FTYPE_SG - Scatter Gather
  595. * @CB_FTYPE_INTRABSS_FWD - Intra BSS forwarding
  596. * @CB_FTYPE_RX_INFO - Rx information
  597. * @CB_FTYPE_MESH_RX_INFO - Mesh Rx information
  598. * @CB_FTYPE_MESH_TX_INFO - Mesh Tx information
  599. * @CB_FTYPE_DMS - Directed Multicast Service
  600. */
  601. enum cb_ftype {
  602. CB_FTYPE_INVALID = 0,
  603. CB_FTYPE_MCAST2UCAST = 1,
  604. CB_FTYPE_TSO = 2,
  605. CB_FTYPE_TSO_SG = 3,
  606. CB_FTYPE_SG = 4,
  607. CB_FTYPE_INTRABSS_FWD = 5,
  608. CB_FTYPE_RX_INFO = 6,
  609. CB_FTYPE_MESH_RX_INFO = 7,
  610. CB_FTYPE_MESH_TX_INFO = 8,
  611. CB_FTYPE_DMS = 9,
  612. };
  613. /**
  614. * @qdf_nbuf_t - Platform indepedent packet abstraction
  615. */
  616. typedef __qdf_nbuf_t qdf_nbuf_t;
  617. /**
  618. * struct qdf_nbuf_track_t - Network buffer track structure
  619. *
  620. * @p_next: Pointer to next
  621. * @net_buf: Pointer to network buffer
  622. * @func_name: Function name
  623. * @line_num: Line number
  624. * @size: Size
  625. * @map_func_name: nbuf mapping function name
  626. * @map_line_num: mapping function line number
  627. * @unmap_func_name: nbuf unmapping function name
  628. * @unmap_line_num: mapping function line number
  629. * @is_nbuf_mapped: indicate mapped/unmapped nbuf
  630. * @time: mapping function timestamp
  631. */
  632. struct qdf_nbuf_track_t {
  633. struct qdf_nbuf_track_t *p_next;
  634. qdf_nbuf_t net_buf;
  635. char func_name[QDF_MEM_FUNC_NAME_SIZE];
  636. uint32_t line_num;
  637. size_t size;
  638. char map_func_name[QDF_MEM_FUNC_NAME_SIZE];
  639. uint32_t map_line_num;
  640. char unmap_func_name[QDF_MEM_FUNC_NAME_SIZE];
  641. uint32_t unmap_line_num;
  642. bool is_nbuf_mapped;
  643. qdf_time_t time;
  644. };
  645. typedef struct qdf_nbuf_track_t QDF_NBUF_TRACK;
  646. /**
  647. * typedef qdf_nbuf_queue_head_t - Platform indepedent nbuf queue head
  648. */
  649. typedef __qdf_nbuf_queue_head_t qdf_nbuf_queue_head_t;
  650. /**
  651. * @qdf_dma_map_cb_t - Dma map callback prototype
  652. */
  653. typedef void (*qdf_dma_map_cb_t)(void *arg, qdf_nbuf_t buf,
  654. qdf_dma_map_t dmap);
  655. /**
  656. * @qdf_nbuf_queue_t - Platform independent packet queue abstraction
  657. */
  658. typedef __qdf_nbuf_queue_t qdf_nbuf_queue_t;
  659. /* BUS/DMA mapping routines */
  660. static inline QDF_STATUS
  661. qdf_nbuf_dmamap_create(qdf_device_t osdev, qdf_dma_map_t *dmap)
  662. {
  663. return __qdf_nbuf_dmamap_create(osdev, dmap);
  664. }
  665. static inline void
  666. qdf_nbuf_dmamap_destroy(qdf_device_t osdev, qdf_dma_map_t dmap)
  667. {
  668. __qdf_nbuf_dmamap_destroy(osdev, dmap);
  669. }
  670. static inline void
  671. qdf_nbuf_dmamap_set_cb(qdf_dma_map_t dmap, qdf_dma_map_cb_t cb, void *arg)
  672. {
  673. __qdf_nbuf_dmamap_set_cb(dmap, cb, arg);
  674. }
  675. static inline void
  676. qdf_nbuf_set_send_complete_flag(qdf_nbuf_t buf, bool flag)
  677. {
  678. __qdf_nbuf_set_send_complete_flag(buf, flag);
  679. }
  680. #define QDF_NBUF_QUEUE_WALK_SAFE(queue, var, tvar) \
  681. __qdf_nbuf_queue_walk_safe(queue, var, tvar)
  682. #ifdef NBUF_MAP_UNMAP_DEBUG
  683. /**
  684. * qdf_nbuf_map_check_for_leaks() - check for nbut map leaks
  685. *
  686. * Check for net buffers that have been mapped, but never unmapped.
  687. *
  688. * Returns: None
  689. */
  690. void qdf_nbuf_map_check_for_leaks(void);
  691. QDF_STATUS qdf_nbuf_map_debug(qdf_device_t osdev,
  692. qdf_nbuf_t buf,
  693. qdf_dma_dir_t dir,
  694. const char *func,
  695. uint32_t line);
  696. #define qdf_nbuf_map(osdev, buf, dir) \
  697. qdf_nbuf_map_debug(osdev, buf, dir, __func__, __LINE__)
  698. void qdf_nbuf_unmap_debug(qdf_device_t osdev,
  699. qdf_nbuf_t buf,
  700. qdf_dma_dir_t dir,
  701. const char *func,
  702. uint32_t line);
  703. #define qdf_nbuf_unmap(osdev, buf, dir) \
  704. qdf_nbuf_unmap_debug(osdev, buf, dir, __func__, __LINE__)
  705. QDF_STATUS qdf_nbuf_map_single_debug(qdf_device_t osdev,
  706. qdf_nbuf_t buf,
  707. qdf_dma_dir_t dir,
  708. const char *func,
  709. uint32_t line);
  710. #define qdf_nbuf_map_single(osdev, buf, dir) \
  711. qdf_nbuf_map_single_debug(osdev, buf, dir, __func__, __LINE__)
  712. void qdf_nbuf_unmap_single_debug(qdf_device_t osdev,
  713. qdf_nbuf_t buf,
  714. qdf_dma_dir_t dir,
  715. const char *func,
  716. uint32_t line);
  717. #define qdf_nbuf_unmap_single(osdev, buf, dir) \
  718. qdf_nbuf_unmap_single_debug(osdev, buf, dir, __func__, __LINE__)
  719. QDF_STATUS qdf_nbuf_map_nbytes_debug(qdf_device_t osdev,
  720. qdf_nbuf_t buf,
  721. qdf_dma_dir_t dir,
  722. int nbytes,
  723. const char *func,
  724. uint32_t line);
  725. #define qdf_nbuf_map_nbytes(osdev, buf, dir, nbytes) \
  726. qdf_nbuf_map_nbytes_debug(osdev, buf, dir, nbytes, __func__, __LINE__)
  727. void qdf_nbuf_unmap_nbytes_debug(qdf_device_t osdev,
  728. qdf_nbuf_t buf,
  729. qdf_dma_dir_t dir,
  730. int nbytes,
  731. const char *func,
  732. uint32_t line);
  733. #define qdf_nbuf_unmap_nbytes(osdev, buf, dir, nbytes) \
  734. qdf_nbuf_unmap_nbytes_debug(osdev, buf, dir, nbytes, __func__, __LINE__)
  735. QDF_STATUS qdf_nbuf_map_nbytes_single_debug(qdf_device_t osdev,
  736. qdf_nbuf_t buf,
  737. qdf_dma_dir_t dir,
  738. int nbytes,
  739. const char *func,
  740. uint32_t line);
  741. #define qdf_nbuf_map_nbytes_single(osdev, buf, dir, nbytes) \
  742. qdf_nbuf_map_nbytes_single_debug(osdev, buf, dir, nbytes, \
  743. __func__, __LINE__)
  744. void qdf_nbuf_unmap_nbytes_single_debug(qdf_device_t osdev,
  745. qdf_nbuf_t buf,
  746. qdf_dma_dir_t dir,
  747. int nbytes,
  748. const char *func,
  749. uint32_t line);
  750. #define qdf_nbuf_unmap_nbytes_single(osdev, buf, dir, nbytes) \
  751. qdf_nbuf_unmap_nbytes_single_debug(osdev, buf, dir, nbytes, \
  752. __func__, __LINE__)
  753. #else /* NBUF_MAP_UNMAP_DEBUG */
  754. static inline void qdf_nbuf_map_check_for_leaks(void) {}
  755. static inline QDF_STATUS
  756. qdf_nbuf_map(qdf_device_t osdev, qdf_nbuf_t buf, qdf_dma_dir_t dir)
  757. {
  758. return __qdf_nbuf_map(osdev, buf, dir);
  759. }
  760. static inline void
  761. qdf_nbuf_unmap(qdf_device_t osdev, qdf_nbuf_t buf, qdf_dma_dir_t dir)
  762. {
  763. __qdf_nbuf_unmap(osdev, buf, dir);
  764. }
  765. static inline QDF_STATUS
  766. qdf_nbuf_map_single(qdf_device_t osdev, qdf_nbuf_t buf, qdf_dma_dir_t dir)
  767. {
  768. return __qdf_nbuf_map_single(osdev, buf, dir);
  769. }
  770. static inline void
  771. qdf_nbuf_unmap_single(qdf_device_t osdev, qdf_nbuf_t buf, qdf_dma_dir_t dir)
  772. {
  773. __qdf_nbuf_unmap_single(osdev, buf, dir);
  774. }
  775. static inline QDF_STATUS
  776. qdf_nbuf_map_nbytes(qdf_device_t osdev, qdf_nbuf_t buf,
  777. qdf_dma_dir_t dir, int nbytes)
  778. {
  779. return __qdf_nbuf_map_nbytes(osdev, buf, dir, nbytes);
  780. }
  781. static inline void
  782. qdf_nbuf_unmap_nbytes(qdf_device_t osdev,
  783. qdf_nbuf_t buf, qdf_dma_dir_t dir, int nbytes)
  784. {
  785. __qdf_nbuf_unmap_nbytes(osdev, buf, dir, nbytes);
  786. }
  787. static inline QDF_STATUS
  788. qdf_nbuf_map_nbytes_single(
  789. qdf_device_t osdev, qdf_nbuf_t buf, qdf_dma_dir_t dir, int nbytes)
  790. {
  791. return __qdf_nbuf_map_nbytes_single(osdev, buf, dir, nbytes);
  792. }
  793. static inline void
  794. qdf_nbuf_unmap_nbytes_single(
  795. qdf_device_t osdev, qdf_nbuf_t buf, qdf_dma_dir_t dir, int nbytes)
  796. {
  797. return __qdf_nbuf_unmap_nbytes_single(osdev, buf, dir, nbytes);
  798. }
  799. #endif /* NBUF_MAP_UNMAP_DEBUG */
  800. /**
  801. * qdf_nbuf_queue_head_dequeue() - dequeue nbuf from the head of queue
  802. * @nbuf_queue_head: pointer to nbuf queue head
  803. *
  804. * Return: pointer to network buffer dequeued
  805. */
  806. static inline
  807. qdf_nbuf_t qdf_nbuf_queue_head_dequeue(qdf_nbuf_queue_head_t *nbuf_queue_head)
  808. {
  809. return __qdf_nbuf_queue_head_dequeue(nbuf_queue_head);
  810. }
  811. /**
  812. * qdf_nbuf_queue_head_qlen() - length of the queue
  813. * @nbuf_queue_head: pointer to nbuf queue head
  814. *
  815. * Return: length of queue (number of nbufs) pointed by qdf_nbuf_queue_head_t
  816. */
  817. static inline
  818. uint32_t qdf_nbuf_queue_head_qlen(qdf_nbuf_queue_head_t *nbuf_queue_head)
  819. {
  820. return __qdf_nbuf_queue_head_qlen(nbuf_queue_head);
  821. }
  822. /**
  823. * qdf_nbuf_queue_head_enqueue_tail() - enqueue nbuf into queue tail
  824. * @nbuf_queue_head: pointer to nbuf queue head
  825. * @nbuf: nbuf to be enqueued
  826. *
  827. * Return: None
  828. */
  829. static inline
  830. void qdf_nbuf_queue_head_enqueue_tail(qdf_nbuf_queue_head_t *nbuf_queue_head,
  831. qdf_nbuf_t nbuf)
  832. {
  833. return __qdf_nbuf_queue_head_enqueue_tail(nbuf_queue_head, nbuf);
  834. }
  835. /**
  836. * qdf_nbuf_queue_head_init() - initialize qdf_nbuf_queue_head_t
  837. * @nbuf_queue_head: pointer to nbuf queue head to be initialized
  838. *
  839. * Return: None
  840. */
  841. static inline
  842. void qdf_nbuf_queue_head_init(qdf_nbuf_queue_head_t *nbuf_queue_head)
  843. {
  844. return __qdf_nbuf_queue_head_init(nbuf_queue_head);
  845. }
  846. /**
  847. * qdf_nbuf_queue_head_purge() - purge qdf_nbuf_queue_head_t
  848. * @nbuf_queue_head: pointer to nbuf queue head to be purged
  849. *
  850. * Return: None
  851. */
  852. static inline
  853. void qdf_nbuf_queue_head_purge(qdf_nbuf_queue_head_t *nbuf_queue_head)
  854. {
  855. return __qdf_nbuf_queue_head_purge(nbuf_queue_head);
  856. }
  857. /**
  858. * qdf_nbuf_queue_head_lock() - Acquire the nbuf_queue_head lock
  859. * @head: nbuf_queue_head of the nbuf_list for which lock is to be acquired
  860. *
  861. * Return: void
  862. */
  863. static inline void qdf_nbuf_queue_head_lock(qdf_nbuf_queue_head_t *head)
  864. {
  865. __qdf_nbuf_queue_head_lock(head);
  866. }
  867. /**
  868. * qdf_nbuf_queue_head_unlock() - Release the nbuf queue lock
  869. * @head: nbuf_queue_head of the nbuf_list for which lock is to be release
  870. *
  871. * Return: void
  872. */
  873. static inline void qdf_nbuf_queue_head_unlock(qdf_nbuf_queue_head_t *head)
  874. {
  875. __qdf_nbuf_queue_head_unlock(head);
  876. }
  877. static inline void
  878. qdf_nbuf_sync_for_cpu(qdf_device_t osdev, qdf_nbuf_t buf, qdf_dma_dir_t dir)
  879. {
  880. __qdf_nbuf_sync_for_cpu(osdev, buf, dir);
  881. }
  882. /**
  883. * qdf_nbuf_dma_inv_range() - Invalidate the specified virtual address range
  884. * @buf_start: start address
  885. * @buf_end: end address
  886. *
  887. * Return: none
  888. */
  889. static inline void
  890. qdf_nbuf_dma_inv_range(const void *buf_start, const void *buf_end)
  891. {
  892. __qdf_nbuf_dma_inv_range(buf_start, buf_end);
  893. }
  894. static inline int qdf_nbuf_get_num_frags(qdf_nbuf_t buf)
  895. {
  896. return __qdf_nbuf_get_num_frags(buf);
  897. }
  898. /**
  899. * qdf_nbuf_get_frag_len() - get fragment length
  900. * @buf: Network buffer
  901. * @frag_num: Fragment number
  902. *
  903. * Return: Fragment length
  904. */
  905. static inline int qdf_nbuf_get_frag_len(qdf_nbuf_t buf, int frag_num)
  906. {
  907. QDF_BUG(!(frag_num >= QDF_NBUF_CB_TX_MAX_EXTRA_FRAGS));
  908. return __qdf_nbuf_get_frag_len(buf, frag_num);
  909. }
  910. /**
  911. * qdf_nbuf_get_frag_vaddr() - get fragment virtual address
  912. * @buf: Network buffer
  913. * @frag_num: Fragment number
  914. *
  915. * Return: Fragment virtual address
  916. */
  917. static inline unsigned char *qdf_nbuf_get_frag_vaddr(qdf_nbuf_t buf,
  918. int frag_num)
  919. {
  920. QDF_BUG(!(frag_num >= QDF_NBUF_CB_TX_MAX_EXTRA_FRAGS));
  921. return __qdf_nbuf_get_frag_vaddr(buf, frag_num);
  922. }
  923. /**
  924. * qdf_nbuf_get_frag_vaddr_always() - get fragment virtual address
  925. * @buf: Network buffer
  926. *
  927. * Return: Fragment virtual address
  928. */
  929. static inline unsigned char *
  930. qdf_nbuf_get_frag_vaddr_always(qdf_nbuf_t buf)
  931. {
  932. return __qdf_nbuf_get_frag_vaddr_always(buf);
  933. }
  934. /**
  935. * qdf_nbuf_get_frag_paddr() - get physical address for skb linear buffer
  936. * or skb fragment, based on frag_num passed
  937. * @buf: Network buffer
  938. * @frag_num: Fragment number
  939. *
  940. * Return: Fragment physical address
  941. */
  942. static inline qdf_dma_addr_t qdf_nbuf_get_frag_paddr(qdf_nbuf_t buf,
  943. unsigned int frag_num)
  944. {
  945. QDF_BUG(!(frag_num >= QDF_NBUF_CB_TX_MAX_EXTRA_FRAGS));
  946. return __qdf_nbuf_get_frag_paddr(buf, frag_num);
  947. }
  948. /**
  949. * qdf_nbuf_get_tx_frag_paddr() - get physical address for skb fragments only
  950. * @buf: Network buffer
  951. *
  952. * Return: Fragment physical address
  953. * Usage guideline: Use “qdf_nbuf_frag_map()” to dma map the specific
  954. * skb fragment , followed by “qdf_nbuf_get_tx_frag_paddr”
  955. */
  956. static inline qdf_dma_addr_t qdf_nbuf_get_tx_frag_paddr(qdf_nbuf_t buf)
  957. {
  958. return __qdf_nbuf_get_tx_frag_paddr(buf);
  959. }
  960. /**
  961. * qdf_nbuf_get_frag_is_wordstream() - is fragment wordstream
  962. * @buf: Network buffer
  963. * @frag_num: Fragment number
  964. *
  965. * Return: Fragment wordstream or not
  966. */
  967. static inline int qdf_nbuf_get_frag_is_wordstream(qdf_nbuf_t buf, int frag_num)
  968. {
  969. QDF_BUG(!(frag_num >= QDF_NBUF_CB_TX_MAX_EXTRA_FRAGS));
  970. return __qdf_nbuf_get_frag_is_wordstream(buf, frag_num);
  971. }
  972. /**
  973. * qdf_nbuf_set_frag_is_wordstream() - set fragment wordstream
  974. * @buf: Network buffer
  975. * @frag_num: Fragment number
  976. * @is_wordstream: Wordstream
  977. *
  978. * Return: none
  979. */
  980. static inline void
  981. qdf_nbuf_set_frag_is_wordstream(qdf_nbuf_t buf,
  982. int frag_num, int is_wordstream)
  983. {
  984. QDF_BUG(!(frag_num >= QDF_NBUF_CB_TX_MAX_EXTRA_FRAGS));
  985. __qdf_nbuf_set_frag_is_wordstream(buf, frag_num, is_wordstream);
  986. }
  987. static inline void
  988. qdf_nbuf_set_vdev_ctx(qdf_nbuf_t buf, uint8_t vdev_id)
  989. {
  990. __qdf_nbuf_set_vdev_ctx(buf, vdev_id);
  991. }
  992. static inline void
  993. qdf_nbuf_set_tx_ftype(qdf_nbuf_t buf, enum cb_ftype type)
  994. {
  995. __qdf_nbuf_set_tx_ftype(buf, type);
  996. }
  997. static inline void
  998. qdf_nbuf_set_rx_ftype(qdf_nbuf_t buf, enum cb_ftype type)
  999. {
  1000. __qdf_nbuf_set_rx_ftype(buf, type);
  1001. }
  1002. static inline uint8_t
  1003. qdf_nbuf_get_vdev_ctx(qdf_nbuf_t buf)
  1004. {
  1005. return __qdf_nbuf_get_vdev_ctx(buf);
  1006. }
  1007. static inline enum cb_ftype qdf_nbuf_get_tx_ftype(qdf_nbuf_t buf)
  1008. {
  1009. return __qdf_nbuf_get_tx_ftype(buf);
  1010. }
  1011. static inline enum cb_ftype qdf_nbuf_get_rx_ftype(qdf_nbuf_t buf)
  1012. {
  1013. return __qdf_nbuf_get_rx_ftype(buf);
  1014. }
  1015. static inline qdf_dma_addr_t
  1016. qdf_nbuf_mapped_paddr_get(qdf_nbuf_t buf)
  1017. {
  1018. return __qdf_nbuf_mapped_paddr_get(buf);
  1019. }
  1020. static inline void
  1021. qdf_nbuf_mapped_paddr_set(qdf_nbuf_t buf, qdf_dma_addr_t paddr)
  1022. {
  1023. __qdf_nbuf_mapped_paddr_set(buf, paddr);
  1024. }
  1025. static inline void
  1026. qdf_nbuf_frag_push_head(qdf_nbuf_t buf,
  1027. int frag_len, char *frag_vaddr,
  1028. qdf_dma_addr_t frag_paddr)
  1029. {
  1030. __qdf_nbuf_frag_push_head(buf, frag_len, frag_vaddr, frag_paddr);
  1031. }
  1032. #define qdf_nbuf_num_frags_init(_nbuf) __qdf_nbuf_num_frags_init((_nbuf))
  1033. /**
  1034. * qdf_nbuf_set_rx_chfrag_start() - set msdu start bit
  1035. * @buf: Network buffer
  1036. * @val: 0/1
  1037. *
  1038. * Return: void
  1039. */
  1040. static inline void
  1041. qdf_nbuf_set_rx_chfrag_start(qdf_nbuf_t buf, uint8_t val)
  1042. {
  1043. __qdf_nbuf_set_rx_chfrag_start(buf, val);
  1044. }
  1045. /**
  1046. * qdf_nbuf_is_rx_chfrag_start() - get msdu start bit
  1047. * @buf: Network buffer
  1048. *
  1049. * Return: integer value - 0/1
  1050. */
  1051. static inline int qdf_nbuf_is_rx_chfrag_start(qdf_nbuf_t buf)
  1052. {
  1053. return __qdf_nbuf_is_rx_chfrag_start(buf);
  1054. }
  1055. /**
  1056. * qdf_nbuf_set_rx_chfrag_cont() - set msdu continuation bit
  1057. * @buf: Network buffer
  1058. * @val: 0/1
  1059. *
  1060. * Return: void
  1061. */
  1062. static inline void
  1063. qdf_nbuf_set_rx_chfrag_cont(qdf_nbuf_t buf, uint8_t val)
  1064. {
  1065. __qdf_nbuf_set_rx_chfrag_cont(buf, val);
  1066. }
  1067. /**
  1068. * qdf_nbuf_is_rx_chfrag_cont() - get msdu continuation bit
  1069. * @buf: Network buffer
  1070. *
  1071. * Return: integer value - 0/1
  1072. */
  1073. static inline int qdf_nbuf_is_rx_chfrag_cont(qdf_nbuf_t buf)
  1074. {
  1075. return __qdf_nbuf_is_rx_chfrag_cont(buf);
  1076. }
  1077. /**
  1078. * qdf_nbuf_set_rx_chfrag_end() - set msdu end bit
  1079. * @buf: Network buffer
  1080. * @val: 0/1
  1081. *
  1082. * Return: void
  1083. */
  1084. static inline void qdf_nbuf_set_rx_chfrag_end(qdf_nbuf_t buf, uint8_t val)
  1085. {
  1086. __qdf_nbuf_set_rx_chfrag_end(buf, val);
  1087. }
  1088. /**
  1089. * qdf_nbuf_is_rx_chfrag_end() - set msdu end bit
  1090. * @buf: Network buffer
  1091. *
  1092. * Return: integer value - 0/1
  1093. */
  1094. static inline int qdf_nbuf_is_rx_chfrag_end(qdf_nbuf_t buf)
  1095. {
  1096. return __qdf_nbuf_is_rx_chfrag_end(buf);
  1097. }
  1098. /**
  1099. * qdf_nbuf_set_da_mcbc() - set da is mcbc
  1100. * @buf: Network buffer
  1101. * @val: 0/1
  1102. *
  1103. * Return: void
  1104. */
  1105. static inline void
  1106. qdf_nbuf_set_da_mcbc(qdf_nbuf_t buf, uint8_t val)
  1107. {
  1108. __qdf_nbuf_set_da_mcbc(buf, val);
  1109. }
  1110. /**
  1111. * qdf_nbuf_is_da_mcbc() - get da is mcbc bit
  1112. * @buf: Network buffer
  1113. *
  1114. * Return: integer value - 0/1
  1115. */
  1116. static inline int qdf_nbuf_is_da_mcbc(qdf_nbuf_t buf)
  1117. {
  1118. return __qdf_nbuf_is_da_mcbc(buf);
  1119. }
  1120. /**
  1121. * qdf_nbuf_set_da_valid() - set da valid bit
  1122. * @buf: Network buffer
  1123. * @val: 0/1
  1124. *
  1125. * Return: void
  1126. */
  1127. static inline void qdf_nbuf_set_da_valid(qdf_nbuf_t buf, uint8_t val)
  1128. {
  1129. __qdf_nbuf_set_da_valid(buf, val);
  1130. }
  1131. /**
  1132. * qdf_nbuf_is_da_valid() - get da valid bit
  1133. * @buf: Network buffer
  1134. *
  1135. * Return: integer value - 0/1
  1136. */
  1137. static inline int qdf_nbuf_is_da_valid(qdf_nbuf_t buf)
  1138. {
  1139. return __qdf_nbuf_is_da_valid(buf);
  1140. }
  1141. /**
  1142. * qdf_nbuf_set_sa_valid() - set sa valid bit
  1143. * @buf: Network buffer
  1144. * @val: 0/1
  1145. *
  1146. * Return: void
  1147. */
  1148. static inline void qdf_nbuf_set_sa_valid(qdf_nbuf_t buf, uint8_t val)
  1149. {
  1150. __qdf_nbuf_set_sa_valid(buf, val);
  1151. }
  1152. /**
  1153. * qdf_nbuf_is_sa_valid() - get da valid bit
  1154. * @buf: Network buffer
  1155. *
  1156. * Return: integer value - 0/1
  1157. */
  1158. static inline int qdf_nbuf_is_sa_valid(qdf_nbuf_t buf)
  1159. {
  1160. return __qdf_nbuf_is_sa_valid(buf);
  1161. }
  1162. /**
  1163. * qdf_nbuf_set_rx_retry_flag() - set rx retry flag bit
  1164. * @buf: Network buffer
  1165. * @val: 0/1
  1166. *
  1167. * Return: void
  1168. */
  1169. static inline void qdf_nbuf_set_rx_retry_flag(qdf_nbuf_t buf, uint8_t val)
  1170. {
  1171. __qdf_nbuf_set_rx_retry_flag(buf, val);
  1172. }
  1173. /**
  1174. * qdf_nbuf_is_rx_retry_flag() - get rx retry flag bit
  1175. * @buf: Network buffer
  1176. *
  1177. * Return: integer value - 0/1
  1178. */
  1179. static inline int qdf_nbuf_is_rx_retry_flag(qdf_nbuf_t buf)
  1180. {
  1181. return __qdf_nbuf_is_rx_retry_flag(buf);
  1182. }
  1183. /**
  1184. * qdf_nbuf_set_raw_frame() - set raw_frame bit
  1185. * @buf: Network buffer
  1186. * @val: 0/1
  1187. *
  1188. * Return: void
  1189. */
  1190. static inline void qdf_nbuf_set_raw_frame(qdf_nbuf_t buf, uint8_t val)
  1191. {
  1192. __qdf_nbuf_set_raw_frame(buf, val);
  1193. }
  1194. /**
  1195. * qdf_nbuf_is_raw_frame() - get raw_frame bit
  1196. * @buf: Network buffer
  1197. *
  1198. * Return: integer value - 0/1
  1199. */
  1200. static inline int qdf_nbuf_is_raw_frame(qdf_nbuf_t buf)
  1201. {
  1202. return __qdf_nbuf_is_raw_frame(buf);
  1203. }
  1204. /**
  1205. * qdf_nbuf_set_tid_val() - set tid_val
  1206. * @buf: Network buffer
  1207. * @val: 4 bits tid value
  1208. */
  1209. static inline void qdf_nbuf_set_tid_val(qdf_nbuf_t buf, uint8_t val)
  1210. {
  1211. __qdf_nbuf_set_tid_val(buf, val);
  1212. }
  1213. /**
  1214. * qdf_nbuf_get_tid_val() - get tid_val
  1215. * @buf: Network buffer
  1216. *
  1217. * Return: integer value[4 bits tid value]
  1218. */
  1219. static inline uint8_t qdf_nbuf_get_tid_val(qdf_nbuf_t buf)
  1220. {
  1221. return __qdf_nbuf_get_tid_val(buf);
  1222. }
  1223. /**
  1224. * qdf_nbuf_set_frag_list() - set frag list bit
  1225. * @buf: Network buffer
  1226. * @val: 0/1
  1227. *
  1228. * Return: void
  1229. */
  1230. static inline void qdf_nbuf_set_is_frag(qdf_nbuf_t buf, uint8_t val)
  1231. {
  1232. __qdf_nbuf_set_is_frag(buf, val);
  1233. }
  1234. /**
  1235. * qdf_nbuf_is_sa_valid() - get da frag list bit
  1236. * @buf: Network buffer
  1237. *
  1238. * Return: integer value - 0/1
  1239. */
  1240. static inline int qdf_nbuf_is_frag(qdf_nbuf_t buf)
  1241. {
  1242. return __qdf_nbuf_is_frag(buf);
  1243. }
  1244. /**
  1245. * qdf_nbuf_set_tx_chfrag_start() - set msdu start bit
  1246. * @buf: Network buffer
  1247. * @val: 0/1
  1248. *
  1249. * Return: void
  1250. */
  1251. static inline void
  1252. qdf_nbuf_set_tx_chfrag_start(qdf_nbuf_t buf, uint8_t val)
  1253. {
  1254. __qdf_nbuf_set_tx_chfrag_start(buf, val);
  1255. }
  1256. /**
  1257. * qdf_nbuf_is_tx_chfrag_start() - get msdu start bit
  1258. * @buf: Network buffer
  1259. *
  1260. * Return: integer value - 0/1
  1261. */
  1262. static inline int qdf_nbuf_is_tx_chfrag_start(qdf_nbuf_t buf)
  1263. {
  1264. return __qdf_nbuf_is_tx_chfrag_start(buf);
  1265. }
  1266. /**
  1267. * qdf_nbuf_set_tx_chfrag_cont() - set msdu continuation bit
  1268. * @buf: Network buffer
  1269. * @val: 0/1
  1270. *
  1271. * Return: void
  1272. */
  1273. static inline void
  1274. qdf_nbuf_set_tx_chfrag_cont(qdf_nbuf_t buf, uint8_t val)
  1275. {
  1276. __qdf_nbuf_set_tx_chfrag_cont(buf, val);
  1277. }
  1278. /**
  1279. * qdf_nbuf_is_tx_chfrag_cont() - get msdu continuation bit
  1280. * @buf: Network buffer
  1281. *
  1282. * Return: integer value - 0/1
  1283. */
  1284. static inline int qdf_nbuf_is_tx_chfrag_cont(qdf_nbuf_t buf)
  1285. {
  1286. return __qdf_nbuf_is_tx_chfrag_cont(buf);
  1287. }
  1288. /**
  1289. * qdf_nbuf_set_tx_chfrag_end() - set msdu end bit
  1290. * @buf: Network buffer
  1291. * @val: 0/1
  1292. *
  1293. * Return: void
  1294. */
  1295. static inline void qdf_nbuf_set_tx_chfrag_end(qdf_nbuf_t buf, uint8_t val)
  1296. {
  1297. __qdf_nbuf_set_tx_chfrag_end(buf, val);
  1298. }
  1299. /**
  1300. * qdf_nbuf_is_tx_chfrag_end() - set msdu end bit
  1301. * @buf: Network buffer
  1302. *
  1303. * Return: integer value - 0/1
  1304. */
  1305. static inline int qdf_nbuf_is_tx_chfrag_end(qdf_nbuf_t buf)
  1306. {
  1307. return __qdf_nbuf_is_tx_chfrag_end(buf);
  1308. }
  1309. static inline void
  1310. qdf_nbuf_dma_map_info(qdf_dma_map_t bmap, qdf_dmamap_info_t *sg)
  1311. {
  1312. __qdf_nbuf_dma_map_info(bmap, sg);
  1313. }
  1314. /**
  1315. * qdf_nbuf_is_tso() - is the network buffer a jumbo packet?
  1316. * @buf: Network buffer
  1317. *
  1318. * Return: 1 - this is a jumbo packet 0 - not a jumbo packet
  1319. */
  1320. static inline uint8_t qdf_nbuf_is_tso(qdf_nbuf_t nbuf)
  1321. {
  1322. return __qdf_nbuf_is_tso(nbuf);
  1323. }
  1324. /**
  1325. * qdf_nbuf_get_users() - function to get the number of users referencing this
  1326. * network buffer
  1327. *
  1328. * @nbuf: network buffer
  1329. *
  1330. * Return: number of user references to nbuf.
  1331. */
  1332. static inline int qdf_nbuf_get_users(qdf_nbuf_t nbuf)
  1333. {
  1334. return __qdf_nbuf_get_users(nbuf);
  1335. }
  1336. /**
  1337. * qdf_nbuf_next() - get the next packet in the linked list
  1338. * @buf: Network buffer
  1339. *
  1340. * This function can be used when nbufs are directly linked into a list,
  1341. * rather than using a separate network buffer queue object.
  1342. *
  1343. * Return: next network buffer in the linked list
  1344. */
  1345. static inline qdf_nbuf_t qdf_nbuf_next(qdf_nbuf_t buf)
  1346. {
  1347. return __qdf_nbuf_next(buf);
  1348. }
  1349. #ifdef NBUF_MEMORY_DEBUG
  1350. #define QDF_NET_BUF_TRACK_MAX_SIZE (1024)
  1351. void qdf_net_buf_debug_init(void);
  1352. void qdf_net_buf_debug_exit(void);
  1353. void qdf_net_buf_debug_clean(void);
  1354. void qdf_net_buf_debug_add_node(qdf_nbuf_t net_buf, size_t size,
  1355. const char *func_name, uint32_t line_num);
  1356. /**
  1357. * qdf_net_buf_debug_update_node() - update nbuf in debug hash table
  1358. *
  1359. * Return: none
  1360. */
  1361. void qdf_net_buf_debug_update_node(qdf_nbuf_t net_buf, const char *func_name,
  1362. uint32_t line_num);
  1363. void qdf_net_buf_debug_delete_node(qdf_nbuf_t net_buf);
  1364. /**
  1365. * qdf_net_buf_debug_update_map_node() - update nbuf in debug
  1366. * hash table with the mapping function info
  1367. * @nbuf: network buffer
  1368. * @func: function name that requests for mapping the nbuf
  1369. * @line_num: function line number
  1370. *
  1371. * Return: none
  1372. */
  1373. void qdf_net_buf_debug_update_map_node(qdf_nbuf_t net_buf,
  1374. const char *func_name,
  1375. uint32_t line_num);
  1376. /**
  1377. * qdf_net_buf_debug_update_unmap_node() - update nbuf in debug
  1378. * hash table with the unmap function info
  1379. * @nbuf: network buffer
  1380. * @func: function name that requests for unmapping the nbuf
  1381. * @line_num: function line number
  1382. *
  1383. * Return: none
  1384. */
  1385. void qdf_net_buf_debug_update_unmap_node(qdf_nbuf_t net_buf,
  1386. const char *func_name,
  1387. uint32_t line_num);
  1388. /**
  1389. * qdf_net_buf_debug_acquire_skb() - acquire skb to avoid memory leak
  1390. * @net_buf: Network buf holding head segment (single)
  1391. * @func_name: pointer to function name
  1392. * @line_num: line number
  1393. *
  1394. * WLAN driver module's SKB which are allocated by network stack are
  1395. * suppose to call this API before freeing it such that the SKB
  1396. * is not reported as memory leak.
  1397. *
  1398. * Return: none
  1399. */
  1400. void qdf_net_buf_debug_acquire_skb(qdf_nbuf_t net_buf,
  1401. const char *func_name,
  1402. uint32_t line_num);
  1403. void qdf_net_buf_debug_release_skb(qdf_nbuf_t net_buf);
  1404. /* nbuf allocation rouines */
  1405. #define qdf_nbuf_alloc(d, s, r, a, p) \
  1406. qdf_nbuf_alloc_debug(d, s, r, a, p, __func__, __LINE__)
  1407. qdf_nbuf_t qdf_nbuf_alloc_debug(qdf_device_t osdev, qdf_size_t size,
  1408. int reserve, int align, int prio,
  1409. const char *func, uint32_t line);
  1410. /**
  1411. * qdf_nbuf_alloc_no_recycler() - Allocates skb
  1412. * @size: Size to be allocated for skb
  1413. * @reserve: Reserved headroom size
  1414. * @align: Align
  1415. * @func: Function name of the call site
  1416. * @line: Line number of the callsite
  1417. *
  1418. * This API allocates skb of required size and aligns if needed and reserves
  1419. * some space in the front. This skb allocation is not from skb recycler pool.
  1420. *
  1421. * Return: Allocated nbuf pointer
  1422. */
  1423. #define qdf_nbuf_alloc_no_recycler(s, r, a) \
  1424. qdf_nbuf_alloc_no_recycler_debug(s, r, a, __func__, __LINE__)
  1425. qdf_nbuf_t qdf_nbuf_alloc_no_recycler_debug(size_t size, int reserve, int align,
  1426. const char *func, uint32_t line);
  1427. #define qdf_nbuf_free(d) \
  1428. qdf_nbuf_free_debug(d, __func__, __LINE__)
  1429. void qdf_nbuf_free_debug(qdf_nbuf_t nbuf, const char *func, uint32_t line);
  1430. #define qdf_nbuf_clone(buf) \
  1431. qdf_nbuf_clone_debug(buf, __func__, __LINE__)
  1432. /**
  1433. * qdf_nbuf_clone_debug() - clone the nbuf (copy is readonly)
  1434. * @buf: nbuf to clone from
  1435. * @func: name of the calling function
  1436. * @line: line number of the callsite
  1437. *
  1438. * This function clones the nbuf and creates a memory tracking
  1439. * node corresponding to that cloned skbuff structure.
  1440. *
  1441. * Return: cloned buffer
  1442. */
  1443. qdf_nbuf_t qdf_nbuf_clone_debug(qdf_nbuf_t buf, const char *func,
  1444. uint32_t line);
  1445. #define qdf_nbuf_copy(buf) \
  1446. qdf_nbuf_copy_debug(buf, __func__, __LINE__)
  1447. /**
  1448. * qdf_nbuf_copy_debug() - returns a private copy of the buf
  1449. * @buf: nbuf to copy from
  1450. * @func: name of the calling function
  1451. * @line: line number of the callsite
  1452. *
  1453. * This API returns a private copy of the buf, the buf returned is completely
  1454. * modifiable by callers. It also creates a memory tracking node corresponding
  1455. * to that new skbuff structure.
  1456. *
  1457. * Return: copied buffer
  1458. */
  1459. qdf_nbuf_t qdf_nbuf_copy_debug(qdf_nbuf_t buf, const char *func, uint32_t line);
  1460. #define qdf_nbuf_copy_expand(buf, headroom, tailroom) \
  1461. qdf_nbuf_copy_expand_debug(buf, headroom, tailroom, __func__, __LINE__)
  1462. /**
  1463. * qdf_nbuf_copy_expand_debug() - copy and expand nbuf
  1464. * @buf: Network buf instance
  1465. * @headroom: Additional headroom to be added
  1466. * @tailroom: Additional tailroom to be added
  1467. * @func: name of the calling function
  1468. * @line: line number of the callsite
  1469. *
  1470. * Return: New nbuf that is a copy of buf, with additional head and tailroom
  1471. * or NULL if there is no memory
  1472. */
  1473. qdf_nbuf_t
  1474. qdf_nbuf_copy_expand_debug(qdf_nbuf_t buf, int headroom, int tailroom,
  1475. const char *func, uint32_t line);
  1476. /**
  1477. * qdf_nbuf_unshare() - make a copy of the shared nbuf
  1478. * @buf: Network buf instance
  1479. *
  1480. * Return: New nbuf which is a copy of the received nbuf if it is cloned,
  1481. * else, return the original nbuf
  1482. */
  1483. #define qdf_nbuf_unshare(d) \
  1484. qdf_nbuf_unshare_debug(d, __func__, __LINE__)
  1485. qdf_nbuf_t
  1486. qdf_nbuf_unshare_debug(qdf_nbuf_t buf, const char *func_name,
  1487. uint32_t line_num);
  1488. #else /* NBUF_MEMORY_DEBUG */
  1489. static inline void qdf_net_buf_debug_init(void) {}
  1490. static inline void qdf_net_buf_debug_exit(void) {}
  1491. static inline void qdf_net_buf_debug_acquire_skb(qdf_nbuf_t net_buf,
  1492. const char *func_name,
  1493. uint32_t line_num)
  1494. {
  1495. }
  1496. static inline void qdf_net_buf_debug_release_skb(qdf_nbuf_t net_buf)
  1497. {
  1498. }
  1499. static inline void
  1500. qdf_net_buf_debug_update_node(qdf_nbuf_t net_buf, const char *func_name,
  1501. uint32_t line_num)
  1502. {
  1503. }
  1504. static inline void
  1505. qdf_net_buf_debug_update_map_node(qdf_nbuf_t net_buf,
  1506. const char *func_name,
  1507. uint32_t line_num)
  1508. {
  1509. }
  1510. static inline void
  1511. qdf_net_buf_debug_update_unmap_node(qdf_nbuf_t net_buf,
  1512. const char *func_name,
  1513. uint32_t line_num)
  1514. {
  1515. }
  1516. /* Nbuf allocation rouines */
  1517. #define qdf_nbuf_alloc(osdev, size, reserve, align, prio) \
  1518. qdf_nbuf_alloc_fl(osdev, size, reserve, align, prio, \
  1519. __func__, __LINE__)
  1520. #define qdf_nbuf_alloc_no_recycler(size, reserve, align) \
  1521. qdf_nbuf_alloc_no_recycler_fl(size, reserve, align, __func__, __LINE__)
  1522. static inline qdf_nbuf_t
  1523. qdf_nbuf_alloc_fl(qdf_device_t osdev, qdf_size_t size, int reserve, int align,
  1524. int prio, const char *func, uint32_t line)
  1525. {
  1526. qdf_nbuf_t nbuf;
  1527. nbuf = __qdf_nbuf_alloc(osdev, size, reserve, align, prio, func, line);
  1528. if (qdf_likely(nbuf))
  1529. qdf_mem_skb_inc(nbuf->truesize);
  1530. return nbuf;
  1531. }
  1532. /**
  1533. * qdf_nbuf_alloc_no_recycler_fl() - Allocate SKB
  1534. * @size: Size to be allocated for skb
  1535. * @reserve: Reserved headroom size
  1536. * @align: Align
  1537. * @func: Function name of the call site
  1538. * @line: Line number of the callsite
  1539. *
  1540. * This API allocates skb of required size and aligns if needed and reserves
  1541. * some space in the front. This skb allocation is not from skb recycler pool.
  1542. *
  1543. * Return: Allocated nbuf pointer
  1544. */
  1545. static inline qdf_nbuf_t
  1546. qdf_nbuf_alloc_no_recycler_fl(size_t size, int reserve, int align,
  1547. const char *func, uint32_t line)
  1548. {
  1549. qdf_nbuf_t nbuf;
  1550. nbuf = __qdf_nbuf_alloc_no_recycler(size, reserve, align, func, line);
  1551. if (qdf_likely(nbuf))
  1552. qdf_mem_skb_inc(nbuf->truesize);
  1553. return nbuf;
  1554. }
  1555. static inline void qdf_nbuf_free(qdf_nbuf_t buf)
  1556. {
  1557. if (qdf_likely(buf))
  1558. __qdf_nbuf_free(buf);
  1559. }
  1560. /**
  1561. * qdf_nbuf_clone() - clone the nbuf (copy is readonly)
  1562. * @buf: Pointer to network buffer
  1563. *
  1564. * This function clones the nbuf and returns new sk_buff
  1565. * structure.
  1566. *
  1567. * Return: cloned skb
  1568. */
  1569. static inline qdf_nbuf_t qdf_nbuf_clone(qdf_nbuf_t buf)
  1570. {
  1571. return __qdf_nbuf_clone(buf);
  1572. }
  1573. /**
  1574. * qdf_nbuf_copy() - returns a private copy of the buf
  1575. * @buf: Pointer to network buffer
  1576. *
  1577. * This API returns a private copy of the buf, the buf returned is completely
  1578. * modifiable by callers
  1579. *
  1580. * Return: skb or NULL
  1581. */
  1582. static inline qdf_nbuf_t qdf_nbuf_copy(qdf_nbuf_t buf)
  1583. {
  1584. return __qdf_nbuf_copy(buf);
  1585. }
  1586. /**
  1587. * qdf_nbuf_copy_expand() - copy and expand nbuf
  1588. * @buf: Network buf instance
  1589. * @headroom: Additional headroom to be added
  1590. * @tailroom: Additional tailroom to be added
  1591. *
  1592. * Return: New nbuf that is a copy of buf, with additional head and tailroom
  1593. * or NULL if there is no memory
  1594. */
  1595. static inline qdf_nbuf_t qdf_nbuf_copy_expand(qdf_nbuf_t buf, int headroom,
  1596. int tailroom)
  1597. {
  1598. return __qdf_nbuf_copy_expand(buf, headroom, tailroom);
  1599. }
  1600. static inline qdf_nbuf_t qdf_nbuf_unshare(qdf_nbuf_t buf)
  1601. {
  1602. return __qdf_nbuf_unshare(buf);
  1603. }
  1604. #endif /* NBUF_MEMORY_DEBUG */
  1605. /**
  1606. * qdf_nbuf_copy_expand_fraglist() - copy and expand nbuf and
  1607. * get reference of the fraglist.
  1608. * @buf: Network buf instance
  1609. * @headroom: Additional headroom to be added
  1610. * @tailroom: Additional tailroom to be added
  1611. *
  1612. * Return: New nbuf that is a copy of buf, with additional head and tailroom
  1613. * or NULL if there is no memory
  1614. */
  1615. static inline qdf_nbuf_t
  1616. qdf_nbuf_copy_expand_fraglist(qdf_nbuf_t buf, int headroom,
  1617. int tailroom)
  1618. {
  1619. buf = qdf_nbuf_copy_expand(buf, headroom, tailroom);
  1620. /* get fraglist reference */
  1621. if (buf)
  1622. __qdf_nbuf_get_ref_fraglist(buf);
  1623. return buf;
  1624. }
  1625. #ifdef WLAN_FEATURE_FASTPATH
  1626. /**
  1627. * qdf_nbuf_init_fast() - before put buf into pool,turn it to init state
  1628. *
  1629. * @buf: buf instance
  1630. * Return: data pointer of this buf where new data has to be
  1631. * put, or NULL if there is not enough room in this buf.
  1632. */
  1633. void qdf_nbuf_init_fast(qdf_nbuf_t nbuf);
  1634. #endif /* WLAN_FEATURE_FASTPATH */
  1635. /**
  1636. * @qdf_nbuf_list_free() - free a list of nbufs
  1637. * @buf_list: A list of nbufs to be freed
  1638. *
  1639. * Return: none
  1640. */
  1641. static inline void qdf_nbuf_list_free(qdf_nbuf_t buf_list)
  1642. {
  1643. while (buf_list) {
  1644. qdf_nbuf_t next = qdf_nbuf_next(buf_list);
  1645. qdf_nbuf_free(buf_list);
  1646. buf_list = next;
  1647. }
  1648. }
  1649. static inline void qdf_nbuf_tx_free(qdf_nbuf_t buf_list, int tx_err)
  1650. {
  1651. qdf_nbuf_list_free(buf_list);
  1652. }
  1653. static inline void qdf_nbuf_ref(qdf_nbuf_t buf)
  1654. {
  1655. __qdf_nbuf_ref(buf);
  1656. }
  1657. static inline int qdf_nbuf_shared(qdf_nbuf_t buf)
  1658. {
  1659. return __qdf_nbuf_shared(buf);
  1660. }
  1661. static inline QDF_STATUS qdf_nbuf_cat(qdf_nbuf_t dst, qdf_nbuf_t src)
  1662. {
  1663. return __qdf_nbuf_cat(dst, src);
  1664. }
  1665. /**
  1666. * @qdf_nbuf_copy_bits() - return the length of the copy bits for skb
  1667. * @skb: SKB pointer
  1668. * @offset: offset
  1669. * @len: Length
  1670. * @to: To
  1671. *
  1672. * Return: int32_t
  1673. */
  1674. static inline int32_t
  1675. qdf_nbuf_copy_bits(qdf_nbuf_t nbuf, uint32_t offset, uint32_t len, void *to)
  1676. {
  1677. return __qdf_nbuf_copy_bits(nbuf, offset, len, to);
  1678. }
  1679. /* nbuf manipulation routines */
  1680. /**
  1681. * @qdf_nbuf_head() - return the address of an nbuf's buffer
  1682. * @buf: netbuf
  1683. *
  1684. * Return: head address
  1685. */
  1686. static inline uint8_t *qdf_nbuf_head(qdf_nbuf_t buf)
  1687. {
  1688. return __qdf_nbuf_head(buf);
  1689. }
  1690. /**
  1691. * qdf_nbuf_data() - Return the address of the start of data within an nbuf
  1692. * @buf: Network buffer
  1693. *
  1694. * Return: Data address
  1695. */
  1696. static inline uint8_t *qdf_nbuf_data(qdf_nbuf_t buf)
  1697. {
  1698. return __qdf_nbuf_data(buf);
  1699. }
  1700. /**
  1701. * qdf_nbuf_data_addr() - Return the address of skb->data
  1702. * @buf: Network buffer
  1703. *
  1704. * Return: Data address
  1705. */
  1706. static inline uint8_t *qdf_nbuf_data_addr(qdf_nbuf_t buf)
  1707. {
  1708. return __qdf_nbuf_data_addr(buf);
  1709. }
  1710. /**
  1711. * qdf_nbuf_headroom() - amount of headroom int the current nbuf
  1712. * @buf: Network buffer
  1713. *
  1714. * Return: Amount of head room
  1715. */
  1716. static inline uint32_t qdf_nbuf_headroom(qdf_nbuf_t buf)
  1717. {
  1718. return __qdf_nbuf_headroom(buf);
  1719. }
  1720. /**
  1721. * qdf_nbuf_tailroom() - amount of tail space available
  1722. * @buf: Network buffer
  1723. *
  1724. * Return: amount of tail room
  1725. */
  1726. static inline uint32_t qdf_nbuf_tailroom(qdf_nbuf_t buf)
  1727. {
  1728. return __qdf_nbuf_tailroom(buf);
  1729. }
  1730. /**
  1731. * qdf_nbuf_push_head() - push data in the front
  1732. * @buf: Network buf instance
  1733. * @size: Size to be pushed
  1734. *
  1735. * Return: New data pointer of this buf after data has been pushed,
  1736. * or NULL if there is not enough room in this buf.
  1737. */
  1738. static inline uint8_t *qdf_nbuf_push_head(qdf_nbuf_t buf, qdf_size_t size)
  1739. {
  1740. return __qdf_nbuf_push_head(buf, size);
  1741. }
  1742. /**
  1743. * qdf_nbuf_put_tail() - puts data in the end
  1744. * @buf: Network buf instance
  1745. * @size: Size to be pushed
  1746. *
  1747. * Return: Data pointer of this buf where new data has to be
  1748. * put, or NULL if there is not enough room in this buf.
  1749. */
  1750. static inline uint8_t *qdf_nbuf_put_tail(qdf_nbuf_t buf, qdf_size_t size)
  1751. {
  1752. return __qdf_nbuf_put_tail(buf, size);
  1753. }
  1754. /**
  1755. * qdf_nbuf_pull_head() - pull data out from the front
  1756. * @buf: Network buf instance
  1757. * @size: Size to be popped
  1758. *
  1759. * Return: New data pointer of this buf after data has been popped,
  1760. * or NULL if there is not sufficient data to pull.
  1761. */
  1762. static inline uint8_t *qdf_nbuf_pull_head(qdf_nbuf_t buf, qdf_size_t size)
  1763. {
  1764. return __qdf_nbuf_pull_head(buf, size);
  1765. }
  1766. /**
  1767. * qdf_nbuf_trim_tail() - trim data out from the end
  1768. * @buf: Network buf instance
  1769. * @size: Size to be popped
  1770. *
  1771. * Return: none
  1772. */
  1773. static inline void qdf_nbuf_trim_tail(qdf_nbuf_t buf, qdf_size_t size)
  1774. {
  1775. __qdf_nbuf_trim_tail(buf, size);
  1776. }
  1777. /**
  1778. * qdf_nbuf_len() - get the length of the buf
  1779. * @buf: Network buf instance
  1780. *
  1781. * Return: total length of this buf.
  1782. */
  1783. static inline qdf_size_t qdf_nbuf_len(qdf_nbuf_t buf)
  1784. {
  1785. return __qdf_nbuf_len(buf);
  1786. }
  1787. /**
  1788. * qdf_nbuf_set_pktlen() - set the length of the buf
  1789. * @buf: Network buf instance
  1790. * @size: Size to be set
  1791. *
  1792. * Return: none
  1793. */
  1794. static inline void qdf_nbuf_set_pktlen(qdf_nbuf_t buf, uint32_t len)
  1795. {
  1796. __qdf_nbuf_set_pktlen(buf, len);
  1797. }
  1798. /**
  1799. * qdf_nbuf_reserve() - trim data out from the end
  1800. * @buf: Network buf instance
  1801. * @size: Size to be popped
  1802. *
  1803. * Return: none
  1804. */
  1805. static inline void qdf_nbuf_reserve(qdf_nbuf_t buf, qdf_size_t size)
  1806. {
  1807. __qdf_nbuf_reserve(buf, size);
  1808. }
  1809. /**
  1810. * qdf_nbuf_set_data_pointer() - set data pointer
  1811. * @buf: Network buf instance
  1812. * @data: data pointer
  1813. *
  1814. * Return: none
  1815. */
  1816. static inline void qdf_nbuf_set_data_pointer(qdf_nbuf_t buf, uint8_t *data)
  1817. {
  1818. __qdf_nbuf_set_data_pointer(buf, data);
  1819. }
  1820. /**
  1821. * qdf_nbuf_set_len() - set data length
  1822. * @buf: Network buf instance
  1823. * @len: data length
  1824. * Return: none
  1825. */
  1826. static inline void qdf_nbuf_set_len(qdf_nbuf_t buf, uint32_t len)
  1827. {
  1828. __qdf_nbuf_set_len(buf, len);
  1829. }
  1830. /**
  1831. * qdf_nbuf_set_tail_pointer() - set data tail pointer
  1832. * @buf: Network buf instance
  1833. * @len: length of data
  1834. *
  1835. * Return: none
  1836. */
  1837. static inline void qdf_nbuf_set_tail_pointer(qdf_nbuf_t buf, int len)
  1838. {
  1839. __qdf_nbuf_set_tail_pointer(buf, len);
  1840. }
  1841. /**
  1842. * qdf_nbuf_unlink_no_lock() - unlink a nbuf from nbuf list
  1843. * @buf: Network buf instance
  1844. * @list: list to use
  1845. *
  1846. * This is a lockless version, driver must acquire locks if it
  1847. * needs to synchronize
  1848. *
  1849. * Return: none
  1850. */
  1851. static inline void
  1852. qdf_nbuf_unlink_no_lock(qdf_nbuf_t buf, qdf_nbuf_queue_head_t *list)
  1853. {
  1854. __qdf_nbuf_unlink_no_lock(buf, list);
  1855. }
  1856. /**
  1857. * qdf_nbuf_reset() - reset the buffer data and pointer
  1858. * @buf: Network buf instance
  1859. * @reserve: reserve
  1860. * @align: align
  1861. *
  1862. * Return: none
  1863. */
  1864. static inline void qdf_nbuf_reset(qdf_nbuf_t buf, int reserve, int align)
  1865. {
  1866. __qdf_nbuf_reset(buf, reserve, align);
  1867. }
  1868. /**
  1869. * qdf_nbuf_dev_scratch_is_supported() - dev_scratch support for network buffer
  1870. * in kernel
  1871. *
  1872. * Return: true if dev_scratch is supported
  1873. * false if dev_scratch is not supported
  1874. */
  1875. static inline bool qdf_nbuf_is_dev_scratch_supported(void)
  1876. {
  1877. return __qdf_nbuf_is_dev_scratch_supported();
  1878. }
  1879. /**
  1880. * qdf_nbuf_get_dev_scratch() - get dev_scratch of network buffer
  1881. * @buf: Pointer to network buffer
  1882. *
  1883. * Return: dev_scratch if dev_scratch supported
  1884. * 0 if dev_scratch not supported
  1885. */
  1886. static inline unsigned long qdf_nbuf_get_dev_scratch(qdf_nbuf_t buf)
  1887. {
  1888. return __qdf_nbuf_get_dev_scratch(buf);
  1889. }
  1890. /**
  1891. * qdf_nbuf_set_dev_scratch() - set dev_scratch of network buffer
  1892. * @buf: Pointer to network buffer
  1893. * @value: value to be set in dev_scratch of network buffer
  1894. *
  1895. * Return: void
  1896. */
  1897. static inline void qdf_nbuf_set_dev_scratch(qdf_nbuf_t buf, unsigned long value)
  1898. {
  1899. __qdf_nbuf_set_dev_scratch(buf, value);
  1900. }
  1901. /**
  1902. * qdf_nbuf_peek_header() - return the data pointer & length of the header
  1903. * @buf: Network nbuf
  1904. * @addr: Data pointer
  1905. * @len: Length of the data
  1906. *
  1907. * Return: none
  1908. */
  1909. static inline void
  1910. qdf_nbuf_peek_header(qdf_nbuf_t buf, uint8_t **addr, uint32_t *len)
  1911. {
  1912. __qdf_nbuf_peek_header(buf, addr, len);
  1913. }
  1914. /* nbuf queue routines */
  1915. /**
  1916. * qdf_nbuf_queue_init() - initialize buf queue
  1917. * @head: Network buf queue head
  1918. *
  1919. * Return: none
  1920. */
  1921. static inline void qdf_nbuf_queue_init(qdf_nbuf_queue_t *head)
  1922. {
  1923. __qdf_nbuf_queue_init(head);
  1924. }
  1925. /**
  1926. * qdf_nbuf_queue_add() - append a nbuf to the tail of the buf queue
  1927. * @head: Network buf queue head
  1928. * @buf: Network buf
  1929. *
  1930. * Return: none
  1931. */
  1932. static inline void qdf_nbuf_queue_add(qdf_nbuf_queue_t *head, qdf_nbuf_t buf)
  1933. {
  1934. __qdf_nbuf_queue_add(head, buf);
  1935. }
  1936. /**
  1937. * qdf_nbuf_queue_insert_head() - insert nbuf at the head of queue
  1938. * @head: Network buf queue head
  1939. * @buf: Network buf
  1940. *
  1941. * Return: none
  1942. */
  1943. static inline void
  1944. qdf_nbuf_queue_insert_head(qdf_nbuf_queue_t *head, qdf_nbuf_t buf)
  1945. {
  1946. __qdf_nbuf_queue_insert_head(head, buf);
  1947. }
  1948. /**
  1949. * qdf_nbuf_queue_remove() - retrieve a buf from the head of the buf queue
  1950. * @head: Network buf queue head
  1951. *
  1952. * Return: The head buf in the buf queue.
  1953. */
  1954. static inline qdf_nbuf_t qdf_nbuf_queue_remove(qdf_nbuf_queue_t *head)
  1955. {
  1956. return __qdf_nbuf_queue_remove(head);
  1957. }
  1958. /**
  1959. * qdf_nbuf_queue_len() - get the length of the queue
  1960. * @head: Network buf queue head
  1961. *
  1962. * Return: length of the queue
  1963. */
  1964. static inline uint32_t qdf_nbuf_queue_len(qdf_nbuf_queue_t *head)
  1965. {
  1966. return __qdf_nbuf_queue_len(head);
  1967. }
  1968. /**
  1969. * qdf_nbuf_queue_next() - get the next guy/packet of the given buffer
  1970. * @buf: Network buffer
  1971. *
  1972. * Return: next buffer/packet
  1973. */
  1974. static inline qdf_nbuf_t qdf_nbuf_queue_next(qdf_nbuf_t buf)
  1975. {
  1976. return __qdf_nbuf_queue_next(buf);
  1977. }
  1978. /**
  1979. * @qdf_nbuf_is_queue_empty() - check if the buf queue is empty
  1980. * @nbq: Network buf queue handle
  1981. *
  1982. * Return: true if queue is empty
  1983. * false if queue is not emty
  1984. */
  1985. static inline bool qdf_nbuf_is_queue_empty(qdf_nbuf_queue_t *nbq)
  1986. {
  1987. return __qdf_nbuf_is_queue_empty(nbq);
  1988. }
  1989. static inline qdf_nbuf_queue_t *
  1990. qdf_nbuf_queue_append(qdf_nbuf_queue_t *dest, qdf_nbuf_queue_t *src)
  1991. {
  1992. return __qdf_nbuf_queue_append(dest, src);
  1993. }
  1994. static inline void
  1995. qdf_nbuf_queue_free(qdf_nbuf_queue_t *head)
  1996. {
  1997. qdf_nbuf_t buf = NULL;
  1998. while ((buf = qdf_nbuf_queue_remove(head)) != NULL)
  1999. qdf_nbuf_free(buf);
  2000. }
  2001. static inline qdf_nbuf_t
  2002. qdf_nbuf_queue_first(qdf_nbuf_queue_t *head)
  2003. {
  2004. return __qdf_nbuf_queue_first(head);
  2005. }
  2006. static inline qdf_nbuf_t
  2007. qdf_nbuf_queue_last(qdf_nbuf_queue_t *head)
  2008. {
  2009. return __qdf_nbuf_queue_last(head);
  2010. }
  2011. /**
  2012. * qdf_nbuf_get_protocol() - return the protocol value of the skb
  2013. * @skb: Pointer to network buffer
  2014. *
  2015. * Return: skb protocol
  2016. */
  2017. static inline uint16_t qdf_nbuf_get_protocol(struct sk_buff *skb)
  2018. {
  2019. return __qdf_nbuf_get_protocol(skb);
  2020. }
  2021. /**
  2022. * qdf_nbuf_get_ip_summed() - return the ip checksum value of the skb
  2023. * @skb: Pointer to network buffer
  2024. *
  2025. * Return: skb ip_summed
  2026. */
  2027. static inline uint8_t qdf_nbuf_get_ip_summed(struct sk_buff *skb)
  2028. {
  2029. return __qdf_nbuf_get_ip_summed(skb);
  2030. }
  2031. /**
  2032. * qdf_nbuf_set_ip_summed() - sets the ip_summed value of the skb
  2033. * @skb: Pointer to network buffer
  2034. * @ip_summed: ip checksum
  2035. *
  2036. * Return: none
  2037. */
  2038. static inline void qdf_nbuf_set_ip_summed(struct sk_buff *skb,
  2039. uint8_t ip_summed)
  2040. {
  2041. __qdf_nbuf_set_ip_summed(skb, ip_summed);
  2042. }
  2043. /**
  2044. * qdf_nbuf_set_next() - add a packet to a linked list
  2045. * @this_buf: Predecessor buffer
  2046. * @next_buf: Successor buffer
  2047. *
  2048. * This function can be used to directly link nbufs, rather than using
  2049. * a separate network buffer queue object.
  2050. *
  2051. * Return: none
  2052. */
  2053. static inline void qdf_nbuf_set_next(qdf_nbuf_t this_buf, qdf_nbuf_t next_buf)
  2054. {
  2055. __qdf_nbuf_set_next(this_buf, next_buf);
  2056. }
  2057. /* nbuf extension routines */
  2058. /**
  2059. * qdf_nbuf_set_next_ext() - link extension of this packet contained in a new
  2060. * nbuf
  2061. * @this_buf: predecessor buffer
  2062. * @next_buf: successor buffer
  2063. *
  2064. * This function is used to link up many nbufs containing a single logical
  2065. * packet - not a collection of packets. Do not use for linking the first
  2066. * extension to the head
  2067. *
  2068. * Return: none
  2069. */
  2070. static inline void
  2071. qdf_nbuf_set_next_ext(qdf_nbuf_t this_buf, qdf_nbuf_t next_buf)
  2072. {
  2073. __qdf_nbuf_set_next_ext(this_buf, next_buf);
  2074. }
  2075. /**
  2076. * qdf_nbuf_next_ext() - get the next packet extension in the linked list
  2077. * @buf: Network buffer
  2078. *
  2079. * Return: Next network buffer in the linked list
  2080. */
  2081. static inline qdf_nbuf_t qdf_nbuf_next_ext(qdf_nbuf_t buf)
  2082. {
  2083. return __qdf_nbuf_next_ext(buf);
  2084. }
  2085. /**
  2086. * qdf_nbuf_append_ext_list() - link list of packet extensions to the head
  2087. * segment
  2088. * @head_buf: Network buf holding head segment (single)
  2089. * @ext_list: Network buf list holding linked extensions to the head
  2090. * @ext_len: Total length of all buffers in the extension list
  2091. *
  2092. * This function is used to link up a list of packet extensions (seg1, 2,
  2093. * ...) to the nbuf holding the head segment (seg0)
  2094. *
  2095. * Return: none
  2096. */
  2097. static inline void
  2098. qdf_nbuf_append_ext_list(qdf_nbuf_t head_buf, qdf_nbuf_t ext_list,
  2099. qdf_size_t ext_len)
  2100. {
  2101. __qdf_nbuf_append_ext_list(head_buf, ext_list, ext_len);
  2102. }
  2103. /**
  2104. * qdf_nbuf_get_ext_list() - Get the link to extended nbuf list.
  2105. * @head_buf: Network buf holding head segment (single)
  2106. *
  2107. * This ext_list is populated when we have Jumbo packet, for example in case of
  2108. * monitor mode amsdu packet reception, and are stiched using frags_list.
  2109. *
  2110. * Return: Network buf list holding linked extensions from head buf.
  2111. */
  2112. static inline qdf_nbuf_t qdf_nbuf_get_ext_list(qdf_nbuf_t head_buf)
  2113. {
  2114. return (qdf_nbuf_t)__qdf_nbuf_get_ext_list(head_buf);
  2115. }
  2116. /**
  2117. * qdf_nbuf_get_tx_cksum() - gets the tx checksum offload demand
  2118. * @buf: Network buffer
  2119. *
  2120. * Return: qdf_nbuf_tx_cksum_t checksum offload demand for the frame
  2121. */
  2122. static inline qdf_nbuf_tx_cksum_t qdf_nbuf_get_tx_cksum(qdf_nbuf_t buf)
  2123. {
  2124. return __qdf_nbuf_get_tx_cksum(buf);
  2125. }
  2126. /**
  2127. * qdf_nbuf_set_rx_cksum() - drivers that support hw checksumming use this to
  2128. * indicate checksum info to the stack.
  2129. * @buf: Network buffer
  2130. * @cksum: Checksum
  2131. *
  2132. * Return: none
  2133. */
  2134. static inline void
  2135. qdf_nbuf_set_rx_cksum(qdf_nbuf_t buf, qdf_nbuf_rx_cksum_t *cksum)
  2136. {
  2137. __qdf_nbuf_set_rx_cksum(buf, cksum);
  2138. }
  2139. /**
  2140. * qdf_nbuf_get_tid() - this function extracts the TID value from nbuf
  2141. * @buf: Network buffer
  2142. *
  2143. * Return: TID value
  2144. */
  2145. static inline uint8_t qdf_nbuf_get_tid(qdf_nbuf_t buf)
  2146. {
  2147. return __qdf_nbuf_get_tid(buf);
  2148. }
  2149. /**
  2150. * qdf_nbuf_set_tid() - this function sets the TID value in nbuf
  2151. * @buf: Network buffer
  2152. * @tid: TID value
  2153. *
  2154. * Return: none
  2155. */
  2156. static inline void qdf_nbuf_set_tid(qdf_nbuf_t buf, uint8_t tid)
  2157. {
  2158. __qdf_nbuf_set_tid(buf, tid);
  2159. }
  2160. /**
  2161. * qdf_nbuf_get_exemption_type() - this function extracts the exemption type
  2162. * from nbuf
  2163. * @buf: Network buffer
  2164. *
  2165. * Return: Exemption type
  2166. */
  2167. static inline uint8_t qdf_nbuf_get_exemption_type(qdf_nbuf_t buf)
  2168. {
  2169. return __qdf_nbuf_get_exemption_type(buf);
  2170. }
  2171. /**
  2172. * qdf_nbuf_set_protocol() - this function peeks data into the buffer at given
  2173. * offset
  2174. * @buf: Network buffer
  2175. * @proto: Protocol
  2176. *
  2177. * Return: none
  2178. */
  2179. static inline void qdf_nbuf_set_protocol(qdf_nbuf_t buf, uint16_t proto)
  2180. {
  2181. __qdf_nbuf_set_protocol(buf, proto);
  2182. }
  2183. /**
  2184. * qdf_nbuf_trace_get_proto_type() - this function return packet proto type
  2185. * @buf: Network buffer
  2186. *
  2187. * Return: Packet protocol type
  2188. */
  2189. static inline uint8_t qdf_nbuf_trace_get_proto_type(qdf_nbuf_t buf)
  2190. {
  2191. return __qdf_nbuf_trace_get_proto_type(buf);
  2192. }
  2193. /**
  2194. * qdf_nbuf_reg_trace_cb() - this function registers protocol trace callback
  2195. * @cb_func_ptr: Callback pointer
  2196. *
  2197. * Return: none
  2198. */
  2199. static inline void qdf_nbuf_reg_trace_cb(qdf_nbuf_trace_update_t cb_func_ptr)
  2200. {
  2201. __qdf_nbuf_reg_trace_cb(cb_func_ptr);
  2202. }
  2203. /**
  2204. * qdf_nbuf_set_tx_parallel_dnload_frm() - set tx parallel download
  2205. * @buf: Network buffer
  2206. * @candi: Candidate of parallel download frame
  2207. *
  2208. * This function stores a flag specifying this TX frame is suitable for
  2209. * downloading though a 2nd TX data pipe that is used for short frames for
  2210. * protocols that can accept out-of-order delivery.
  2211. *
  2212. * Return: none
  2213. */
  2214. static inline void
  2215. qdf_nbuf_set_tx_parallel_dnload_frm(qdf_nbuf_t buf, uint8_t candi)
  2216. {
  2217. __qdf_nbuf_set_tx_htt2_frm(buf, candi);
  2218. }
  2219. /**
  2220. * qdf_nbuf_get_tx_parallel_dnload_frm() - get tx parallel download
  2221. * @buf: Network buffer
  2222. *
  2223. * This function return whether this TX frame is allow to download though a 2nd
  2224. * TX data pipe or not.
  2225. *
  2226. * Return: none
  2227. */
  2228. static inline uint8_t qdf_nbuf_get_tx_parallel_dnload_frm(qdf_nbuf_t buf)
  2229. {
  2230. return __qdf_nbuf_get_tx_htt2_frm(buf);
  2231. }
  2232. /**
  2233. * qdf_nbuf_get_dhcp_subtype() - get the subtype
  2234. * of DHCP packet.
  2235. * @buf: Pointer to DHCP packet buffer
  2236. *
  2237. * This func. returns the subtype of DHCP packet.
  2238. *
  2239. * Return: subtype of the DHCP packet.
  2240. */
  2241. static inline enum qdf_proto_subtype
  2242. qdf_nbuf_get_dhcp_subtype(qdf_nbuf_t buf)
  2243. {
  2244. return __qdf_nbuf_data_get_dhcp_subtype(qdf_nbuf_data(buf));
  2245. }
  2246. /**
  2247. * qdf_nbuf_data_get_dhcp_subtype() - get the subtype
  2248. * of DHCP packet.
  2249. * @buf: Pointer to DHCP packet data buffer
  2250. *
  2251. * This func. returns the subtype of DHCP packet.
  2252. *
  2253. * Return: subtype of the DHCP packet.
  2254. */
  2255. static inline enum qdf_proto_subtype
  2256. qdf_nbuf_data_get_dhcp_subtype(uint8_t *data)
  2257. {
  2258. return __qdf_nbuf_data_get_dhcp_subtype(data);
  2259. }
  2260. /**
  2261. * qdf_nbuf_get_eapol_subtype() - get the subtype
  2262. * of EAPOL packet.
  2263. * @buf: Pointer to EAPOL packet buffer
  2264. *
  2265. * This func. returns the subtype of EAPOL packet.
  2266. *
  2267. * Return: subtype of the EAPOL packet.
  2268. */
  2269. static inline enum qdf_proto_subtype
  2270. qdf_nbuf_get_eapol_subtype(qdf_nbuf_t buf)
  2271. {
  2272. return __qdf_nbuf_data_get_eapol_subtype(qdf_nbuf_data(buf));
  2273. }
  2274. /**
  2275. * qdf_nbuf_data_get_eapol_subtype() - get the subtype
  2276. * of EAPOL packet.
  2277. * @data: Pointer to EAPOL packet data buffer
  2278. *
  2279. * This func. returns the subtype of EAPOL packet.
  2280. *
  2281. * Return: subtype of the EAPOL packet.
  2282. */
  2283. static inline enum qdf_proto_subtype
  2284. qdf_nbuf_data_get_eapol_subtype(uint8_t *data)
  2285. {
  2286. return __qdf_nbuf_data_get_eapol_subtype(data);
  2287. }
  2288. /**
  2289. * qdf_nbuf_get_arp_subtype() - get the subtype
  2290. * of ARP packet.
  2291. * @buf: Pointer to ARP packet buffer
  2292. *
  2293. * This func. returns the subtype of ARP packet.
  2294. *
  2295. * Return: subtype of the ARP packet.
  2296. */
  2297. static inline enum qdf_proto_subtype
  2298. qdf_nbuf_get_arp_subtype(qdf_nbuf_t buf)
  2299. {
  2300. return __qdf_nbuf_data_get_arp_subtype(qdf_nbuf_data(buf));
  2301. }
  2302. /**
  2303. * qdf_nbuf_data_get_arp_subtype() - get the subtype
  2304. * of ARP packet.
  2305. * @data: Pointer to ARP packet data buffer
  2306. *
  2307. * This func. returns the subtype of ARP packet.
  2308. *
  2309. * Return: subtype of the ARP packet.
  2310. */
  2311. static inline enum qdf_proto_subtype
  2312. qdf_nbuf_data_get_arp_subtype(uint8_t *data)
  2313. {
  2314. return __qdf_nbuf_data_get_arp_subtype(data);
  2315. }
  2316. /**
  2317. * qdf_nbuf_get_icmp_subtype() - get the subtype
  2318. * of IPV4 ICMP packet.
  2319. * @buf: Pointer to IPV4 ICMP packet buffer
  2320. *
  2321. * This func. returns the subtype of ICMP packet.
  2322. *
  2323. * Return: subtype of the ICMP packet.
  2324. */
  2325. static inline enum qdf_proto_subtype
  2326. qdf_nbuf_get_icmp_subtype(qdf_nbuf_t buf)
  2327. {
  2328. return __qdf_nbuf_data_get_icmp_subtype(qdf_nbuf_data(buf));
  2329. }
  2330. /**
  2331. * qdf_nbuf_data_get_icmp_subtype() - get the subtype
  2332. * of IPV4 ICMP packet.
  2333. * @data: Pointer to IPV4 ICMP packet data buffer
  2334. *
  2335. * This func. returns the subtype of ICMP packet.
  2336. *
  2337. * Return: subtype of the ICMP packet.
  2338. */
  2339. static inline enum qdf_proto_subtype
  2340. qdf_nbuf_data_get_icmp_subtype(uint8_t *data)
  2341. {
  2342. return __qdf_nbuf_data_get_icmp_subtype(data);
  2343. }
  2344. /**
  2345. * qdf_nbuf_get_icmpv6_subtype() - get the subtype
  2346. * of IPV6 ICMPV6 packet.
  2347. * @buf: Pointer to IPV6 ICMPV6 packet buffer
  2348. *
  2349. * This func. returns the subtype of ICMPV6 packet.
  2350. *
  2351. * Return: subtype of the ICMPV6 packet.
  2352. */
  2353. static inline enum qdf_proto_subtype
  2354. qdf_nbuf_get_icmpv6_subtype(qdf_nbuf_t buf)
  2355. {
  2356. return __qdf_nbuf_data_get_icmpv6_subtype(qdf_nbuf_data(buf));
  2357. }
  2358. /**
  2359. * qdf_nbuf_data_get_icmpv6_subtype() - get the subtype
  2360. * of IPV6 ICMPV6 packet.
  2361. * @data: Pointer to IPV6 ICMPV6 packet data buffer
  2362. *
  2363. * This func. returns the subtype of ICMPV6 packet.
  2364. *
  2365. * Return: subtype of the ICMPV6 packet.
  2366. */
  2367. static inline enum qdf_proto_subtype
  2368. qdf_nbuf_data_get_icmpv6_subtype(uint8_t *data)
  2369. {
  2370. return __qdf_nbuf_data_get_icmpv6_subtype(data);
  2371. }
  2372. /**
  2373. * qdf_nbuf_data_get_ipv4_proto() - get the proto type
  2374. * of IPV4 packet.
  2375. * @data: Pointer to IPV4 packet data buffer
  2376. *
  2377. * This func. returns the proto type of IPV4 packet.
  2378. *
  2379. * Return: proto type of IPV4 packet.
  2380. */
  2381. static inline uint8_t
  2382. qdf_nbuf_data_get_ipv4_proto(uint8_t *data)
  2383. {
  2384. return __qdf_nbuf_data_get_ipv4_proto(data);
  2385. }
  2386. /**
  2387. * qdf_nbuf_data_get_ipv6_proto() - get the proto type
  2388. * of IPV6 packet.
  2389. * @data: Pointer to IPV6 packet data buffer
  2390. *
  2391. * This func. returns the proto type of IPV6 packet.
  2392. *
  2393. * Return: proto type of IPV6 packet.
  2394. */
  2395. static inline uint8_t
  2396. qdf_nbuf_data_get_ipv6_proto(uint8_t *data)
  2397. {
  2398. return __qdf_nbuf_data_get_ipv6_proto(data);
  2399. }
  2400. /**
  2401. * qdf_nbuf_is_ipv4_pkt() - check if packet is a ipv4 packet or not
  2402. * @buf: buffer
  2403. *
  2404. * This api is for Tx packets.
  2405. *
  2406. * Return: true if packet is ipv4 packet
  2407. */
  2408. static inline
  2409. bool qdf_nbuf_is_ipv4_pkt(qdf_nbuf_t buf)
  2410. {
  2411. return __qdf_nbuf_data_is_ipv4_pkt(qdf_nbuf_data(buf));
  2412. }
  2413. /**
  2414. * qdf_nbuf_data_is_ipv4_pkt() - check if packet is a ipv4 packet or not
  2415. * @data: data
  2416. *
  2417. * This api is for Tx packets.
  2418. *
  2419. * Return: true if packet is ipv4 packet
  2420. */
  2421. static inline
  2422. bool qdf_nbuf_data_is_ipv4_pkt(uint8_t *data)
  2423. {
  2424. return __qdf_nbuf_data_is_ipv4_pkt(data);
  2425. }
  2426. /**
  2427. * qdf_nbuf_is_ipv4_dhcp_pkt() - check if packet is a dhcp packet or not
  2428. * @buf: buffer
  2429. *
  2430. * This api is for ipv4 packet.
  2431. *
  2432. * Return: true if packet is DHCP packet
  2433. */
  2434. static inline
  2435. bool qdf_nbuf_is_ipv4_dhcp_pkt(qdf_nbuf_t buf)
  2436. {
  2437. return __qdf_nbuf_data_is_ipv4_dhcp_pkt(qdf_nbuf_data(buf));
  2438. }
  2439. /**
  2440. * qdf_nbuf_data_is_ipv4_dhcp_pkt() - check if it is DHCP packet.
  2441. * @data: Pointer to DHCP packet data buffer
  2442. *
  2443. * This func. checks whether it is a DHCP packet or not.
  2444. *
  2445. * Return: true if it is a DHCP packet
  2446. * false if not
  2447. */
  2448. static inline
  2449. bool qdf_nbuf_data_is_ipv4_dhcp_pkt(uint8_t *data)
  2450. {
  2451. return __qdf_nbuf_data_is_ipv4_dhcp_pkt(data);
  2452. }
  2453. /**
  2454. * qdf_nbuf_data_is_ipv6_mdsn_pkt() - check if it is MDNS packet.
  2455. * @data: Pointer to packet data buffer
  2456. *
  2457. * This func. checks whether it is a MDNS packet or not.
  2458. *
  2459. * Return: true if it is a MDNS packet, false if not
  2460. */
  2461. static inline
  2462. bool qdf_nbuf_is_ipv6_mdns_pkt(qdf_nbuf_t buf)
  2463. {
  2464. return __qdf_nbuf_data_is_ipv6_mdns_pkt(qdf_nbuf_data(buf));
  2465. }
  2466. /**
  2467. * qdf_nbuf_data_is_ipv6_dhcp_pkt() - check if it is DHCP packet.
  2468. * @data: Pointer to DHCP packet data buffer
  2469. *
  2470. * This func. checks whether it is a DHCP packet or not.
  2471. *
  2472. * Return: true if it is a DHCP packet
  2473. * false if not
  2474. */
  2475. static inline
  2476. bool qdf_nbuf_is_ipv6_dhcp_pkt(qdf_nbuf_t buf)
  2477. {
  2478. return __qdf_nbuf_data_is_ipv6_dhcp_pkt(qdf_nbuf_data(buf));
  2479. }
  2480. /**
  2481. * qdf_nbuf_is_ipv4_eapol_pkt() - check if packet is a eapol packet or not
  2482. * @buf: buffer
  2483. *
  2484. * This api is for ipv4 packet.
  2485. *
  2486. * Return: true if packet is EAPOL packet
  2487. */
  2488. static inline
  2489. bool qdf_nbuf_is_ipv4_eapol_pkt(qdf_nbuf_t buf)
  2490. {
  2491. return __qdf_nbuf_data_is_ipv4_eapol_pkt(qdf_nbuf_data(buf));
  2492. }
  2493. /**
  2494. * qdf_nbuf_data_is_ipv4_eapol_pkt() - check if it is EAPOL packet.
  2495. * @data: Pointer to EAPOL packet data buffer
  2496. *
  2497. * This func. checks whether it is a EAPOL packet or not.
  2498. *
  2499. * Return: true if it is a EAPOL packet
  2500. * false if not
  2501. */
  2502. static inline
  2503. bool qdf_nbuf_data_is_ipv4_eapol_pkt(uint8_t *data)
  2504. {
  2505. return __qdf_nbuf_data_is_ipv4_eapol_pkt(data);
  2506. }
  2507. /**
  2508. * qdf_nbuf_is_ipv4_wapi_pkt() - check if packet is a wapi packet or not
  2509. * @buf: buffer
  2510. *
  2511. * This api is for ipv4 packet.
  2512. *
  2513. * Return: true if packet is WAPI packet
  2514. */
  2515. static inline
  2516. bool qdf_nbuf_is_ipv4_wapi_pkt(qdf_nbuf_t buf)
  2517. {
  2518. return __qdf_nbuf_is_ipv4_wapi_pkt(buf);
  2519. }
  2520. /**
  2521. * qdf_nbuf_is_ipv4_tdls_pkt() - check if packet is a tdls packet or not
  2522. * @buf: buffer
  2523. *
  2524. * This api is for ipv4 packet.
  2525. *
  2526. * Return: true if packet is TDLS packet
  2527. */
  2528. static inline
  2529. bool qdf_nbuf_is_ipv4_tdls_pkt(qdf_nbuf_t buf)
  2530. {
  2531. return __qdf_nbuf_is_ipv4_tdls_pkt(buf);
  2532. }
  2533. /**
  2534. * qdf_nbuf_is_ipv4_arp_pkt() - check if packet is a arp packet or not
  2535. * @buf: buffer
  2536. *
  2537. * This api is for ipv4 packet.
  2538. *
  2539. * Return: true if packet is ARP packet
  2540. */
  2541. static inline
  2542. bool qdf_nbuf_is_ipv4_arp_pkt(qdf_nbuf_t buf)
  2543. {
  2544. return __qdf_nbuf_data_is_ipv4_arp_pkt(qdf_nbuf_data(buf));
  2545. }
  2546. /**
  2547. * qdf_nbuf_data_is_ipv4_arp_pkt() - check if it is ARP packet.
  2548. * @data: Pointer to ARP packet data buffer
  2549. *
  2550. * This func. checks whether it is a ARP packet or not.
  2551. *
  2552. * Return: TRUE if it is a ARP packet
  2553. * FALSE if not
  2554. */
  2555. static inline
  2556. bool qdf_nbuf_data_is_ipv4_arp_pkt(uint8_t *data)
  2557. {
  2558. return __qdf_nbuf_data_is_ipv4_arp_pkt(data);
  2559. }
  2560. /**
  2561. * qdf_nbuf_data_is_arp_req() - check if ARP packet is request.
  2562. * @buf: buffer
  2563. *
  2564. * This func. checks whether it is a ARP request or not.
  2565. *
  2566. * Return: true if it is a ARP request or FALSE if not
  2567. */
  2568. static inline
  2569. bool qdf_nbuf_data_is_arp_req(qdf_nbuf_t buf)
  2570. {
  2571. return __qdf_nbuf_data_is_arp_req(qdf_nbuf_data(buf));
  2572. }
  2573. /**
  2574. * qdf_nbuf_data_is_arp_rsp() - check if ARP packet is response.
  2575. * @buf: buffer
  2576. *
  2577. * This func. checks whether it is a ARP response or not.
  2578. *
  2579. * Return: true if it is a ARP response or FALSE if not
  2580. */
  2581. static inline
  2582. bool qdf_nbuf_data_is_arp_rsp(qdf_nbuf_t buf)
  2583. {
  2584. return __qdf_nbuf_data_is_arp_rsp(qdf_nbuf_data(buf));
  2585. }
  2586. /**
  2587. * qdf_nbuf_data_get_arp_src_ip() - get ARP packet source IP gateway.
  2588. * @buf: buffer
  2589. *
  2590. * Return: ARP packet source IP value.
  2591. */
  2592. static inline
  2593. uint32_t qdf_nbuf_get_arp_src_ip(qdf_nbuf_t buf)
  2594. {
  2595. return __qdf_nbuf_get_arp_src_ip(qdf_nbuf_data(buf));
  2596. }
  2597. /**
  2598. * qdf_nbuf_data_get_arp_tgt_ip() - get ARP packet target IP gateway.
  2599. * @buf: buffer
  2600. *
  2601. * Return: ARP packet target IP value.
  2602. */
  2603. static inline
  2604. uint32_t qdf_nbuf_get_arp_tgt_ip(qdf_nbuf_t buf)
  2605. {
  2606. return __qdf_nbuf_get_arp_tgt_ip(qdf_nbuf_data(buf));
  2607. }
  2608. /**
  2609. * qdf_nbuf_get_dns_domain_name() - get dns domain name of required length
  2610. * @buf: buffer
  2611. * @len: length to copy
  2612. *
  2613. * Return: dns domain name
  2614. */
  2615. static inline
  2616. uint8_t *qdf_nbuf_get_dns_domain_name(qdf_nbuf_t buf, uint32_t len)
  2617. {
  2618. return __qdf_nbuf_get_dns_domain_name(qdf_nbuf_data(buf), len);
  2619. }
  2620. /**
  2621. * qdf_nbuf_data_is_dns_query() - check if skb data is a dns query
  2622. * @buf: buffer
  2623. *
  2624. * Return: true if packet is dns query packet.
  2625. * false otherwise.
  2626. */
  2627. static inline
  2628. bool qdf_nbuf_data_is_dns_query(qdf_nbuf_t buf)
  2629. {
  2630. return __qdf_nbuf_data_is_dns_query(qdf_nbuf_data(buf));
  2631. }
  2632. /**
  2633. * qdf_nbuf_data_is_dns_response() - check if skb data is a dns response
  2634. * @buf: buffer
  2635. *
  2636. * Return: true if packet is dns response packet.
  2637. * false otherwise.
  2638. */
  2639. static inline
  2640. bool qdf_nbuf_data_is_dns_response(qdf_nbuf_t buf)
  2641. {
  2642. return __qdf_nbuf_data_is_dns_response(qdf_nbuf_data(buf));
  2643. }
  2644. /**
  2645. * qdf_nbuf_data_is_tcp_syn() - check if skb data is a tcp syn
  2646. * @buf: buffer
  2647. *
  2648. * Return: true if packet is tcp syn packet.
  2649. * false otherwise.
  2650. */
  2651. static inline
  2652. bool qdf_nbuf_data_is_tcp_syn(qdf_nbuf_t buf)
  2653. {
  2654. return __qdf_nbuf_data_is_tcp_syn(qdf_nbuf_data(buf));
  2655. }
  2656. /**
  2657. * qdf_nbuf_data_is_tcp_syn_ack() - check if skb data is a tcp syn ack
  2658. * @buf: buffer
  2659. *
  2660. * Return: true if packet is tcp syn ack packet.
  2661. * false otherwise.
  2662. */
  2663. static inline
  2664. bool qdf_nbuf_data_is_tcp_syn_ack(qdf_nbuf_t buf)
  2665. {
  2666. return __qdf_nbuf_data_is_tcp_syn_ack(qdf_nbuf_data(buf));
  2667. }
  2668. /**
  2669. * qdf_nbuf_data_is_tcp_ack() - check if skb data is a tcp ack
  2670. * @buf: buffer
  2671. *
  2672. * Return: true if packet is tcp ack packet.
  2673. * false otherwise.
  2674. */
  2675. static inline
  2676. bool qdf_nbuf_data_is_tcp_ack(qdf_nbuf_t buf)
  2677. {
  2678. return __qdf_nbuf_data_is_tcp_ack(qdf_nbuf_data(buf));
  2679. }
  2680. /**
  2681. * qdf_nbuf_data_get_tcp_src_port() - get tcp src port
  2682. * @buf: buffer
  2683. *
  2684. * Return: tcp source port value.
  2685. */
  2686. static inline
  2687. uint16_t qdf_nbuf_data_get_tcp_src_port(qdf_nbuf_t buf)
  2688. {
  2689. return __qdf_nbuf_data_get_tcp_src_port(qdf_nbuf_data(buf));
  2690. }
  2691. /**
  2692. * qdf_nbuf_data_get_tcp_dst_port() - get tcp dst port
  2693. * @buf: buffer
  2694. *
  2695. * Return: tcp destination port value.
  2696. */
  2697. static inline
  2698. uint16_t qdf_nbuf_data_get_tcp_dst_port(qdf_nbuf_t buf)
  2699. {
  2700. return __qdf_nbuf_data_get_tcp_dst_port(qdf_nbuf_data(buf));
  2701. }
  2702. /**
  2703. * qdf_nbuf_data_is_icmpv4_req() - check if ICMPv4 packet is request.
  2704. * @buf: buffer
  2705. *
  2706. * This func. checks whether it is a ICMPv4 request or not.
  2707. *
  2708. * Return: true if it is a ICMPv4 request or fALSE if not
  2709. */
  2710. static inline
  2711. bool qdf_nbuf_data_is_icmpv4_req(qdf_nbuf_t buf)
  2712. {
  2713. return __qdf_nbuf_data_is_icmpv4_req(qdf_nbuf_data(buf));
  2714. }
  2715. /**
  2716. * qdf_nbuf_data_is_icmpv4_rsp() - check if ICMPv4 packet is res
  2717. * @buf: buffer
  2718. *
  2719. * Return: true if packet is icmpv4 response
  2720. * false otherwise.
  2721. */
  2722. static inline
  2723. bool qdf_nbuf_data_is_icmpv4_rsp(qdf_nbuf_t buf)
  2724. {
  2725. return __qdf_nbuf_data_is_icmpv4_rsp(qdf_nbuf_data(buf));
  2726. }
  2727. /**
  2728. * qdf_nbuf_get_icmpv4_src_ip() - get icmpv4 src IP
  2729. * @buf: buffer
  2730. *
  2731. * Return: icmpv4 packet source IP value.
  2732. */
  2733. static inline
  2734. uint32_t qdf_nbuf_get_icmpv4_src_ip(qdf_nbuf_t buf)
  2735. {
  2736. return __qdf_nbuf_get_icmpv4_src_ip(qdf_nbuf_data(buf));
  2737. }
  2738. /**
  2739. * qdf_nbuf_data_get_icmpv4_tgt_ip() - get icmpv4 target IP
  2740. * @buf: buffer
  2741. *
  2742. * Return: icmpv4 packet target IP value.
  2743. */
  2744. static inline
  2745. uint32_t qdf_nbuf_get_icmpv4_tgt_ip(qdf_nbuf_t buf)
  2746. {
  2747. return __qdf_nbuf_get_icmpv4_tgt_ip(qdf_nbuf_data(buf));
  2748. }
  2749. /**
  2750. * qdf_nbuf_is_ipv6_pkt() - check if it is IPV6 packet.
  2751. * @buf: Pointer to IPV6 packet buffer
  2752. *
  2753. * This func. checks whether it is a IPV6 packet or not.
  2754. *
  2755. * Return: TRUE if it is a IPV6 packet
  2756. * FALSE if not
  2757. */
  2758. static inline
  2759. bool qdf_nbuf_is_ipv6_pkt(qdf_nbuf_t buf)
  2760. {
  2761. return __qdf_nbuf_data_is_ipv6_pkt(qdf_nbuf_data(buf));
  2762. }
  2763. /**
  2764. * qdf_nbuf_data_is_ipv6_pkt() - check if it is IPV6 packet.
  2765. * @data: Pointer to IPV6 packet data buffer
  2766. *
  2767. * This func. checks whether it is a IPV6 packet or not.
  2768. *
  2769. * Return: TRUE if it is a IPV6 packet
  2770. * FALSE if not
  2771. */
  2772. static inline
  2773. bool qdf_nbuf_data_is_ipv6_pkt(uint8_t *data)
  2774. {
  2775. return __qdf_nbuf_data_is_ipv6_pkt(data);
  2776. }
  2777. /**
  2778. * qdf_nbuf_data_is_ipv4_mcast_pkt() - check if it is IPV4 multicast packet.
  2779. * @data: Pointer to IPV4 packet data buffer
  2780. *
  2781. * This func. checks whether it is a IPV4 multicast packet or not.
  2782. *
  2783. * Return: TRUE if it is a IPV4 multicast packet
  2784. * FALSE if not
  2785. */
  2786. static inline
  2787. bool qdf_nbuf_data_is_ipv4_mcast_pkt(uint8_t *data)
  2788. {
  2789. return __qdf_nbuf_data_is_ipv4_mcast_pkt(data);
  2790. }
  2791. /**
  2792. * qdf_nbuf_data_is_ipv6_mcast_pkt() - check if it is IPV6 multicast packet.
  2793. * @data: Pointer to IPV6 packet data buffer
  2794. *
  2795. * This func. checks whether it is a IPV6 multicast packet or not.
  2796. *
  2797. * Return: TRUE if it is a IPV6 multicast packet
  2798. * FALSE if not
  2799. */
  2800. static inline
  2801. bool qdf_nbuf_data_is_ipv6_mcast_pkt(uint8_t *data)
  2802. {
  2803. return __qdf_nbuf_data_is_ipv6_mcast_pkt(data);
  2804. }
  2805. /**
  2806. * qdf_nbuf_is_icmp_pkt() - check if it is IPV4 ICMP packet.
  2807. * @buf: Pointer to IPV4 ICMP packet buffer
  2808. *
  2809. * This func. checks whether it is a ICMP packet or not.
  2810. *
  2811. * Return: TRUE if it is a ICMP packet
  2812. * FALSE if not
  2813. */
  2814. static inline
  2815. bool qdf_nbuf_is_icmp_pkt(qdf_nbuf_t buf)
  2816. {
  2817. return __qdf_nbuf_data_is_icmp_pkt(qdf_nbuf_data(buf));
  2818. }
  2819. /**
  2820. * qdf_nbuf_data_is_icmp_pkt() - check if it is IPV4 ICMP packet.
  2821. * @data: Pointer to IPV4 ICMP packet data buffer
  2822. *
  2823. * This func. checks whether it is a ICMP packet or not.
  2824. *
  2825. * Return: TRUE if it is a ICMP packet
  2826. * FALSE if not
  2827. */
  2828. static inline
  2829. bool qdf_nbuf_data_is_icmp_pkt(uint8_t *data)
  2830. {
  2831. return __qdf_nbuf_data_is_icmp_pkt(data);
  2832. }
  2833. /**
  2834. * qdf_nbuf_is_icmpv6_pkt() - check if it is IPV6 ICMPV6 packet.
  2835. * @buf: Pointer to IPV6 ICMPV6 packet buffer
  2836. *
  2837. * This func. checks whether it is a ICMPV6 packet or not.
  2838. *
  2839. * Return: TRUE if it is a ICMPV6 packet
  2840. * FALSE if not
  2841. */
  2842. static inline
  2843. bool qdf_nbuf_is_icmpv6_pkt(qdf_nbuf_t buf)
  2844. {
  2845. return __qdf_nbuf_data_is_icmpv6_pkt(qdf_nbuf_data(buf));
  2846. }
  2847. /**
  2848. * qdf_nbuf_data_is_icmpv6_pkt() - check if it is IPV6 ICMPV6 packet.
  2849. * @data: Pointer to IPV6 ICMPV6 packet data buffer
  2850. *
  2851. * This func. checks whether it is a ICMPV6 packet or not.
  2852. *
  2853. * Return: TRUE if it is a ICMPV6 packet
  2854. * FALSE if not
  2855. */
  2856. static inline
  2857. bool qdf_nbuf_data_is_icmpv6_pkt(uint8_t *data)
  2858. {
  2859. return __qdf_nbuf_data_is_icmpv6_pkt(data);
  2860. }
  2861. /**
  2862. * qdf_nbuf_is_ipv4_udp_pkt() - check if it is IPV4 UDP packet.
  2863. * @buf: Pointer to IPV4 UDP packet buffer
  2864. *
  2865. * This func. checks whether it is a IPV4 UDP packet or not.
  2866. *
  2867. * Return: TRUE if it is a IPV4 UDP packet
  2868. * FALSE if not
  2869. */
  2870. static inline
  2871. bool qdf_nbuf_is_ipv4_udp_pkt(qdf_nbuf_t buf)
  2872. {
  2873. return __qdf_nbuf_data_is_ipv4_udp_pkt(qdf_nbuf_data(buf));
  2874. }
  2875. /**
  2876. * qdf_nbuf_data_is_ipv4_udp_pkt() - check if it is IPV4 UDP packet.
  2877. * @data: Pointer to IPV4 UDP packet data buffer
  2878. *
  2879. * This func. checks whether it is a IPV4 UDP packet or not.
  2880. *
  2881. * Return: TRUE if it is a IPV4 UDP packet
  2882. * FALSE if not
  2883. */
  2884. static inline
  2885. bool qdf_nbuf_data_is_ipv4_udp_pkt(uint8_t *data)
  2886. {
  2887. return __qdf_nbuf_data_is_ipv4_udp_pkt(data);
  2888. }
  2889. /**
  2890. * qdf_nbuf_is_ipv4_tcp_pkt() - check if it is IPV4 TCP packet.
  2891. * @buf: Pointer to IPV4 TCP packet buffer
  2892. *
  2893. * This func. checks whether it is a IPV4 TCP packet or not.
  2894. *
  2895. * Return: TRUE if it is a IPV4 TCP packet
  2896. * FALSE if not
  2897. */
  2898. static inline
  2899. bool qdf_nbuf_is_ipv4_tcp_pkt(qdf_nbuf_t buf)
  2900. {
  2901. return __qdf_nbuf_data_is_ipv4_tcp_pkt(qdf_nbuf_data(buf));
  2902. }
  2903. /**
  2904. * qdf_nbuf_data_is_ipv4_tcp_pkt() - check if it is IPV4 TCP packet.
  2905. * @data: Pointer to IPV4 TCP packet data buffer
  2906. *
  2907. * This func. checks whether it is a IPV4 TCP packet or not.
  2908. *
  2909. * Return: TRUE if it is a IPV4 TCP packet
  2910. * FALSE if not
  2911. */
  2912. static inline
  2913. bool qdf_nbuf_data_is_ipv4_tcp_pkt(uint8_t *data)
  2914. {
  2915. return __qdf_nbuf_data_is_ipv4_tcp_pkt(data);
  2916. }
  2917. /**
  2918. * qdf_nbuf_is_ipv6_udp_pkt() - check if it is IPV6 UDP packet.
  2919. * @buf: Pointer to IPV6 UDP packet buffer
  2920. *
  2921. * This func. checks whether it is a IPV6 UDP packet or not.
  2922. *
  2923. * Return: TRUE if it is a IPV6 UDP packet
  2924. * FALSE if not
  2925. */
  2926. static inline
  2927. bool qdf_nbuf_is_ipv6_udp_pkt(qdf_nbuf_t buf)
  2928. {
  2929. return __qdf_nbuf_data_is_ipv6_udp_pkt(qdf_nbuf_data(buf));
  2930. }
  2931. /**
  2932. * qdf_nbuf_data_is_ipv6_udp_pkt() - check if it is IPV6 UDP packet.
  2933. * @data: Pointer to IPV6 UDP packet data buffer
  2934. *
  2935. * This func. checks whether it is a IPV6 UDP packet or not.
  2936. *
  2937. * Return: TRUE if it is a IPV6 UDP packet
  2938. * FALSE if not
  2939. */
  2940. static inline
  2941. bool qdf_nbuf_data_is_ipv6_udp_pkt(uint8_t *data)
  2942. {
  2943. return __qdf_nbuf_data_is_ipv6_udp_pkt(data);
  2944. }
  2945. /**
  2946. * qdf_nbuf_is_ipv6_tcp_pkt() - check if it is IPV6 TCP packet.
  2947. * @buf: Pointer to IPV6 TCP packet buffer
  2948. *
  2949. * This func. checks whether it is a IPV6 TCP packet or not.
  2950. *
  2951. * Return: TRUE if it is a IPV6 TCP packet
  2952. * FALSE if not
  2953. */
  2954. static inline
  2955. bool qdf_nbuf_is_ipv6_tcp_pkt(qdf_nbuf_t buf)
  2956. {
  2957. return __qdf_nbuf_data_is_ipv6_tcp_pkt(qdf_nbuf_data(buf));
  2958. }
  2959. /**
  2960. * qdf_nbuf_data_is_ipv6_tcp_pkt() - check if it is IPV6 TCP packet.
  2961. * @data: Pointer to IPV6 TCP packet data buffer
  2962. *
  2963. * This func. checks whether it is a IPV6 TCP packet or not.
  2964. *
  2965. * Return: TRUE if it is a IPV6 TCP packet
  2966. * FALSE if not
  2967. */
  2968. static inline
  2969. bool qdf_nbuf_data_is_ipv6_tcp_pkt(uint8_t *data)
  2970. {
  2971. return __qdf_nbuf_data_is_ipv6_tcp_pkt(data);
  2972. }
  2973. /**
  2974. * qdf_nbuf_is_bcast_pkt() - check if it is broadcast packet.
  2975. * @buf: Network buffer
  2976. *
  2977. * This func. checks whether packet is broadcast or not.
  2978. *
  2979. * Return: TRUE if it is broadcast packet
  2980. * FALSE if not
  2981. */
  2982. static inline
  2983. bool qdf_nbuf_is_bcast_pkt(qdf_nbuf_t buf)
  2984. {
  2985. return __qdf_nbuf_is_bcast_pkt(buf);
  2986. }
  2987. /**
  2988. * qdf_nbuf_reset_num_frags() - decrement the number of fragments
  2989. * @buf: Network buffer
  2990. *
  2991. * Return: Number of fragments
  2992. */
  2993. static inline void qdf_nbuf_reset_num_frags(qdf_nbuf_t buf)
  2994. {
  2995. __qdf_nbuf_reset_num_frags(buf);
  2996. }
  2997. /**
  2998. * qdf_dmaaddr_to_32s - return high and low parts of dma_addr
  2999. *
  3000. * Returns the high and low 32-bits of the DMA addr in the provided ptrs
  3001. *
  3002. * Return: N/A
  3003. */
  3004. static inline void qdf_dmaaddr_to_32s(qdf_dma_addr_t dmaaddr,
  3005. uint32_t *lo, uint32_t *hi)
  3006. {
  3007. return __qdf_dmaaddr_to_32s(dmaaddr, lo, hi);
  3008. }
  3009. /**
  3010. * qdf_nbuf_get_tso_info() - function to divide a jumbo TSO
  3011. * network buffer into segments
  3012. * @nbuf: network buffer to be segmented
  3013. * @tso_info: This is the output. The information about the
  3014. * TSO segments will be populated within this.
  3015. *
  3016. * This function fragments a TCP jumbo packet into smaller
  3017. * segments to be transmitted by the driver. It chains the TSO
  3018. * segments created into a list.
  3019. *
  3020. * Return: number of TSO segments
  3021. */
  3022. static inline uint32_t qdf_nbuf_get_tso_info(qdf_device_t osdev,
  3023. qdf_nbuf_t nbuf, struct qdf_tso_info_t *tso_info)
  3024. {
  3025. return __qdf_nbuf_get_tso_info(osdev, nbuf, tso_info);
  3026. }
  3027. /**
  3028. * qdf_nbuf_unmap_tso_segment() - function to dma unmap TSO segment element
  3029. *
  3030. * @osdev: qdf device handle
  3031. * @tso_seg: TSO segment element to be unmapped
  3032. * @is_last_seg: whether this is last tso seg or not
  3033. *
  3034. * Return: none
  3035. */
  3036. static inline void qdf_nbuf_unmap_tso_segment(qdf_device_t osdev,
  3037. struct qdf_tso_seg_elem_t *tso_seg,
  3038. bool is_last_seg)
  3039. {
  3040. return __qdf_nbuf_unmap_tso_segment(osdev, tso_seg, is_last_seg);
  3041. }
  3042. /**
  3043. * qdf_nbuf_get_tcp_payload_len() - function to return the tso payload len
  3044. * @nbuf: network buffer
  3045. *
  3046. * Return: size of the tso packet
  3047. */
  3048. static inline size_t qdf_nbuf_get_tcp_payload_len(qdf_nbuf_t nbuf)
  3049. {
  3050. return __qdf_nbuf_get_tcp_payload_len(nbuf);
  3051. }
  3052. /**
  3053. * qdf_nbuf_get_tso_num_seg() - function to calculate the number
  3054. * of TCP segments within the TSO jumbo packet
  3055. * @nbuf: TSO jumbo network buffer to be segmented
  3056. *
  3057. * This function calculates the number of TCP segments that the
  3058. network buffer can be divided into.
  3059. *
  3060. * Return: number of TCP segments
  3061. */
  3062. static inline uint32_t qdf_nbuf_get_tso_num_seg(qdf_nbuf_t nbuf)
  3063. {
  3064. return __qdf_nbuf_get_tso_num_seg(nbuf);
  3065. }
  3066. /**
  3067. * qdf_nbuf_inc_users() - function to increment the number of
  3068. * users referencing this network buffer
  3069. *
  3070. * @nbuf: network buffer
  3071. *
  3072. * This function increments the number of users referencing this
  3073. * network buffer
  3074. *
  3075. * Return: the network buffer
  3076. */
  3077. static inline qdf_nbuf_t qdf_nbuf_inc_users(qdf_nbuf_t nbuf)
  3078. {
  3079. return __qdf_nbuf_inc_users(nbuf);
  3080. }
  3081. /**
  3082. * qdf_nbuf_data_attr_get() - Get data_attr field from cvg_nbuf_cb
  3083. *
  3084. * @nbuf: Network buffer (skb on linux)
  3085. *
  3086. * This function returns the values of data_attr field
  3087. * in struct cvg_nbuf_cb{}, to which skb->cb is typecast.
  3088. * This value is actually the value programmed in CE descriptor.
  3089. *
  3090. * Return: Value of data_attr
  3091. */
  3092. static inline uint32_t qdf_nbuf_data_attr_get(qdf_nbuf_t buf)
  3093. {
  3094. return __qdf_nbuf_data_attr_get(buf);
  3095. }
  3096. /**
  3097. * qdf_nbuf_data_attr_set() - Sets data_attr field in cvg_nbuf_cb
  3098. *
  3099. * @nbuf: Network buffer (skb on linux)
  3100. * @data_attr: Value to be stored cvg_nbuf_cb->data_attr
  3101. *
  3102. * This function stores the value to be programmed in CE
  3103. * descriptor as part skb->cb which is typecast to struct cvg_nbuf_cb{}
  3104. *
  3105. * Return: void
  3106. */
  3107. static inline
  3108. void qdf_nbuf_data_attr_set(qdf_nbuf_t buf, uint32_t data_attr)
  3109. {
  3110. __qdf_nbuf_data_attr_set(buf, data_attr);
  3111. }
  3112. /**
  3113. * qdf_nbuf_tx_info_get() - Parse skb and get Tx metadata
  3114. *
  3115. * @nbuf: Network buffer (skb on linux)
  3116. *
  3117. * This function parses the payload to figure out relevant
  3118. * Tx meta-data e.g. whether to enable tx_classify bit
  3119. * in CE.
  3120. *
  3121. * Return: void
  3122. */
  3123. #define qdf_nbuf_tx_info_get __qdf_nbuf_tx_info_get
  3124. void qdf_nbuf_set_state(qdf_nbuf_t nbuf, uint8_t current_state);
  3125. void qdf_nbuf_tx_desc_count_display(void);
  3126. void qdf_nbuf_tx_desc_count_clear(void);
  3127. static inline qdf_nbuf_t
  3128. qdf_nbuf_realloc_headroom(qdf_nbuf_t buf, uint32_t headroom)
  3129. {
  3130. return __qdf_nbuf_realloc_headroom(buf, headroom);
  3131. }
  3132. static inline qdf_nbuf_t
  3133. qdf_nbuf_realloc_tailroom(qdf_nbuf_t buf, uint32_t tailroom)
  3134. {
  3135. return __qdf_nbuf_realloc_tailroom(buf, tailroom);
  3136. }
  3137. static inline qdf_nbuf_t
  3138. qdf_nbuf_expand(qdf_nbuf_t buf, uint32_t headroom, uint32_t tailroom)
  3139. {
  3140. return __qdf_nbuf_expand(buf, headroom, tailroom);
  3141. }
  3142. static inline int
  3143. qdf_nbuf_linearize(qdf_nbuf_t buf)
  3144. {
  3145. return __qdf_nbuf_linearize(buf);
  3146. }
  3147. static inline bool
  3148. qdf_nbuf_is_cloned(qdf_nbuf_t buf)
  3149. {
  3150. return __qdf_nbuf_is_cloned(buf);
  3151. }
  3152. static inline void
  3153. qdf_nbuf_frag_info(qdf_nbuf_t buf, qdf_sglist_t *sg)
  3154. {
  3155. __qdf_nbuf_frag_info(buf, sg);
  3156. }
  3157. static inline qdf_nbuf_tx_cksum_t
  3158. qdf_nbuf_tx_cksum_info(qdf_nbuf_t buf, uint8_t **hdr_off, uint8_t **where)
  3159. {
  3160. return __qdf_nbuf_tx_cksum_info(buf, hdr_off, where);
  3161. }
  3162. static inline void qdf_nbuf_reset_ctxt(__qdf_nbuf_t nbuf)
  3163. {
  3164. __qdf_nbuf_reset_ctxt(nbuf);
  3165. }
  3166. static inline void qdf_nbuf_init(qdf_nbuf_t buf)
  3167. {
  3168. __qdf_nbuf_init(buf);
  3169. }
  3170. static inline void *qdf_nbuf_network_header(qdf_nbuf_t buf)
  3171. {
  3172. return __qdf_nbuf_network_header(buf);
  3173. }
  3174. static inline void *qdf_nbuf_transport_header(qdf_nbuf_t buf)
  3175. {
  3176. return __qdf_nbuf_transport_header(buf);
  3177. }
  3178. static inline qdf_size_t qdf_nbuf_tcp_tso_size(qdf_nbuf_t buf)
  3179. {
  3180. return __qdf_nbuf_tcp_tso_size(buf);
  3181. }
  3182. static inline void *qdf_nbuf_get_cb(qdf_nbuf_t nbuf)
  3183. {
  3184. return __qdf_nbuf_get_cb(nbuf);
  3185. }
  3186. static inline uint32_t qdf_nbuf_get_nr_frags(qdf_nbuf_t nbuf)
  3187. {
  3188. return __qdf_nbuf_get_nr_frags(nbuf);
  3189. }
  3190. static inline qdf_size_t qdf_nbuf_headlen(qdf_nbuf_t buf)
  3191. {
  3192. return __qdf_nbuf_headlen(buf);
  3193. }
  3194. static inline QDF_STATUS qdf_nbuf_frag_map(qdf_device_t osdev,
  3195. qdf_nbuf_t buf, int offset,
  3196. qdf_dma_dir_t dir, int cur_frag)
  3197. {
  3198. return __qdf_nbuf_frag_map(osdev, buf, offset, dir, cur_frag);
  3199. }
  3200. static inline bool qdf_nbuf_tso_tcp_v4(qdf_nbuf_t buf)
  3201. {
  3202. return __qdf_nbuf_tso_tcp_v4(buf);
  3203. }
  3204. static inline bool qdf_nbuf_tso_tcp_v6(qdf_nbuf_t buf)
  3205. {
  3206. return __qdf_nbuf_tso_tcp_v6(buf);
  3207. }
  3208. static inline uint32_t qdf_nbuf_tcp_seq(qdf_nbuf_t buf)
  3209. {
  3210. return __qdf_nbuf_tcp_seq(buf);
  3211. }
  3212. static inline qdf_size_t qdf_nbuf_l2l3l4_hdr_len(qdf_nbuf_t buf)
  3213. {
  3214. return __qdf_nbuf_l2l3l4_hdr_len(buf);
  3215. }
  3216. static inline bool qdf_nbuf_is_nonlinear(qdf_nbuf_t buf)
  3217. {
  3218. return __qdf_nbuf_is_nonlinear(buf);
  3219. }
  3220. static inline uint32_t
  3221. qdf_nbuf_get_frag_size(qdf_nbuf_t buf, uint32_t frag_num)
  3222. {
  3223. return __qdf_nbuf_get_frag_size(buf, frag_num);
  3224. }
  3225. static inline uint32_t qdf_nbuf_get_priority(qdf_nbuf_t buf)
  3226. {
  3227. return __qdf_nbuf_get_priority(buf);
  3228. }
  3229. static inline void qdf_nbuf_set_priority(qdf_nbuf_t buf, uint32_t p)
  3230. {
  3231. __qdf_nbuf_set_priority(buf, p);
  3232. }
  3233. static inline void qdf_nbuf_record_rx_queue(qdf_nbuf_t buf, uint32_t queue_id)
  3234. {
  3235. __qdf_nbuf_record_rx_queue(buf, queue_id);
  3236. }
  3237. static inline uint16_t
  3238. qdf_nbuf_get_queue_mapping(qdf_nbuf_t buf)
  3239. {
  3240. return __qdf_nbuf_get_queue_mapping(buf);
  3241. }
  3242. static inline uint8_t *
  3243. qdf_nbuf_get_priv_ptr(qdf_nbuf_t buf)
  3244. {
  3245. return __qdf_nbuf_get_priv_ptr(buf);
  3246. }
  3247. /**
  3248. * qdf_nbuf_update_radiotap() - update radiotap at head of nbuf.
  3249. * @rx_status: rx_status containing required info to update radiotap
  3250. * @nbuf: Pointer to nbuf
  3251. * @headroom_sz: Available headroom size
  3252. *
  3253. * Return: radiotap length.
  3254. */
  3255. unsigned int qdf_nbuf_update_radiotap(struct mon_rx_status *rx_status,
  3256. qdf_nbuf_t nbuf, uint32_t headroom_sz);
  3257. /**
  3258. * qdf_nbuf_mark_wakeup_frame() - mark wakeup frame.
  3259. * @buf: Pointer to nbuf
  3260. *
  3261. * Return: None
  3262. */
  3263. static inline void
  3264. qdf_nbuf_mark_wakeup_frame(qdf_nbuf_t buf)
  3265. {
  3266. __qdf_nbuf_mark_wakeup_frame(buf);
  3267. }
  3268. /**
  3269. * qdf_nbuf_reg_free_cb - Registers nbuf free callback
  3270. * @cb_func_ptr: Callback pointer
  3271. *
  3272. * This function registers nbuf free callback
  3273. *
  3274. * Return: void
  3275. */
  3276. static inline void
  3277. qdf_nbuf_reg_free_cb(qdf_nbuf_free_t cb_func_ptr)
  3278. {
  3279. __qdf_nbuf_reg_free_cb(cb_func_ptr);
  3280. }
  3281. /**
  3282. * qdf_nbuf_set_timestamp() - set the timestamp for frame
  3283. *
  3284. * @buf: sk buff
  3285. *
  3286. * Return: void
  3287. */
  3288. static inline void
  3289. qdf_nbuf_set_timestamp(struct sk_buff *skb)
  3290. {
  3291. __qdf_nbuf_set_timestamp(skb);
  3292. }
  3293. /**
  3294. * qdf_nbuf_get_timestamp() - get the timestamp for frame
  3295. *
  3296. * @buf: sk buff
  3297. *
  3298. * Return: timestamp stored in skb in ms
  3299. */
  3300. static inline uint64_t
  3301. qdf_nbuf_get_timestamp(struct sk_buff *skb)
  3302. {
  3303. return __qdf_nbuf_get_timestamp(skb);
  3304. }
  3305. /**
  3306. * qdf_nbuf_get_timedelta_ms() - get time difference in ms
  3307. *
  3308. * @buf: sk buff
  3309. *
  3310. * Return: time difference ms
  3311. */
  3312. static inline uint64_t
  3313. qdf_nbuf_get_timedelta_ms(struct sk_buff *skb)
  3314. {
  3315. return __qdf_nbuf_get_timedelta_ms(skb);
  3316. }
  3317. /**
  3318. * qdf_nbuf_get_timedelta_us() - get time difference in micro seconds
  3319. *
  3320. * @buf: sk buff
  3321. *
  3322. * Return: time difference in micro seconds
  3323. */
  3324. static inline uint64_t
  3325. qdf_nbuf_get_timedelta_us(struct sk_buff *skb)
  3326. {
  3327. return __qdf_nbuf_get_timedelta_us(skb);
  3328. }
  3329. /**
  3330. * qdf_nbuf_count_get() - get global nbuf gauge
  3331. *
  3332. * Return: global nbuf gauge
  3333. */
  3334. static inline int qdf_nbuf_count_get(void)
  3335. {
  3336. return __qdf_nbuf_count_get();
  3337. }
  3338. /**
  3339. * qdf_nbuf_count_inc() - increment nbuf global count
  3340. *
  3341. * @buf: sk buff
  3342. *
  3343. * Return: void
  3344. */
  3345. static inline void qdf_nbuf_count_inc(qdf_nbuf_t buf)
  3346. {
  3347. return __qdf_nbuf_count_inc(buf);
  3348. }
  3349. /**
  3350. * qdf_nbuf_count_dec() - decrement nbuf global count
  3351. *
  3352. * @buf: sk buff
  3353. *
  3354. * Return: void
  3355. */
  3356. static inline void qdf_nbuf_count_dec(qdf_nbuf_t buf)
  3357. {
  3358. return __qdf_nbuf_count_dec(buf);
  3359. }
  3360. /**
  3361. * qdf_nbuf_mod_init() - Intialization routine for qdf_nbuf
  3362. *
  3363. * Return void
  3364. */
  3365. static inline void qdf_nbuf_mod_init(void)
  3366. {
  3367. return __qdf_nbuf_mod_init();
  3368. }
  3369. /**
  3370. * qdf_nbuf_mod_init() - Unintialization routine for qdf_nbuf
  3371. *
  3372. * Return void
  3373. */
  3374. static inline void qdf_nbuf_mod_exit(void)
  3375. {
  3376. return __qdf_nbuf_mod_exit();
  3377. }
  3378. /**
  3379. * qdf_nbuf_orphan() - orphan a nbuf
  3380. * @buf: Pointer to network buffer
  3381. *
  3382. * If a buffer currently has an owner then we call the
  3383. * owner's destructor function
  3384. *
  3385. * Return: void
  3386. */
  3387. static inline void qdf_nbuf_orphan(qdf_nbuf_t buf)
  3388. {
  3389. return __qdf_nbuf_orphan(buf);
  3390. }
  3391. /**
  3392. * qdf_nbuf_get_frag_size_by_idx() - Get size of nbuf frag at index idx
  3393. * @nbuf: qdf_nbuf_t
  3394. * @idx: Frag index for which frag size is requested
  3395. *
  3396. * Return: Frag size
  3397. */
  3398. static inline unsigned int qdf_nbuf_get_frag_size_by_idx(qdf_nbuf_t nbuf,
  3399. uint8_t idx)
  3400. {
  3401. return __qdf_nbuf_get_frag_size_by_idx(nbuf, idx);
  3402. }
  3403. /**
  3404. * qdf_nbuf_get_frag_addr() - Get nbuf frag address at index idx
  3405. * @nbuf: qdf_nbuf_t
  3406. * @idx: Frag index for which frag address is requested
  3407. *
  3408. * Return: Frag address
  3409. */
  3410. static inline qdf_frag_t qdf_nbuf_get_frag_addr(qdf_nbuf_t nbuf, uint8_t idx)
  3411. {
  3412. return __qdf_nbuf_get_frag_addr(nbuf, idx);
  3413. }
  3414. /**
  3415. * qdf_nbuf_trim_add_frag_size() - Increase/Decrease frag_size by size
  3416. * @nbuf: qdf_nbuf_t
  3417. * @idx: Frag index
  3418. * @size: Size by which frag_size needs to be increased/decreased
  3419. * +Ve means increase, -Ve means decrease
  3420. * @truesize: truesize
  3421. */
  3422. static inline void qdf_nbuf_trim_add_frag_size(qdf_nbuf_t nbuf, uint8_t idx,
  3423. int size, unsigned int truesize)
  3424. {
  3425. __qdf_nbuf_trim_add_frag_size(nbuf, idx, size, truesize);
  3426. }
  3427. /**
  3428. * qdf_nbuf_set_mark() - Set nbuf mark
  3429. * @nbuf: qdf_nbuf_t
  3430. * @mark: Value to set mark
  3431. *
  3432. * Return: none
  3433. */
  3434. static inline void qdf_nbuf_set_mark(qdf_nbuf_t nbuf, uint32_t mark)
  3435. {
  3436. __qdf_nbuf_set_mark(nbuf, mark);
  3437. }
  3438. /**
  3439. * qdf_nbuf_get_mark() - Get nbuf mark
  3440. * @nbuf: qdf_nbuf_t
  3441. *
  3442. * Return: mark value
  3443. */
  3444. static inline uint32_t qdf_nbuf_get_mark(qdf_nbuf_t nbuf)
  3445. {
  3446. return __qdf_nbuf_get_mark(nbuf);
  3447. }
  3448. /**
  3449. * qdf_nbuf_get_data_len() - Return the size of the nbuf from
  3450. * data pointer to end pointer
  3451. * @nbuf: qdf_nbuf_t
  3452. *
  3453. * Return: size of network buffer from data pointer to end
  3454. * pointer
  3455. */
  3456. static inline qdf_size_t qdf_nbuf_get_data_len(qdf_nbuf_t nbuf)
  3457. {
  3458. return __qdf_nbuf_get_data_len(nbuf);
  3459. }
  3460. #ifdef NBUF_FRAG_MEMORY_DEBUG
  3461. #define qdf_nbuf_move_frag_page_offset(f, i, o) \
  3462. qdf_nbuf_move_frag_page_offset_debug(f, i, o, __func__, __LINE__)
  3463. /**
  3464. * qdf_nbuf_move_frag_page_offset_debug() - Move frag page_offset by size
  3465. * and adjust length by size.
  3466. * @nbuf: qdf_nbuf_t
  3467. * @idx: Frag index
  3468. * @offset: Frag page offset should be moved by offset.
  3469. * +Ve - Move offset forward.
  3470. * -Ve - Move offset backward.
  3471. * @func: Caller function name
  3472. * @line: Caller function line no.
  3473. *
  3474. * Return: QDF_STATUS
  3475. */
  3476. QDF_STATUS qdf_nbuf_move_frag_page_offset_debug(qdf_nbuf_t nbuf, uint8_t idx,
  3477. int offset, const char *func,
  3478. uint32_t line);
  3479. #define qdf_nbuf_add_rx_frag(f, b, o, l, s, r) \
  3480. qdf_nbuf_add_rx_frag_debug(f, b, o, l, s, r, __func__, __LINE__)
  3481. /**
  3482. * qdf_nbuf_add_rx_frag_debug() - Add frag to nbuf at index frag_idx
  3483. * @buf: Frag pointer needs to be added in nbuf
  3484. * @nbuf: qdf_nbuf_t where frag will be added
  3485. * @offset: Offset in frag to be added to nbuf_frags
  3486. * @frag_len: Frag length
  3487. * @truesize: truesize
  3488. * @take_frag_ref: Whether to take ref for frag or not
  3489. * This bool must be set as per below comdition:
  3490. * 1. False: If this frag is being added in any nbuf
  3491. * for the first time after allocation
  3492. * 2. True: If frag is already attached part of any
  3493. * nbuf
  3494. * @func: Caller function name
  3495. * @line: Caller function line no.
  3496. *
  3497. * Return: none
  3498. */
  3499. void qdf_nbuf_add_rx_frag_debug(qdf_frag_t buf, qdf_nbuf_t nbuf,
  3500. int offset, int frag_len,
  3501. unsigned int truesize, bool take_frag_ref,
  3502. const char *func, uint32_t line);
  3503. /**
  3504. * qdf_net_buf_debug_acquire_frag() - Add frag nodes to frag debug tracker
  3505. * when nbuf is received from network stack
  3506. * @buf: qdf_nbuf_t
  3507. * @func: Caller function name
  3508. * @line: Caller function line no.
  3509. *
  3510. * Return: none
  3511. */
  3512. void qdf_net_buf_debug_acquire_frag(qdf_nbuf_t buf, const char *func,
  3513. uint32_t line);
  3514. /**
  3515. * qdf_net_buf_debug_release_frag() - Update frag nodes in frag debug tracker
  3516. * when nbuf is sent to network stack
  3517. * @buf: qdf_nbuf_t
  3518. * @func: Caller function name
  3519. * @line: Caller function line no.
  3520. *
  3521. * Return: none
  3522. */
  3523. void qdf_net_buf_debug_release_frag(qdf_nbuf_t buf, const char *func,
  3524. uint32_t line);
  3525. #else /* NBUF_FRAG_MEMORY_DEBUG */
  3526. /**
  3527. * qdf_nbuf_move_frag_page_offset() - Move frag page_offset by size
  3528. * and adjust length by size.
  3529. * @nbuf: qdf_nbuf_t
  3530. * @idx: Frag index
  3531. * @offset: Frag page offset should be moved by offset.
  3532. * +Ve - Move offset forward.
  3533. * -Ve - Move offset backward.
  3534. */
  3535. static inline QDF_STATUS qdf_nbuf_move_frag_page_offset(qdf_nbuf_t nbuf,
  3536. uint8_t idx,
  3537. int offset)
  3538. {
  3539. return __qdf_nbuf_move_frag_page_offset(nbuf, idx, offset);
  3540. }
  3541. /**
  3542. * qdf_nbuf_add_rx_frag() - Add frag to nbuf at index frag_idx
  3543. * @buf: Frag pointer needs to be added in nbuf frag
  3544. * @nbuf: qdf_nbuf_t where frag will be added
  3545. * @offset: Offset in frag to be added to nbuf_frags
  3546. * @frag_len: Frag length
  3547. * @truesize: truesize
  3548. * @take_frag_ref: Whether to take ref for frag or not
  3549. * This bool must be set as per below comdition:
  3550. * 1. False: If this frag is being added in any nbuf
  3551. * for the first time after allocation
  3552. * 2. True: If frag is already attached part of any
  3553. * nbuf
  3554. *
  3555. * qdf_nbuf_add_rx_frag takes ref_count based on boolean flag take_frag_ref
  3556. */
  3557. static inline void qdf_nbuf_add_rx_frag(qdf_frag_t buf, qdf_nbuf_t nbuf,
  3558. int offset, int frag_len,
  3559. unsigned int truesize,
  3560. bool take_frag_ref)
  3561. {
  3562. __qdf_nbuf_add_rx_frag(buf, nbuf, offset,
  3563. frag_len, truesize, take_frag_ref);
  3564. }
  3565. static inline void qdf_net_buf_debug_acquire_frag(qdf_nbuf_t buf,
  3566. const char *func,
  3567. uint32_t line)
  3568. {
  3569. }
  3570. static inline void qdf_net_buf_debug_release_frag(qdf_nbuf_t buf,
  3571. const char *func,
  3572. uint32_t line)
  3573. {
  3574. }
  3575. #endif /* NBUF_FRAG_MEMORY_DEBUG */
  3576. #ifdef MEMORY_DEBUG
  3577. /**
  3578. * qdf_nbuf_acquire_track_lock - acquire the nbuf spinlock at the
  3579. * specified index
  3580. * @index: index to get the lock
  3581. * @irq_flag: lock flag for using nbuf lock
  3582. *
  3583. * Return: none
  3584. */
  3585. void qdf_nbuf_acquire_track_lock(uint32_t index,
  3586. unsigned long irq_flag);
  3587. /**
  3588. * qdf_nbuf_release_track_lock - release the nbuf spinlock at the
  3589. * specified index
  3590. * @index: index of the lock to be released
  3591. * @irq_flag: lock flag for using nbuf lock
  3592. *
  3593. * Return: none
  3594. */
  3595. void qdf_nbuf_release_track_lock(uint32_t index,
  3596. unsigned long irq_flag);
  3597. /**
  3598. * qdf_nbuf_get_track_tbl - get the QDF_NBUF_TRACK entry from the track
  3599. * table at the specified index
  3600. * @index: index to get the table entry
  3601. *
  3602. * Return: the QDF_NBUF_TRACK entry at the specified index in the table
  3603. */
  3604. QDF_NBUF_TRACK *qdf_nbuf_get_track_tbl(uint32_t index);
  3605. #endif /* MEMORY_DEBUG */
  3606. #ifdef CONFIG_NBUF_AP_PLATFORM
  3607. #include <i_qdf_nbuf_api_w.h>
  3608. #else
  3609. #include <i_qdf_nbuf_api_m.h>
  3610. #endif
  3611. #endif /* _QDF_NBUF_H */