qdf_nbuf.h 53 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207
  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. #ifndef REMOVE_INIT_DEBUG_CODE
  333. static inline void
  334. qdf_nbuf_sync_for_cpu(qdf_device_t osdev, qdf_nbuf_t buf, qdf_dma_dir_t dir)
  335. {
  336. __qdf_nbuf_sync_for_cpu(osdev, buf, dir);
  337. }
  338. #endif
  339. static inline QDF_STATUS
  340. qdf_nbuf_map_single(qdf_device_t osdev, qdf_nbuf_t buf, qdf_dma_dir_t dir)
  341. {
  342. return __qdf_nbuf_map_single(osdev, buf, dir);
  343. }
  344. static inline QDF_STATUS
  345. qdf_nbuf_map_nbytes_single(
  346. qdf_device_t osdev, qdf_nbuf_t buf, qdf_dma_dir_t dir, int nbytes)
  347. {
  348. return __qdf_nbuf_map_nbytes_single(osdev, buf, dir, nbytes);
  349. }
  350. static inline void
  351. qdf_nbuf_unmap_single(qdf_device_t osdev, qdf_nbuf_t buf, qdf_dma_dir_t dir)
  352. {
  353. __qdf_nbuf_unmap_single(osdev, buf, dir);
  354. }
  355. static inline void
  356. qdf_nbuf_unmap_nbytes_single(
  357. qdf_device_t osdev, qdf_nbuf_t buf, qdf_dma_dir_t dir, int nbytes)
  358. {
  359. return __qdf_nbuf_unmap_nbytes_single(osdev, buf, dir, nbytes);
  360. }
  361. static inline int qdf_nbuf_get_num_frags(qdf_nbuf_t buf)
  362. {
  363. return __qdf_nbuf_get_num_frags(buf);
  364. }
  365. /**
  366. * qdf_nbuf_get_frag_len() - get fragment length
  367. * @buf: Network buffer
  368. * @frag_num: Fragment number
  369. *
  370. * Return: Fragment length
  371. */
  372. static inline int qdf_nbuf_get_frag_len(qdf_nbuf_t buf, int frag_num)
  373. {
  374. QDF_BUG(!(frag_num >= QDF_NBUF_CB_TX_MAX_EXTRA_FRAGS));
  375. return __qdf_nbuf_get_frag_len(buf, frag_num);
  376. }
  377. /**
  378. * qdf_nbuf_get_frag_vaddr() - get fragment virtual address
  379. * @buf: Network buffer
  380. * @frag_num: Fragment number
  381. *
  382. * Return: Fragment virtual address
  383. */
  384. static inline unsigned char *qdf_nbuf_get_frag_vaddr(qdf_nbuf_t buf,
  385. int frag_num)
  386. {
  387. QDF_BUG(!(frag_num >= QDF_NBUF_CB_TX_MAX_EXTRA_FRAGS));
  388. return __qdf_nbuf_get_frag_vaddr(buf, frag_num);
  389. }
  390. /**
  391. * qdf_nbuf_get_frag_vaddr_always() - get fragment virtual address
  392. * @buf: Network buffer
  393. *
  394. * Return: Fragment virtual address
  395. */
  396. static inline unsigned char *
  397. qdf_nbuf_get_frag_vaddr_always(qdf_nbuf_t buf)
  398. {
  399. return __qdf_nbuf_get_frag_vaddr_always(buf);
  400. }
  401. /**
  402. * qdf_nbuf_get_frag_paddr() - get fragment physical address
  403. * @buf: Network buffer
  404. * @frag_num: Fragment number
  405. *
  406. * Return: Fragment physical address
  407. */
  408. static inline qdf_dma_addr_t qdf_nbuf_get_frag_paddr(qdf_nbuf_t buf,
  409. unsigned int frag_num)
  410. {
  411. QDF_BUG(!(frag_num >= QDF_NBUF_CB_TX_MAX_EXTRA_FRAGS));
  412. return __qdf_nbuf_get_frag_paddr(buf, frag_num);
  413. }
  414. /**
  415. * qdf_nbuf_get_frag_is_wordstream() - is fragment wordstream
  416. * @buf: Network buffer
  417. * @frag_num: Fragment number
  418. *
  419. * Return: Fragment wordstream or not
  420. */
  421. static inline int qdf_nbuf_get_frag_is_wordstream(qdf_nbuf_t buf, int frag_num)
  422. {
  423. QDF_BUG(!(frag_num >= QDF_NBUF_CB_TX_MAX_EXTRA_FRAGS));
  424. return __qdf_nbuf_get_frag_is_wordstream(buf, frag_num);
  425. }
  426. static inline int qdf_nbuf_ipa_owned_get(qdf_nbuf_t buf)
  427. {
  428. return __qdf_nbuf_ipa_owned_get(buf);
  429. }
  430. static inline void qdf_nbuf_ipa_owned_set(qdf_nbuf_t buf)
  431. {
  432. __qdf_nbuf_ipa_owned_set(buf);
  433. }
  434. static inline int qdf_nbuf_ipa_priv_get(qdf_nbuf_t buf)
  435. {
  436. return __qdf_nbuf_ipa_priv_get(buf);
  437. }
  438. static inline void qdf_nbuf_ipa_priv_set(qdf_nbuf_t buf, uint32_t priv)
  439. {
  440. QDF_BUG(!(priv & QDF_NBUF_IPA_CHECK_MASK));
  441. __qdf_nbuf_ipa_priv_set(buf, priv);
  442. }
  443. /**
  444. * qdf_nbuf_set_frag_is_wordstream() - set fragment wordstream
  445. * @buf: Network buffer
  446. * @frag_num: Fragment number
  447. * @is_wordstream: Wordstream
  448. *
  449. * Return: none
  450. */
  451. static inline void
  452. qdf_nbuf_set_frag_is_wordstream(qdf_nbuf_t buf,
  453. int frag_num, int is_wordstream)
  454. {
  455. QDF_BUG(!(frag_num >= QDF_NBUF_CB_TX_MAX_EXTRA_FRAGS));
  456. __qdf_nbuf_set_frag_is_wordstream(buf, frag_num, is_wordstream);
  457. }
  458. static inline void
  459. qdf_nbuf_set_vdev_ctx(qdf_nbuf_t buf, void *vdev_ctx)
  460. {
  461. __qdf_nbuf_set_vdev_ctx(buf, vdev_ctx);
  462. }
  463. static inline void
  464. qdf_nbuf_set_fctx_type(qdf_nbuf_t buf, void *ctx, uint8_t type)
  465. {
  466. __qdf_nbuf_set_fctx_type(buf, ctx, type);
  467. }
  468. static inline void *
  469. qdf_nbuf_get_vdev_ctx(qdf_nbuf_t buf)
  470. {
  471. return __qdf_nbuf_get_vdev_ctx(buf);
  472. }
  473. static inline void *qdf_nbuf_get_fctx(qdf_nbuf_t buf)
  474. {
  475. return __qdf_nbuf_get_fctx(buf);
  476. }
  477. static inline uint8_t qdf_nbuf_get_ftype(qdf_nbuf_t buf)
  478. {
  479. return __qdf_nbuf_get_ftype(buf);
  480. }
  481. static inline qdf_dma_addr_t
  482. qdf_nbuf_mapped_paddr_get(qdf_nbuf_t buf)
  483. {
  484. return __qdf_nbuf_mapped_paddr_get(buf);
  485. }
  486. static inline void
  487. qdf_nbuf_mapped_paddr_set(qdf_nbuf_t buf, qdf_dma_addr_t paddr)
  488. {
  489. __qdf_nbuf_mapped_paddr_set(buf, paddr);
  490. }
  491. static inline void
  492. qdf_nbuf_frag_push_head(qdf_nbuf_t buf,
  493. int frag_len, char *frag_vaddr,
  494. qdf_dma_addr_t frag_paddr)
  495. {
  496. __qdf_nbuf_frag_push_head(buf, frag_len, frag_vaddr, frag_paddr);
  497. }
  498. #define qdf_nbuf_num_frags_init(_nbuf) __qdf_nbuf_num_frags_init((_nbuf))
  499. /* For efficiency, it is the responsibility of the caller to ensure that val
  500. * is either 0 or 1.
  501. */
  502. static inline void
  503. qdf_nbuf_set_chfrag_start(qdf_nbuf_t buf, uint8_t val)
  504. {
  505. __qdf_nbuf_set_chfrag_start(buf, val);
  506. }
  507. static inline int qdf_nbuf_is_chfrag_start(qdf_nbuf_t buf)
  508. {
  509. return __qdf_nbuf_is_chfrag_start(buf);
  510. }
  511. /* For efficiency, it is the responsibility of the caller to ensure that val
  512. * is either 0 or 1.
  513. */
  514. static inline void qdf_nbuf_set_chfrag_end(qdf_nbuf_t buf, uint8_t val)
  515. {
  516. __qdf_nbuf_set_chfrag_end(buf, val);
  517. }
  518. static inline int qdf_nbuf_is_chfrag_end(qdf_nbuf_t buf)
  519. {
  520. return __qdf_nbuf_is_chfrag_end(buf);
  521. }
  522. static inline void
  523. qdf_nbuf_dma_map_info(qdf_dma_map_t bmap, qdf_dmamap_info_t *sg)
  524. {
  525. __qdf_nbuf_dma_map_info(bmap, sg);
  526. }
  527. #ifdef MEMORY_DEBUG
  528. void qdf_net_buf_debug_init(void);
  529. void qdf_net_buf_debug_exit(void);
  530. void qdf_net_buf_debug_clean(void);
  531. void qdf_net_buf_debug_add_node(qdf_nbuf_t net_buf, size_t size,
  532. uint8_t *file_name, uint32_t line_num);
  533. void qdf_net_buf_debug_delete_node(qdf_nbuf_t net_buf);
  534. void qdf_net_buf_debug_release_skb(qdf_nbuf_t net_buf);
  535. /* nbuf allocation rouines */
  536. #define qdf_nbuf_alloc(d, s, r, a, p) \
  537. qdf_nbuf_alloc_debug(d, s, r, a, p, __FILE__, __LINE__)
  538. static inline qdf_nbuf_t
  539. qdf_nbuf_alloc_debug(qdf_device_t osdev, qdf_size_t size, int reserve,
  540. int align, int prio, uint8_t *file_name,
  541. uint32_t line_num)
  542. {
  543. qdf_nbuf_t net_buf;
  544. net_buf = __qdf_nbuf_alloc(osdev, size, reserve, align, prio);
  545. /* Store SKB in internal QDF tracking table */
  546. if (qdf_likely(net_buf))
  547. qdf_net_buf_debug_add_node(net_buf, size, file_name, line_num);
  548. return net_buf;
  549. }
  550. static inline void qdf_nbuf_free(qdf_nbuf_t net_buf)
  551. {
  552. /* Remove SKB from internal QDF tracking table */
  553. if (qdf_likely(net_buf))
  554. qdf_net_buf_debug_delete_node(net_buf);
  555. __qdf_nbuf_free(net_buf);
  556. }
  557. #define qdf_nbuf_clone(buf) \
  558. qdf_nbuf_clone_debug(buf, __FILE__, __LINE__)
  559. /**
  560. * qdf_nbuf_clone_debug() - clone the nbuf (copy is readonly)
  561. * @buf: nbuf to clone from
  562. * @file_name: pointer to file name
  563. * @line_num: line number
  564. *
  565. * This function clones the nbuf and creates a memory tracking
  566. * node corresponding to that cloned skbuff structure.
  567. *
  568. * Return: cloned buffer
  569. */
  570. static inline qdf_nbuf_t
  571. qdf_nbuf_clone_debug(qdf_nbuf_t buf, uint8_t *file_name,
  572. uint32_t line_num)
  573. {
  574. qdf_nbuf_t cloned_buf;
  575. cloned_buf = __qdf_nbuf_clone(buf);
  576. /* Store SKB in internal QDF tracking table */
  577. if (qdf_likely(cloned_buf))
  578. qdf_net_buf_debug_add_node(cloned_buf, 0, file_name, line_num);
  579. return cloned_buf;
  580. }
  581. #define qdf_nbuf_copy(buf) \
  582. qdf_nbuf_copy_debug(buf, __FILE__, __LINE__)
  583. /**
  584. * qdf_nbuf_copy_debug() - returns a private copy of the buf
  585. * @buf: nbuf to copy from
  586. * @file_name: pointer to file name
  587. * @line_num: line number
  588. *
  589. * This API returns a private copy of the buf, the buf returned is completely
  590. * modifiable by callers. It also creates a memory tracking node corresponding
  591. * to that new skbuff structure.
  592. *
  593. * Return: copied buffer
  594. */
  595. static inline qdf_nbuf_t
  596. qdf_nbuf_copy_debug(qdf_nbuf_t buf, uint8_t *file_name,
  597. uint32_t line_num)
  598. {
  599. qdf_nbuf_t copied_buf;
  600. copied_buf = __qdf_nbuf_copy(buf);
  601. /* Store SKB in internal QDF tracking table */
  602. if (qdf_likely(copied_buf))
  603. qdf_net_buf_debug_add_node(copied_buf, 0, file_name, line_num);
  604. return copied_buf;
  605. }
  606. #else
  607. static inline void qdf_net_buf_debug_release_skb(qdf_nbuf_t net_buf)
  608. {
  609. return;
  610. }
  611. /* Nbuf allocation rouines */
  612. static inline qdf_nbuf_t
  613. qdf_nbuf_alloc(qdf_device_t osdev,
  614. qdf_size_t size, int reserve, int align, int prio)
  615. {
  616. return __qdf_nbuf_alloc(osdev, size, reserve, align, prio);
  617. }
  618. static inline void qdf_nbuf_free(qdf_nbuf_t buf)
  619. {
  620. __qdf_nbuf_free(buf);
  621. }
  622. /**
  623. * qdf_nbuf_clone() - clone the nbuf (copy is readonly)
  624. * @buf: Pointer to network buffer
  625. *
  626. * This function clones the nbuf and returns new sk_buff
  627. * structure.
  628. *
  629. * Return: cloned skb
  630. */
  631. static inline qdf_nbuf_t qdf_nbuf_clone(qdf_nbuf_t buf)
  632. {
  633. return __qdf_nbuf_clone(buf);
  634. }
  635. /**
  636. * qdf_nbuf_copy() - returns a private copy of the buf
  637. * @buf: Pointer to network buffer
  638. *
  639. * This API returns a private copy of the buf, the buf returned is completely
  640. * modifiable by callers
  641. *
  642. * Return: skb or NULL
  643. */
  644. static inline qdf_nbuf_t qdf_nbuf_copy(qdf_nbuf_t buf)
  645. {
  646. return __qdf_nbuf_copy(buf);
  647. }
  648. #endif
  649. #ifdef WLAN_FEATURE_FASTPATH
  650. /**
  651. * qdf_nbuf_init_fast() - before put buf into pool,turn it to init state
  652. *
  653. * @buf: buf instance
  654. * Return: data pointer of this buf where new data has to be
  655. * put, or NULL if there is not enough room in this buf.
  656. */
  657. static inline void qdf_nbuf_init_fast(qdf_nbuf_t nbuf)
  658. {
  659. atomic_set(&nbuf->users, 1);
  660. nbuf->data = nbuf->head + NET_SKB_PAD;
  661. skb_reset_tail_pointer(nbuf);
  662. }
  663. #endif /* WLAN_FEATURE_FASTPATH */
  664. static inline void qdf_nbuf_tx_free(qdf_nbuf_t buf_list, int tx_err)
  665. {
  666. __qdf_nbuf_tx_free(buf_list, tx_err);
  667. }
  668. static inline void qdf_nbuf_ref(qdf_nbuf_t buf)
  669. {
  670. __qdf_nbuf_ref(buf);
  671. }
  672. static inline int qdf_nbuf_shared(qdf_nbuf_t buf)
  673. {
  674. return __qdf_nbuf_shared(buf);
  675. }
  676. static inline QDF_STATUS qdf_nbuf_cat(qdf_nbuf_t dst, qdf_nbuf_t src)
  677. {
  678. return __qdf_nbuf_cat(dst, src);
  679. }
  680. /**
  681. * @qdf_nbuf_copy_bits() - return the length of the copy bits for skb
  682. * @skb: SKB pointer
  683. * @offset: offset
  684. * @len: Length
  685. * @to: To
  686. *
  687. * Return: int32_t
  688. */
  689. static inline int32_t
  690. qdf_nbuf_copy_bits(qdf_nbuf_t nbuf, uint32_t offset, uint32_t len, void *to)
  691. {
  692. return __qdf_nbuf_copy_bits(nbuf, offset, len, to);
  693. }
  694. /* nbuf manipulation routines */
  695. /**
  696. * @qdf_nbuf_head() - return the address of an nbuf's buffer
  697. * @buf: netbuf
  698. *
  699. * Return: head address
  700. */
  701. static inline uint8_t *qdf_nbuf_head(qdf_nbuf_t buf)
  702. {
  703. return __qdf_nbuf_head(buf);
  704. }
  705. /**
  706. * qdf_nbuf_data() - Return the address of the start of data within an nbuf
  707. * @buf: Network buffer
  708. *
  709. * Return: Data address
  710. */
  711. static inline uint8_t *qdf_nbuf_data(qdf_nbuf_t buf)
  712. {
  713. return __qdf_nbuf_data(buf);
  714. }
  715. /**
  716. * qdf_nbuf_data_addr() - Return the address of skb->data
  717. * @buf: Network buffer
  718. *
  719. * Return: Data address
  720. */
  721. static inline uint8_t *qdf_nbuf_data_addr(qdf_nbuf_t buf)
  722. {
  723. return __qdf_nbuf_data_addr(buf);
  724. }
  725. /**
  726. * qdf_nbuf_headroom() - amount of headroom int the current nbuf
  727. * @buf: Network buffer
  728. *
  729. * Return: Amount of head room
  730. */
  731. static inline uint32_t qdf_nbuf_headroom(qdf_nbuf_t buf)
  732. {
  733. return __qdf_nbuf_headroom(buf);
  734. }
  735. /**
  736. * qdf_nbuf_tailroom() - amount of tail space available
  737. * @buf: Network buffer
  738. *
  739. * Return: amount of tail room
  740. */
  741. static inline uint32_t qdf_nbuf_tailroom(qdf_nbuf_t buf)
  742. {
  743. return __qdf_nbuf_tailroom(buf);
  744. }
  745. /**
  746. * qdf_nbuf_push_head() - push data in the front
  747. * @buf: Network buf instance
  748. * @size: Size to be pushed
  749. *
  750. * Return: New data pointer of this buf after data has been pushed,
  751. * or NULL if there is not enough room in this buf.
  752. */
  753. static inline uint8_t *qdf_nbuf_push_head(qdf_nbuf_t buf, qdf_size_t size)
  754. {
  755. return __qdf_nbuf_push_head(buf, size);
  756. }
  757. /**
  758. * qdf_nbuf_put_tail() - puts data in the end
  759. * @buf: Network buf instance
  760. * @size: Size to be pushed
  761. *
  762. * Return: Data pointer of this buf where new data has to be
  763. * put, or NULL if there is not enough room in this buf.
  764. */
  765. static inline uint8_t *qdf_nbuf_put_tail(qdf_nbuf_t buf, qdf_size_t size)
  766. {
  767. return __qdf_nbuf_put_tail(buf, size);
  768. }
  769. /**
  770. * qdf_nbuf_pull_head() - pull data out from the front
  771. * @buf: Network buf instance
  772. * @size: Size to be popped
  773. *
  774. * Return: New data pointer of this buf after data has been popped,
  775. * or NULL if there is not sufficient data to pull.
  776. */
  777. static inline uint8_t *qdf_nbuf_pull_head(qdf_nbuf_t buf, qdf_size_t size)
  778. {
  779. return __qdf_nbuf_pull_head(buf, size);
  780. }
  781. /**
  782. * qdf_nbuf_trim_tail() - trim data out from the end
  783. * @buf: Network buf instance
  784. * @size: Size to be popped
  785. *
  786. * Return: none
  787. */
  788. static inline void qdf_nbuf_trim_tail(qdf_nbuf_t buf, qdf_size_t size)
  789. {
  790. __qdf_nbuf_trim_tail(buf, size);
  791. }
  792. /**
  793. * qdf_nbuf_len() - get the length of the buf
  794. * @buf: Network buf instance
  795. *
  796. * Return: total length of this buf.
  797. */
  798. static inline qdf_size_t qdf_nbuf_len(qdf_nbuf_t buf)
  799. {
  800. return __qdf_nbuf_len(buf);
  801. }
  802. /**
  803. * qdf_nbuf_set_pktlen() - set the length of the buf
  804. * @buf: Network buf instance
  805. * @size: Size to be set
  806. *
  807. * Return: none
  808. */
  809. static inline void qdf_nbuf_set_pktlen(qdf_nbuf_t buf, uint32_t len)
  810. {
  811. __qdf_nbuf_set_pktlen(buf, len);
  812. }
  813. /**
  814. * qdf_nbuf_reserve() - trim data out from the end
  815. * @buf: Network buf instance
  816. * @size: Size to be popped
  817. *
  818. * Return: none
  819. */
  820. static inline void qdf_nbuf_reserve(qdf_nbuf_t buf, qdf_size_t size)
  821. {
  822. __qdf_nbuf_reserve(buf, size);
  823. }
  824. /**
  825. * qdf_nbuf_peek_header() - return the data pointer & length of the header
  826. * @buf: Network nbuf
  827. * @addr: Data pointer
  828. * @len: Length of the data
  829. *
  830. * Return: none
  831. */
  832. static inline void
  833. qdf_nbuf_peek_header(qdf_nbuf_t buf, uint8_t **addr, uint32_t *len)
  834. {
  835. __qdf_nbuf_peek_header(buf, addr, len);
  836. }
  837. /* nbuf queue routines */
  838. /**
  839. * qdf_nbuf_queue_init() - initialize buf queue
  840. * @head: Network buf queue head
  841. *
  842. * Return: none
  843. */
  844. static inline void qdf_nbuf_queue_init(qdf_nbuf_queue_t *head)
  845. {
  846. __qdf_nbuf_queue_init(head);
  847. }
  848. /**
  849. * qdf_nbuf_queue_add() - append a nbuf to the tail of the buf queue
  850. * @head: Network buf queue head
  851. * @buf: Network buf
  852. *
  853. * Return: none
  854. */
  855. static inline void qdf_nbuf_queue_add(qdf_nbuf_queue_t *head, qdf_nbuf_t buf)
  856. {
  857. __qdf_nbuf_queue_add(head, buf);
  858. }
  859. /**
  860. * qdf_nbuf_queue_insert_head() - insert nbuf at the head of queue
  861. * @head: Network buf queue head
  862. * @buf: Network buf
  863. *
  864. * Return: none
  865. */
  866. static inline void
  867. qdf_nbuf_queue_insert_head(qdf_nbuf_queue_t *head, qdf_nbuf_t buf)
  868. {
  869. __qdf_nbuf_queue_insert_head(head, buf);
  870. }
  871. /**
  872. * qdf_nbuf_queue_remove() - retrieve a buf from the head of the buf queue
  873. * @head: Network buf queue head
  874. *
  875. * Return: The head buf in the buf queue.
  876. */
  877. static inline qdf_nbuf_t qdf_nbuf_queue_remove(qdf_nbuf_queue_t *head)
  878. {
  879. return __qdf_nbuf_queue_remove(head);
  880. }
  881. /**
  882. * qdf_nbuf_queue_len() - get the length of the queue
  883. * @head: Network buf queue head
  884. *
  885. * Return: length of the queue
  886. */
  887. static inline uint32_t qdf_nbuf_queue_len(qdf_nbuf_queue_t *head)
  888. {
  889. return __qdf_nbuf_queue_len(head);
  890. }
  891. /**
  892. * qdf_nbuf_queue_next() - get the next guy/packet of the given buffer
  893. * @buf: Network buffer
  894. *
  895. * Return: next buffer/packet
  896. */
  897. static inline qdf_nbuf_t qdf_nbuf_queue_next(qdf_nbuf_t buf)
  898. {
  899. return __qdf_nbuf_queue_next(buf);
  900. }
  901. /**
  902. * @qdf_nbuf_is_queue_empty() - check if the buf queue is empty
  903. * @nbq: Network buf queue handle
  904. *
  905. * Return: true if queue is empty
  906. * false if queue is not emty
  907. */
  908. static inline bool qdf_nbuf_is_queue_empty(qdf_nbuf_queue_t *nbq)
  909. {
  910. return __qdf_nbuf_is_queue_empty(nbq);
  911. }
  912. static inline qdf_nbuf_queue_t *
  913. qdf_nbuf_queue_append(qdf_nbuf_queue_t *dest, qdf_nbuf_queue_t *src)
  914. {
  915. return __qdf_nbuf_queue_append(dest, src);
  916. }
  917. static inline void
  918. qdf_nbuf_queue_free(qdf_nbuf_queue_t *head)
  919. {
  920. __qdf_nbuf_queue_free(head);
  921. }
  922. static inline qdf_nbuf_t
  923. qdf_nbuf_queue_first(qdf_nbuf_queue_t *head)
  924. {
  925. return __qdf_nbuf_queue_first(head);
  926. }
  927. /**
  928. * qdf_nbuf_next() - get the next packet in the linked list
  929. * @buf: Network buffer
  930. *
  931. * This function can be used when nbufs are directly linked into a list,
  932. * rather than using a separate network buffer queue object.
  933. *
  934. * Return: next network buffer in the linked list
  935. */
  936. static inline qdf_nbuf_t qdf_nbuf_next(qdf_nbuf_t buf)
  937. {
  938. return __qdf_nbuf_next(buf);
  939. }
  940. /**
  941. * qdf_nbuf_get_protocol() - return the protocol value of the skb
  942. * @skb: Pointer to network buffer
  943. *
  944. * Return: skb protocol
  945. */
  946. static inline uint16_t qdf_nbuf_get_protocol(struct sk_buff *skb)
  947. {
  948. return __qdf_nbuf_get_protocol(skb);
  949. }
  950. /**
  951. * qdf_nbuf_get_ip_summed() - return the ip checksum value of the skb
  952. * @skb: Pointer to network buffer
  953. *
  954. * Return: skb ip_summed
  955. */
  956. static inline uint8_t qdf_nbuf_get_ip_summed(struct sk_buff *skb)
  957. {
  958. return __qdf_nbuf_get_ip_summed(skb);
  959. }
  960. /**
  961. * qdf_nbuf_set_ip_summed() - sets the ip_summed value of the skb
  962. * @skb: Pointer to network buffer
  963. * @ip_summed: ip checksum
  964. *
  965. * Return: none
  966. */
  967. static inline void qdf_nbuf_set_ip_summed(struct sk_buff *skb,
  968. uint8_t ip_summed)
  969. {
  970. __qdf_nbuf_set_ip_summed(skb, ip_summed);
  971. }
  972. /**
  973. * qdf_nbuf_set_next() - add a packet to a linked list
  974. * @this_buf: Predecessor buffer
  975. * @next_buf: Successor buffer
  976. *
  977. * This function can be used to directly link nbufs, rather than using
  978. * a separate network buffer queue object.
  979. *
  980. * Return: none
  981. */
  982. static inline void qdf_nbuf_set_next(qdf_nbuf_t this_buf, qdf_nbuf_t next_buf)
  983. {
  984. __qdf_nbuf_set_next(this_buf, next_buf);
  985. }
  986. /* nbuf extension routines */
  987. /**
  988. * qdf_nbuf_set_next_ext() - link extension of this packet contained in a new
  989. * nbuf
  990. * @this_buf: predecessor buffer
  991. * @next_buf: successor buffer
  992. *
  993. * This function is used to link up many nbufs containing a single logical
  994. * packet - not a collection of packets. Do not use for linking the first
  995. * extension to the head
  996. *
  997. * Return: none
  998. */
  999. static inline void
  1000. qdf_nbuf_set_next_ext(qdf_nbuf_t this_buf, qdf_nbuf_t next_buf)
  1001. {
  1002. __qdf_nbuf_set_next_ext(this_buf, next_buf);
  1003. }
  1004. /**
  1005. * qdf_nbuf_next_ext() - get the next packet extension in the linked list
  1006. * @buf: Network buffer
  1007. *
  1008. * Return: Next network buffer in the linked list
  1009. */
  1010. static inline qdf_nbuf_t qdf_nbuf_next_ext(qdf_nbuf_t buf)
  1011. {
  1012. return __qdf_nbuf_next_ext(buf);
  1013. }
  1014. /**
  1015. * qdf_nbuf_append_ext_list() - link list of packet extensions to the head
  1016. * segment
  1017. * @head_buf: Network buf holding head segment (single)
  1018. * @ext_list: Network buf list holding linked extensions to the head
  1019. * @ext_len: Total length of all buffers in the extension list
  1020. *
  1021. * This function is used to link up a list of packet extensions (seg1, 2,
  1022. * ...) to the nbuf holding the head segment (seg0)
  1023. *
  1024. * Return: none
  1025. */
  1026. static inline void
  1027. qdf_nbuf_append_ext_list(qdf_nbuf_t head_buf, qdf_nbuf_t ext_list,
  1028. qdf_size_t ext_len)
  1029. {
  1030. __qdf_nbuf_append_ext_list(head_buf, ext_list, ext_len);
  1031. }
  1032. /**
  1033. * qdf_nbuf_get_ext_list() - Get the link to extended nbuf list.
  1034. * @head_buf: Network buf holding head segment (single)
  1035. *
  1036. * This ext_list is populated when we have Jumbo packet, for example in case of
  1037. * monitor mode amsdu packet reception, and are stiched using frags_list.
  1038. *
  1039. * Return: Network buf list holding linked extensions from head buf.
  1040. */
  1041. static inline qdf_nbuf_t qdf_nbuf_get_ext_list(qdf_nbuf_t head_buf)
  1042. {
  1043. return (qdf_nbuf_t)__qdf_nbuf_get_ext_list(head_buf);
  1044. }
  1045. /**
  1046. * qdf_nbuf_get_tx_cksum() - gets the tx checksum offload demand
  1047. * @buf: Network buffer
  1048. *
  1049. * Return: qdf_nbuf_tx_cksum_t checksum offload demand for the frame
  1050. */
  1051. static inline qdf_nbuf_tx_cksum_t qdf_nbuf_get_tx_cksum(qdf_nbuf_t buf)
  1052. {
  1053. return __qdf_nbuf_get_tx_cksum(buf);
  1054. }
  1055. /**
  1056. * qdf_nbuf_set_rx_cksum() - drivers that support hw checksumming use this to
  1057. * indicate checksum info to the stack.
  1058. * @buf: Network buffer
  1059. * @cksum: Checksum
  1060. *
  1061. * Return: none
  1062. */
  1063. static inline void
  1064. qdf_nbuf_set_rx_cksum(qdf_nbuf_t buf, qdf_nbuf_rx_cksum_t *cksum)
  1065. {
  1066. __qdf_nbuf_set_rx_cksum(buf, cksum);
  1067. }
  1068. /**
  1069. * qdf_nbuf_get_tid() - this function extracts the TID value from nbuf
  1070. * @buf: Network buffer
  1071. *
  1072. * Return: TID value
  1073. */
  1074. static inline uint8_t qdf_nbuf_get_tid(qdf_nbuf_t buf)
  1075. {
  1076. return __qdf_nbuf_get_tid(buf);
  1077. }
  1078. /**
  1079. * qdf_nbuf_set_tid() - this function sets the TID value in nbuf
  1080. * @buf: Network buffer
  1081. * @tid: TID value
  1082. *
  1083. * Return: none
  1084. */
  1085. static inline void qdf_nbuf_set_tid(qdf_nbuf_t buf, uint8_t tid)
  1086. {
  1087. __qdf_nbuf_set_tid(buf, tid);
  1088. }
  1089. /**
  1090. * qdf_nbuf_get_exemption_type() - this function extracts the exemption type
  1091. * from nbuf
  1092. * @buf: Network buffer
  1093. *
  1094. * Return: Exemption type
  1095. */
  1096. static inline uint8_t qdf_nbuf_get_exemption_type(qdf_nbuf_t buf)
  1097. {
  1098. return __qdf_nbuf_get_exemption_type(buf);
  1099. }
  1100. /**
  1101. * qdf_nbuf_set_protocol() - this function peeks data into the buffer at given
  1102. * offset
  1103. * @buf: Network buffer
  1104. * @proto: Protocol
  1105. *
  1106. * Return: none
  1107. */
  1108. static inline void qdf_nbuf_set_protocol(qdf_nbuf_t buf, uint16_t proto)
  1109. {
  1110. __qdf_nbuf_set_protocol(buf, proto);
  1111. }
  1112. /**
  1113. * qdf_nbuf_trace_get_proto_type() - this function return packet proto type
  1114. * @buf: Network buffer
  1115. *
  1116. * Return: Packet protocol type
  1117. */
  1118. static inline uint8_t qdf_nbuf_trace_get_proto_type(qdf_nbuf_t buf)
  1119. {
  1120. return __qdf_nbuf_trace_get_proto_type(buf);
  1121. }
  1122. /**
  1123. * qdf_nbuf_reg_trace_cb() - this function registers protocol trace callback
  1124. * @cb_func_ptr: Callback pointer
  1125. *
  1126. * Return: none
  1127. */
  1128. static inline void qdf_nbuf_reg_trace_cb(qdf_nbuf_trace_update_t cb_func_ptr)
  1129. {
  1130. __qdf_nbuf_reg_trace_cb(cb_func_ptr);
  1131. }
  1132. /**
  1133. * qdf_nbuf_set_tx_parallel_dnload_frm() - set tx parallel download
  1134. * @buf: Network buffer
  1135. * @candi: Candidate of parallel download frame
  1136. *
  1137. * This function stores a flag specifying this TX frame is suitable for
  1138. * downloading though a 2nd TX data pipe that is used for short frames for
  1139. * protocols that can accept out-of-order delivery.
  1140. *
  1141. * Return: none
  1142. */
  1143. static inline void
  1144. qdf_nbuf_set_tx_parallel_dnload_frm(qdf_nbuf_t buf, uint8_t candi)
  1145. {
  1146. __qdf_nbuf_set_tx_htt2_frm(buf, candi);
  1147. }
  1148. /**
  1149. * qdf_nbuf_get_tx_parallel_dnload_frm() - get tx parallel download
  1150. * @buf: Network buffer
  1151. *
  1152. * This function return whether this TX frame is allow to download though a 2nd
  1153. * TX data pipe or not.
  1154. *
  1155. * Return: none
  1156. */
  1157. static inline uint8_t qdf_nbuf_get_tx_parallel_dnload_frm(qdf_nbuf_t buf)
  1158. {
  1159. return __qdf_nbuf_get_tx_htt2_frm(buf);
  1160. }
  1161. /**
  1162. * qdf_nbuf_get_dhcp_subtype() - get the subtype
  1163. * of DHCP packet.
  1164. * @buf: Pointer to DHCP packet buffer
  1165. *
  1166. * This func. returns the subtype of DHCP packet.
  1167. *
  1168. * Return: subtype of the DHCP packet.
  1169. */
  1170. static inline enum qdf_proto_subtype
  1171. qdf_nbuf_get_dhcp_subtype(qdf_nbuf_t buf)
  1172. {
  1173. return __qdf_nbuf_data_get_dhcp_subtype(qdf_nbuf_data(buf));
  1174. }
  1175. /**
  1176. * qdf_nbuf_data_get_dhcp_subtype() - get the subtype
  1177. * of DHCP packet.
  1178. * @buf: Pointer to DHCP packet data buffer
  1179. *
  1180. * This func. returns the subtype of DHCP packet.
  1181. *
  1182. * Return: subtype of the DHCP packet.
  1183. */
  1184. static inline enum qdf_proto_subtype
  1185. qdf_nbuf_data_get_dhcp_subtype(uint8_t *data)
  1186. {
  1187. return __qdf_nbuf_data_get_dhcp_subtype(data);
  1188. }
  1189. /**
  1190. * qdf_nbuf_get_eapol_subtype() - get the subtype
  1191. * of EAPOL packet.
  1192. * @buf: Pointer to EAPOL packet buffer
  1193. *
  1194. * This func. returns the subtype of EAPOL packet.
  1195. *
  1196. * Return: subtype of the EAPOL packet.
  1197. */
  1198. static inline enum qdf_proto_subtype
  1199. qdf_nbuf_get_eapol_subtype(qdf_nbuf_t buf)
  1200. {
  1201. return __qdf_nbuf_data_get_eapol_subtype(qdf_nbuf_data(buf));
  1202. }
  1203. /**
  1204. * qdf_nbuf_data_get_eapol_subtype() - get the subtype
  1205. * of EAPOL packet.
  1206. * @data: Pointer to EAPOL packet data buffer
  1207. *
  1208. * This func. returns the subtype of EAPOL packet.
  1209. *
  1210. * Return: subtype of the EAPOL packet.
  1211. */
  1212. static inline enum qdf_proto_subtype
  1213. qdf_nbuf_data_get_eapol_subtype(uint8_t *data)
  1214. {
  1215. return __qdf_nbuf_data_get_eapol_subtype(data);
  1216. }
  1217. /**
  1218. * qdf_nbuf_get_arp_subtype() - get the subtype
  1219. * of ARP packet.
  1220. * @buf: Pointer to ARP packet buffer
  1221. *
  1222. * This func. returns the subtype of ARP packet.
  1223. *
  1224. * Return: subtype of the ARP packet.
  1225. */
  1226. static inline enum qdf_proto_subtype
  1227. qdf_nbuf_get_arp_subtype(qdf_nbuf_t buf)
  1228. {
  1229. return __qdf_nbuf_data_get_arp_subtype(qdf_nbuf_data(buf));
  1230. }
  1231. /**
  1232. * qdf_nbuf_data_get_arp_subtype() - get the subtype
  1233. * of ARP packet.
  1234. * @data: Pointer to ARP packet data buffer
  1235. *
  1236. * This func. returns the subtype of ARP packet.
  1237. *
  1238. * Return: subtype of the ARP packet.
  1239. */
  1240. static inline enum qdf_proto_subtype
  1241. qdf_nbuf_data_get_arp_subtype(uint8_t *data)
  1242. {
  1243. return __qdf_nbuf_data_get_arp_subtype(data);
  1244. }
  1245. /**
  1246. * qdf_nbuf_get_icmp_subtype() - get the subtype
  1247. * of IPV4 ICMP packet.
  1248. * @buf: Pointer to IPV4 ICMP packet buffer
  1249. *
  1250. * This func. returns the subtype of ICMP packet.
  1251. *
  1252. * Return: subtype of the ICMP packet.
  1253. */
  1254. static inline enum qdf_proto_subtype
  1255. qdf_nbuf_get_icmp_subtype(qdf_nbuf_t buf)
  1256. {
  1257. return __qdf_nbuf_data_get_icmp_subtype(qdf_nbuf_data(buf));
  1258. }
  1259. /**
  1260. * qdf_nbuf_data_get_icmp_subtype() - get the subtype
  1261. * of IPV4 ICMP packet.
  1262. * @data: Pointer to IPV4 ICMP packet data buffer
  1263. *
  1264. * This func. returns the subtype of ICMP packet.
  1265. *
  1266. * Return: subtype of the ICMP packet.
  1267. */
  1268. static inline enum qdf_proto_subtype
  1269. qdf_nbuf_data_get_icmp_subtype(uint8_t *data)
  1270. {
  1271. return __qdf_nbuf_data_get_icmp_subtype(data);
  1272. }
  1273. /**
  1274. * qdf_nbuf_get_icmpv6_subtype() - get the subtype
  1275. * of IPV6 ICMPV6 packet.
  1276. * @buf: Pointer to IPV6 ICMPV6 packet buffer
  1277. *
  1278. * This func. returns the subtype of ICMPV6 packet.
  1279. *
  1280. * Return: subtype of the ICMPV6 packet.
  1281. */
  1282. static inline enum qdf_proto_subtype
  1283. qdf_nbuf_get_icmpv6_subtype(qdf_nbuf_t buf)
  1284. {
  1285. return __qdf_nbuf_data_get_icmpv6_subtype(qdf_nbuf_data(buf));
  1286. }
  1287. /**
  1288. * qdf_nbuf_data_get_icmpv6_subtype() - get the subtype
  1289. * of IPV6 ICMPV6 packet.
  1290. * @data: Pointer to IPV6 ICMPV6 packet data buffer
  1291. *
  1292. * This func. returns the subtype of ICMPV6 packet.
  1293. *
  1294. * Return: subtype of the ICMPV6 packet.
  1295. */
  1296. static inline enum qdf_proto_subtype
  1297. qdf_nbuf_data_get_icmpv6_subtype(uint8_t *data)
  1298. {
  1299. return __qdf_nbuf_data_get_icmpv6_subtype(data);
  1300. }
  1301. /**
  1302. * qdf_nbuf_data_get_ipv4_proto() - get the proto type
  1303. * of IPV4 packet.
  1304. * @data: Pointer to IPV4 packet data buffer
  1305. *
  1306. * This func. returns the proto type of IPV4 packet.
  1307. *
  1308. * Return: proto type of IPV4 packet.
  1309. */
  1310. static inline uint8_t
  1311. qdf_nbuf_data_get_ipv4_proto(uint8_t *data)
  1312. {
  1313. return __qdf_nbuf_data_get_ipv4_proto(data);
  1314. }
  1315. /**
  1316. * qdf_nbuf_data_get_ipv6_proto() - get the proto type
  1317. * of IPV6 packet.
  1318. * @data: Pointer to IPV6 packet data buffer
  1319. *
  1320. * This func. returns the proto type of IPV6 packet.
  1321. *
  1322. * Return: proto type of IPV6 packet.
  1323. */
  1324. static inline uint8_t
  1325. qdf_nbuf_data_get_ipv6_proto(uint8_t *data)
  1326. {
  1327. return __qdf_nbuf_data_get_ipv6_proto(data);
  1328. }
  1329. /**
  1330. * qdf_nbuf_is_ipv4_pkt() - check if packet is a ipv4 packet or not
  1331. * @buf: buffer
  1332. *
  1333. * This api is for Tx packets.
  1334. *
  1335. * Return: true if packet is ipv4 packet
  1336. */
  1337. static inline
  1338. bool qdf_nbuf_is_ipv4_pkt(qdf_nbuf_t buf)
  1339. {
  1340. return __qdf_nbuf_data_is_ipv4_pkt(qdf_nbuf_data(buf));
  1341. }
  1342. /**
  1343. * qdf_nbuf_data_is_ipv4_pkt() - check if packet is a ipv4 packet or not
  1344. * @data: data
  1345. *
  1346. * This api is for Tx packets.
  1347. *
  1348. * Return: true if packet is ipv4 packet
  1349. */
  1350. static inline
  1351. bool qdf_nbuf_data_is_ipv4_pkt(uint8_t *data)
  1352. {
  1353. return __qdf_nbuf_data_is_ipv4_pkt(data);
  1354. }
  1355. /**
  1356. * qdf_nbuf_is_ipv4_dhcp_pkt() - check if packet is a dhcp packet or not
  1357. * @buf: buffer
  1358. *
  1359. * This api is for ipv4 packet.
  1360. *
  1361. * Return: true if packet is DHCP packet
  1362. */
  1363. static inline
  1364. bool qdf_nbuf_is_ipv4_dhcp_pkt(qdf_nbuf_t buf)
  1365. {
  1366. return __qdf_nbuf_data_is_ipv4_dhcp_pkt(qdf_nbuf_data(buf));
  1367. }
  1368. /**
  1369. * qdf_nbuf_data_is_ipv4_dhcp_pkt() - check if it is DHCP packet.
  1370. * @data: Pointer to DHCP packet data buffer
  1371. *
  1372. * This func. checks whether it is a DHCP packet or not.
  1373. *
  1374. * Return: true if it is a DHCP packet
  1375. * false if not
  1376. */
  1377. static inline
  1378. bool qdf_nbuf_data_is_ipv4_dhcp_pkt(uint8_t *data)
  1379. {
  1380. return __qdf_nbuf_data_is_ipv4_dhcp_pkt(data);
  1381. }
  1382. /**
  1383. * qdf_nbuf_is_ipv4_eapol_pkt() - check if packet is a eapol packet or not
  1384. * @buf: buffer
  1385. *
  1386. * This api is for ipv4 packet.
  1387. *
  1388. * Return: true if packet is EAPOL packet
  1389. */
  1390. static inline
  1391. bool qdf_nbuf_is_ipv4_eapol_pkt(qdf_nbuf_t buf)
  1392. {
  1393. return __qdf_nbuf_data_is_ipv4_eapol_pkt(qdf_nbuf_data(buf));
  1394. }
  1395. /**
  1396. * qdf_nbuf_data_is_ipv4_eapol_pkt() - check if it is EAPOL packet.
  1397. * @data: Pointer to EAPOL packet data buffer
  1398. *
  1399. * This func. checks whether it is a EAPOL packet or not.
  1400. *
  1401. * Return: true if it is a EAPOL packet
  1402. * false if not
  1403. */
  1404. static inline
  1405. bool qdf_nbuf_data_is_ipv4_eapol_pkt(uint8_t *data)
  1406. {
  1407. return __qdf_nbuf_data_is_ipv4_eapol_pkt(data);
  1408. }
  1409. /**
  1410. * qdf_nbuf_is_ipv4_wapi_pkt() - check if packet is a wapi packet or not
  1411. * @buf: buffer
  1412. *
  1413. * This api is for ipv4 packet.
  1414. *
  1415. * Return: true if packet is WAPI packet
  1416. */
  1417. static inline
  1418. bool qdf_nbuf_is_ipv4_wapi_pkt(qdf_nbuf_t buf)
  1419. {
  1420. return __qdf_nbuf_is_ipv4_wapi_pkt(buf);
  1421. }
  1422. /**
  1423. * qdf_nbuf_is_ipv4_arp_pkt() - check if packet is a arp packet or not
  1424. * @buf: buffer
  1425. *
  1426. * This api is for ipv4 packet.
  1427. *
  1428. * Return: true if packet is ARP packet
  1429. */
  1430. static inline
  1431. bool qdf_nbuf_is_ipv4_arp_pkt(qdf_nbuf_t buf)
  1432. {
  1433. return __qdf_nbuf_data_is_ipv4_arp_pkt(qdf_nbuf_data(buf));
  1434. }
  1435. /**
  1436. * qdf_nbuf_data_is_ipv4_arp_pkt() - check if it is ARP packet.
  1437. * @data: Pointer to ARP packet data buffer
  1438. *
  1439. * This func. checks whether it is a ARP packet or not.
  1440. *
  1441. * Return: TRUE if it is a ARP packet
  1442. * FALSE if not
  1443. */
  1444. static inline
  1445. bool qdf_nbuf_data_is_ipv4_arp_pkt(uint8_t *data)
  1446. {
  1447. return __qdf_nbuf_data_is_ipv4_arp_pkt(data);
  1448. }
  1449. /**
  1450. * qdf_nbuf_is_ipv6_pkt() - check if it is IPV6 packet.
  1451. * @buf: Pointer to IPV6 packet buffer
  1452. *
  1453. * This func. checks whether it is a IPV6 packet or not.
  1454. *
  1455. * Return: TRUE if it is a IPV6 packet
  1456. * FALSE if not
  1457. */
  1458. static inline
  1459. bool qdf_nbuf_is_ipv6_pkt(qdf_nbuf_t buf)
  1460. {
  1461. return __qdf_nbuf_data_is_ipv6_pkt(qdf_nbuf_data(buf));
  1462. }
  1463. /**
  1464. * qdf_nbuf_data_is_ipv6_pkt() - check if it is IPV6 packet.
  1465. * @data: Pointer to IPV6 packet data buffer
  1466. *
  1467. * This func. checks whether it is a IPV6 packet or not.
  1468. *
  1469. * Return: TRUE if it is a IPV6 packet
  1470. * FALSE if not
  1471. */
  1472. static inline
  1473. bool qdf_nbuf_data_is_ipv6_pkt(uint8_t *data)
  1474. {
  1475. return __qdf_nbuf_data_is_ipv6_pkt(data);
  1476. }
  1477. /**
  1478. * qdf_nbuf_data_is_ipv4_mcast_pkt() - check if it is IPV4 multicast packet.
  1479. * @data: Pointer to IPV4 packet data buffer
  1480. *
  1481. * This func. checks whether it is a IPV4 multicast packet or not.
  1482. *
  1483. * Return: TRUE if it is a IPV4 multicast packet
  1484. * FALSE if not
  1485. */
  1486. static inline
  1487. bool qdf_nbuf_data_is_ipv4_mcast_pkt(uint8_t *data)
  1488. {
  1489. return __qdf_nbuf_data_is_ipv4_mcast_pkt(data);
  1490. }
  1491. /**
  1492. * qdf_nbuf_data_is_ipv6_mcast_pkt() - check if it is IPV6 multicast packet.
  1493. * @data: Pointer to IPV6 packet data buffer
  1494. *
  1495. * This func. checks whether it is a IPV6 multicast packet or not.
  1496. *
  1497. * Return: TRUE if it is a IPV6 multicast packet
  1498. * FALSE if not
  1499. */
  1500. static inline
  1501. bool qdf_nbuf_data_is_ipv6_mcast_pkt(uint8_t *data)
  1502. {
  1503. return __qdf_nbuf_data_is_ipv6_mcast_pkt(data);
  1504. }
  1505. /**
  1506. * qdf_nbuf_is_icmp_pkt() - check if it is IPV4 ICMP packet.
  1507. * @buf: Pointer to IPV4 ICMP packet buffer
  1508. *
  1509. * This func. checks whether it is a ICMP packet or not.
  1510. *
  1511. * Return: TRUE if it is a ICMP packet
  1512. * FALSE if not
  1513. */
  1514. static inline
  1515. bool qdf_nbuf_is_icmp_pkt(qdf_nbuf_t buf)
  1516. {
  1517. return __qdf_nbuf_data_is_icmp_pkt(qdf_nbuf_data(buf));
  1518. }
  1519. /**
  1520. * qdf_nbuf_data_is_icmp_pkt() - check if it is IPV4 ICMP packet.
  1521. * @data: Pointer to IPV4 ICMP packet data buffer
  1522. *
  1523. * This func. checks whether it is a ICMP packet or not.
  1524. *
  1525. * Return: TRUE if it is a ICMP packet
  1526. * FALSE if not
  1527. */
  1528. static inline
  1529. bool qdf_nbuf_data_is_icmp_pkt(uint8_t *data)
  1530. {
  1531. return __qdf_nbuf_data_is_icmp_pkt(data);
  1532. }
  1533. /**
  1534. * qdf_nbuf_is_icmpv6_pkt() - check if it is IPV6 ICMPV6 packet.
  1535. * @buf: Pointer to IPV6 ICMPV6 packet buffer
  1536. *
  1537. * This func. checks whether it is a ICMPV6 packet or not.
  1538. *
  1539. * Return: TRUE if it is a ICMPV6 packet
  1540. * FALSE if not
  1541. */
  1542. static inline
  1543. bool qdf_nbuf_is_icmpv6_pkt(qdf_nbuf_t buf)
  1544. {
  1545. return __qdf_nbuf_data_is_icmpv6_pkt(qdf_nbuf_data(buf));
  1546. }
  1547. /**
  1548. * qdf_nbuf_data_is_icmpv6_pkt() - check if it is IPV6 ICMPV6 packet.
  1549. * @data: Pointer to IPV6 ICMPV6 packet data buffer
  1550. *
  1551. * This func. checks whether it is a ICMPV6 packet or not.
  1552. *
  1553. * Return: TRUE if it is a ICMPV6 packet
  1554. * FALSE if not
  1555. */
  1556. static inline
  1557. bool qdf_nbuf_data_is_icmpv6_pkt(uint8_t *data)
  1558. {
  1559. return __qdf_nbuf_data_is_icmpv6_pkt(data);
  1560. }
  1561. /**
  1562. * qdf_nbuf_is_ipv4_udp_pkt() - check if it is IPV4 UDP packet.
  1563. * @buf: Pointer to IPV4 UDP packet buffer
  1564. *
  1565. * This func. checks whether it is a IPV4 UDP packet or not.
  1566. *
  1567. * Return: TRUE if it is a IPV4 UDP packet
  1568. * FALSE if not
  1569. */
  1570. static inline
  1571. bool qdf_nbuf_is_ipv4_udp_pkt(qdf_nbuf_t buf)
  1572. {
  1573. return __qdf_nbuf_data_is_ipv4_udp_pkt(qdf_nbuf_data(buf));
  1574. }
  1575. /**
  1576. * qdf_nbuf_data_is_ipv4_udp_pkt() - check if it is IPV4 UDP packet.
  1577. * @data: Pointer to IPV4 UDP packet data buffer
  1578. *
  1579. * This func. checks whether it is a IPV4 UDP packet or not.
  1580. *
  1581. * Return: TRUE if it is a IPV4 UDP packet
  1582. * FALSE if not
  1583. */
  1584. static inline
  1585. bool qdf_nbuf_data_is_ipv4_udp_pkt(uint8_t *data)
  1586. {
  1587. return __qdf_nbuf_data_is_ipv4_udp_pkt(data);
  1588. }
  1589. /**
  1590. * qdf_nbuf_is_ipv4_tcp_pkt() - check if it is IPV4 TCP packet.
  1591. * @buf: Pointer to IPV4 TCP packet buffer
  1592. *
  1593. * This func. checks whether it is a IPV4 TCP packet or not.
  1594. *
  1595. * Return: TRUE if it is a IPV4 TCP packet
  1596. * FALSE if not
  1597. */
  1598. static inline
  1599. bool qdf_nbuf_is_ipv4_tcp_pkt(qdf_nbuf_t buf)
  1600. {
  1601. return __qdf_nbuf_data_is_ipv4_tcp_pkt(qdf_nbuf_data(buf));
  1602. }
  1603. /**
  1604. * qdf_nbuf_data_is_ipv4_tcp_pkt() - check if it is IPV4 TCP packet.
  1605. * @data: Pointer to IPV4 TCP packet data buffer
  1606. *
  1607. * This func. checks whether it is a IPV4 TCP packet or not.
  1608. *
  1609. * Return: TRUE if it is a IPV4 TCP packet
  1610. * FALSE if not
  1611. */
  1612. static inline
  1613. bool qdf_nbuf_data_is_ipv4_tcp_pkt(uint8_t *data)
  1614. {
  1615. return __qdf_nbuf_data_is_ipv4_tcp_pkt(data);
  1616. }
  1617. /**
  1618. * qdf_nbuf_is_ipv6_udp_pkt() - check if it is IPV6 UDP packet.
  1619. * @buf: Pointer to IPV6 UDP packet buffer
  1620. *
  1621. * This func. checks whether it is a IPV6 UDP packet or not.
  1622. *
  1623. * Return: TRUE if it is a IPV6 UDP packet
  1624. * FALSE if not
  1625. */
  1626. static inline
  1627. bool qdf_nbuf_is_ipv6_udp_pkt(qdf_nbuf_t buf)
  1628. {
  1629. return __qdf_nbuf_data_is_ipv6_udp_pkt(qdf_nbuf_data(buf));
  1630. }
  1631. /**
  1632. * qdf_nbuf_data_is_ipv6_udp_pkt() - check if it is IPV6 UDP packet.
  1633. * @data: Pointer to IPV6 UDP packet data buffer
  1634. *
  1635. * This func. checks whether it is a IPV6 UDP packet or not.
  1636. *
  1637. * Return: TRUE if it is a IPV6 UDP packet
  1638. * FALSE if not
  1639. */
  1640. static inline
  1641. bool qdf_nbuf_data_is_ipv6_udp_pkt(uint8_t *data)
  1642. {
  1643. return __qdf_nbuf_data_is_ipv6_udp_pkt(data);
  1644. }
  1645. /**
  1646. * qdf_nbuf_is_ipv6_tcp_pkt() - check if it is IPV6 TCP packet.
  1647. * @buf: Pointer to IPV6 TCP packet buffer
  1648. *
  1649. * This func. checks whether it is a IPV6 TCP packet or not.
  1650. *
  1651. * Return: TRUE if it is a IPV6 TCP packet
  1652. * FALSE if not
  1653. */
  1654. static inline
  1655. bool qdf_nbuf_is_ipv6_tcp_pkt(qdf_nbuf_t buf)
  1656. {
  1657. return __qdf_nbuf_data_is_ipv6_tcp_pkt(qdf_nbuf_data(buf));
  1658. }
  1659. /**
  1660. * qdf_nbuf_data_is_ipv6_tcp_pkt() - check if it is IPV6 TCP packet.
  1661. * @data: Pointer to IPV6 TCP packet data buffer
  1662. *
  1663. * This func. checks whether it is a IPV6 TCP packet or not.
  1664. *
  1665. * Return: TRUE if it is a IPV6 TCP packet
  1666. * FALSE if not
  1667. */
  1668. static inline
  1669. bool qdf_nbuf_data_is_ipv6_tcp_pkt(uint8_t *data)
  1670. {
  1671. return __qdf_nbuf_data_is_ipv6_tcp_pkt(data);
  1672. }
  1673. /**
  1674. * qdf_invalidate_range() - invalidate virtual address range
  1675. * @start: start address of the address range
  1676. * @end: end address of the address range
  1677. *
  1678. * Note that this function does not write back the cache entries.
  1679. *
  1680. * Return: none
  1681. */
  1682. static inline void qdf_invalidate_range(void *start, void *end)
  1683. {
  1684. __qdf_invalidate_range(start, end);
  1685. }
  1686. /**
  1687. * qdf_nbuf_reset_num_frags() - decrement the number of fragments
  1688. * @buf: Network buffer
  1689. *
  1690. * Return: Number of fragments
  1691. */
  1692. static inline void qdf_nbuf_reset_num_frags(qdf_nbuf_t buf)
  1693. {
  1694. __qdf_nbuf_reset_num_frags(buf);
  1695. }
  1696. /**
  1697. * qdf_dmaaddr_to_32s - return high and low parts of dma_addr
  1698. *
  1699. * Returns the high and low 32-bits of the DMA addr in the provided ptrs
  1700. *
  1701. * Return: N/A
  1702. */
  1703. static inline void qdf_dmaaddr_to_32s(qdf_dma_addr_t dmaaddr,
  1704. uint32_t *lo, uint32_t *hi)
  1705. {
  1706. return __qdf_dmaaddr_to_32s(dmaaddr, lo, hi);
  1707. }
  1708. /**
  1709. * qdf_nbuf_is_tso() - is the network buffer a jumbo packet?
  1710. * @buf: Network buffer
  1711. *
  1712. * Return: 1 - this is a jumbo packet 0 - not a jumbo packet
  1713. */
  1714. static inline uint8_t qdf_nbuf_is_tso(qdf_nbuf_t nbuf)
  1715. {
  1716. return __qdf_nbuf_is_tso(nbuf);
  1717. }
  1718. /**
  1719. * qdf_nbuf_get_tso_info() - function to divide a jumbo TSO
  1720. * network buffer into segments
  1721. * @nbuf: network buffer to be segmented
  1722. * @tso_info: This is the output. The information about the
  1723. * TSO segments will be populated within this.
  1724. *
  1725. * This function fragments a TCP jumbo packet into smaller
  1726. * segments to be transmitted by the driver. It chains the TSO
  1727. * segments created into a list.
  1728. *
  1729. * Return: number of TSO segments
  1730. */
  1731. static inline uint32_t qdf_nbuf_get_tso_info(qdf_device_t osdev,
  1732. qdf_nbuf_t nbuf, struct qdf_tso_info_t *tso_info)
  1733. {
  1734. return __qdf_nbuf_get_tso_info(osdev, nbuf, tso_info);
  1735. }
  1736. /**
  1737. * qdf_nbuf_unmap_tso_segment() - function to dma unmap TSO segment element
  1738. *
  1739. * @osdev: qdf device handle
  1740. * @tso_seg: TSO segment element to be unmapped
  1741. * @is_last_seg: whether this is last tso seg or not
  1742. *
  1743. * Return: none
  1744. */
  1745. static inline void qdf_nbuf_unmap_tso_segment(qdf_device_t osdev,
  1746. struct qdf_tso_seg_elem_t *tso_seg,
  1747. bool is_last_seg)
  1748. {
  1749. return __qdf_nbuf_unmap_tso_segment(osdev, tso_seg, is_last_seg);
  1750. }
  1751. /**
  1752. * qdf_nbuf_get_tso_num_seg() - function to calculate the number
  1753. * of TCP segments within the TSO jumbo packet
  1754. * @nbuf: TSO jumbo network buffer to be segmented
  1755. *
  1756. * This function calculates the number of TCP segments that the
  1757. network buffer can be divided into.
  1758. *
  1759. * Return: number of TCP segments
  1760. */
  1761. static inline uint32_t qdf_nbuf_get_tso_num_seg(qdf_nbuf_t nbuf)
  1762. {
  1763. return __qdf_nbuf_get_tso_num_seg(nbuf);
  1764. }
  1765. /**
  1766. * qdf_nbuf_inc_users() - function to increment the number of
  1767. * users referencing this network buffer
  1768. *
  1769. * @nbuf: network buffer
  1770. *
  1771. * This function increments the number of users referencing this
  1772. * network buffer
  1773. *
  1774. * Return: the network buffer
  1775. */
  1776. static inline qdf_nbuf_t qdf_nbuf_inc_users(qdf_nbuf_t nbuf)
  1777. {
  1778. return __qdf_nbuf_inc_users(nbuf);
  1779. }
  1780. /**
  1781. * qdf_nbuf_get_users() - function to get the number of users referencing this
  1782. * network buffer
  1783. *
  1784. * @nbuf: network buffer
  1785. *
  1786. * Return: number of user references to nbuf.
  1787. */
  1788. static inline int qdf_nbuf_get_users(qdf_nbuf_t nbuf)
  1789. {
  1790. return __qdf_nbuf_get_users(nbuf);
  1791. }
  1792. /**
  1793. * qdf_nbuf_data_attr_get() - Get data_attr field from cvg_nbuf_cb
  1794. *
  1795. * @nbuf: Network buffer (skb on linux)
  1796. *
  1797. * This function returns the values of data_attr field
  1798. * in struct cvg_nbuf_cb{}, to which skb->cb is typecast.
  1799. * This value is actually the value programmed in CE descriptor.
  1800. *
  1801. * Return: Value of data_attr
  1802. */
  1803. static inline uint32_t qdf_nbuf_data_attr_get(qdf_nbuf_t buf)
  1804. {
  1805. return __qdf_nbuf_data_attr_get(buf);
  1806. }
  1807. /**
  1808. * qdf_nbuf_data_attr_set() - Sets data_attr field in cvg_nbuf_cb
  1809. *
  1810. * @nbuf: Network buffer (skb on linux)
  1811. * @data_attr: Value to be stored cvg_nbuf_cb->data_attr
  1812. *
  1813. * This function stores the value to be programmed in CE
  1814. * descriptor as part skb->cb which is typecast to struct cvg_nbuf_cb{}
  1815. *
  1816. * Return: void
  1817. */
  1818. static inline
  1819. void qdf_nbuf_data_attr_set(qdf_nbuf_t buf, uint32_t data_attr)
  1820. {
  1821. __qdf_nbuf_data_attr_set(buf, data_attr);
  1822. }
  1823. /**
  1824. * qdf_nbuf_tx_info_get() - Parse skb and get Tx metadata
  1825. *
  1826. * @nbuf: Network buffer (skb on linux)
  1827. *
  1828. * This function parses the payload to figure out relevant
  1829. * Tx meta-data e.g. whether to enable tx_classify bit
  1830. * in CE.
  1831. *
  1832. * Return: void
  1833. */
  1834. #define qdf_nbuf_tx_info_get __qdf_nbuf_tx_info_get
  1835. void qdf_nbuf_set_state(qdf_nbuf_t nbuf, uint8_t current_state);
  1836. void qdf_nbuf_tx_desc_count_display(void);
  1837. void qdf_nbuf_tx_desc_count_clear(void);
  1838. static inline qdf_nbuf_t
  1839. qdf_nbuf_realloc_headroom(qdf_nbuf_t buf, uint32_t headroom)
  1840. {
  1841. return __qdf_nbuf_realloc_headroom(buf, headroom);
  1842. }
  1843. static inline qdf_nbuf_t
  1844. qdf_nbuf_realloc_tailroom(qdf_nbuf_t buf, uint32_t tailroom)
  1845. {
  1846. return __qdf_nbuf_realloc_tailroom(buf, tailroom);
  1847. }
  1848. static inline qdf_nbuf_t
  1849. qdf_nbuf_expand(qdf_nbuf_t buf, uint32_t headroom, uint32_t tailroom)
  1850. {
  1851. return __qdf_nbuf_expand(buf, headroom, tailroom);
  1852. }
  1853. static inline qdf_nbuf_t
  1854. qdf_nbuf_unshare(qdf_nbuf_t buf)
  1855. {
  1856. return __qdf_nbuf_unshare(buf);
  1857. }
  1858. static inline bool
  1859. qdf_nbuf_is_cloned(qdf_nbuf_t buf)
  1860. {
  1861. return __qdf_nbuf_is_cloned(buf);
  1862. }
  1863. static inline void
  1864. qdf_nbuf_frag_info(qdf_nbuf_t buf, qdf_sglist_t *sg)
  1865. {
  1866. __qdf_nbuf_frag_info(buf, sg);
  1867. }
  1868. static inline qdf_nbuf_tx_cksum_t
  1869. qdf_nbuf_tx_cksum_info(qdf_nbuf_t buf, uint8_t **hdr_off, uint8_t **where)
  1870. {
  1871. return __qdf_nbuf_tx_cksum_info(buf, hdr_off, where);
  1872. }
  1873. static inline void qdf_nbuf_reset_ctxt(__qdf_nbuf_t nbuf)
  1874. {
  1875. __qdf_nbuf_reset_ctxt(nbuf);
  1876. }
  1877. static inline void
  1878. qdf_nbuf_set_rx_info(__qdf_nbuf_t nbuf, void *info, uint32_t len)
  1879. {
  1880. __qdf_nbuf_set_rx_info(nbuf, info, len);
  1881. }
  1882. static inline void *qdf_nbuf_get_rx_info(__qdf_nbuf_t nbuf)
  1883. {
  1884. return __qdf_nbuf_get_rx_info(nbuf);
  1885. }
  1886. static inline void qdf_nbuf_init(qdf_nbuf_t buf)
  1887. {
  1888. __qdf_nbuf_init(buf);
  1889. }
  1890. static inline void *qdf_nbuf_network_header(qdf_nbuf_t buf)
  1891. {
  1892. return __qdf_nbuf_network_header(buf);
  1893. }
  1894. static inline void *qdf_nbuf_transport_header(qdf_nbuf_t buf)
  1895. {
  1896. return __qdf_nbuf_transport_header(buf);
  1897. }
  1898. static inline qdf_size_t qdf_nbuf_tcp_tso_size(qdf_nbuf_t buf)
  1899. {
  1900. return __qdf_nbuf_tcp_tso_size(buf);
  1901. }
  1902. static inline void *qdf_nbuf_get_cb(qdf_nbuf_t nbuf)
  1903. {
  1904. return __qdf_nbuf_get_cb(nbuf);
  1905. }
  1906. static inline uint32_t qdf_nbuf_get_nr_frags(qdf_nbuf_t nbuf)
  1907. {
  1908. return __qdf_nbuf_get_nr_frags(nbuf);
  1909. }
  1910. static inline qdf_size_t qdf_nbuf_headlen(qdf_nbuf_t buf)
  1911. {
  1912. return __qdf_nbuf_headlen(buf);
  1913. }
  1914. static inline QDF_STATUS qdf_nbuf_frag_map(qdf_device_t osdev,
  1915. qdf_nbuf_t buf, int offset,
  1916. qdf_dma_dir_t dir, int cur_frag)
  1917. {
  1918. return __qdf_nbuf_frag_map(osdev, buf, offset, dir, cur_frag);
  1919. }
  1920. static inline bool qdf_nbuf_tso_tcp_v4(qdf_nbuf_t buf)
  1921. {
  1922. return __qdf_nbuf_tso_tcp_v4(buf);
  1923. }
  1924. static inline bool qdf_nbuf_tso_tcp_v6(qdf_nbuf_t buf)
  1925. {
  1926. return __qdf_nbuf_tso_tcp_v6(buf);
  1927. }
  1928. static inline uint32_t qdf_nbuf_tcp_seq(qdf_nbuf_t buf)
  1929. {
  1930. return __qdf_nbuf_tcp_seq(buf);
  1931. }
  1932. static inline qdf_size_t qdf_nbuf_l2l3l4_hdr_len(qdf_nbuf_t buf)
  1933. {
  1934. return __qdf_nbuf_l2l3l4_hdr_len(buf);
  1935. }
  1936. static inline bool qdf_nbuf_is_nonlinear(qdf_nbuf_t buf)
  1937. {
  1938. return __qdf_nbuf_is_nonlinear(buf);
  1939. }
  1940. static inline uint32_t
  1941. qdf_nbuf_get_frag_size(qdf_nbuf_t buf, uint32_t frag_num)
  1942. {
  1943. return __qdf_nbuf_get_frag_size(buf, frag_num);
  1944. }
  1945. static inline uint32_t qdf_nbuf_get_priority(qdf_nbuf_t buf)
  1946. {
  1947. return __qdf_nbuf_get_priority(buf);
  1948. }
  1949. static inline void qdf_nbuf_set_priority(qdf_nbuf_t buf, uint32_t p)
  1950. {
  1951. __qdf_nbuf_set_priority(buf, p);
  1952. }
  1953. static inline uint16_t
  1954. qdf_nbuf_get_queue_mapping(qdf_nbuf_t buf)
  1955. {
  1956. return __qdf_nbuf_get_queue_mapping(buf);
  1957. }
  1958. static inline uint8_t *
  1959. qdf_nbuf_get_priv_ptr(qdf_nbuf_t buf)
  1960. {
  1961. return __qdf_nbuf_get_priv_ptr(buf);
  1962. }
  1963. /**
  1964. * qdf_nbuf_update_radiotap() - update radiotap at head of nbuf.
  1965. * @rx_status: rx_status containing required info to update radiotap
  1966. * @nbuf: Pointer to nbuf
  1967. * @headroom_sz: Available headroom size
  1968. *
  1969. * Return: radiotap length.
  1970. */
  1971. unsigned int qdf_nbuf_update_radiotap(struct mon_rx_status *rx_status,
  1972. qdf_nbuf_t nbuf, uint32_t headroom_sz);
  1973. /**
  1974. * qdf_nbuf_mark_wakeup_frame() - mark wakeup frame.
  1975. * @buf: Pointer to nbuf
  1976. *
  1977. * Return: None
  1978. */
  1979. static inline void
  1980. qdf_nbuf_mark_wakeup_frame(qdf_nbuf_t buf)
  1981. {
  1982. __qdf_nbuf_mark_wakeup_frame(buf);
  1983. }
  1984. #endif /* _QDF_NBUF_H */