qdf_nbuf.h 103 KB

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