qdf_nbuf.h 120 KB

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