qdf_nbuf.h 79 KB

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