qdf_nbuf.h 105 KB

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