qdf_nbuf.h 79 KB

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