qdf_nbuf.h 106 KB

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