qdf_nbuf.h 93 KB

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