qdf_nbuf.h 50 KB

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