qdf_nbuf.h 67 KB

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