qdf_nbuf.h 54 KB

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