qdf_nbuf.h 79 KB

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