qdf_nbuf.h 80 KB

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