qdf_nbuf.h 81 KB

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