qdf_nbuf.h 91 KB

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