qdf_nbuf.h 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043
  1. /*
  2. * Copyright (c) 2014-2016 The Linux Foundation. All rights reserved.
  3. *
  4. * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  5. *
  6. *
  7. * Permission to use, copy, modify, and/or distribute this software for
  8. * any purpose with or without fee is hereby granted, provided that the
  9. * above copyright notice and this permission notice appear in all
  10. * copies.
  11. *
  12. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  13. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  14. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  15. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  16. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  17. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  18. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  19. * PERFORMANCE OF THIS SOFTWARE.
  20. */
  21. /*
  22. * This file was originally distributed by Qualcomm Atheros, Inc.
  23. * under proprietary terms before Copyright ownership was assigned
  24. * to the Linux Foundation.
  25. */
  26. /**
  27. * DOC: qdf_nbuf_public network buffer API
  28. * This file defines the network buffer abstraction.
  29. */
  30. #ifndef _QDF_NBUF_H
  31. #define _QDF_NBUF_H
  32. #include <qdf_util.h>
  33. #include <qdf_types.h>
  34. #include <qdf_lock.h>
  35. #include <i_qdf_nbuf.h>
  36. #include <i_qdf_trace.h>
  37. #include <qdf_net_types.h>
  38. #define IPA_NBUF_OWNER_ID 0xaa55aa55
  39. #define QDF_NBUF_PKT_TRAC_TYPE_EAPOL 0x02
  40. #define QDF_NBUF_PKT_TRAC_TYPE_DHCP 0x04
  41. #define QDF_NBUF_PKT_TRAC_TYPE_MGMT_ACTION 0x08
  42. #define QDF_NBUF_PKT_TRAC_TYPE_ARP 0x10
  43. #define QDF_NBUF_PKT_TRAC_MAX_STRING 12
  44. #define QDF_NBUF_PKT_TRAC_PROTO_STRING 4
  45. #define QDF_NBUF_PKT_ERROR 1
  46. #define QDF_NBUF_TRAC_IPV4_OFFSET 14
  47. #define QDF_NBUF_TRAC_IPV4_HEADER_SIZE 20
  48. #define QDF_NBUF_TRAC_DHCP_SRV_PORT 67
  49. #define QDF_NBUF_TRAC_DHCP_CLI_PORT 68
  50. #define QDF_NBUF_TRAC_ETH_TYPE_OFFSET 12
  51. #define QDF_NBUF_TRAC_EAPOL_ETH_TYPE 0x888E
  52. #define QDF_NBUF_TRAC_WAPI_ETH_TYPE 0x88b4
  53. #define QDF_NBUF_TRAC_ARP_ETH_TYPE 0x0806
  54. #define QDF_NBUF_TRAC_IPV4_ETH_TYPE 0x0800
  55. #define QDF_NBUF_TRAC_IPV6_ETH_TYPE 0x86dd
  56. #define QDF_NBUF_DEST_MAC_OFFSET 0
  57. #define QDF_NBUF_SRC_MAC_OFFSET 6
  58. #define QDF_NBUF_TRAC_IPV4_PROTO_TYPE_OFFSET 23
  59. #define QDF_NBUF_TRAC_IPV4_DEST_ADDR_OFFSET 30
  60. #define QDF_NBUF_TRAC_IPV6_PROTO_TYPE_OFFSET 20
  61. #define QDF_NBUF_TRAC_IPV4_ADDR_MCAST_MASK 0xE0000000
  62. #define QDF_NBUF_TRAC_IPV4_ADDR_BCAST_MASK 0xF0000000
  63. #define QDF_NBUF_TRAC_ICMP_TYPE 1
  64. #define QDF_NBUF_TRAC_TCP_TYPE 6
  65. #define QDF_NBUF_TRAC_UDP_TYPE 17
  66. #define QDF_NBUF_TRAC_ICMPV6_TYPE 0x3a
  67. /* EAPOL Related MASK */
  68. #define EAPOL_PACKET_TYPE_OFFSET 15
  69. #define EAPOL_KEY_INFO_OFFSET 19
  70. #define EAPOL_PKT_LEN_OFFSET 16
  71. #define EAPOL_KEY_LEN_OFFSET 21
  72. #define EAPOL_MASK 0x8013
  73. #define EAPOL_M1_BIT_MASK 0x8000
  74. #define EAPOL_M2_BIT_MASK 0x0001
  75. #define EAPOL_M3_BIT_MASK 0x8013
  76. #define EAPOL_M4_BIT_MASK 0x0003
  77. /* Tracked Packet types */
  78. #define QDF_NBUF_TX_PKT_INVALID 0
  79. #define QDF_NBUF_TX_PKT_DATA_TRACK 1
  80. #define QDF_NBUF_TX_PKT_MGMT_TRACK 2
  81. /* Different Packet states */
  82. #define QDF_NBUF_TX_PKT_HDD 1
  83. #define QDF_NBUF_TX_PKT_TXRX_ENQUEUE 2
  84. #define QDF_NBUF_TX_PKT_TXRX_DEQUEUE 3
  85. #define QDF_NBUF_TX_PKT_TXRX 4
  86. #define QDF_NBUF_TX_PKT_HTT 5
  87. #define QDF_NBUF_TX_PKT_HTC 6
  88. #define QDF_NBUF_TX_PKT_HIF 7
  89. #define QDF_NBUF_TX_PKT_CE 8
  90. #define QDF_NBUF_TX_PKT_FREE 9
  91. #define QDF_NBUF_TX_PKT_STATE_MAX 10
  92. /**
  93. * struct mon_rx_status - This will have monitor mode rx_status extracted from
  94. * htt_rx_desc used later to update radiotap information.
  95. * @tsft: Time Synchronization Function timer
  96. * @chan_freq: Capture channel frequency
  97. * @chan_num: Capture channel number
  98. * @chan_flags: Bitmap of Channel flags, IEEE80211_CHAN_TURBO,
  99. * IEEE80211_CHAN_CCK...
  100. * @vht_flags: VHT flgs, only present for VHT frames.
  101. * @vht_flag_values1-5: Contains corresponding data for flags field
  102. * @rate: Rate in terms 500Kbps
  103. * @rtap_flags: Bit map of available fields in the radiotap
  104. * @ant_signal_db: Rx packet RSSI
  105. * @nr_ant: Number of Antennas used for streaming
  106. * @mcs: MCS index of Rx frame
  107. * @is_stbc: Is STBC enabled
  108. * @sgi: Rx frame short guard interval
  109. * @ldpc: ldpc enabled
  110. * @beamformed: Is frame beamformed.
  111. */
  112. struct mon_rx_status {
  113. uint64_t tsft;
  114. uint16_t chan_freq;
  115. uint16_t chan_num;
  116. uint16_t chan_flags;
  117. uint16_t vht_flags;
  118. uint16_t vht_flag_values6;
  119. uint8_t rate;
  120. uint8_t rtap_flags;
  121. uint8_t ant_signal_db;
  122. uint8_t nr_ant;
  123. uint8_t mcs;
  124. uint8_t vht_flag_values1;
  125. uint8_t vht_flag_values2;
  126. uint8_t vht_flag_values3[4];
  127. uint8_t vht_flag_values4;
  128. uint8_t vht_flag_values5;
  129. uint8_t is_stbc;
  130. uint8_t sgi;
  131. uint8_t ldpc;
  132. uint8_t beamformed;
  133. };
  134. /* DHCP Related Mask */
  135. #define QDF_DHCP_OPTION53 (0x35)
  136. #define QDF_DHCP_OPTION53_LENGTH (1)
  137. #define QDF_DHCP_OPTION53_OFFSET (0x11A)
  138. #define QDF_DHCP_OPTION53_LENGTH_OFFSET (0x11B)
  139. #define QDF_DHCP_OPTION53_STATUS_OFFSET (0x11C)
  140. #define DHCP_PKT_LEN_OFFSET 16
  141. #define DHCP_TRANSACTION_ID_OFFSET 46
  142. #define QDF_DHCP_DISCOVER (1)
  143. #define QDF_DHCP_OFFER (2)
  144. #define QDF_DHCP_REQUEST (3)
  145. #define QDF_DHCP_DECLINE (4)
  146. #define QDF_DHCP_ACK (5)
  147. #define QDF_DHCP_NAK (6)
  148. #define QDF_DHCP_RELEASE (7)
  149. #define QDF_DHCP_INFORM (8)
  150. /* ARP Related Mask */
  151. #define ARP_SUB_TYPE_OFFSET 20
  152. #define ARP_REQUEST (1)
  153. #define ARP_RESPONSE (2)
  154. /* IPV4 Related Mask */
  155. #define IPV4_PKT_LEN_OFFSET 16
  156. #define IPV4_TCP_SEQ_NUM_OFFSET 38
  157. #define IPV4_SRC_PORT_OFFSET 34
  158. #define IPV4_DST_PORT_OFFSET 36
  159. /* IPV4 ICMP Related Mask */
  160. #define ICMP_SEQ_NUM_OFFSET 40
  161. #define ICMP_SUBTYPE_OFFSET 34
  162. #define ICMP_REQUEST 0x08
  163. #define ICMP_RESPONSE 0x00
  164. /* IPV6 Related Mask */
  165. #define IPV6_PKT_LEN_OFFSET 18
  166. #define IPV6_TCP_SEQ_NUM_OFFSET 58
  167. #define IPV6_SRC_PORT_OFFSET 54
  168. #define IPV6_DST_PORT_OFFSET 56
  169. /* IPV6 ICMPV6 Related Mask */
  170. #define ICMPV6_SEQ_NUM_OFFSET 60
  171. #define ICMPV6_SUBTYPE_OFFSET 54
  172. #define ICMPV6_REQUEST 0x80
  173. #define ICMPV6_RESPONSE 0x81
  174. #define QDF_NBUF_IPA_CHECK_MASK 0x80000000
  175. /**
  176. * qdf_proto_type - protocol type
  177. * @QDF_PROTO_TYPE_DHCP - DHCP
  178. * @QDF_PROTO_TYPE_EAPOL - EAPOL
  179. * @QDF_PROTO_TYPE_ARP - ARP
  180. * @QDF_PROTO_TYPE_MGMT - MGMT
  181. */
  182. enum qdf_proto_type {
  183. QDF_PROTO_TYPE_DHCP,
  184. QDF_PROTO_TYPE_EAPOL,
  185. QDF_PROTO_TYPE_ARP,
  186. QDF_PROTO_TYPE_MGMT,
  187. QDF_PROTO_TYPE_MAX
  188. };
  189. /**
  190. * qdf_proto_subtype - subtype of packet
  191. * @QDF_PROTO_EAPOL_M1 - EAPOL 1/4
  192. * @QDF_PROTO_EAPOL_M2 - EAPOL 2/4
  193. * @QDF_PROTO_EAPOL_M3 - EAPOL 3/4
  194. * @QDF_PROTO_EAPOL_M4 - EAPOL 4/4
  195. * @QDF_PROTO_DHCP_DISCOVER - discover
  196. * @QDF_PROTO_DHCP_REQUEST - request
  197. * @QDF_PROTO_DHCP_OFFER - offer
  198. * @QDF_PROTO_DHCP_ACK - ACK
  199. * @QDF_PROTO_DHCP_NACK - NACK
  200. * @QDF_PROTO_DHCP_RELEASE - release
  201. * @QDF_PROTO_DHCP_INFORM - inform
  202. * @QDF_PROTO_DHCP_DECLINE - decline
  203. * @QDF_PROTO_ARP_REQ - arp request
  204. * @QDF_PROTO_ARP_RES - arp response
  205. * @QDF_PROTO_ICMP_REQ - icmp request
  206. * @QDF_PROTO_ICMP_RES - icmp response
  207. * @QDF_PROTO_ICMPV6_REQ - icmpv6 request
  208. * @QDF_PROTO_ICMPV6_RES - icmpv6 response
  209. * @QDF_PROTO_IPV4_UDP - ipv4 udp
  210. * @QDF_PROTO_IPV4_TCP - ipv4 tcp
  211. * @QDF_PROTO_IPV6_UDP - ipv6 udp
  212. * @QDF_PROTO_IPV6_TCP - ipv6 tcp
  213. * @QDF_PROTO_MGMT_ASSOC -assoc
  214. * @QDF_PROTO_MGMT_DISASSOC - disassoc
  215. * @QDF_PROTO_MGMT_AUTH - auth
  216. * @QDF_PROTO_MGMT_DEAUTH - deauth
  217. */
  218. enum qdf_proto_subtype {
  219. QDF_PROTO_INVALID,
  220. QDF_PROTO_EAPOL_M1,
  221. QDF_PROTO_EAPOL_M2,
  222. QDF_PROTO_EAPOL_M3,
  223. QDF_PROTO_EAPOL_M4,
  224. QDF_PROTO_DHCP_DISCOVER,
  225. QDF_PROTO_DHCP_REQUEST,
  226. QDF_PROTO_DHCP_OFFER,
  227. QDF_PROTO_DHCP_ACK,
  228. QDF_PROTO_DHCP_NACK,
  229. QDF_PROTO_DHCP_RELEASE,
  230. QDF_PROTO_DHCP_INFORM,
  231. QDF_PROTO_DHCP_DECLINE,
  232. QDF_PROTO_ARP_REQ,
  233. QDF_PROTO_ARP_RES,
  234. QDF_PROTO_ICMP_REQ,
  235. QDF_PROTO_ICMP_RES,
  236. QDF_PROTO_ICMPV6_REQ,
  237. QDF_PROTO_ICMPV6_RES,
  238. QDF_PROTO_IPV4_UDP,
  239. QDF_PROTO_IPV4_TCP,
  240. QDF_PROTO_IPV6_UDP,
  241. QDF_PROTO_IPV6_TCP,
  242. QDF_PROTO_MGMT_ASSOC,
  243. QDF_PROTO_MGMT_DISASSOC,
  244. QDF_PROTO_MGMT_AUTH,
  245. QDF_PROTO_MGMT_DEAUTH,
  246. QDF_PROTO_SUBTYPE_MAX
  247. };
  248. /**
  249. * @qdf_nbuf_t - Platform indepedent packet abstraction
  250. */
  251. typedef __qdf_nbuf_t qdf_nbuf_t;
  252. /**
  253. * @qdf_dma_map_cb_t - Dma map callback prototype
  254. */
  255. typedef void (*qdf_dma_map_cb_t)(void *arg, qdf_nbuf_t buf,
  256. qdf_dma_map_t dmap);
  257. /**
  258. * @qdf_nbuf_queue_t - Platform independent packet queue abstraction
  259. */
  260. typedef __qdf_nbuf_queue_t qdf_nbuf_queue_t;
  261. /* BUS/DMA mapping routines */
  262. static inline QDF_STATUS
  263. qdf_nbuf_dmamap_create(qdf_device_t osdev, qdf_dma_map_t *dmap)
  264. {
  265. return __qdf_nbuf_dmamap_create(osdev, dmap);
  266. }
  267. static inline void
  268. qdf_nbuf_dmamap_destroy(qdf_device_t osdev, qdf_dma_map_t dmap)
  269. {
  270. __qdf_nbuf_dmamap_destroy(osdev, dmap);
  271. }
  272. static inline void
  273. qdf_nbuf_dmamap_set_cb(qdf_dma_map_t dmap, qdf_dma_map_cb_t cb, void *arg)
  274. {
  275. __qdf_nbuf_dmamap_set_cb(dmap, cb, arg);
  276. }
  277. static inline void
  278. qdf_nbuf_set_send_complete_flag(qdf_nbuf_t buf, bool flag)
  279. {
  280. __qdf_nbuf_set_send_complete_flag(buf, flag);
  281. }
  282. static inline QDF_STATUS
  283. qdf_nbuf_map(qdf_device_t osdev, qdf_nbuf_t buf, qdf_dma_dir_t dir)
  284. {
  285. return __qdf_nbuf_map(osdev, buf, dir);
  286. }
  287. static inline void
  288. qdf_nbuf_unmap(qdf_device_t osdev, qdf_nbuf_t buf, qdf_dma_dir_t dir)
  289. {
  290. __qdf_nbuf_unmap(osdev, buf, dir);
  291. }
  292. static inline QDF_STATUS
  293. qdf_nbuf_map_nbytes(qdf_device_t osdev, qdf_nbuf_t buf,
  294. qdf_dma_dir_t dir, int nbytes)
  295. {
  296. return __qdf_nbuf_map_nbytes(osdev, buf, dir, nbytes);
  297. }
  298. static inline void
  299. qdf_nbuf_unmap_nbytes(qdf_device_t osdev,
  300. qdf_nbuf_t buf, qdf_dma_dir_t dir, int nbytes)
  301. {
  302. __qdf_nbuf_unmap_nbytes(osdev, buf, dir, nbytes);
  303. }
  304. #ifndef REMOVE_INIT_DEBUG_CODE
  305. static inline void
  306. qdf_nbuf_sync_for_cpu(qdf_device_t osdev, qdf_nbuf_t buf, qdf_dma_dir_t dir)
  307. {
  308. __qdf_nbuf_sync_for_cpu(osdev, buf, dir);
  309. }
  310. #endif
  311. static inline QDF_STATUS
  312. qdf_nbuf_map_single(qdf_device_t osdev, qdf_nbuf_t buf, qdf_dma_dir_t dir)
  313. {
  314. return __qdf_nbuf_map_single(osdev, buf, dir);
  315. }
  316. static inline QDF_STATUS
  317. qdf_nbuf_map_nbytes_single(
  318. qdf_device_t osdev, qdf_nbuf_t buf, qdf_dma_dir_t dir, int nbytes)
  319. {
  320. return __qdf_nbuf_map_nbytes_single(osdev, buf, dir, nbytes);
  321. }
  322. static inline void
  323. qdf_nbuf_unmap_single(qdf_device_t osdev, qdf_nbuf_t buf, qdf_dma_dir_t dir)
  324. {
  325. __qdf_nbuf_unmap_single(osdev, buf, dir);
  326. }
  327. static inline void
  328. qdf_nbuf_unmap_nbytes_single(
  329. qdf_device_t osdev, qdf_nbuf_t buf, qdf_dma_dir_t dir, int nbytes)
  330. {
  331. return __qdf_nbuf_unmap_nbytes_single(osdev, buf, dir, nbytes);
  332. }
  333. static inline int qdf_nbuf_get_num_frags(qdf_nbuf_t buf)
  334. {
  335. return __qdf_nbuf_get_num_frags(buf);
  336. }
  337. /**
  338. * qdf_nbuf_get_frag_len() - get fragment length
  339. * @buf: Network buffer
  340. * @frag_num: Fragment number
  341. *
  342. * Return: Fragment length
  343. */
  344. static inline int qdf_nbuf_get_frag_len(qdf_nbuf_t buf, int frag_num)
  345. {
  346. QDF_BUG(!(frag_num >= QDF_NBUF_CB_TX_MAX_EXTRA_FRAGS));
  347. return __qdf_nbuf_get_frag_len(buf, frag_num);
  348. }
  349. /**
  350. * qdf_nbuf_get_frag_vaddr() - get fragment virtual address
  351. * @buf: Network buffer
  352. * @frag_num: Fragment number
  353. *
  354. * Return: Fragment virtual address
  355. */
  356. static inline unsigned char *qdf_nbuf_get_frag_vaddr(qdf_nbuf_t buf,
  357. int frag_num)
  358. {
  359. QDF_BUG(!(frag_num >= QDF_NBUF_CB_TX_MAX_EXTRA_FRAGS));
  360. return __qdf_nbuf_get_frag_vaddr(buf, frag_num);
  361. }
  362. /**
  363. * qdf_nbuf_get_frag_vaddr_always() - get fragment virtual address
  364. * @buf: Network buffer
  365. *
  366. * Return: Fragment virtual address
  367. */
  368. static inline unsigned char *
  369. qdf_nbuf_get_frag_vaddr_always(qdf_nbuf_t buf)
  370. {
  371. return __qdf_nbuf_get_frag_vaddr_always(buf);
  372. }
  373. /**
  374. * qdf_nbuf_get_frag_paddr() - get fragment physical address
  375. * @buf: Network buffer
  376. * @frag_num: Fragment number
  377. *
  378. * Return: Fragment physical address
  379. */
  380. static inline qdf_dma_addr_t qdf_nbuf_get_frag_paddr(qdf_nbuf_t buf,
  381. unsigned int frag_num)
  382. {
  383. QDF_BUG(!(frag_num >= QDF_NBUF_CB_TX_MAX_EXTRA_FRAGS));
  384. return __qdf_nbuf_get_frag_paddr(buf, frag_num);
  385. }
  386. /**
  387. * qdf_nbuf_get_frag_is_wordstream() - is fragment wordstream
  388. * @buf: Network buffer
  389. * @frag_num: Fragment number
  390. *
  391. * Return: Fragment wordstream or not
  392. */
  393. static inline int qdf_nbuf_get_frag_is_wordstream(qdf_nbuf_t buf, int frag_num)
  394. {
  395. QDF_BUG(!(frag_num >= QDF_NBUF_CB_TX_MAX_EXTRA_FRAGS));
  396. return __qdf_nbuf_get_frag_is_wordstream(buf, frag_num);
  397. }
  398. static inline int qdf_nbuf_ipa_owned_get(qdf_nbuf_t buf)
  399. {
  400. return __qdf_nbuf_ipa_owned_get(buf);
  401. }
  402. static inline void qdf_nbuf_ipa_owned_set(qdf_nbuf_t buf)
  403. {
  404. __qdf_nbuf_ipa_owned_set(buf);
  405. }
  406. static inline int qdf_nbuf_ipa_priv_get(qdf_nbuf_t buf)
  407. {
  408. return __qdf_nbuf_ipa_priv_get(buf);
  409. }
  410. static inline void qdf_nbuf_ipa_priv_set(qdf_nbuf_t buf, uint32_t priv)
  411. {
  412. QDF_BUG(!(priv & QDF_NBUF_IPA_CHECK_MASK));
  413. __qdf_nbuf_ipa_priv_set(buf, priv);
  414. }
  415. /**
  416. * qdf_nbuf_set_frag_is_wordstream() - set fragment wordstream
  417. * @buf: Network buffer
  418. * @frag_num: Fragment number
  419. * @is_wordstream: Wordstream
  420. *
  421. * Return: none
  422. */
  423. static inline void
  424. qdf_nbuf_set_frag_is_wordstream(qdf_nbuf_t buf,
  425. int frag_num, int is_wordstream)
  426. {
  427. QDF_BUG(!(frag_num >= QDF_NBUF_CB_TX_MAX_EXTRA_FRAGS));
  428. __qdf_nbuf_set_frag_is_wordstream(buf, frag_num, is_wordstream);
  429. }
  430. static inline void
  431. qdf_nbuf_set_vdev_ctx(qdf_nbuf_t buf, void *vdev_ctx)
  432. {
  433. __qdf_nbuf_set_vdev_ctx(buf, vdev_ctx);
  434. }
  435. static inline void
  436. qdf_nbuf_set_fctx_type(qdf_nbuf_t buf, void *ctx, uint8_t type)
  437. {
  438. __qdf_nbuf_set_fctx_type(buf, ctx, type);
  439. }
  440. static inline void *
  441. qdf_nbuf_get_vdev_ctx(qdf_nbuf_t buf)
  442. {
  443. return __qdf_nbuf_get_vdev_ctx(buf);
  444. }
  445. static inline void *qdf_nbuf_get_fctx(qdf_nbuf_t buf)
  446. {
  447. return __qdf_nbuf_get_fctx(buf);
  448. }
  449. static inline uint8_t qdf_nbuf_get_ftype(qdf_nbuf_t buf)
  450. {
  451. return __qdf_nbuf_get_ftype(buf);
  452. }
  453. static inline qdf_dma_addr_t
  454. qdf_nbuf_mapped_paddr_get(qdf_nbuf_t buf)
  455. {
  456. return __qdf_nbuf_mapped_paddr_get(buf);
  457. }
  458. static inline void
  459. qdf_nbuf_mapped_paddr_set(qdf_nbuf_t buf, qdf_dma_addr_t paddr)
  460. {
  461. __qdf_nbuf_mapped_paddr_set(buf, paddr);
  462. }
  463. static inline void
  464. qdf_nbuf_frag_push_head(qdf_nbuf_t buf,
  465. int frag_len, char *frag_vaddr,
  466. qdf_dma_addr_t frag_paddr)
  467. {
  468. __qdf_nbuf_frag_push_head(buf, frag_len, frag_vaddr, frag_paddr);
  469. }
  470. #define qdf_nbuf_num_frags_init(_nbuf) __qdf_nbuf_num_frags_init((_nbuf))
  471. /* For efficiency, it is the responsibility of the caller to ensure that val
  472. * is either 0 or 1.
  473. */
  474. static inline void
  475. qdf_nbuf_set_chfrag_start(qdf_nbuf_t buf, uint8_t val)
  476. {
  477. __qdf_nbuf_set_chfrag_start(buf, val);
  478. }
  479. static inline int qdf_nbuf_is_chfrag_start(qdf_nbuf_t buf)
  480. {
  481. return __qdf_nbuf_is_chfrag_start(buf);
  482. }
  483. /* For efficiency, it is the responsibility of the caller to ensure that val
  484. * is either 0 or 1.
  485. */
  486. static inline void qdf_nbuf_set_chfrag_end(qdf_nbuf_t buf, uint8_t val)
  487. {
  488. __qdf_nbuf_set_chfrag_end(buf, val);
  489. }
  490. static inline int qdf_nbuf_is_chfrag_end(qdf_nbuf_t buf)
  491. {
  492. return __qdf_nbuf_is_chfrag_end(buf);
  493. }
  494. static inline void
  495. qdf_nbuf_dma_map_info(qdf_dma_map_t bmap, qdf_dmamap_info_t *sg)
  496. {
  497. __qdf_nbuf_dma_map_info(bmap, sg);
  498. }
  499. #ifdef MEMORY_DEBUG
  500. void qdf_net_buf_debug_init(void);
  501. void qdf_net_buf_debug_exit(void);
  502. void qdf_net_buf_debug_clean(void);
  503. void qdf_net_buf_debug_add_node(qdf_nbuf_t net_buf, size_t size,
  504. uint8_t *file_name, uint32_t line_num);
  505. void qdf_net_buf_debug_delete_node(qdf_nbuf_t net_buf);
  506. void qdf_net_buf_debug_release_skb(qdf_nbuf_t net_buf);
  507. /* nbuf allocation rouines */
  508. #define qdf_nbuf_alloc(d, s, r, a, p) \
  509. qdf_nbuf_alloc_debug(d, s, r, a, p, __FILE__, __LINE__)
  510. static inline qdf_nbuf_t
  511. qdf_nbuf_alloc_debug(qdf_device_t osdev, qdf_size_t size, int reserve,
  512. int align, int prio, uint8_t *file_name,
  513. uint32_t line_num)
  514. {
  515. qdf_nbuf_t net_buf;
  516. net_buf = __qdf_nbuf_alloc(osdev, size, reserve, align, prio);
  517. /* Store SKB in internal QDF tracking table */
  518. if (qdf_likely(net_buf))
  519. qdf_net_buf_debug_add_node(net_buf, size, file_name, line_num);
  520. return net_buf;
  521. }
  522. static inline void qdf_nbuf_free(qdf_nbuf_t net_buf)
  523. {
  524. /* Remove SKB from internal QDF tracking table */
  525. if (qdf_likely(net_buf))
  526. qdf_net_buf_debug_delete_node(net_buf);
  527. __qdf_nbuf_free(net_buf);
  528. }
  529. #else
  530. static inline void qdf_net_buf_debug_release_skb(qdf_nbuf_t net_buf)
  531. {
  532. return;
  533. }
  534. /* Nbuf allocation rouines */
  535. static inline qdf_nbuf_t
  536. qdf_nbuf_alloc(qdf_device_t osdev,
  537. qdf_size_t size, int reserve, int align, int prio)
  538. {
  539. return __qdf_nbuf_alloc(osdev, size, reserve, align, prio);
  540. }
  541. static inline void qdf_nbuf_free(qdf_nbuf_t buf)
  542. {
  543. __qdf_nbuf_free(buf);
  544. }
  545. #endif
  546. #ifdef WLAN_FEATURE_FASTPATH
  547. /**
  548. * qdf_nbuf_init_fast() - before put buf into pool,turn it to init state
  549. *
  550. * @buf: buf instance
  551. * Return: data pointer of this buf where new data has to be
  552. * put, or NULL if there is not enough room in this buf.
  553. */
  554. static inline void qdf_nbuf_init_fast(qdf_nbuf_t nbuf)
  555. {
  556. atomic_set(&nbuf->users, 1);
  557. nbuf->data = nbuf->head + NET_SKB_PAD;
  558. skb_reset_tail_pointer(nbuf);
  559. }
  560. #endif /* WLAN_FEATURE_FASTPATH */
  561. static inline void qdf_nbuf_tx_free(qdf_nbuf_t buf_list, int tx_err)
  562. {
  563. __qdf_nbuf_tx_free(buf_list, tx_err);
  564. }
  565. static inline void qdf_nbuf_ref(qdf_nbuf_t buf)
  566. {
  567. __qdf_nbuf_ref(buf);
  568. }
  569. static inline int qdf_nbuf_shared(qdf_nbuf_t buf)
  570. {
  571. return __qdf_nbuf_shared(buf);
  572. }
  573. static inline qdf_nbuf_t qdf_nbuf_copy(qdf_nbuf_t buf)
  574. {
  575. return __qdf_nbuf_copy(buf);
  576. }
  577. static inline QDF_STATUS qdf_nbuf_cat(qdf_nbuf_t dst, qdf_nbuf_t src)
  578. {
  579. return __qdf_nbuf_cat(dst, src);
  580. }
  581. /**
  582. * @qdf_nbuf_copy_bits() - return the length of the copy bits for skb
  583. * @skb: SKB pointer
  584. * @offset: offset
  585. * @len: Length
  586. * @to: To
  587. *
  588. * Return: int32_t
  589. */
  590. static inline int32_t
  591. qdf_nbuf_copy_bits(qdf_nbuf_t nbuf, uint32_t offset, uint32_t len, void *to)
  592. {
  593. return __qdf_nbuf_copy_bits(nbuf, offset, len, to);
  594. }
  595. /**
  596. * qdf_nbuf_clone() - clone the nbuf (copy is readonly)
  597. * @buf: nbuf to clone from
  598. *
  599. * Return: cloned buffer
  600. */
  601. static inline qdf_nbuf_t qdf_nbuf_clone(qdf_nbuf_t buf)
  602. {
  603. return __qdf_nbuf_clone(buf);
  604. }
  605. /* nbuf manipulation routines */
  606. /**
  607. * @qdf_nbuf_head() - return the address of an nbuf's buffer
  608. * @buf: netbuf
  609. *
  610. * Return: head address
  611. */
  612. static inline uint8_t *qdf_nbuf_head(qdf_nbuf_t buf)
  613. {
  614. return __qdf_nbuf_head(buf);
  615. }
  616. /**
  617. * qdf_nbuf_data() - Return the address of the start of data within an nbuf
  618. * @buf: Network buffer
  619. *
  620. * Return: Data address
  621. */
  622. static inline uint8_t *qdf_nbuf_data(qdf_nbuf_t buf)
  623. {
  624. return __qdf_nbuf_data(buf);
  625. }
  626. /**
  627. * qdf_nbuf_data_addr() - Return the address of skb->data
  628. * @buf: Network buffer
  629. *
  630. * Return: Data address
  631. */
  632. static inline uint8_t *qdf_nbuf_data_addr(qdf_nbuf_t buf)
  633. {
  634. return __qdf_nbuf_data_addr(buf);
  635. }
  636. /**
  637. * qdf_nbuf_headroom() - amount of headroom int the current nbuf
  638. * @buf: Network buffer
  639. *
  640. * Return: Amount of head room
  641. */
  642. static inline uint32_t qdf_nbuf_headroom(qdf_nbuf_t buf)
  643. {
  644. return __qdf_nbuf_headroom(buf);
  645. }
  646. /**
  647. * qdf_nbuf_tailroom() - amount of tail space available
  648. * @buf: Network buffer
  649. *
  650. * Return: amount of tail room
  651. */
  652. static inline uint32_t qdf_nbuf_tailroom(qdf_nbuf_t buf)
  653. {
  654. return __qdf_nbuf_tailroom(buf);
  655. }
  656. /**
  657. * qdf_nbuf_push_head() - push data in the front
  658. * @buf: Network buf instance
  659. * @size: Size to be pushed
  660. *
  661. * Return: New data pointer of this buf after data has been pushed,
  662. * or NULL if there is not enough room in this buf.
  663. */
  664. static inline uint8_t *qdf_nbuf_push_head(qdf_nbuf_t buf, qdf_size_t size)
  665. {
  666. return __qdf_nbuf_push_head(buf, size);
  667. }
  668. /**
  669. * qdf_nbuf_put_tail() - puts data in the end
  670. * @buf: Network buf instance
  671. * @size: Size to be pushed
  672. *
  673. * Return: Data pointer of this buf where new data has to be
  674. * put, or NULL if there is not enough room in this buf.
  675. */
  676. static inline uint8_t *qdf_nbuf_put_tail(qdf_nbuf_t buf, qdf_size_t size)
  677. {
  678. return __qdf_nbuf_put_tail(buf, size);
  679. }
  680. /**
  681. * qdf_nbuf_pull_head() - pull data out from the front
  682. * @buf: Network buf instance
  683. * @size: Size to be popped
  684. *
  685. * Return: New data pointer of this buf after data has been popped,
  686. * or NULL if there is not sufficient data to pull.
  687. */
  688. static inline uint8_t *qdf_nbuf_pull_head(qdf_nbuf_t buf, qdf_size_t size)
  689. {
  690. return __qdf_nbuf_pull_head(buf, size);
  691. }
  692. /**
  693. * qdf_nbuf_trim_tail() - trim data out from the end
  694. * @buf: Network buf instance
  695. * @size: Size to be popped
  696. *
  697. * Return: none
  698. */
  699. static inline void qdf_nbuf_trim_tail(qdf_nbuf_t buf, qdf_size_t size)
  700. {
  701. __qdf_nbuf_trim_tail(buf, size);
  702. }
  703. /**
  704. * qdf_nbuf_len() - get the length of the buf
  705. * @buf: Network buf instance
  706. *
  707. * Return: total length of this buf.
  708. */
  709. static inline qdf_size_t qdf_nbuf_len(qdf_nbuf_t buf)
  710. {
  711. return __qdf_nbuf_len(buf);
  712. }
  713. /**
  714. * qdf_nbuf_set_pktlen() - set the length of the buf
  715. * @buf: Network buf instance
  716. * @size: Size to be set
  717. *
  718. * Return: none
  719. */
  720. static inline void qdf_nbuf_set_pktlen(qdf_nbuf_t buf, uint32_t len)
  721. {
  722. __qdf_nbuf_set_pktlen(buf, len);
  723. }
  724. /**
  725. * qdf_nbuf_reserve() - trim data out from the end
  726. * @buf: Network buf instance
  727. * @size: Size to be popped
  728. *
  729. * Return: none
  730. */
  731. static inline void qdf_nbuf_reserve(qdf_nbuf_t buf, qdf_size_t size)
  732. {
  733. __qdf_nbuf_reserve(buf, size);
  734. }
  735. /**
  736. * qdf_nbuf_peek_header() - return the data pointer & length of the header
  737. * @buf: Network nbuf
  738. * @addr: Data pointer
  739. * @len: Length of the data
  740. *
  741. * Return: none
  742. */
  743. static inline void
  744. qdf_nbuf_peek_header(qdf_nbuf_t buf, uint8_t **addr, uint32_t *len)
  745. {
  746. __qdf_nbuf_peek_header(buf, addr, len);
  747. }
  748. /* nbuf queue routines */
  749. /**
  750. * qdf_nbuf_queue_init() - initialize buf queue
  751. * @head: Network buf queue head
  752. *
  753. * Return: none
  754. */
  755. static inline void qdf_nbuf_queue_init(qdf_nbuf_queue_t *head)
  756. {
  757. __qdf_nbuf_queue_init(head);
  758. }
  759. /**
  760. * qdf_nbuf_queue_add() - append a nbuf to the tail of the buf queue
  761. * @head: Network buf queue head
  762. * @buf: Network buf
  763. *
  764. * Return: none
  765. */
  766. static inline void qdf_nbuf_queue_add(qdf_nbuf_queue_t *head, qdf_nbuf_t buf)
  767. {
  768. __qdf_nbuf_queue_add(head, buf);
  769. }
  770. /**
  771. * qdf_nbuf_queue_insert_head() - insert nbuf at the head of queue
  772. * @head: Network buf queue head
  773. * @buf: Network buf
  774. *
  775. * Return: none
  776. */
  777. static inline void
  778. qdf_nbuf_queue_insert_head(qdf_nbuf_queue_t *head, qdf_nbuf_t buf)
  779. {
  780. __qdf_nbuf_queue_insert_head(head, buf);
  781. }
  782. /**
  783. * qdf_nbuf_queue_remove() - retrieve a buf from the head of the buf queue
  784. * @head: Network buf queue head
  785. *
  786. * Return: The head buf in the buf queue.
  787. */
  788. static inline qdf_nbuf_t qdf_nbuf_queue_remove(qdf_nbuf_queue_t *head)
  789. {
  790. return __qdf_nbuf_queue_remove(head);
  791. }
  792. /**
  793. * qdf_nbuf_queue_len() - get the length of the queue
  794. * @head: Network buf queue head
  795. *
  796. * Return: length of the queue
  797. */
  798. static inline uint32_t qdf_nbuf_queue_len(qdf_nbuf_queue_t *head)
  799. {
  800. return __qdf_nbuf_queue_len(head);
  801. }
  802. /**
  803. * qdf_nbuf_queue_next() - get the next guy/packet of the given buffer
  804. * @buf: Network buffer
  805. *
  806. * Return: next buffer/packet
  807. */
  808. static inline qdf_nbuf_t qdf_nbuf_queue_next(qdf_nbuf_t buf)
  809. {
  810. return __qdf_nbuf_queue_next(buf);
  811. }
  812. /**
  813. * @qdf_nbuf_is_queue_empty() - check if the buf queue is empty
  814. * @nbq: Network buf queue handle
  815. *
  816. * Return: true if queue is empty
  817. * false if queue is not emty
  818. */
  819. static inline bool qdf_nbuf_is_queue_empty(qdf_nbuf_queue_t *nbq)
  820. {
  821. return __qdf_nbuf_is_queue_empty(nbq);
  822. }
  823. static inline qdf_nbuf_queue_t *
  824. qdf_nbuf_queue_append(qdf_nbuf_queue_t *dest, qdf_nbuf_queue_t *src)
  825. {
  826. return __qdf_nbuf_queue_append(dest, src);
  827. }
  828. static inline void
  829. qdf_nbuf_queue_free(qdf_nbuf_queue_t *head)
  830. {
  831. __qdf_nbuf_queue_free(head);
  832. }
  833. static inline qdf_nbuf_t
  834. qdf_nbuf_queue_first(qdf_nbuf_queue_t *head)
  835. {
  836. return __qdf_nbuf_queue_first(head);
  837. }
  838. /**
  839. * qdf_nbuf_next() - get the next packet in the linked list
  840. * @buf: Network buffer
  841. *
  842. * This function can be used when nbufs are directly linked into a list,
  843. * rather than using a separate network buffer queue object.
  844. *
  845. * Return: next network buffer in the linked list
  846. */
  847. static inline qdf_nbuf_t qdf_nbuf_next(qdf_nbuf_t buf)
  848. {
  849. return __qdf_nbuf_next(buf);
  850. }
  851. /**
  852. * qdf_nbuf_get_protocol() - return the protocol value of the skb
  853. * @skb: Pointer to network buffer
  854. *
  855. * Return: skb protocol
  856. */
  857. static inline uint16_t qdf_nbuf_get_protocol(struct sk_buff *skb)
  858. {
  859. return __qdf_nbuf_get_protocol(skb);
  860. }
  861. /**
  862. * qdf_nbuf_get_ip_summed() - return the ip checksum value of the skb
  863. * @skb: Pointer to network buffer
  864. *
  865. * Return: skb ip_summed
  866. */
  867. static inline uint8_t qdf_nbuf_get_ip_summed(struct sk_buff *skb)
  868. {
  869. return __qdf_nbuf_get_ip_summed(skb);
  870. }
  871. /**
  872. * qdf_nbuf_set_ip_summed() - sets the ip_summed value of the skb
  873. * @skb: Pointer to network buffer
  874. * @ip_summed: ip checksum
  875. *
  876. * Return: none
  877. */
  878. static inline void qdf_nbuf_set_ip_summed(struct sk_buff *skb,
  879. uint8_t ip_summed)
  880. {
  881. __qdf_nbuf_set_ip_summed(skb, ip_summed);
  882. }
  883. /**
  884. * qdf_nbuf_set_next() - add a packet to a linked list
  885. * @this_buf: Predecessor buffer
  886. * @next_buf: Successor buffer
  887. *
  888. * This function can be used to directly link nbufs, rather than using
  889. * a separate network buffer queue object.
  890. *
  891. * Return: none
  892. */
  893. static inline void qdf_nbuf_set_next(qdf_nbuf_t this_buf, qdf_nbuf_t next_buf)
  894. {
  895. __qdf_nbuf_set_next(this_buf, next_buf);
  896. }
  897. /* nbuf extension routines */
  898. /**
  899. * qdf_nbuf_set_next_ext() - link extension of this packet contained in a new
  900. * nbuf
  901. * @this_buf: predecessor buffer
  902. * @next_buf: successor buffer
  903. *
  904. * This function is used to link up many nbufs containing a single logical
  905. * packet - not a collection of packets. Do not use for linking the first
  906. * extension to the head
  907. *
  908. * Return: none
  909. */
  910. static inline void
  911. qdf_nbuf_set_next_ext(qdf_nbuf_t this_buf, qdf_nbuf_t next_buf)
  912. {
  913. __qdf_nbuf_set_next_ext(this_buf, next_buf);
  914. }
  915. /**
  916. * qdf_nbuf_next_ext() - get the next packet extension in the linked list
  917. * @buf: Network buffer
  918. *
  919. * Return: Next network buffer in the linked list
  920. */
  921. static inline qdf_nbuf_t qdf_nbuf_next_ext(qdf_nbuf_t buf)
  922. {
  923. return __qdf_nbuf_next_ext(buf);
  924. }
  925. /**
  926. * qdf_nbuf_append_ext_list() - link list of packet extensions to the head
  927. * segment
  928. * @head_buf: Network buf holding head segment (single)
  929. * @ext_list: Network buf list holding linked extensions to the head
  930. * @ext_len: Total length of all buffers in the extension list
  931. *
  932. * This function is used to link up a list of packet extensions (seg1, 2,
  933. * ...) to the nbuf holding the head segment (seg0)
  934. *
  935. * Return: none
  936. */
  937. static inline void
  938. qdf_nbuf_append_ext_list(qdf_nbuf_t head_buf, qdf_nbuf_t ext_list,
  939. qdf_size_t ext_len)
  940. {
  941. __qdf_nbuf_append_ext_list(head_buf, ext_list, ext_len);
  942. }
  943. /**
  944. * qdf_nbuf_get_ext_list() - Get the link to extended nbuf list.
  945. * @head_buf: Network buf holding head segment (single)
  946. *
  947. * This ext_list is populated when we have Jumbo packet, for example in case of
  948. * monitor mode amsdu packet reception, and are stiched using frags_list.
  949. *
  950. * Return: Network buf list holding linked extensions from head buf.
  951. */
  952. static inline qdf_nbuf_t qdf_nbuf_get_ext_list(qdf_nbuf_t head_buf)
  953. {
  954. return (qdf_nbuf_t)__qdf_nbuf_get_ext_list(head_buf);
  955. }
  956. /**
  957. * qdf_nbuf_get_tx_cksum() - gets the tx checksum offload demand
  958. * @buf: Network buffer
  959. *
  960. * Return: qdf_nbuf_tx_cksum_t checksum offload demand for the frame
  961. */
  962. static inline qdf_nbuf_tx_cksum_t qdf_nbuf_get_tx_cksum(qdf_nbuf_t buf)
  963. {
  964. return __qdf_nbuf_get_tx_cksum(buf);
  965. }
  966. /**
  967. * qdf_nbuf_set_rx_cksum() - drivers that support hw checksumming use this to
  968. * indicate checksum info to the stack.
  969. * @buf: Network buffer
  970. * @cksum: Checksum
  971. *
  972. * Return: none
  973. */
  974. static inline void
  975. qdf_nbuf_set_rx_cksum(qdf_nbuf_t buf, qdf_nbuf_rx_cksum_t *cksum)
  976. {
  977. __qdf_nbuf_set_rx_cksum(buf, cksum);
  978. }
  979. /**
  980. * qdf_nbuf_get_tid() - this function extracts the TID value from nbuf
  981. * @buf: Network buffer
  982. *
  983. * Return: TID value
  984. */
  985. static inline uint8_t qdf_nbuf_get_tid(qdf_nbuf_t buf)
  986. {
  987. return __qdf_nbuf_get_tid(buf);
  988. }
  989. /**
  990. * qdf_nbuf_set_tid() - this function sets the TID value in nbuf
  991. * @buf: Network buffer
  992. * @tid: TID value
  993. *
  994. * Return: none
  995. */
  996. static inline void qdf_nbuf_set_tid(qdf_nbuf_t buf, uint8_t tid)
  997. {
  998. __qdf_nbuf_set_tid(buf, tid);
  999. }
  1000. /**
  1001. * qdf_nbuf_get_exemption_type() - this function extracts the exemption type
  1002. * from nbuf
  1003. * @buf: Network buffer
  1004. *
  1005. * Return: Exemption type
  1006. */
  1007. static inline uint8_t qdf_nbuf_get_exemption_type(qdf_nbuf_t buf)
  1008. {
  1009. return __qdf_nbuf_get_exemption_type(buf);
  1010. }
  1011. /**
  1012. * qdf_nbuf_set_protocol() - this function peeks data into the buffer at given
  1013. * offset
  1014. * @buf: Network buffer
  1015. * @proto: Protocol
  1016. *
  1017. * Return: none
  1018. */
  1019. static inline void qdf_nbuf_set_protocol(qdf_nbuf_t buf, uint16_t proto)
  1020. {
  1021. __qdf_nbuf_set_protocol(buf, proto);
  1022. }
  1023. /**
  1024. * qdf_nbuf_trace_get_proto_type() - this function return packet proto type
  1025. * @buf: Network buffer
  1026. *
  1027. * Return: Packet protocol type
  1028. */
  1029. static inline uint8_t qdf_nbuf_trace_get_proto_type(qdf_nbuf_t buf)
  1030. {
  1031. return __qdf_nbuf_trace_get_proto_type(buf);
  1032. }
  1033. /**
  1034. * qdf_nbuf_reg_trace_cb() - this function registers protocol trace callback
  1035. * @cb_func_ptr: Callback pointer
  1036. *
  1037. * Return: none
  1038. */
  1039. static inline void qdf_nbuf_reg_trace_cb(qdf_nbuf_trace_update_t cb_func_ptr)
  1040. {
  1041. __qdf_nbuf_reg_trace_cb(cb_func_ptr);
  1042. }
  1043. /**
  1044. * qdf_nbuf_set_tx_parallel_dnload_frm() - set tx parallel download
  1045. * @buf: Network buffer
  1046. * @candi: Candidate of parallel download frame
  1047. *
  1048. * This function stores a flag specifying this TX frame is suitable for
  1049. * downloading though a 2nd TX data pipe that is used for short frames for
  1050. * protocols that can accept out-of-order delivery.
  1051. *
  1052. * Return: none
  1053. */
  1054. static inline void
  1055. qdf_nbuf_set_tx_parallel_dnload_frm(qdf_nbuf_t buf, uint8_t candi)
  1056. {
  1057. __qdf_nbuf_set_tx_htt2_frm(buf, candi);
  1058. }
  1059. /**
  1060. * qdf_nbuf_get_tx_parallel_dnload_frm() - get tx parallel download
  1061. * @buf: Network buffer
  1062. *
  1063. * This function return whether this TX frame is allow to download though a 2nd
  1064. * TX data pipe or not.
  1065. *
  1066. * Return: none
  1067. */
  1068. static inline uint8_t qdf_nbuf_get_tx_parallel_dnload_frm(qdf_nbuf_t buf)
  1069. {
  1070. return __qdf_nbuf_get_tx_htt2_frm(buf);
  1071. }
  1072. /**
  1073. * qdf_nbuf_get_dhcp_subtype() - get the subtype
  1074. * of DHCP packet.
  1075. * @buf: Pointer to DHCP packet buffer
  1076. *
  1077. * This func. returns the subtype of DHCP packet.
  1078. *
  1079. * Return: subtype of the DHCP packet.
  1080. */
  1081. static inline enum qdf_proto_subtype
  1082. qdf_nbuf_get_dhcp_subtype(qdf_nbuf_t buf)
  1083. {
  1084. return __qdf_nbuf_data_get_dhcp_subtype(qdf_nbuf_data(buf));
  1085. }
  1086. /**
  1087. * qdf_nbuf_data_get_dhcp_subtype() - get the subtype
  1088. * of DHCP packet.
  1089. * @buf: Pointer to DHCP packet data buffer
  1090. *
  1091. * This func. returns the subtype of DHCP packet.
  1092. *
  1093. * Return: subtype of the DHCP packet.
  1094. */
  1095. static inline enum qdf_proto_subtype
  1096. qdf_nbuf_data_get_dhcp_subtype(uint8_t *data)
  1097. {
  1098. return __qdf_nbuf_data_get_dhcp_subtype(data);
  1099. }
  1100. /**
  1101. * qdf_nbuf_get_eapol_subtype() - get the subtype
  1102. * of EAPOL packet.
  1103. * @buf: Pointer to EAPOL packet buffer
  1104. *
  1105. * This func. returns the subtype of EAPOL packet.
  1106. *
  1107. * Return: subtype of the EAPOL packet.
  1108. */
  1109. static inline enum qdf_proto_subtype
  1110. qdf_nbuf_get_eapol_subtype(qdf_nbuf_t buf)
  1111. {
  1112. return __qdf_nbuf_data_get_eapol_subtype(qdf_nbuf_data(buf));
  1113. }
  1114. /**
  1115. * qdf_nbuf_data_get_eapol_subtype() - get the subtype
  1116. * of EAPOL packet.
  1117. * @data: Pointer to EAPOL packet data buffer
  1118. *
  1119. * This func. returns the subtype of EAPOL packet.
  1120. *
  1121. * Return: subtype of the EAPOL packet.
  1122. */
  1123. static inline enum qdf_proto_subtype
  1124. qdf_nbuf_data_get_eapol_subtype(uint8_t *data)
  1125. {
  1126. return __qdf_nbuf_data_get_eapol_subtype(data);
  1127. }
  1128. /**
  1129. * qdf_nbuf_get_arp_subtype() - get the subtype
  1130. * of ARP packet.
  1131. * @buf: Pointer to ARP packet buffer
  1132. *
  1133. * This func. returns the subtype of ARP packet.
  1134. *
  1135. * Return: subtype of the ARP packet.
  1136. */
  1137. static inline enum qdf_proto_subtype
  1138. qdf_nbuf_get_arp_subtype(qdf_nbuf_t buf)
  1139. {
  1140. return __qdf_nbuf_data_get_arp_subtype(qdf_nbuf_data(buf));
  1141. }
  1142. /**
  1143. * qdf_nbuf_data_get_arp_subtype() - get the subtype
  1144. * of ARP packet.
  1145. * @data: Pointer to ARP packet data buffer
  1146. *
  1147. * This func. returns the subtype of ARP packet.
  1148. *
  1149. * Return: subtype of the ARP packet.
  1150. */
  1151. static inline enum qdf_proto_subtype
  1152. qdf_nbuf_data_get_arp_subtype(uint8_t *data)
  1153. {
  1154. return __qdf_nbuf_data_get_arp_subtype(data);
  1155. }
  1156. /**
  1157. * qdf_nbuf_get_icmp_subtype() - get the subtype
  1158. * of IPV4 ICMP packet.
  1159. * @buf: Pointer to IPV4 ICMP packet buffer
  1160. *
  1161. * This func. returns the subtype of ICMP packet.
  1162. *
  1163. * Return: subtype of the ICMP packet.
  1164. */
  1165. static inline enum qdf_proto_subtype
  1166. qdf_nbuf_get_icmp_subtype(qdf_nbuf_t buf)
  1167. {
  1168. return __qdf_nbuf_data_get_icmp_subtype(qdf_nbuf_data(buf));
  1169. }
  1170. /**
  1171. * qdf_nbuf_data_get_icmp_subtype() - get the subtype
  1172. * of IPV4 ICMP packet.
  1173. * @data: Pointer to IPV4 ICMP packet data buffer
  1174. *
  1175. * This func. returns the subtype of ICMP packet.
  1176. *
  1177. * Return: subtype of the ICMP packet.
  1178. */
  1179. static inline enum qdf_proto_subtype
  1180. qdf_nbuf_data_get_icmp_subtype(uint8_t *data)
  1181. {
  1182. return __qdf_nbuf_data_get_icmp_subtype(data);
  1183. }
  1184. /**
  1185. * qdf_nbuf_get_icmpv6_subtype() - get the subtype
  1186. * of IPV6 ICMPV6 packet.
  1187. * @buf: Pointer to IPV6 ICMPV6 packet buffer
  1188. *
  1189. * This func. returns the subtype of ICMPV6 packet.
  1190. *
  1191. * Return: subtype of the ICMPV6 packet.
  1192. */
  1193. static inline enum qdf_proto_subtype
  1194. qdf_nbuf_get_icmpv6_subtype(qdf_nbuf_t buf)
  1195. {
  1196. return __qdf_nbuf_data_get_icmpv6_subtype(qdf_nbuf_data(buf));
  1197. }
  1198. /**
  1199. * qdf_nbuf_data_get_icmpv6_subtype() - get the subtype
  1200. * of IPV6 ICMPV6 packet.
  1201. * @data: Pointer to IPV6 ICMPV6 packet data buffer
  1202. *
  1203. * This func. returns the subtype of ICMPV6 packet.
  1204. *
  1205. * Return: subtype of the ICMPV6 packet.
  1206. */
  1207. static inline enum qdf_proto_subtype
  1208. qdf_nbuf_data_get_icmpv6_subtype(uint8_t *data)
  1209. {
  1210. return __qdf_nbuf_data_get_icmpv6_subtype(data);
  1211. }
  1212. /**
  1213. * qdf_nbuf_data_get_ipv4_proto() - get the proto type
  1214. * of IPV4 packet.
  1215. * @data: Pointer to IPV4 packet data buffer
  1216. *
  1217. * This func. returns the proto type of IPV4 packet.
  1218. *
  1219. * Return: proto type of IPV4 packet.
  1220. */
  1221. static inline uint8_t
  1222. qdf_nbuf_data_get_ipv4_proto(uint8_t *data)
  1223. {
  1224. return __qdf_nbuf_data_get_ipv4_proto(data);
  1225. }
  1226. /**
  1227. * qdf_nbuf_data_get_ipv6_proto() - get the proto type
  1228. * of IPV6 packet.
  1229. * @data: Pointer to IPV6 packet data buffer
  1230. *
  1231. * This func. returns the proto type of IPV6 packet.
  1232. *
  1233. * Return: proto type of IPV6 packet.
  1234. */
  1235. static inline uint8_t
  1236. qdf_nbuf_data_get_ipv6_proto(uint8_t *data)
  1237. {
  1238. return __qdf_nbuf_data_get_ipv6_proto(data);
  1239. }
  1240. /**
  1241. * qdf_nbuf_is_ipv4_pkt() - check if packet is a ipv4 packet or not
  1242. * @buf: buffer
  1243. *
  1244. * This api is for Tx packets.
  1245. *
  1246. * Return: true if packet is ipv4 packet
  1247. */
  1248. static inline
  1249. bool qdf_nbuf_is_ipv4_pkt(qdf_nbuf_t buf)
  1250. {
  1251. return __qdf_nbuf_data_is_ipv4_pkt(qdf_nbuf_data(buf));
  1252. }
  1253. /**
  1254. * qdf_nbuf_data_is_ipv4_pkt() - check if packet is a ipv4 packet or not
  1255. * @data: data
  1256. *
  1257. * This api is for Tx packets.
  1258. *
  1259. * Return: true if packet is ipv4 packet
  1260. */
  1261. static inline
  1262. bool qdf_nbuf_data_is_ipv4_pkt(uint8_t *data)
  1263. {
  1264. return __qdf_nbuf_data_is_ipv4_pkt(data);
  1265. }
  1266. /**
  1267. * qdf_nbuf_is_ipv4_dhcp_pkt() - check if packet is a dhcp packet or not
  1268. * @buf: buffer
  1269. *
  1270. * This api is for ipv4 packet.
  1271. *
  1272. * Return: true if packet is DHCP packet
  1273. */
  1274. static inline
  1275. bool qdf_nbuf_is_ipv4_dhcp_pkt(qdf_nbuf_t buf)
  1276. {
  1277. return __qdf_nbuf_data_is_ipv4_dhcp_pkt(qdf_nbuf_data(buf));
  1278. }
  1279. /**
  1280. * qdf_nbuf_data_is_ipv4_dhcp_pkt() - check if it is DHCP packet.
  1281. * @data: Pointer to DHCP packet data buffer
  1282. *
  1283. * This func. checks whether it is a DHCP packet or not.
  1284. *
  1285. * Return: true if it is a DHCP packet
  1286. * false if not
  1287. */
  1288. static inline
  1289. bool qdf_nbuf_data_is_ipv4_dhcp_pkt(uint8_t *data)
  1290. {
  1291. return __qdf_nbuf_data_is_ipv4_dhcp_pkt(data);
  1292. }
  1293. /**
  1294. * qdf_nbuf_is_ipv4_eapol_pkt() - check if packet is a eapol packet or not
  1295. * @buf: buffer
  1296. *
  1297. * This api is for ipv4 packet.
  1298. *
  1299. * Return: true if packet is EAPOL packet
  1300. */
  1301. static inline
  1302. bool qdf_nbuf_is_ipv4_eapol_pkt(qdf_nbuf_t buf)
  1303. {
  1304. return __qdf_nbuf_data_is_ipv4_eapol_pkt(qdf_nbuf_data(buf));
  1305. }
  1306. /**
  1307. * qdf_nbuf_data_is_ipv4_eapol_pkt() - check if it is EAPOL packet.
  1308. * @data: Pointer to EAPOL packet data buffer
  1309. *
  1310. * This func. checks whether it is a EAPOL packet or not.
  1311. *
  1312. * Return: true if it is a EAPOL packet
  1313. * false if not
  1314. */
  1315. static inline
  1316. bool qdf_nbuf_data_is_ipv4_eapol_pkt(uint8_t *data)
  1317. {
  1318. return __qdf_nbuf_data_is_ipv4_eapol_pkt(data);
  1319. }
  1320. /**
  1321. * qdf_nbuf_is_ipv4_wapi_pkt() - check if packet is a wapi packet or not
  1322. * @buf: buffer
  1323. *
  1324. * This api is for ipv4 packet.
  1325. *
  1326. * Return: true if packet is WAPI packet
  1327. */
  1328. static inline
  1329. bool qdf_nbuf_is_ipv4_wapi_pkt(qdf_nbuf_t buf)
  1330. {
  1331. return __qdf_nbuf_is_ipv4_wapi_pkt(buf);
  1332. }
  1333. /**
  1334. * qdf_nbuf_is_ipv4_arp_pkt() - check if packet is a arp packet or not
  1335. * @buf: buffer
  1336. *
  1337. * This api is for ipv4 packet.
  1338. *
  1339. * Return: true if packet is ARP packet
  1340. */
  1341. static inline
  1342. bool qdf_nbuf_is_ipv4_arp_pkt(qdf_nbuf_t buf)
  1343. {
  1344. return __qdf_nbuf_data_is_ipv4_arp_pkt(qdf_nbuf_data(buf));
  1345. }
  1346. /**
  1347. * qdf_nbuf_data_is_ipv4_arp_pkt() - check if it is ARP packet.
  1348. * @data: Pointer to ARP packet data buffer
  1349. *
  1350. * This func. checks whether it is a ARP packet or not.
  1351. *
  1352. * Return: TRUE if it is a ARP packet
  1353. * FALSE if not
  1354. */
  1355. static inline
  1356. bool qdf_nbuf_data_is_ipv4_arp_pkt(uint8_t *data)
  1357. {
  1358. return __qdf_nbuf_data_is_ipv4_arp_pkt(data);
  1359. }
  1360. /**
  1361. * qdf_nbuf_is_ipv6_pkt() - check if it is IPV6 packet.
  1362. * @buf: Pointer to IPV6 packet buffer
  1363. *
  1364. * This func. checks whether it is a IPV6 packet or not.
  1365. *
  1366. * Return: TRUE if it is a IPV6 packet
  1367. * FALSE if not
  1368. */
  1369. static inline
  1370. bool qdf_nbuf_is_ipv6_pkt(qdf_nbuf_t buf)
  1371. {
  1372. return __qdf_nbuf_data_is_ipv6_pkt(qdf_nbuf_data(buf));
  1373. }
  1374. /**
  1375. * qdf_nbuf_data_is_ipv6_pkt() - check if it is IPV6 packet.
  1376. * @data: Pointer to IPV6 packet data buffer
  1377. *
  1378. * This func. checks whether it is a IPV6 packet or not.
  1379. *
  1380. * Return: TRUE if it is a IPV6 packet
  1381. * FALSE if not
  1382. */
  1383. static inline
  1384. bool qdf_nbuf_data_is_ipv6_pkt(uint8_t *data)
  1385. {
  1386. return __qdf_nbuf_data_is_ipv6_pkt(data);
  1387. }
  1388. /**
  1389. * qdf_nbuf_data_is_ipv4_mcast_pkt() - check if it is IPV4 multicast packet.
  1390. * @data: Pointer to IPV4 packet data buffer
  1391. *
  1392. * This func. checks whether it is a IPV4 multicast packet or not.
  1393. *
  1394. * Return: TRUE if it is a IPV4 multicast packet
  1395. * FALSE if not
  1396. */
  1397. static inline
  1398. bool qdf_nbuf_data_is_ipv4_mcast_pkt(uint8_t *data)
  1399. {
  1400. return __qdf_nbuf_data_is_ipv4_mcast_pkt(data);
  1401. }
  1402. /**
  1403. * qdf_nbuf_is_icmp_pkt() - check if it is IPV4 ICMP packet.
  1404. * @buf: Pointer to IPV4 ICMP packet buffer
  1405. *
  1406. * This func. checks whether it is a ICMP packet or not.
  1407. *
  1408. * Return: TRUE if it is a ICMP packet
  1409. * FALSE if not
  1410. */
  1411. static inline
  1412. bool qdf_nbuf_is_icmp_pkt(qdf_nbuf_t buf)
  1413. {
  1414. return __qdf_nbuf_data_is_icmp_pkt(qdf_nbuf_data(buf));
  1415. }
  1416. /**
  1417. * qdf_nbuf_data_is_icmp_pkt() - check if it is IPV4 ICMP packet.
  1418. * @data: Pointer to IPV4 ICMP packet data buffer
  1419. *
  1420. * This func. checks whether it is a ICMP packet or not.
  1421. *
  1422. * Return: TRUE if it is a ICMP packet
  1423. * FALSE if not
  1424. */
  1425. static inline
  1426. bool qdf_nbuf_data_is_icmp_pkt(uint8_t *data)
  1427. {
  1428. return __qdf_nbuf_data_is_icmp_pkt(data);
  1429. }
  1430. /**
  1431. * qdf_nbuf_is_icmpv6_pkt() - check if it is IPV6 ICMPV6 packet.
  1432. * @buf: Pointer to IPV6 ICMPV6 packet buffer
  1433. *
  1434. * This func. checks whether it is a ICMPV6 packet or not.
  1435. *
  1436. * Return: TRUE if it is a ICMPV6 packet
  1437. * FALSE if not
  1438. */
  1439. static inline
  1440. bool qdf_nbuf_is_icmpv6_pkt(qdf_nbuf_t buf)
  1441. {
  1442. return __qdf_nbuf_data_is_icmpv6_pkt(qdf_nbuf_data(buf));
  1443. }
  1444. /**
  1445. * qdf_nbuf_data_is_icmpv6_pkt() - check if it is IPV6 ICMPV6 packet.
  1446. * @data: Pointer to IPV6 ICMPV6 packet data buffer
  1447. *
  1448. * This func. checks whether it is a ICMPV6 packet or not.
  1449. *
  1450. * Return: TRUE if it is a ICMPV6 packet
  1451. * FALSE if not
  1452. */
  1453. static inline
  1454. bool qdf_nbuf_data_is_icmpv6_pkt(uint8_t *data)
  1455. {
  1456. return __qdf_nbuf_data_is_icmpv6_pkt(data);
  1457. }
  1458. /**
  1459. * qdf_nbuf_is_ipv4_udp_pkt() - check if it is IPV4 UDP packet.
  1460. * @buf: Pointer to IPV4 UDP packet buffer
  1461. *
  1462. * This func. checks whether it is a IPV4 UDP packet or not.
  1463. *
  1464. * Return: TRUE if it is a IPV4 UDP packet
  1465. * FALSE if not
  1466. */
  1467. static inline
  1468. bool qdf_nbuf_is_ipv4_udp_pkt(qdf_nbuf_t buf)
  1469. {
  1470. return __qdf_nbuf_data_is_ipv4_udp_pkt(qdf_nbuf_data(buf));
  1471. }
  1472. /**
  1473. * qdf_nbuf_data_is_ipv4_udp_pkt() - check if it is IPV4 UDP packet.
  1474. * @data: Pointer to IPV4 UDP packet data buffer
  1475. *
  1476. * This func. checks whether it is a IPV4 UDP packet or not.
  1477. *
  1478. * Return: TRUE if it is a IPV4 UDP packet
  1479. * FALSE if not
  1480. */
  1481. static inline
  1482. bool qdf_nbuf_data_is_ipv4_udp_pkt(uint8_t *data)
  1483. {
  1484. return __qdf_nbuf_data_is_ipv4_udp_pkt(data);
  1485. }
  1486. /**
  1487. * qdf_nbuf_is_ipv4_tcp_pkt() - check if it is IPV4 TCP packet.
  1488. * @buf: Pointer to IPV4 TCP packet buffer
  1489. *
  1490. * This func. checks whether it is a IPV4 TCP packet or not.
  1491. *
  1492. * Return: TRUE if it is a IPV4 TCP packet
  1493. * FALSE if not
  1494. */
  1495. static inline
  1496. bool qdf_nbuf_is_ipv4_tcp_pkt(qdf_nbuf_t buf)
  1497. {
  1498. return __qdf_nbuf_data_is_ipv4_tcp_pkt(qdf_nbuf_data(buf));
  1499. }
  1500. /**
  1501. * qdf_nbuf_data_is_ipv4_tcp_pkt() - check if it is IPV4 TCP packet.
  1502. * @data: Pointer to IPV4 TCP packet data buffer
  1503. *
  1504. * This func. checks whether it is a IPV4 TCP packet or not.
  1505. *
  1506. * Return: TRUE if it is a IPV4 TCP packet
  1507. * FALSE if not
  1508. */
  1509. static inline
  1510. bool qdf_nbuf_data_is_ipv4_tcp_pkt(uint8_t *data)
  1511. {
  1512. return __qdf_nbuf_data_is_ipv4_tcp_pkt(data);
  1513. }
  1514. /**
  1515. * qdf_nbuf_is_ipv6_udp_pkt() - check if it is IPV6 UDP packet.
  1516. * @buf: Pointer to IPV6 UDP packet buffer
  1517. *
  1518. * This func. checks whether it is a IPV6 UDP packet or not.
  1519. *
  1520. * Return: TRUE if it is a IPV6 UDP packet
  1521. * FALSE if not
  1522. */
  1523. static inline
  1524. bool qdf_nbuf_is_ipv6_udp_pkt(qdf_nbuf_t buf)
  1525. {
  1526. return __qdf_nbuf_data_is_ipv6_udp_pkt(qdf_nbuf_data(buf));
  1527. }
  1528. /**
  1529. * qdf_nbuf_data_is_ipv6_udp_pkt() - check if it is IPV6 UDP packet.
  1530. * @data: Pointer to IPV6 UDP packet data buffer
  1531. *
  1532. * This func. checks whether it is a IPV6 UDP packet or not.
  1533. *
  1534. * Return: TRUE if it is a IPV6 UDP packet
  1535. * FALSE if not
  1536. */
  1537. static inline
  1538. bool qdf_nbuf_data_is_ipv6_udp_pkt(uint8_t *data)
  1539. {
  1540. return __qdf_nbuf_data_is_ipv6_udp_pkt(data);
  1541. }
  1542. /**
  1543. * qdf_nbuf_is_ipv6_tcp_pkt() - check if it is IPV6 TCP packet.
  1544. * @buf: Pointer to IPV6 TCP packet buffer
  1545. *
  1546. * This func. checks whether it is a IPV6 TCP packet or not.
  1547. *
  1548. * Return: TRUE if it is a IPV6 TCP packet
  1549. * FALSE if not
  1550. */
  1551. static inline
  1552. bool qdf_nbuf_is_ipv6_tcp_pkt(qdf_nbuf_t buf)
  1553. {
  1554. return __qdf_nbuf_data_is_ipv6_tcp_pkt(qdf_nbuf_data(buf));
  1555. }
  1556. /**
  1557. * qdf_nbuf_data_is_ipv6_tcp_pkt() - check if it is IPV6 TCP packet.
  1558. * @data: Pointer to IPV6 TCP packet data buffer
  1559. *
  1560. * This func. checks whether it is a IPV6 TCP packet or not.
  1561. *
  1562. * Return: TRUE if it is a IPV6 TCP packet
  1563. * FALSE if not
  1564. */
  1565. static inline
  1566. bool qdf_nbuf_data_is_ipv6_tcp_pkt(uint8_t *data)
  1567. {
  1568. return __qdf_nbuf_data_is_ipv6_tcp_pkt(data);
  1569. }
  1570. /**
  1571. * qdf_invalidate_range() - invalidate virtual address range
  1572. * @start: start address of the address range
  1573. * @end: end address of the address range
  1574. *
  1575. * Note that this function does not write back the cache entries.
  1576. *
  1577. * Return: none
  1578. */
  1579. static inline void qdf_invalidate_range(void *start, void *end)
  1580. {
  1581. __qdf_invalidate_range(start, end);
  1582. }
  1583. /**
  1584. * qdf_nbuf_reset_num_frags() - decrement the number of fragments
  1585. * @buf: Network buffer
  1586. *
  1587. * Return: Number of fragments
  1588. */
  1589. static inline void qdf_nbuf_reset_num_frags(qdf_nbuf_t buf)
  1590. {
  1591. __qdf_nbuf_reset_num_frags(buf);
  1592. }
  1593. /**
  1594. * qdf_dmaaddr_to_32s - return high and low parts of dma_addr
  1595. *
  1596. * Returns the high and low 32-bits of the DMA addr in the provided ptrs
  1597. *
  1598. * Return: N/A
  1599. */
  1600. static inline void qdf_dmaaddr_to_32s(qdf_dma_addr_t dmaaddr,
  1601. uint32_t *lo, uint32_t *hi)
  1602. {
  1603. return __qdf_dmaaddr_to_32s(dmaaddr, lo, hi);
  1604. }
  1605. /**
  1606. * qdf_nbuf_is_tso() - is the network buffer a jumbo packet?
  1607. * @buf: Network buffer
  1608. *
  1609. * Return: 1 - this is a jumbo packet 0 - not a jumbo packet
  1610. */
  1611. static inline uint8_t qdf_nbuf_is_tso(qdf_nbuf_t nbuf)
  1612. {
  1613. return __qdf_nbuf_is_tso(nbuf);
  1614. }
  1615. /**
  1616. * qdf_nbuf_get_tso_info() - function to divide a jumbo TSO
  1617. * network buffer into segments
  1618. * @nbuf: network buffer to be segmented
  1619. * @tso_info: This is the output. The information about the
  1620. * TSO segments will be populated within this.
  1621. *
  1622. * This function fragments a TCP jumbo packet into smaller
  1623. * segments to be transmitted by the driver. It chains the TSO
  1624. * segments created into a list.
  1625. *
  1626. * Return: number of TSO segments
  1627. */
  1628. static inline uint32_t qdf_nbuf_get_tso_info(qdf_device_t osdev,
  1629. qdf_nbuf_t nbuf, struct qdf_tso_info_t *tso_info)
  1630. {
  1631. return __qdf_nbuf_get_tso_info(osdev, nbuf, tso_info);
  1632. }
  1633. /**
  1634. * qdf_nbuf_get_tso_num_seg() - function to calculate the number
  1635. * of TCP segments within the TSO jumbo packet
  1636. * @nbuf: TSO jumbo network buffer to be segmented
  1637. *
  1638. * This function calculates the number of TCP segments that the
  1639. network buffer can be divided into.
  1640. *
  1641. * Return: number of TCP segments
  1642. */
  1643. static inline uint32_t qdf_nbuf_get_tso_num_seg(qdf_nbuf_t nbuf)
  1644. {
  1645. return __qdf_nbuf_get_tso_num_seg(nbuf);
  1646. }
  1647. /**
  1648. * qdf_nbuf_inc_users() - function to increment the number of
  1649. * users referencing this network buffer
  1650. *
  1651. * @nbuf: network buffer
  1652. *
  1653. * This function increments the number of users referencing this
  1654. * network buffer
  1655. *
  1656. * Return: the network buffer
  1657. */
  1658. static inline qdf_nbuf_t qdf_nbuf_inc_users(qdf_nbuf_t nbuf)
  1659. {
  1660. return __qdf_nbuf_inc_users(nbuf);
  1661. }
  1662. /**
  1663. * qdf_nbuf_data_attr_get() - Get data_attr field from cvg_nbuf_cb
  1664. *
  1665. * @nbuf: Network buffer (skb on linux)
  1666. *
  1667. * This function returns the values of data_attr field
  1668. * in struct cvg_nbuf_cb{}, to which skb->cb is typecast.
  1669. * This value is actually the value programmed in CE descriptor.
  1670. *
  1671. * Return: Value of data_attr
  1672. */
  1673. static inline uint32_t qdf_nbuf_data_attr_get(qdf_nbuf_t buf)
  1674. {
  1675. return __qdf_nbuf_data_attr_get(buf);
  1676. }
  1677. /**
  1678. * qdf_nbuf_data_attr_set() - Sets data_attr field in cvg_nbuf_cb
  1679. *
  1680. * @nbuf: Network buffer (skb on linux)
  1681. * @data_attr: Value to be stored cvg_nbuf_cb->data_attr
  1682. *
  1683. * This function stores the value to be programmed in CE
  1684. * descriptor as part skb->cb which is typecast to struct cvg_nbuf_cb{}
  1685. *
  1686. * Return: void
  1687. */
  1688. static inline
  1689. void qdf_nbuf_data_attr_set(qdf_nbuf_t buf, uint32_t data_attr)
  1690. {
  1691. __qdf_nbuf_data_attr_set(buf, data_attr);
  1692. }
  1693. /**
  1694. * qdf_nbuf_tx_info_get() - Parse skb and get Tx metadata
  1695. *
  1696. * @nbuf: Network buffer (skb on linux)
  1697. *
  1698. * This function parses the payload to figure out relevant
  1699. * Tx meta-data e.g. whether to enable tx_classify bit
  1700. * in CE.
  1701. *
  1702. * Return: void
  1703. */
  1704. #define qdf_nbuf_tx_info_get __qdf_nbuf_tx_info_get
  1705. void qdf_nbuf_set_state(qdf_nbuf_t nbuf, uint8_t current_state);
  1706. void qdf_nbuf_tx_desc_count_display(void);
  1707. void qdf_nbuf_tx_desc_count_clear(void);
  1708. static inline qdf_nbuf_t
  1709. qdf_nbuf_realloc_headroom(qdf_nbuf_t buf, uint32_t headroom)
  1710. {
  1711. return __qdf_nbuf_realloc_headroom(buf, headroom);
  1712. }
  1713. static inline qdf_nbuf_t
  1714. qdf_nbuf_realloc_tailroom(qdf_nbuf_t buf, uint32_t tailroom)
  1715. {
  1716. return __qdf_nbuf_realloc_tailroom(buf, tailroom);
  1717. }
  1718. static inline qdf_nbuf_t
  1719. qdf_nbuf_expand(qdf_nbuf_t buf, uint32_t headroom, uint32_t tailroom)
  1720. {
  1721. return __qdf_nbuf_expand(buf, headroom, tailroom);
  1722. }
  1723. static inline qdf_nbuf_t
  1724. qdf_nbuf_unshare(qdf_nbuf_t buf)
  1725. {
  1726. return __qdf_nbuf_unshare(buf);
  1727. }
  1728. static inline bool
  1729. qdf_nbuf_is_cloned(qdf_nbuf_t buf)
  1730. {
  1731. return __qdf_nbuf_is_cloned(buf);
  1732. }
  1733. static inline void
  1734. qdf_nbuf_frag_info(qdf_nbuf_t buf, qdf_sglist_t *sg)
  1735. {
  1736. __qdf_nbuf_frag_info(buf, sg);
  1737. }
  1738. static inline qdf_nbuf_tx_cksum_t
  1739. qdf_nbuf_tx_cksum_info(qdf_nbuf_t buf, uint8_t **hdr_off, uint8_t **where)
  1740. {
  1741. return __qdf_nbuf_tx_cksum_info(buf, hdr_off, where);
  1742. }
  1743. static inline void qdf_nbuf_reset_ctxt(__qdf_nbuf_t nbuf)
  1744. {
  1745. __qdf_nbuf_reset_ctxt(nbuf);
  1746. }
  1747. static inline void
  1748. qdf_nbuf_set_rx_info(__qdf_nbuf_t nbuf, void *info, uint32_t len)
  1749. {
  1750. __qdf_nbuf_set_rx_info(nbuf, info, len);
  1751. }
  1752. static inline void *qdf_nbuf_get_rx_info(__qdf_nbuf_t nbuf)
  1753. {
  1754. return __qdf_nbuf_get_rx_info(nbuf);
  1755. }
  1756. static inline void qdf_nbuf_init(qdf_nbuf_t buf)
  1757. {
  1758. __qdf_nbuf_init(buf);
  1759. }
  1760. static inline void *qdf_nbuf_network_header(qdf_nbuf_t buf)
  1761. {
  1762. return __qdf_nbuf_network_header(buf);
  1763. }
  1764. static inline void *qdf_nbuf_transport_header(qdf_nbuf_t buf)
  1765. {
  1766. return __qdf_nbuf_transport_header(buf);
  1767. }
  1768. static inline qdf_size_t qdf_nbuf_tcp_tso_size(qdf_nbuf_t buf)
  1769. {
  1770. return __qdf_nbuf_tcp_tso_size(buf);
  1771. }
  1772. static inline void *qdf_nbuf_get_cb(qdf_nbuf_t nbuf)
  1773. {
  1774. return __qdf_nbuf_get_cb(nbuf);
  1775. }
  1776. static inline uint32_t qdf_nbuf_get_nr_frags(qdf_nbuf_t nbuf)
  1777. {
  1778. return __qdf_nbuf_get_nr_frags(nbuf);
  1779. }
  1780. static inline qdf_size_t qdf_nbuf_headlen(qdf_nbuf_t buf)
  1781. {
  1782. return __qdf_nbuf_headlen(buf);
  1783. }
  1784. static inline QDF_STATUS qdf_nbuf_frag_map(qdf_device_t osdev,
  1785. qdf_nbuf_t buf, int offset,
  1786. qdf_dma_dir_t dir, int cur_frag)
  1787. {
  1788. return __qdf_nbuf_frag_map(osdev, buf, offset, dir, cur_frag);
  1789. }
  1790. static inline bool qdf_nbuf_tso_tcp_v4(qdf_nbuf_t buf)
  1791. {
  1792. return __qdf_nbuf_tso_tcp_v4(buf);
  1793. }
  1794. static inline bool qdf_nbuf_tso_tcp_v6(qdf_nbuf_t buf)
  1795. {
  1796. return __qdf_nbuf_tso_tcp_v6(buf);
  1797. }
  1798. static inline uint32_t qdf_nbuf_tcp_seq(qdf_nbuf_t buf)
  1799. {
  1800. return __qdf_nbuf_tcp_seq(buf);
  1801. }
  1802. static inline qdf_size_t qdf_nbuf_l2l3l4_hdr_len(qdf_nbuf_t buf)
  1803. {
  1804. return __qdf_nbuf_l2l3l4_hdr_len(buf);
  1805. }
  1806. static inline bool qdf_nbuf_is_nonlinear(qdf_nbuf_t buf)
  1807. {
  1808. return __qdf_nbuf_is_nonlinear(buf);
  1809. }
  1810. static inline uint32_t
  1811. qdf_nbuf_get_frag_size(qdf_nbuf_t buf, uint32_t frag_num)
  1812. {
  1813. return __qdf_nbuf_get_frag_size(buf, frag_num);
  1814. }
  1815. static inline uint32_t qdf_nbuf_get_priority(qdf_nbuf_t buf)
  1816. {
  1817. return __qdf_nbuf_get_priority(buf);
  1818. }
  1819. static inline void qdf_nbuf_set_priority(qdf_nbuf_t buf, uint32_t p)
  1820. {
  1821. __qdf_nbuf_set_priority(buf, p);
  1822. }
  1823. static inline uint8_t *
  1824. qdf_nbuf_get_priv_ptr(qdf_nbuf_t buf)
  1825. {
  1826. return __qdf_nbuf_get_priv_ptr(buf);
  1827. }
  1828. /**
  1829. * qdf_nbuf_update_radiotap() - update radiotap at head of nbuf.
  1830. * @rx_status: rx_status containing required info to update radiotap
  1831. * @nbuf: Pointer to nbuf
  1832. * @headroom_sz: Available headroom size
  1833. *
  1834. * Return: radiotap length.
  1835. */
  1836. unsigned int qdf_nbuf_update_radiotap(struct mon_rx_status *rx_status,
  1837. qdf_nbuf_t nbuf, uint32_t headroom_sz);
  1838. #endif /* _QDF_NBUF_H */