qdf_nbuf.h 102 KB

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