qdf_nbuf.h 135 KB

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