qdf_nbuf.h 91 KB

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