qdf_nbuf.h 81 KB

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