qdf_nbuf.h 148 KB

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