qdf_nbuf.h 79 KB

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