qdf_nbuf.h 108 KB

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