qdf_nbuf.h 133 KB

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