qdf_nbuf.h 100 KB

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