core.h 143 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947
  1. /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
  2. /* Copyright(c) 2019-2020 Realtek Corporation
  3. */
  4. #ifndef __RTW89_CORE_H__
  5. #define __RTW89_CORE_H__
  6. #include <linux/average.h>
  7. #include <linux/bitfield.h>
  8. #include <linux/firmware.h>
  9. #include <linux/iopoll.h>
  10. #include <linux/workqueue.h>
  11. #include <net/mac80211.h>
  12. #include <linux/version.h>
  13. struct rtw89_dev;
  14. struct rtw89_pci_info;
  15. struct rtw89_mac_gen_def;
  16. struct rtw89_phy_gen_def;
  17. extern const struct ieee80211_ops rtw89_ops;
  18. #define MASKBYTE0 0xff
  19. #define MASKBYTE1 0xff00
  20. #define MASKBYTE2 0xff0000
  21. #define MASKBYTE3 0xff000000
  22. #define MASKBYTE4 0xff00000000ULL
  23. #define MASKHWORD 0xffff0000
  24. #define MASKLWORD 0x0000ffff
  25. #define MASKDWORD 0xffffffff
  26. #define RFREG_MASK 0xfffff
  27. #define INV_RF_DATA 0xffffffff
  28. #define RTW89_TRACK_WORK_PERIOD round_jiffies_relative(HZ * 2)
  29. #define RTW89_FORBID_BA_TIMER round_jiffies_relative(HZ * 4)
  30. #define CFO_TRACK_MAX_USER 64
  31. #define MAX_RSSI 110
  32. #define RSSI_FACTOR 1
  33. #define RTW89_RSSI_RAW_TO_DBM(rssi) ((s8)((rssi) >> RSSI_FACTOR) - MAX_RSSI)
  34. #define RTW89_TX_DIV_RSSI_RAW_TH (2 << RSSI_FACTOR)
  35. #define RTW89_RADIOTAP_ROOM ALIGN(sizeof(struct ieee80211_radiotap_he), 64)
  36. #define RTW89_HTC_MASK_VARIANT GENMASK(1, 0)
  37. #define RTW89_HTC_VARIANT_HE 3
  38. #define RTW89_HTC_MASK_CTL_ID GENMASK(5, 2)
  39. #define RTW89_HTC_VARIANT_HE_CID_OM 1
  40. #define RTW89_HTC_VARIANT_HE_CID_CAS 6
  41. #define RTW89_HTC_MASK_CTL_INFO GENMASK(31, 6)
  42. #define RTW89_HTC_MASK_HTC_OM_RX_NSS GENMASK(8, 6)
  43. enum htc_om_channel_width {
  44. HTC_OM_CHANNEL_WIDTH_20 = 0,
  45. HTC_OM_CHANNEL_WIDTH_40 = 1,
  46. HTC_OM_CHANNEL_WIDTH_80 = 2,
  47. HTC_OM_CHANNEL_WIDTH_160_OR_80_80 = 3,
  48. };
  49. #define RTW89_HTC_MASK_HTC_OM_CH_WIDTH GENMASK(10, 9)
  50. #define RTW89_HTC_MASK_HTC_OM_UL_MU_DIS BIT(11)
  51. #define RTW89_HTC_MASK_HTC_OM_TX_NSTS GENMASK(14, 12)
  52. #define RTW89_HTC_MASK_HTC_OM_ER_SU_DIS BIT(15)
  53. #define RTW89_HTC_MASK_HTC_OM_DL_MU_MIMO_RR BIT(16)
  54. #define RTW89_HTC_MASK_HTC_OM_UL_MU_DATA_DIS BIT(17)
  55. #define RTW89_TF_PAD GENMASK(11, 0)
  56. #define RTW89_TF_BASIC_USER_INFO_SZ 6
  57. #define RTW89_GET_TF_USER_INFO_AID12(data) \
  58. le32_get_bits(*((const __le32 *)(data)), GENMASK(11, 0))
  59. #define RTW89_GET_TF_USER_INFO_RUA(data) \
  60. le32_get_bits(*((const __le32 *)(data)), GENMASK(19, 12))
  61. #define RTW89_GET_TF_USER_INFO_UL_MCS(data) \
  62. le32_get_bits(*((const __le32 *)(data)), GENMASK(24, 21))
  63. enum rtw89_subband {
  64. RTW89_CH_2G = 0,
  65. RTW89_CH_5G_BAND_1 = 1,
  66. /* RTW89_CH_5G_BAND_2 = 2, unused */
  67. RTW89_CH_5G_BAND_3 = 3,
  68. RTW89_CH_5G_BAND_4 = 4,
  69. RTW89_CH_6G_BAND_IDX0, /* Low */
  70. RTW89_CH_6G_BAND_IDX1, /* Low */
  71. RTW89_CH_6G_BAND_IDX2, /* Mid */
  72. RTW89_CH_6G_BAND_IDX3, /* Mid */
  73. RTW89_CH_6G_BAND_IDX4, /* High */
  74. RTW89_CH_6G_BAND_IDX5, /* High */
  75. RTW89_CH_6G_BAND_IDX6, /* Ultra-high */
  76. RTW89_CH_6G_BAND_IDX7, /* Ultra-high */
  77. RTW89_SUBBAND_NR,
  78. RTW89_SUBBAND_2GHZ_5GHZ_NR = RTW89_CH_5G_BAND_4 + 1,
  79. };
  80. enum rtw89_gain_offset {
  81. RTW89_GAIN_OFFSET_2G_CCK,
  82. RTW89_GAIN_OFFSET_2G_OFDM,
  83. RTW89_GAIN_OFFSET_5G_LOW,
  84. RTW89_GAIN_OFFSET_5G_MID,
  85. RTW89_GAIN_OFFSET_5G_HIGH,
  86. RTW89_GAIN_OFFSET_NR,
  87. };
  88. enum rtw89_hci_type {
  89. RTW89_HCI_TYPE_PCIE,
  90. RTW89_HCI_TYPE_USB,
  91. RTW89_HCI_TYPE_SDIO,
  92. };
  93. enum rtw89_core_chip_id {
  94. RTL8852A,
  95. RTL8852B,
  96. RTL8852C,
  97. RTL8851B,
  98. RTL8922A,
  99. };
  100. enum rtw89_chip_gen {
  101. RTW89_CHIP_AX,
  102. RTW89_CHIP_BE,
  103. RTW89_CHIP_GEN_NUM,
  104. };
  105. enum rtw89_cv {
  106. CHIP_CAV,
  107. CHIP_CBV,
  108. CHIP_CCV,
  109. CHIP_CDV,
  110. CHIP_CEV,
  111. CHIP_CFV,
  112. CHIP_CV_MAX,
  113. CHIP_CV_INVALID = CHIP_CV_MAX,
  114. };
  115. enum rtw89_bacam_ver {
  116. RTW89_BACAM_V0,
  117. RTW89_BACAM_V1,
  118. RTW89_BACAM_V0_EXT = 99,
  119. };
  120. enum rtw89_core_tx_type {
  121. RTW89_CORE_TX_TYPE_DATA,
  122. RTW89_CORE_TX_TYPE_MGMT,
  123. RTW89_CORE_TX_TYPE_FWCMD,
  124. };
  125. enum rtw89_core_rx_type {
  126. RTW89_CORE_RX_TYPE_WIFI = 0,
  127. RTW89_CORE_RX_TYPE_PPDU_STAT = 1,
  128. RTW89_CORE_RX_TYPE_CHAN_INFO = 2,
  129. RTW89_CORE_RX_TYPE_BB_SCOPE = 3,
  130. RTW89_CORE_RX_TYPE_F2P_TXCMD = 4,
  131. RTW89_CORE_RX_TYPE_SS2FW = 5,
  132. RTW89_CORE_RX_TYPE_TX_REPORT = 6,
  133. RTW89_CORE_RX_TYPE_TX_REL_HOST = 7,
  134. RTW89_CORE_RX_TYPE_DFS_REPORT = 8,
  135. RTW89_CORE_RX_TYPE_TX_REL_CPU = 9,
  136. RTW89_CORE_RX_TYPE_C2H = 10,
  137. RTW89_CORE_RX_TYPE_CSI = 11,
  138. RTW89_CORE_RX_TYPE_CQI = 12,
  139. RTW89_CORE_RX_TYPE_H2C = 13,
  140. RTW89_CORE_RX_TYPE_FWDL = 14,
  141. };
  142. enum rtw89_txq_flags {
  143. RTW89_TXQ_F_AMPDU = 0,
  144. RTW89_TXQ_F_BLOCK_BA = 1,
  145. RTW89_TXQ_F_FORBID_BA = 2,
  146. };
  147. enum rtw89_net_type {
  148. RTW89_NET_TYPE_NO_LINK = 0,
  149. RTW89_NET_TYPE_AD_HOC = 1,
  150. RTW89_NET_TYPE_INFRA = 2,
  151. RTW89_NET_TYPE_AP_MODE = 3,
  152. };
  153. enum rtw89_wifi_role {
  154. RTW89_WIFI_ROLE_NONE,
  155. RTW89_WIFI_ROLE_STATION,
  156. RTW89_WIFI_ROLE_AP,
  157. RTW89_WIFI_ROLE_AP_VLAN,
  158. RTW89_WIFI_ROLE_ADHOC,
  159. RTW89_WIFI_ROLE_ADHOC_MASTER,
  160. RTW89_WIFI_ROLE_MESH_POINT,
  161. RTW89_WIFI_ROLE_MONITOR,
  162. RTW89_WIFI_ROLE_P2P_DEVICE,
  163. RTW89_WIFI_ROLE_P2P_CLIENT,
  164. RTW89_WIFI_ROLE_P2P_GO,
  165. RTW89_WIFI_ROLE_NAN,
  166. RTW89_WIFI_ROLE_MLME_MAX
  167. };
  168. enum rtw89_upd_mode {
  169. RTW89_ROLE_CREATE,
  170. RTW89_ROLE_REMOVE,
  171. RTW89_ROLE_TYPE_CHANGE,
  172. RTW89_ROLE_INFO_CHANGE,
  173. RTW89_ROLE_CON_DISCONN,
  174. RTW89_ROLE_BAND_SW,
  175. RTW89_ROLE_FW_RESTORE,
  176. };
  177. enum rtw89_self_role {
  178. RTW89_SELF_ROLE_CLIENT,
  179. RTW89_SELF_ROLE_AP,
  180. RTW89_SELF_ROLE_AP_CLIENT
  181. };
  182. enum rtw89_msk_sO_el {
  183. RTW89_NO_MSK,
  184. RTW89_SMA,
  185. RTW89_TMA,
  186. RTW89_BSSID
  187. };
  188. enum rtw89_sch_tx_sel {
  189. RTW89_SCH_TX_SEL_ALL,
  190. RTW89_SCH_TX_SEL_HIQ,
  191. RTW89_SCH_TX_SEL_MG0,
  192. RTW89_SCH_TX_SEL_MACID,
  193. };
  194. /* RTW89_ADDR_CAM_SEC_NONE : not enabled
  195. * RTW89_ADDR_CAM_SEC_ALL_UNI : 0 - 6 unicast
  196. * RTW89_ADDR_CAM_SEC_NORMAL : 0 - 1 unicast, 2 - 4 group, 5 - 6 BIP
  197. * RTW89_ADDR_CAM_SEC_4GROUP : 0 - 1 unicast, 2 - 5 group, 6 BIP
  198. */
  199. enum rtw89_add_cam_sec_mode {
  200. RTW89_ADDR_CAM_SEC_NONE = 0,
  201. RTW89_ADDR_CAM_SEC_ALL_UNI = 1,
  202. RTW89_ADDR_CAM_SEC_NORMAL = 2,
  203. RTW89_ADDR_CAM_SEC_4GROUP = 3,
  204. };
  205. enum rtw89_sec_key_type {
  206. RTW89_SEC_KEY_TYPE_NONE = 0,
  207. RTW89_SEC_KEY_TYPE_WEP40 = 1,
  208. RTW89_SEC_KEY_TYPE_WEP104 = 2,
  209. RTW89_SEC_KEY_TYPE_TKIP = 3,
  210. RTW89_SEC_KEY_TYPE_WAPI = 4,
  211. RTW89_SEC_KEY_TYPE_GCMSMS4 = 5,
  212. RTW89_SEC_KEY_TYPE_CCMP128 = 6,
  213. RTW89_SEC_KEY_TYPE_CCMP256 = 7,
  214. RTW89_SEC_KEY_TYPE_GCMP128 = 8,
  215. RTW89_SEC_KEY_TYPE_GCMP256 = 9,
  216. RTW89_SEC_KEY_TYPE_BIP_CCMP128 = 10,
  217. };
  218. enum rtw89_port {
  219. RTW89_PORT_0 = 0,
  220. RTW89_PORT_1 = 1,
  221. RTW89_PORT_2 = 2,
  222. RTW89_PORT_3 = 3,
  223. RTW89_PORT_4 = 4,
  224. RTW89_PORT_NUM
  225. };
  226. enum rtw89_band {
  227. RTW89_BAND_2G = 0,
  228. RTW89_BAND_5G = 1,
  229. RTW89_BAND_6G = 2,
  230. RTW89_BAND_NUM,
  231. };
  232. enum rtw89_hw_rate {
  233. RTW89_HW_RATE_CCK1 = 0x0,
  234. RTW89_HW_RATE_CCK2 = 0x1,
  235. RTW89_HW_RATE_CCK5_5 = 0x2,
  236. RTW89_HW_RATE_CCK11 = 0x3,
  237. RTW89_HW_RATE_OFDM6 = 0x4,
  238. RTW89_HW_RATE_OFDM9 = 0x5,
  239. RTW89_HW_RATE_OFDM12 = 0x6,
  240. RTW89_HW_RATE_OFDM18 = 0x7,
  241. RTW89_HW_RATE_OFDM24 = 0x8,
  242. RTW89_HW_RATE_OFDM36 = 0x9,
  243. RTW89_HW_RATE_OFDM48 = 0xA,
  244. RTW89_HW_RATE_OFDM54 = 0xB,
  245. RTW89_HW_RATE_MCS0 = 0x80,
  246. RTW89_HW_RATE_MCS1 = 0x81,
  247. RTW89_HW_RATE_MCS2 = 0x82,
  248. RTW89_HW_RATE_MCS3 = 0x83,
  249. RTW89_HW_RATE_MCS4 = 0x84,
  250. RTW89_HW_RATE_MCS5 = 0x85,
  251. RTW89_HW_RATE_MCS6 = 0x86,
  252. RTW89_HW_RATE_MCS7 = 0x87,
  253. RTW89_HW_RATE_MCS8 = 0x88,
  254. RTW89_HW_RATE_MCS9 = 0x89,
  255. RTW89_HW_RATE_MCS10 = 0x8A,
  256. RTW89_HW_RATE_MCS11 = 0x8B,
  257. RTW89_HW_RATE_MCS12 = 0x8C,
  258. RTW89_HW_RATE_MCS13 = 0x8D,
  259. RTW89_HW_RATE_MCS14 = 0x8E,
  260. RTW89_HW_RATE_MCS15 = 0x8F,
  261. RTW89_HW_RATE_MCS16 = 0x90,
  262. RTW89_HW_RATE_MCS17 = 0x91,
  263. RTW89_HW_RATE_MCS18 = 0x92,
  264. RTW89_HW_RATE_MCS19 = 0x93,
  265. RTW89_HW_RATE_MCS20 = 0x94,
  266. RTW89_HW_RATE_MCS21 = 0x95,
  267. RTW89_HW_RATE_MCS22 = 0x96,
  268. RTW89_HW_RATE_MCS23 = 0x97,
  269. RTW89_HW_RATE_MCS24 = 0x98,
  270. RTW89_HW_RATE_MCS25 = 0x99,
  271. RTW89_HW_RATE_MCS26 = 0x9A,
  272. RTW89_HW_RATE_MCS27 = 0x9B,
  273. RTW89_HW_RATE_MCS28 = 0x9C,
  274. RTW89_HW_RATE_MCS29 = 0x9D,
  275. RTW89_HW_RATE_MCS30 = 0x9E,
  276. RTW89_HW_RATE_MCS31 = 0x9F,
  277. RTW89_HW_RATE_VHT_NSS1_MCS0 = 0x100,
  278. RTW89_HW_RATE_VHT_NSS1_MCS1 = 0x101,
  279. RTW89_HW_RATE_VHT_NSS1_MCS2 = 0x102,
  280. RTW89_HW_RATE_VHT_NSS1_MCS3 = 0x103,
  281. RTW89_HW_RATE_VHT_NSS1_MCS4 = 0x104,
  282. RTW89_HW_RATE_VHT_NSS1_MCS5 = 0x105,
  283. RTW89_HW_RATE_VHT_NSS1_MCS6 = 0x106,
  284. RTW89_HW_RATE_VHT_NSS1_MCS7 = 0x107,
  285. RTW89_HW_RATE_VHT_NSS1_MCS8 = 0x108,
  286. RTW89_HW_RATE_VHT_NSS1_MCS9 = 0x109,
  287. RTW89_HW_RATE_VHT_NSS2_MCS0 = 0x110,
  288. RTW89_HW_RATE_VHT_NSS2_MCS1 = 0x111,
  289. RTW89_HW_RATE_VHT_NSS2_MCS2 = 0x112,
  290. RTW89_HW_RATE_VHT_NSS2_MCS3 = 0x113,
  291. RTW89_HW_RATE_VHT_NSS2_MCS4 = 0x114,
  292. RTW89_HW_RATE_VHT_NSS2_MCS5 = 0x115,
  293. RTW89_HW_RATE_VHT_NSS2_MCS6 = 0x116,
  294. RTW89_HW_RATE_VHT_NSS2_MCS7 = 0x117,
  295. RTW89_HW_RATE_VHT_NSS2_MCS8 = 0x118,
  296. RTW89_HW_RATE_VHT_NSS2_MCS9 = 0x119,
  297. RTW89_HW_RATE_VHT_NSS3_MCS0 = 0x120,
  298. RTW89_HW_RATE_VHT_NSS3_MCS1 = 0x121,
  299. RTW89_HW_RATE_VHT_NSS3_MCS2 = 0x122,
  300. RTW89_HW_RATE_VHT_NSS3_MCS3 = 0x123,
  301. RTW89_HW_RATE_VHT_NSS3_MCS4 = 0x124,
  302. RTW89_HW_RATE_VHT_NSS3_MCS5 = 0x125,
  303. RTW89_HW_RATE_VHT_NSS3_MCS6 = 0x126,
  304. RTW89_HW_RATE_VHT_NSS3_MCS7 = 0x127,
  305. RTW89_HW_RATE_VHT_NSS3_MCS8 = 0x128,
  306. RTW89_HW_RATE_VHT_NSS3_MCS9 = 0x129,
  307. RTW89_HW_RATE_VHT_NSS4_MCS0 = 0x130,
  308. RTW89_HW_RATE_VHT_NSS4_MCS1 = 0x131,
  309. RTW89_HW_RATE_VHT_NSS4_MCS2 = 0x132,
  310. RTW89_HW_RATE_VHT_NSS4_MCS3 = 0x133,
  311. RTW89_HW_RATE_VHT_NSS4_MCS4 = 0x134,
  312. RTW89_HW_RATE_VHT_NSS4_MCS5 = 0x135,
  313. RTW89_HW_RATE_VHT_NSS4_MCS6 = 0x136,
  314. RTW89_HW_RATE_VHT_NSS4_MCS7 = 0x137,
  315. RTW89_HW_RATE_VHT_NSS4_MCS8 = 0x138,
  316. RTW89_HW_RATE_VHT_NSS4_MCS9 = 0x139,
  317. RTW89_HW_RATE_HE_NSS1_MCS0 = 0x180,
  318. RTW89_HW_RATE_HE_NSS1_MCS1 = 0x181,
  319. RTW89_HW_RATE_HE_NSS1_MCS2 = 0x182,
  320. RTW89_HW_RATE_HE_NSS1_MCS3 = 0x183,
  321. RTW89_HW_RATE_HE_NSS1_MCS4 = 0x184,
  322. RTW89_HW_RATE_HE_NSS1_MCS5 = 0x185,
  323. RTW89_HW_RATE_HE_NSS1_MCS6 = 0x186,
  324. RTW89_HW_RATE_HE_NSS1_MCS7 = 0x187,
  325. RTW89_HW_RATE_HE_NSS1_MCS8 = 0x188,
  326. RTW89_HW_RATE_HE_NSS1_MCS9 = 0x189,
  327. RTW89_HW_RATE_HE_NSS1_MCS10 = 0x18A,
  328. RTW89_HW_RATE_HE_NSS1_MCS11 = 0x18B,
  329. RTW89_HW_RATE_HE_NSS2_MCS0 = 0x190,
  330. RTW89_HW_RATE_HE_NSS2_MCS1 = 0x191,
  331. RTW89_HW_RATE_HE_NSS2_MCS2 = 0x192,
  332. RTW89_HW_RATE_HE_NSS2_MCS3 = 0x193,
  333. RTW89_HW_RATE_HE_NSS2_MCS4 = 0x194,
  334. RTW89_HW_RATE_HE_NSS2_MCS5 = 0x195,
  335. RTW89_HW_RATE_HE_NSS2_MCS6 = 0x196,
  336. RTW89_HW_RATE_HE_NSS2_MCS7 = 0x197,
  337. RTW89_HW_RATE_HE_NSS2_MCS8 = 0x198,
  338. RTW89_HW_RATE_HE_NSS2_MCS9 = 0x199,
  339. RTW89_HW_RATE_HE_NSS2_MCS10 = 0x19A,
  340. RTW89_HW_RATE_HE_NSS2_MCS11 = 0x19B,
  341. RTW89_HW_RATE_HE_NSS3_MCS0 = 0x1A0,
  342. RTW89_HW_RATE_HE_NSS3_MCS1 = 0x1A1,
  343. RTW89_HW_RATE_HE_NSS3_MCS2 = 0x1A2,
  344. RTW89_HW_RATE_HE_NSS3_MCS3 = 0x1A3,
  345. RTW89_HW_RATE_HE_NSS3_MCS4 = 0x1A4,
  346. RTW89_HW_RATE_HE_NSS3_MCS5 = 0x1A5,
  347. RTW89_HW_RATE_HE_NSS3_MCS6 = 0x1A6,
  348. RTW89_HW_RATE_HE_NSS3_MCS7 = 0x1A7,
  349. RTW89_HW_RATE_HE_NSS3_MCS8 = 0x1A8,
  350. RTW89_HW_RATE_HE_NSS3_MCS9 = 0x1A9,
  351. RTW89_HW_RATE_HE_NSS3_MCS10 = 0x1AA,
  352. RTW89_HW_RATE_HE_NSS3_MCS11 = 0x1AB,
  353. RTW89_HW_RATE_HE_NSS4_MCS0 = 0x1B0,
  354. RTW89_HW_RATE_HE_NSS4_MCS1 = 0x1B1,
  355. RTW89_HW_RATE_HE_NSS4_MCS2 = 0x1B2,
  356. RTW89_HW_RATE_HE_NSS4_MCS3 = 0x1B3,
  357. RTW89_HW_RATE_HE_NSS4_MCS4 = 0x1B4,
  358. RTW89_HW_RATE_HE_NSS4_MCS5 = 0x1B5,
  359. RTW89_HW_RATE_HE_NSS4_MCS6 = 0x1B6,
  360. RTW89_HW_RATE_HE_NSS4_MCS7 = 0x1B7,
  361. RTW89_HW_RATE_HE_NSS4_MCS8 = 0x1B8,
  362. RTW89_HW_RATE_HE_NSS4_MCS9 = 0x1B9,
  363. RTW89_HW_RATE_HE_NSS4_MCS10 = 0x1BA,
  364. RTW89_HW_RATE_HE_NSS4_MCS11 = 0x1BB,
  365. RTW89_HW_RATE_V1_MCS0 = 0x100,
  366. RTW89_HW_RATE_V1_MCS1 = 0x101,
  367. RTW89_HW_RATE_V1_MCS2 = 0x102,
  368. RTW89_HW_RATE_V1_MCS3 = 0x103,
  369. RTW89_HW_RATE_V1_MCS4 = 0x104,
  370. RTW89_HW_RATE_V1_MCS5 = 0x105,
  371. RTW89_HW_RATE_V1_MCS6 = 0x106,
  372. RTW89_HW_RATE_V1_MCS7 = 0x107,
  373. RTW89_HW_RATE_V1_MCS8 = 0x108,
  374. RTW89_HW_RATE_V1_MCS9 = 0x109,
  375. RTW89_HW_RATE_V1_MCS10 = 0x10A,
  376. RTW89_HW_RATE_V1_MCS11 = 0x10B,
  377. RTW89_HW_RATE_V1_MCS12 = 0x10C,
  378. RTW89_HW_RATE_V1_MCS13 = 0x10D,
  379. RTW89_HW_RATE_V1_MCS14 = 0x10E,
  380. RTW89_HW_RATE_V1_MCS15 = 0x10F,
  381. RTW89_HW_RATE_V1_MCS16 = 0x110,
  382. RTW89_HW_RATE_V1_MCS17 = 0x111,
  383. RTW89_HW_RATE_V1_MCS18 = 0x112,
  384. RTW89_HW_RATE_V1_MCS19 = 0x113,
  385. RTW89_HW_RATE_V1_MCS20 = 0x114,
  386. RTW89_HW_RATE_V1_MCS21 = 0x115,
  387. RTW89_HW_RATE_V1_MCS22 = 0x116,
  388. RTW89_HW_RATE_V1_MCS23 = 0x117,
  389. RTW89_HW_RATE_V1_MCS24 = 0x118,
  390. RTW89_HW_RATE_V1_MCS25 = 0x119,
  391. RTW89_HW_RATE_V1_MCS26 = 0x11A,
  392. RTW89_HW_RATE_V1_MCS27 = 0x11B,
  393. RTW89_HW_RATE_V1_MCS28 = 0x11C,
  394. RTW89_HW_RATE_V1_MCS29 = 0x11D,
  395. RTW89_HW_RATE_V1_MCS30 = 0x11E,
  396. RTW89_HW_RATE_V1_MCS31 = 0x11F,
  397. RTW89_HW_RATE_V1_VHT_NSS1_MCS0 = 0x200,
  398. RTW89_HW_RATE_V1_VHT_NSS1_MCS1 = 0x201,
  399. RTW89_HW_RATE_V1_VHT_NSS1_MCS2 = 0x202,
  400. RTW89_HW_RATE_V1_VHT_NSS1_MCS3 = 0x203,
  401. RTW89_HW_RATE_V1_VHT_NSS1_MCS4 = 0x204,
  402. RTW89_HW_RATE_V1_VHT_NSS1_MCS5 = 0x205,
  403. RTW89_HW_RATE_V1_VHT_NSS1_MCS6 = 0x206,
  404. RTW89_HW_RATE_V1_VHT_NSS1_MCS7 = 0x207,
  405. RTW89_HW_RATE_V1_VHT_NSS1_MCS8 = 0x208,
  406. RTW89_HW_RATE_V1_VHT_NSS1_MCS9 = 0x209,
  407. RTW89_HW_RATE_V1_VHT_NSS1_MCS10 = 0x20A,
  408. RTW89_HW_RATE_V1_VHT_NSS1_MCS11 = 0x20B,
  409. RTW89_HW_RATE_V1_VHT_NSS2_MCS0 = 0x220,
  410. RTW89_HW_RATE_V1_VHT_NSS2_MCS1 = 0x221,
  411. RTW89_HW_RATE_V1_VHT_NSS2_MCS2 = 0x222,
  412. RTW89_HW_RATE_V1_VHT_NSS2_MCS3 = 0x223,
  413. RTW89_HW_RATE_V1_VHT_NSS2_MCS4 = 0x224,
  414. RTW89_HW_RATE_V1_VHT_NSS2_MCS5 = 0x225,
  415. RTW89_HW_RATE_V1_VHT_NSS2_MCS6 = 0x226,
  416. RTW89_HW_RATE_V1_VHT_NSS2_MCS7 = 0x227,
  417. RTW89_HW_RATE_V1_VHT_NSS2_MCS8 = 0x228,
  418. RTW89_HW_RATE_V1_VHT_NSS2_MCS9 = 0x229,
  419. RTW89_HW_RATE_V1_VHT_NSS2_MCS10 = 0x22A,
  420. RTW89_HW_RATE_V1_VHT_NSS2_MCS11 = 0x22B,
  421. RTW89_HW_RATE_V1_VHT_NSS3_MCS0 = 0x240,
  422. RTW89_HW_RATE_V1_VHT_NSS3_MCS1 = 0x241,
  423. RTW89_HW_RATE_V1_VHT_NSS3_MCS2 = 0x242,
  424. RTW89_HW_RATE_V1_VHT_NSS3_MCS3 = 0x243,
  425. RTW89_HW_RATE_V1_VHT_NSS3_MCS4 = 0x244,
  426. RTW89_HW_RATE_V1_VHT_NSS3_MCS5 = 0x245,
  427. RTW89_HW_RATE_V1_VHT_NSS3_MCS6 = 0x246,
  428. RTW89_HW_RATE_V1_VHT_NSS3_MCS7 = 0x247,
  429. RTW89_HW_RATE_V1_VHT_NSS3_MCS8 = 0x248,
  430. RTW89_HW_RATE_V1_VHT_NSS3_MCS9 = 0x249,
  431. RTW89_HW_RATE_V1_VHT_NSS3_MCS10 = 0x24A,
  432. RTW89_HW_RATE_V1_VHT_NSS3_MCS11 = 0x24B,
  433. RTW89_HW_RATE_V1_VHT_NSS4_MCS0 = 0x260,
  434. RTW89_HW_RATE_V1_VHT_NSS4_MCS1 = 0x261,
  435. RTW89_HW_RATE_V1_VHT_NSS4_MCS2 = 0x262,
  436. RTW89_HW_RATE_V1_VHT_NSS4_MCS3 = 0x263,
  437. RTW89_HW_RATE_V1_VHT_NSS4_MCS4 = 0x264,
  438. RTW89_HW_RATE_V1_VHT_NSS4_MCS5 = 0x265,
  439. RTW89_HW_RATE_V1_VHT_NSS4_MCS6 = 0x266,
  440. RTW89_HW_RATE_V1_VHT_NSS4_MCS7 = 0x267,
  441. RTW89_HW_RATE_V1_VHT_NSS4_MCS8 = 0x268,
  442. RTW89_HW_RATE_V1_VHT_NSS4_MCS9 = 0x269,
  443. RTW89_HW_RATE_V1_VHT_NSS4_MCS10 = 0x26A,
  444. RTW89_HW_RATE_V1_VHT_NSS4_MCS11 = 0x26B,
  445. RTW89_HW_RATE_V1_HE_NSS1_MCS0 = 0x300,
  446. RTW89_HW_RATE_V1_HE_NSS1_MCS1 = 0x301,
  447. RTW89_HW_RATE_V1_HE_NSS1_MCS2 = 0x302,
  448. RTW89_HW_RATE_V1_HE_NSS1_MCS3 = 0x303,
  449. RTW89_HW_RATE_V1_HE_NSS1_MCS4 = 0x304,
  450. RTW89_HW_RATE_V1_HE_NSS1_MCS5 = 0x305,
  451. RTW89_HW_RATE_V1_HE_NSS1_MCS6 = 0x306,
  452. RTW89_HW_RATE_V1_HE_NSS1_MCS7 = 0x307,
  453. RTW89_HW_RATE_V1_HE_NSS1_MCS8 = 0x308,
  454. RTW89_HW_RATE_V1_HE_NSS1_MCS9 = 0x309,
  455. RTW89_HW_RATE_V1_HE_NSS1_MCS10 = 0x30A,
  456. RTW89_HW_RATE_V1_HE_NSS1_MCS11 = 0x30B,
  457. RTW89_HW_RATE_V1_HE_NSS2_MCS0 = 0x320,
  458. RTW89_HW_RATE_V1_HE_NSS2_MCS1 = 0x321,
  459. RTW89_HW_RATE_V1_HE_NSS2_MCS2 = 0x322,
  460. RTW89_HW_RATE_V1_HE_NSS2_MCS3 = 0x323,
  461. RTW89_HW_RATE_V1_HE_NSS2_MCS4 = 0x324,
  462. RTW89_HW_RATE_V1_HE_NSS2_MCS5 = 0x325,
  463. RTW89_HW_RATE_V1_HE_NSS2_MCS6 = 0x326,
  464. RTW89_HW_RATE_V1_HE_NSS2_MCS7 = 0x327,
  465. RTW89_HW_RATE_V1_HE_NSS2_MCS8 = 0x328,
  466. RTW89_HW_RATE_V1_HE_NSS2_MCS9 = 0x329,
  467. RTW89_HW_RATE_V1_HE_NSS2_MCS10 = 0x32A,
  468. RTW89_HW_RATE_V1_HE_NSS2_MCS11 = 0x32B,
  469. RTW89_HW_RATE_V1_HE_NSS3_MCS0 = 0x340,
  470. RTW89_HW_RATE_V1_HE_NSS3_MCS1 = 0x341,
  471. RTW89_HW_RATE_V1_HE_NSS3_MCS2 = 0x342,
  472. RTW89_HW_RATE_V1_HE_NSS3_MCS3 = 0x343,
  473. RTW89_HW_RATE_V1_HE_NSS3_MCS4 = 0x344,
  474. RTW89_HW_RATE_V1_HE_NSS3_MCS5 = 0x345,
  475. RTW89_HW_RATE_V1_HE_NSS3_MCS6 = 0x346,
  476. RTW89_HW_RATE_V1_HE_NSS3_MCS7 = 0x347,
  477. RTW89_HW_RATE_V1_HE_NSS3_MCS8 = 0x348,
  478. RTW89_HW_RATE_V1_HE_NSS3_MCS9 = 0x349,
  479. RTW89_HW_RATE_V1_HE_NSS3_MCS10 = 0x34A,
  480. RTW89_HW_RATE_V1_HE_NSS3_MCS11 = 0x34B,
  481. RTW89_HW_RATE_V1_HE_NSS4_MCS0 = 0x360,
  482. RTW89_HW_RATE_V1_HE_NSS4_MCS1 = 0x361,
  483. RTW89_HW_RATE_V1_HE_NSS4_MCS2 = 0x362,
  484. RTW89_HW_RATE_V1_HE_NSS4_MCS3 = 0x363,
  485. RTW89_HW_RATE_V1_HE_NSS4_MCS4 = 0x364,
  486. RTW89_HW_RATE_V1_HE_NSS4_MCS5 = 0x365,
  487. RTW89_HW_RATE_V1_HE_NSS4_MCS6 = 0x366,
  488. RTW89_HW_RATE_V1_HE_NSS4_MCS7 = 0x367,
  489. RTW89_HW_RATE_V1_HE_NSS4_MCS8 = 0x368,
  490. RTW89_HW_RATE_V1_HE_NSS4_MCS9 = 0x369,
  491. RTW89_HW_RATE_V1_HE_NSS4_MCS10 = 0x36A,
  492. RTW89_HW_RATE_V1_HE_NSS4_MCS11 = 0x36B,
  493. RTW89_HW_RATE_V1_EHT_NSS1_MCS0 = 0x400,
  494. RTW89_HW_RATE_V1_EHT_NSS1_MCS1 = 0x401,
  495. RTW89_HW_RATE_V1_EHT_NSS1_MCS2 = 0x402,
  496. RTW89_HW_RATE_V1_EHT_NSS1_MCS3 = 0x403,
  497. RTW89_HW_RATE_V1_EHT_NSS1_MCS4 = 0x404,
  498. RTW89_HW_RATE_V1_EHT_NSS1_MCS5 = 0x405,
  499. RTW89_HW_RATE_V1_EHT_NSS1_MCS6 = 0x406,
  500. RTW89_HW_RATE_V1_EHT_NSS1_MCS7 = 0x407,
  501. RTW89_HW_RATE_V1_EHT_NSS1_MCS8 = 0x408,
  502. RTW89_HW_RATE_V1_EHT_NSS1_MCS9 = 0x409,
  503. RTW89_HW_RATE_V1_EHT_NSS1_MCS10 = 0x40A,
  504. RTW89_HW_RATE_V1_EHT_NSS1_MCS11 = 0x40B,
  505. RTW89_HW_RATE_V1_EHT_NSS1_MCS12 = 0x40C,
  506. RTW89_HW_RATE_V1_EHT_NSS1_MCS13 = 0x40D,
  507. RTW89_HW_RATE_V1_EHT_NSS1_MCS14 = 0x40E,
  508. RTW89_HW_RATE_V1_EHT_NSS1_MCS15 = 0x40F,
  509. RTW89_HW_RATE_V1_EHT_NSS2_MCS0 = 0x420,
  510. RTW89_HW_RATE_V1_EHT_NSS2_MCS1 = 0x421,
  511. RTW89_HW_RATE_V1_EHT_NSS2_MCS2 = 0x422,
  512. RTW89_HW_RATE_V1_EHT_NSS2_MCS3 = 0x423,
  513. RTW89_HW_RATE_V1_EHT_NSS2_MCS4 = 0x424,
  514. RTW89_HW_RATE_V1_EHT_NSS2_MCS5 = 0x425,
  515. RTW89_HW_RATE_V1_EHT_NSS2_MCS6 = 0x426,
  516. RTW89_HW_RATE_V1_EHT_NSS2_MCS7 = 0x427,
  517. RTW89_HW_RATE_V1_EHT_NSS2_MCS8 = 0x428,
  518. RTW89_HW_RATE_V1_EHT_NSS2_MCS9 = 0x429,
  519. RTW89_HW_RATE_V1_EHT_NSS2_MCS10 = 0x42A,
  520. RTW89_HW_RATE_V1_EHT_NSS2_MCS11 = 0x42B,
  521. RTW89_HW_RATE_V1_EHT_NSS2_MCS12 = 0x42C,
  522. RTW89_HW_RATE_V1_EHT_NSS2_MCS13 = 0x42D,
  523. RTW89_HW_RATE_V1_EHT_NSS3_MCS0 = 0x440,
  524. RTW89_HW_RATE_V1_EHT_NSS3_MCS1 = 0x441,
  525. RTW89_HW_RATE_V1_EHT_NSS3_MCS2 = 0x442,
  526. RTW89_HW_RATE_V1_EHT_NSS3_MCS3 = 0x443,
  527. RTW89_HW_RATE_V1_EHT_NSS3_MCS4 = 0x444,
  528. RTW89_HW_RATE_V1_EHT_NSS3_MCS5 = 0x445,
  529. RTW89_HW_RATE_V1_EHT_NSS3_MCS6 = 0x446,
  530. RTW89_HW_RATE_V1_EHT_NSS3_MCS7 = 0x447,
  531. RTW89_HW_RATE_V1_EHT_NSS3_MCS8 = 0x448,
  532. RTW89_HW_RATE_V1_EHT_NSS3_MCS9 = 0x449,
  533. RTW89_HW_RATE_V1_EHT_NSS3_MCS10 = 0x44A,
  534. RTW89_HW_RATE_V1_EHT_NSS3_MCS11 = 0x44B,
  535. RTW89_HW_RATE_V1_EHT_NSS3_MCS12 = 0x44C,
  536. RTW89_HW_RATE_V1_EHT_NSS3_MCS13 = 0x44D,
  537. RTW89_HW_RATE_V1_EHT_NSS4_MCS0 = 0x460,
  538. RTW89_HW_RATE_V1_EHT_NSS4_MCS1 = 0x461,
  539. RTW89_HW_RATE_V1_EHT_NSS4_MCS2 = 0x462,
  540. RTW89_HW_RATE_V1_EHT_NSS4_MCS3 = 0x463,
  541. RTW89_HW_RATE_V1_EHT_NSS4_MCS4 = 0x464,
  542. RTW89_HW_RATE_V1_EHT_NSS4_MCS5 = 0x465,
  543. RTW89_HW_RATE_V1_EHT_NSS4_MCS6 = 0x466,
  544. RTW89_HW_RATE_V1_EHT_NSS4_MCS7 = 0x467,
  545. RTW89_HW_RATE_V1_EHT_NSS4_MCS8 = 0x468,
  546. RTW89_HW_RATE_V1_EHT_NSS4_MCS9 = 0x469,
  547. RTW89_HW_RATE_V1_EHT_NSS4_MCS10 = 0x46A,
  548. RTW89_HW_RATE_V1_EHT_NSS4_MCS11 = 0x46B,
  549. RTW89_HW_RATE_V1_EHT_NSS4_MCS12 = 0x46C,
  550. RTW89_HW_RATE_V1_EHT_NSS4_MCS13 = 0x46D,
  551. RTW89_HW_RATE_NR,
  552. RTW89_HW_RATE_INVAL,
  553. RTW89_HW_RATE_MASK_MOD = GENMASK(8, 7),
  554. RTW89_HW_RATE_MASK_VAL = GENMASK(6, 0),
  555. RTW89_HW_RATE_V1_MASK_MOD = GENMASK(10, 8),
  556. RTW89_HW_RATE_V1_MASK_VAL = GENMASK(7, 0),
  557. };
  558. /* 2G channels,
  559. * 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
  560. */
  561. #define RTW89_2G_CH_NUM 14
  562. /* 5G channels,
  563. * 36, 38, 40, 42, 44, 46, 48, 50,
  564. * 52, 54, 56, 58, 60, 62, 64,
  565. * 100, 102, 104, 106, 108, 110, 112, 114,
  566. * 116, 118, 120, 122, 124, 126, 128, 130,
  567. * 132, 134, 136, 138, 140, 142, 144,
  568. * 149, 151, 153, 155, 157, 159, 161, 163,
  569. * 165, 167, 169, 171, 173, 175, 177
  570. */
  571. #define RTW89_5G_CH_NUM 53
  572. /* 6G channels,
  573. * 1, 3, 5, 7, 9, 11, 13, 15,
  574. * 17, 19, 21, 23, 25, 27, 29, 33,
  575. * 35, 37, 39, 41, 43, 45, 47, 49,
  576. * 51, 53, 55, 57, 59, 61, 65, 67,
  577. * 69, 71, 73, 75, 77, 79, 81, 83,
  578. * 85, 87, 89, 91, 93, 97, 99, 101,
  579. * 103, 105, 107, 109, 111, 113, 115, 117,
  580. * 119, 121, 123, 125, 129, 131, 133, 135,
  581. * 137, 139, 141, 143, 145, 147, 149, 151,
  582. * 153, 155, 157, 161, 163, 165, 167, 169,
  583. * 171, 173, 175, 177, 179, 181, 183, 185,
  584. * 187, 189, 193, 195, 197, 199, 201, 203,
  585. * 205, 207, 209, 211, 213, 215, 217, 219,
  586. * 221, 225, 227, 229, 231, 233, 235, 237,
  587. * 239, 241, 243, 245, 247, 249, 251, 253,
  588. */
  589. #define RTW89_6G_CH_NUM 120
  590. enum rtw89_rate_section {
  591. RTW89_RS_CCK,
  592. RTW89_RS_OFDM,
  593. RTW89_RS_MCS, /* for HT/VHT/HE */
  594. RTW89_RS_HEDCM,
  595. RTW89_RS_OFFSET,
  596. RTW89_RS_NUM,
  597. RTW89_RS_LMT_NUM = RTW89_RS_MCS + 1,
  598. RTW89_RS_TX_SHAPE_NUM = RTW89_RS_OFDM + 1,
  599. };
  600. enum rtw89_rate_offset_indexes {
  601. RTW89_RATE_OFFSET_HE,
  602. RTW89_RATE_OFFSET_VHT,
  603. RTW89_RATE_OFFSET_HT,
  604. RTW89_RATE_OFFSET_OFDM,
  605. RTW89_RATE_OFFSET_CCK,
  606. RTW89_RATE_OFFSET_DLRU_EHT,
  607. RTW89_RATE_OFFSET_DLRU_HE,
  608. RTW89_RATE_OFFSET_EHT,
  609. __RTW89_RATE_OFFSET_NUM,
  610. RTW89_RATE_OFFSET_NUM_AX = RTW89_RATE_OFFSET_CCK + 1,
  611. RTW89_RATE_OFFSET_NUM_BE = RTW89_RATE_OFFSET_EHT + 1,
  612. };
  613. enum rtw89_rate_num {
  614. RTW89_RATE_CCK_NUM = 4,
  615. RTW89_RATE_OFDM_NUM = 8,
  616. RTW89_RATE_HEDCM_NUM = 4, /* for HEDCM MCS0/1/3/4 */
  617. RTW89_RATE_MCS_NUM_AX = 12,
  618. RTW89_RATE_MCS_NUM_BE = 16,
  619. __RTW89_RATE_MCS_NUM = 16,
  620. };
  621. enum rtw89_nss {
  622. RTW89_NSS_1 = 0,
  623. RTW89_NSS_2 = 1,
  624. /* HE DCM only support 1ss and 2ss */
  625. RTW89_NSS_HEDCM_NUM = RTW89_NSS_2 + 1,
  626. RTW89_NSS_3 = 2,
  627. RTW89_NSS_4 = 3,
  628. RTW89_NSS_NUM,
  629. };
  630. enum rtw89_ntx {
  631. RTW89_1TX = 0,
  632. RTW89_2TX = 1,
  633. RTW89_NTX_NUM,
  634. };
  635. enum rtw89_beamforming_type {
  636. RTW89_NONBF = 0,
  637. RTW89_BF = 1,
  638. RTW89_BF_NUM,
  639. };
  640. enum rtw89_ofdma_type {
  641. RTW89_NON_OFDMA = 0,
  642. RTW89_OFDMA = 1,
  643. RTW89_OFDMA_NUM,
  644. };
  645. enum rtw89_regulation_type {
  646. RTW89_WW = 0,
  647. RTW89_ETSI = 1,
  648. RTW89_FCC = 2,
  649. RTW89_MKK = 3,
  650. RTW89_NA = 4,
  651. RTW89_IC = 5,
  652. RTW89_KCC = 6,
  653. RTW89_ACMA = 7,
  654. RTW89_NCC = 8,
  655. RTW89_MEXICO = 9,
  656. RTW89_CHILE = 10,
  657. RTW89_UKRAINE = 11,
  658. RTW89_CN = 12,
  659. RTW89_QATAR = 13,
  660. RTW89_UK = 14,
  661. RTW89_THAILAND = 15,
  662. RTW89_REGD_NUM,
  663. };
  664. enum rtw89_reg_6ghz_power {
  665. RTW89_REG_6GHZ_POWER_VLP = 0,
  666. RTW89_REG_6GHZ_POWER_LPI = 1,
  667. RTW89_REG_6GHZ_POWER_STD = 2,
  668. NUM_OF_RTW89_REG_6GHZ_POWER,
  669. RTW89_REG_6GHZ_POWER_DFLT = RTW89_REG_6GHZ_POWER_VLP,
  670. };
  671. enum rtw89_fw_pkt_ofld_type {
  672. RTW89_PKT_OFLD_TYPE_PROBE_RSP = 0,
  673. RTW89_PKT_OFLD_TYPE_PS_POLL = 1,
  674. RTW89_PKT_OFLD_TYPE_NULL_DATA = 2,
  675. RTW89_PKT_OFLD_TYPE_QOS_NULL = 3,
  676. RTW89_PKT_OFLD_TYPE_CTS2SELF = 4,
  677. RTW89_PKT_OFLD_TYPE_ARP_RSP = 5,
  678. RTW89_PKT_OFLD_TYPE_NDP = 6,
  679. RTW89_PKT_OFLD_TYPE_EAPOL_KEY = 7,
  680. RTW89_PKT_OFLD_TYPE_SA_QUERY = 8,
  681. RTW89_PKT_OFLD_TYPE_PROBE_REQ = 12,
  682. RTW89_PKT_OFLD_TYPE_NUM,
  683. };
  684. struct rtw89_txpwr_byrate {
  685. s8 cck[RTW89_RATE_CCK_NUM];
  686. s8 ofdm[RTW89_RATE_OFDM_NUM];
  687. s8 mcs[RTW89_OFDMA_NUM][RTW89_NSS_NUM][__RTW89_RATE_MCS_NUM];
  688. s8 hedcm[RTW89_OFDMA_NUM][RTW89_NSS_HEDCM_NUM][RTW89_RATE_HEDCM_NUM];
  689. s8 offset[__RTW89_RATE_OFFSET_NUM];
  690. s8 trap;
  691. };
  692. enum rtw89_bandwidth_section_num {
  693. RTW89_BW20_SEC_NUM = 8,
  694. RTW89_BW40_SEC_NUM = 4,
  695. RTW89_BW80_SEC_NUM = 2,
  696. };
  697. #define RTW89_TXPWR_LMT_PAGE_SIZE 40
  698. struct rtw89_txpwr_limit {
  699. s8 cck_20m[RTW89_BF_NUM];
  700. s8 cck_40m[RTW89_BF_NUM];
  701. s8 ofdm[RTW89_BF_NUM];
  702. s8 mcs_20m[RTW89_BW20_SEC_NUM][RTW89_BF_NUM];
  703. s8 mcs_40m[RTW89_BW40_SEC_NUM][RTW89_BF_NUM];
  704. s8 mcs_80m[RTW89_BW80_SEC_NUM][RTW89_BF_NUM];
  705. s8 mcs_160m[RTW89_BF_NUM];
  706. s8 mcs_40m_0p5[RTW89_BF_NUM];
  707. s8 mcs_40m_2p5[RTW89_BF_NUM];
  708. };
  709. #define RTW89_RU_SEC_NUM 8
  710. #define RTW89_TXPWR_LMT_RU_PAGE_SIZE 24
  711. struct rtw89_txpwr_limit_ru {
  712. s8 ru26[RTW89_RU_SEC_NUM];
  713. s8 ru52[RTW89_RU_SEC_NUM];
  714. s8 ru106[RTW89_RU_SEC_NUM];
  715. };
  716. struct rtw89_rate_desc {
  717. enum rtw89_nss nss;
  718. enum rtw89_rate_section rs;
  719. enum rtw89_ofdma_type ofdma;
  720. u8 idx;
  721. };
  722. #define PHY_STS_HDR_LEN 8
  723. #define RF_PATH_MAX 4
  724. #define RTW89_MAX_PPDU_CNT 8
  725. struct rtw89_rx_phy_ppdu {
  726. void *buf;
  727. u32 len;
  728. u8 rssi_avg;
  729. u8 rssi[RF_PATH_MAX];
  730. u8 mac_id;
  731. u8 chan_idx;
  732. u8 ie;
  733. u16 rate;
  734. struct {
  735. bool has;
  736. u8 avg_snr;
  737. u8 evm_max;
  738. u8 evm_min;
  739. } ofdm;
  740. bool to_self;
  741. bool valid;
  742. };
  743. enum rtw89_mac_idx {
  744. RTW89_MAC_0 = 0,
  745. RTW89_MAC_1 = 1,
  746. };
  747. enum rtw89_phy_idx {
  748. RTW89_PHY_0 = 0,
  749. RTW89_PHY_1 = 1,
  750. RTW89_PHY_MAX
  751. };
  752. enum rtw89_sub_entity_idx {
  753. RTW89_SUB_ENTITY_0 = 0,
  754. RTW89_SUB_ENTITY_1 = 1,
  755. NUM_OF_RTW89_SUB_ENTITY,
  756. RTW89_SUB_ENTITY_IDLE = NUM_OF_RTW89_SUB_ENTITY,
  757. };
  758. enum rtw89_rf_path {
  759. RF_PATH_A = 0,
  760. RF_PATH_B = 1,
  761. RF_PATH_C = 2,
  762. RF_PATH_D = 3,
  763. RF_PATH_AB,
  764. RF_PATH_AC,
  765. RF_PATH_AD,
  766. RF_PATH_BC,
  767. RF_PATH_BD,
  768. RF_PATH_CD,
  769. RF_PATH_ABC,
  770. RF_PATH_ABD,
  771. RF_PATH_ACD,
  772. RF_PATH_BCD,
  773. RF_PATH_ABCD,
  774. };
  775. enum rtw89_rf_path_bit {
  776. RF_A = BIT(0),
  777. RF_B = BIT(1),
  778. RF_C = BIT(2),
  779. RF_D = BIT(3),
  780. RF_AB = (RF_A | RF_B),
  781. RF_AC = (RF_A | RF_C),
  782. RF_AD = (RF_A | RF_D),
  783. RF_BC = (RF_B | RF_C),
  784. RF_BD = (RF_B | RF_D),
  785. RF_CD = (RF_C | RF_D),
  786. RF_ABC = (RF_A | RF_B | RF_C),
  787. RF_ABD = (RF_A | RF_B | RF_D),
  788. RF_ACD = (RF_A | RF_C | RF_D),
  789. RF_BCD = (RF_B | RF_C | RF_D),
  790. RF_ABCD = (RF_A | RF_B | RF_C | RF_D),
  791. };
  792. enum rtw89_bandwidth {
  793. RTW89_CHANNEL_WIDTH_20 = 0,
  794. RTW89_CHANNEL_WIDTH_40 = 1,
  795. RTW89_CHANNEL_WIDTH_80 = 2,
  796. RTW89_CHANNEL_WIDTH_160 = 3,
  797. RTW89_CHANNEL_WIDTH_320 = 4,
  798. /* keep index order above */
  799. RTW89_CHANNEL_WIDTH_ORDINARY_NUM = 5,
  800. RTW89_CHANNEL_WIDTH_80_80 = 5,
  801. RTW89_CHANNEL_WIDTH_5 = 6,
  802. RTW89_CHANNEL_WIDTH_10 = 7,
  803. };
  804. enum rtw89_ps_mode {
  805. RTW89_PS_MODE_NONE = 0,
  806. RTW89_PS_MODE_RFOFF = 1,
  807. RTW89_PS_MODE_CLK_GATED = 2,
  808. RTW89_PS_MODE_PWR_GATED = 3,
  809. };
  810. #define RTW89_2G_BW_NUM (RTW89_CHANNEL_WIDTH_40 + 1)
  811. #define RTW89_5G_BW_NUM (RTW89_CHANNEL_WIDTH_160 + 1)
  812. #define RTW89_6G_BW_NUM (RTW89_CHANNEL_WIDTH_320 + 1)
  813. #define RTW89_BYR_BW_NUM (RTW89_CHANNEL_WIDTH_320 + 1)
  814. #define RTW89_PPE_BW_NUM (RTW89_CHANNEL_WIDTH_160 + 1)
  815. enum rtw89_ru_bandwidth {
  816. RTW89_RU26 = 0,
  817. RTW89_RU52 = 1,
  818. RTW89_RU106 = 2,
  819. RTW89_RU52_26 = 3,
  820. RTW89_RU106_26 = 4,
  821. RTW89_RU_NUM,
  822. };
  823. enum rtw89_sc_offset {
  824. RTW89_SC_DONT_CARE = 0,
  825. RTW89_SC_20_UPPER = 1,
  826. RTW89_SC_20_LOWER = 2,
  827. RTW89_SC_20_UPMOST = 3,
  828. RTW89_SC_20_LOWEST = 4,
  829. RTW89_SC_20_UP2X = 5,
  830. RTW89_SC_20_LOW2X = 6,
  831. RTW89_SC_20_UP3X = 7,
  832. RTW89_SC_20_LOW3X = 8,
  833. RTW89_SC_40_UPPER = 9,
  834. RTW89_SC_40_LOWER = 10,
  835. };
  836. enum rtw89_wow_flags {
  837. RTW89_WOW_FLAG_EN_MAGIC_PKT,
  838. RTW89_WOW_FLAG_EN_REKEY_PKT,
  839. RTW89_WOW_FLAG_EN_DISCONNECT,
  840. RTW89_WOW_FLAG_NUM,
  841. };
  842. struct rtw89_chan {
  843. u8 channel;
  844. u8 primary_channel;
  845. enum rtw89_band band_type;
  846. enum rtw89_bandwidth band_width;
  847. /* The follow-up are derived from the above. We must ensure that it
  848. * is assigned correctly in rtw89_chan_create() if new one is added.
  849. */
  850. u32 freq;
  851. enum rtw89_subband subband_type;
  852. enum rtw89_sc_offset pri_ch_idx;
  853. u8 pri_sb_idx;
  854. };
  855. struct rtw89_chan_rcd {
  856. u8 prev_primary_channel;
  857. enum rtw89_band prev_band_type;
  858. bool band_changed;
  859. };
  860. struct rtw89_channel_help_params {
  861. u32 tx_en;
  862. };
  863. struct rtw89_port_reg {
  864. u32 port_cfg;
  865. u32 tbtt_prohib;
  866. u32 bcn_area;
  867. u32 bcn_early;
  868. u32 tbtt_early;
  869. u32 tbtt_agg;
  870. u32 bcn_space;
  871. u32 bcn_forcetx;
  872. u32 bcn_err_cnt;
  873. u32 bcn_err_flag;
  874. u32 dtim_ctrl;
  875. u32 tbtt_shift;
  876. u32 bcn_cnt_tmr;
  877. u32 tsftr_l;
  878. u32 tsftr_h;
  879. u32 md_tsft;
  880. u32 bss_color;
  881. u32 mbssid;
  882. u32 mbssid_drop;
  883. u32 tsf_sync;
  884. u32 hiq_win[RTW89_PORT_NUM];
  885. };
  886. struct rtw89_txwd_body {
  887. __le32 dword0;
  888. __le32 dword1;
  889. __le32 dword2;
  890. __le32 dword3;
  891. __le32 dword4;
  892. __le32 dword5;
  893. } __packed;
  894. struct rtw89_txwd_body_v1 {
  895. __le32 dword0;
  896. __le32 dword1;
  897. __le32 dword2;
  898. __le32 dword3;
  899. __le32 dword4;
  900. __le32 dword5;
  901. __le32 dword6;
  902. __le32 dword7;
  903. } __packed;
  904. struct rtw89_txwd_body_v2 {
  905. __le32 dword0;
  906. __le32 dword1;
  907. __le32 dword2;
  908. __le32 dword3;
  909. __le32 dword4;
  910. __le32 dword5;
  911. __le32 dword6;
  912. __le32 dword7;
  913. } __packed;
  914. struct rtw89_txwd_info {
  915. __le32 dword0;
  916. __le32 dword1;
  917. __le32 dword2;
  918. __le32 dword3;
  919. __le32 dword4;
  920. __le32 dword5;
  921. } __packed;
  922. struct rtw89_txwd_info_v2 {
  923. __le32 dword0;
  924. __le32 dword1;
  925. __le32 dword2;
  926. __le32 dword3;
  927. __le32 dword4;
  928. __le32 dword5;
  929. __le32 dword6;
  930. __le32 dword7;
  931. } __packed;
  932. struct rtw89_rx_desc_info {
  933. u16 pkt_size;
  934. u8 pkt_type;
  935. u8 drv_info_size;
  936. u8 phy_rpt_size;
  937. u8 hdr_cnv_size;
  938. u8 shift;
  939. u8 wl_hd_iv_len;
  940. bool long_rxdesc;
  941. bool bb_sel;
  942. bool mac_info_valid;
  943. u16 data_rate;
  944. u8 gi_ltf;
  945. u8 bw;
  946. u32 free_run_cnt;
  947. u8 user_id;
  948. bool sr_en;
  949. u8 ppdu_cnt;
  950. u8 ppdu_type;
  951. bool icv_err;
  952. bool crc32_err;
  953. bool hw_dec;
  954. bool sw_dec;
  955. bool addr1_match;
  956. u8 frag;
  957. u16 seq;
  958. u8 frame_type;
  959. u8 rx_pl_id;
  960. bool addr_cam_valid;
  961. u8 addr_cam_id;
  962. u8 sec_cam_id;
  963. u8 mac_id;
  964. u16 offset;
  965. u16 rxd_len;
  966. bool ready;
  967. };
  968. struct rtw89_rxdesc_short {
  969. __le32 dword0;
  970. __le32 dword1;
  971. __le32 dword2;
  972. __le32 dword3;
  973. } __packed;
  974. struct rtw89_rxdesc_short_v2 {
  975. __le32 dword0;
  976. __le32 dword1;
  977. __le32 dword2;
  978. __le32 dword3;
  979. __le32 dword4;
  980. __le32 dword5;
  981. } __packed;
  982. struct rtw89_rxdesc_long {
  983. __le32 dword0;
  984. __le32 dword1;
  985. __le32 dword2;
  986. __le32 dword3;
  987. __le32 dword4;
  988. __le32 dword5;
  989. __le32 dword6;
  990. __le32 dword7;
  991. } __packed;
  992. struct rtw89_rxdesc_long_v2 {
  993. __le32 dword0;
  994. __le32 dword1;
  995. __le32 dword2;
  996. __le32 dword3;
  997. __le32 dword4;
  998. __le32 dword5;
  999. __le32 dword6;
  1000. __le32 dword7;
  1001. __le32 dword8;
  1002. __le32 dword9;
  1003. } __packed;
  1004. struct rtw89_tx_desc_info {
  1005. u16 pkt_size;
  1006. u8 wp_offset;
  1007. u8 mac_id;
  1008. u8 qsel;
  1009. u8 ch_dma;
  1010. u8 hdr_llc_len;
  1011. bool is_bmc;
  1012. bool en_wd_info;
  1013. bool wd_page;
  1014. bool use_rate;
  1015. bool dis_data_fb;
  1016. bool tid_indicate;
  1017. bool agg_en;
  1018. bool bk;
  1019. u8 ampdu_density;
  1020. u8 ampdu_num;
  1021. bool sec_en;
  1022. u8 addr_info_nr;
  1023. u8 sec_keyid;
  1024. u8 sec_type;
  1025. u8 sec_cam_idx;
  1026. u8 sec_seq[6];
  1027. u16 data_rate;
  1028. u16 data_retry_lowest_rate;
  1029. bool fw_dl;
  1030. u16 seq;
  1031. bool a_ctrl_bsr;
  1032. u8 hw_ssn_sel;
  1033. #define RTW89_MGMT_HW_SSN_SEL 1
  1034. u8 hw_seq_mode;
  1035. #define RTW89_MGMT_HW_SEQ_MODE 1
  1036. bool hiq;
  1037. u8 port;
  1038. bool er_cap;
  1039. };
  1040. struct rtw89_core_tx_request {
  1041. enum rtw89_core_tx_type tx_type;
  1042. struct sk_buff *skb;
  1043. struct ieee80211_vif *vif;
  1044. struct ieee80211_sta *sta;
  1045. struct rtw89_tx_desc_info desc_info;
  1046. };
  1047. struct rtw89_txq {
  1048. struct list_head list;
  1049. unsigned long flags;
  1050. int wait_cnt;
  1051. };
  1052. struct rtw89_mac_ax_gnt {
  1053. u8 gnt_bt_sw_en;
  1054. u8 gnt_bt;
  1055. u8 gnt_wl_sw_en;
  1056. u8 gnt_wl;
  1057. } __packed;
  1058. #define RTW89_MAC_AX_COEX_GNT_NR 2
  1059. struct rtw89_mac_ax_coex_gnt {
  1060. struct rtw89_mac_ax_gnt band[RTW89_MAC_AX_COEX_GNT_NR];
  1061. };
  1062. enum rtw89_btc_ncnt {
  1063. BTC_NCNT_POWER_ON = 0x0,
  1064. BTC_NCNT_POWER_OFF,
  1065. BTC_NCNT_INIT_COEX,
  1066. BTC_NCNT_SCAN_START,
  1067. BTC_NCNT_SCAN_FINISH,
  1068. BTC_NCNT_SPECIAL_PACKET,
  1069. BTC_NCNT_SWITCH_BAND,
  1070. BTC_NCNT_RFK_TIMEOUT,
  1071. BTC_NCNT_SHOW_COEX_INFO,
  1072. BTC_NCNT_ROLE_INFO,
  1073. BTC_NCNT_CONTROL,
  1074. BTC_NCNT_RADIO_STATE,
  1075. BTC_NCNT_CUSTOMERIZE,
  1076. BTC_NCNT_WL_RFK,
  1077. BTC_NCNT_WL_STA,
  1078. BTC_NCNT_FWINFO,
  1079. BTC_NCNT_TIMER,
  1080. BTC_NCNT_NUM
  1081. };
  1082. enum rtw89_btc_btinfo {
  1083. BTC_BTINFO_L0 = 0,
  1084. BTC_BTINFO_L1,
  1085. BTC_BTINFO_L2,
  1086. BTC_BTINFO_L3,
  1087. BTC_BTINFO_H0,
  1088. BTC_BTINFO_H1,
  1089. BTC_BTINFO_H2,
  1090. BTC_BTINFO_H3,
  1091. BTC_BTINFO_MAX
  1092. };
  1093. enum rtw89_btc_dcnt {
  1094. BTC_DCNT_RUN = 0x0,
  1095. BTC_DCNT_CX_RUNINFO,
  1096. BTC_DCNT_RPT,
  1097. BTC_DCNT_RPT_HANG,
  1098. BTC_DCNT_CYCLE,
  1099. BTC_DCNT_CYCLE_HANG,
  1100. BTC_DCNT_W1,
  1101. BTC_DCNT_W1_HANG,
  1102. BTC_DCNT_B1,
  1103. BTC_DCNT_B1_HANG,
  1104. BTC_DCNT_TDMA_NONSYNC,
  1105. BTC_DCNT_SLOT_NONSYNC,
  1106. BTC_DCNT_BTCNT_HANG,
  1107. BTC_DCNT_WL_SLOT_DRIFT,
  1108. BTC_DCNT_WL_STA_LAST,
  1109. BTC_DCNT_BT_SLOT_DRIFT,
  1110. BTC_DCNT_BT_SLOT_FLOOD,
  1111. BTC_DCNT_FDDT_TRIG,
  1112. BTC_DCNT_E2G,
  1113. BTC_DCNT_E2G_HANG,
  1114. BTC_DCNT_NUM
  1115. };
  1116. enum rtw89_btc_wl_state_cnt {
  1117. BTC_WCNT_SCANAP = 0x0,
  1118. BTC_WCNT_DHCP,
  1119. BTC_WCNT_EAPOL,
  1120. BTC_WCNT_ARP,
  1121. BTC_WCNT_SCBDUPDATE,
  1122. BTC_WCNT_RFK_REQ,
  1123. BTC_WCNT_RFK_GO,
  1124. BTC_WCNT_RFK_REJECT,
  1125. BTC_WCNT_RFK_TIMEOUT,
  1126. BTC_WCNT_CH_UPDATE,
  1127. BTC_WCNT_NUM
  1128. };
  1129. enum rtw89_btc_bt_state_cnt {
  1130. BTC_BCNT_RETRY = 0x0,
  1131. BTC_BCNT_REINIT,
  1132. BTC_BCNT_REENABLE,
  1133. BTC_BCNT_SCBDREAD,
  1134. BTC_BCNT_RELINK,
  1135. BTC_BCNT_IGNOWL,
  1136. BTC_BCNT_INQPAG,
  1137. BTC_BCNT_INQ,
  1138. BTC_BCNT_PAGE,
  1139. BTC_BCNT_ROLESW,
  1140. BTC_BCNT_AFH,
  1141. BTC_BCNT_INFOUPDATE,
  1142. BTC_BCNT_INFOSAME,
  1143. BTC_BCNT_SCBDUPDATE,
  1144. BTC_BCNT_HIPRI_TX,
  1145. BTC_BCNT_HIPRI_RX,
  1146. BTC_BCNT_LOPRI_TX,
  1147. BTC_BCNT_LOPRI_RX,
  1148. BTC_BCNT_POLUT,
  1149. BTC_BCNT_RATECHG,
  1150. BTC_BCNT_NUM
  1151. };
  1152. enum rtw89_btc_bt_profile {
  1153. BTC_BT_NOPROFILE = 0,
  1154. BTC_BT_HFP = BIT(0),
  1155. BTC_BT_HID = BIT(1),
  1156. BTC_BT_A2DP = BIT(2),
  1157. BTC_BT_PAN = BIT(3),
  1158. BTC_PROFILE_MAX = 4,
  1159. };
  1160. struct rtw89_btc_ant_info {
  1161. u8 type; /* shared, dedicated */
  1162. u8 num;
  1163. u8 isolation;
  1164. u8 single_pos: 1;/* Single antenna at S0 or S1 */
  1165. u8 diversity: 1;
  1166. u8 btg_pos: 2;
  1167. u8 stream_cnt: 4;
  1168. };
  1169. enum rtw89_tfc_dir {
  1170. RTW89_TFC_UL,
  1171. RTW89_TFC_DL,
  1172. };
  1173. struct rtw89_btc_wl_smap {
  1174. u32 busy: 1;
  1175. u32 scan: 1;
  1176. u32 connecting: 1;
  1177. u32 roaming: 1;
  1178. u32 _4way: 1;
  1179. u32 rf_off: 1;
  1180. u32 lps: 2;
  1181. u32 ips: 1;
  1182. u32 init_ok: 1;
  1183. u32 traffic_dir : 2;
  1184. u32 rf_off_pre: 1;
  1185. u32 lps_pre: 2;
  1186. };
  1187. enum rtw89_tfc_lv {
  1188. RTW89_TFC_IDLE,
  1189. RTW89_TFC_ULTRA_LOW,
  1190. RTW89_TFC_LOW,
  1191. RTW89_TFC_MID,
  1192. RTW89_TFC_HIGH,
  1193. };
  1194. #define RTW89_TP_SHIFT 18 /* bytes/2s --> Mbps */
  1195. DECLARE_EWMA(tp, 10, 2);
  1196. struct rtw89_traffic_stats {
  1197. /* units in bytes */
  1198. u64 tx_unicast;
  1199. u64 rx_unicast;
  1200. u32 tx_avg_len;
  1201. u32 rx_avg_len;
  1202. /* count for packets */
  1203. u64 tx_cnt;
  1204. u64 rx_cnt;
  1205. /* units in Mbps */
  1206. u32 tx_throughput;
  1207. u32 rx_throughput;
  1208. u32 tx_throughput_raw;
  1209. u32 rx_throughput_raw;
  1210. u32 rx_tf_acc;
  1211. u32 rx_tf_periodic;
  1212. enum rtw89_tfc_lv tx_tfc_lv;
  1213. enum rtw89_tfc_lv rx_tfc_lv;
  1214. struct ewma_tp tx_ewma_tp;
  1215. struct ewma_tp rx_ewma_tp;
  1216. u16 tx_rate;
  1217. u16 rx_rate;
  1218. };
  1219. struct rtw89_btc_statistic {
  1220. u8 rssi; /* 0%~110% (dBm = rssi -110) */
  1221. struct rtw89_traffic_stats traffic;
  1222. };
  1223. #define BTC_WL_RSSI_THMAX 4
  1224. struct rtw89_btc_wl_link_info {
  1225. struct rtw89_btc_statistic stat;
  1226. enum rtw89_tfc_dir dir;
  1227. u8 rssi_state[BTC_WL_RSSI_THMAX];
  1228. u8 mac_addr[ETH_ALEN];
  1229. u8 busy;
  1230. u8 ch;
  1231. u8 bw;
  1232. u8 band;
  1233. u8 role;
  1234. u8 pid;
  1235. u8 phy;
  1236. u8 dtim_period;
  1237. u8 mode;
  1238. u8 mac_id;
  1239. u8 tx_retry;
  1240. u32 bcn_period;
  1241. u32 busy_t;
  1242. u32 tx_time;
  1243. u32 client_cnt;
  1244. u32 rx_rate_drop_cnt;
  1245. u32 active: 1;
  1246. u32 noa: 1;
  1247. u32 client_ps: 1;
  1248. u32 connected: 2;
  1249. };
  1250. union rtw89_btc_wl_state_map {
  1251. u32 val;
  1252. struct rtw89_btc_wl_smap map;
  1253. };
  1254. struct rtw89_btc_bt_hfp_desc {
  1255. u32 exist: 1;
  1256. u32 type: 2;
  1257. u32 rsvd: 29;
  1258. };
  1259. struct rtw89_btc_bt_hid_desc {
  1260. u32 exist: 1;
  1261. u32 slot_info: 2;
  1262. u32 pair_cnt: 2;
  1263. u32 type: 8;
  1264. u32 rsvd: 19;
  1265. };
  1266. struct rtw89_btc_bt_a2dp_desc {
  1267. u8 exist: 1;
  1268. u8 exist_last: 1;
  1269. u8 play_latency: 1;
  1270. u8 type: 3;
  1271. u8 active: 1;
  1272. u8 sink: 1;
  1273. u8 bitpool;
  1274. u16 vendor_id;
  1275. u32 device_name;
  1276. u32 flush_time;
  1277. };
  1278. struct rtw89_btc_bt_pan_desc {
  1279. u32 exist: 1;
  1280. u32 type: 1;
  1281. u32 active: 1;
  1282. u32 rsvd: 29;
  1283. };
  1284. struct rtw89_btc_bt_rfk_info {
  1285. u32 run: 1;
  1286. u32 req: 1;
  1287. u32 timeout: 1;
  1288. u32 rsvd: 29;
  1289. };
  1290. union rtw89_btc_bt_rfk_info_map {
  1291. u32 val;
  1292. struct rtw89_btc_bt_rfk_info map;
  1293. };
  1294. struct rtw89_btc_bt_ver_info {
  1295. u32 fw_coex; /* match with which coex_ver */
  1296. u32 fw;
  1297. };
  1298. struct rtw89_btc_bool_sta_chg {
  1299. u32 now: 1;
  1300. u32 last: 1;
  1301. u32 remain: 1;
  1302. u32 srvd: 29;
  1303. };
  1304. struct rtw89_btc_u8_sta_chg {
  1305. u8 now;
  1306. u8 last;
  1307. u8 remain;
  1308. u8 rsvd;
  1309. };
  1310. struct rtw89_btc_wl_scan_info {
  1311. u8 band[RTW89_PHY_MAX];
  1312. u8 phy_map;
  1313. u8 rsvd;
  1314. };
  1315. struct rtw89_btc_wl_dbcc_info {
  1316. u8 op_band[RTW89_PHY_MAX]; /* op band in each phy */
  1317. u8 scan_band[RTW89_PHY_MAX]; /* scan band in each phy */
  1318. u8 real_band[RTW89_PHY_MAX];
  1319. u8 role[RTW89_PHY_MAX]; /* role in each phy */
  1320. };
  1321. struct rtw89_btc_wl_active_role {
  1322. u8 connected: 1;
  1323. u8 pid: 3;
  1324. u8 phy: 1;
  1325. u8 noa: 1;
  1326. u8 band: 2;
  1327. u8 client_ps: 1;
  1328. u8 bw: 7;
  1329. u8 role;
  1330. u8 ch;
  1331. u16 tx_lvl;
  1332. u16 rx_lvl;
  1333. u16 tx_rate;
  1334. u16 rx_rate;
  1335. };
  1336. struct rtw89_btc_wl_active_role_v1 {
  1337. u8 connected: 1;
  1338. u8 pid: 3;
  1339. u8 phy: 1;
  1340. u8 noa: 1;
  1341. u8 band: 2;
  1342. u8 client_ps: 1;
  1343. u8 bw: 7;
  1344. u8 role;
  1345. u8 ch;
  1346. u16 tx_lvl;
  1347. u16 rx_lvl;
  1348. u16 tx_rate;
  1349. u16 rx_rate;
  1350. u32 noa_duration; /* ms */
  1351. };
  1352. struct rtw89_btc_wl_active_role_v2 {
  1353. u8 connected: 1;
  1354. u8 pid: 3;
  1355. u8 phy: 1;
  1356. u8 noa: 1;
  1357. u8 band: 2;
  1358. u8 client_ps: 1;
  1359. u8 bw: 7;
  1360. u8 role;
  1361. u8 ch;
  1362. u32 noa_duration; /* ms */
  1363. };
  1364. struct rtw89_btc_wl_role_info_bpos {
  1365. u16 none: 1;
  1366. u16 station: 1;
  1367. u16 ap: 1;
  1368. u16 vap: 1;
  1369. u16 adhoc: 1;
  1370. u16 adhoc_master: 1;
  1371. u16 mesh: 1;
  1372. u16 moniter: 1;
  1373. u16 p2p_device: 1;
  1374. u16 p2p_gc: 1;
  1375. u16 p2p_go: 1;
  1376. u16 nan: 1;
  1377. };
  1378. struct rtw89_btc_wl_scc_ctrl {
  1379. u8 null_role1;
  1380. u8 null_role2;
  1381. u8 ebt_null; /* if tx null at EBT slot */
  1382. };
  1383. union rtw89_btc_wl_role_info_map {
  1384. u16 val;
  1385. struct rtw89_btc_wl_role_info_bpos role;
  1386. };
  1387. struct rtw89_btc_wl_role_info { /* struct size must be n*4 bytes */
  1388. u8 connect_cnt;
  1389. u8 link_mode;
  1390. union rtw89_btc_wl_role_info_map role_map;
  1391. struct rtw89_btc_wl_active_role active_role[RTW89_PORT_NUM];
  1392. };
  1393. struct rtw89_btc_wl_role_info_v1 { /* struct size must be n*4 bytes */
  1394. u8 connect_cnt;
  1395. u8 link_mode;
  1396. union rtw89_btc_wl_role_info_map role_map;
  1397. struct rtw89_btc_wl_active_role_v1 active_role_v1[RTW89_PORT_NUM];
  1398. u32 mrole_type; /* btc_wl_mrole_type */
  1399. u32 mrole_noa_duration; /* ms */
  1400. u32 dbcc_en: 1;
  1401. u32 dbcc_chg: 1;
  1402. u32 dbcc_2g_phy: 2; /* which phy operate in 2G, HW_PHY_0 or HW_PHY_1 */
  1403. u32 link_mode_chg: 1;
  1404. u32 rsvd: 27;
  1405. };
  1406. struct rtw89_btc_wl_role_info_v2 { /* struct size must be n*4 bytes */
  1407. u8 connect_cnt;
  1408. u8 link_mode;
  1409. union rtw89_btc_wl_role_info_map role_map;
  1410. struct rtw89_btc_wl_active_role_v2 active_role_v2[RTW89_PORT_NUM];
  1411. u32 mrole_type; /* btc_wl_mrole_type */
  1412. u32 mrole_noa_duration; /* ms */
  1413. u32 dbcc_en: 1;
  1414. u32 dbcc_chg: 1;
  1415. u32 dbcc_2g_phy: 2; /* which phy operate in 2G, HW_PHY_0 or HW_PHY_1 */
  1416. u32 link_mode_chg: 1;
  1417. u32 rsvd: 27;
  1418. };
  1419. struct rtw89_btc_wl_ver_info {
  1420. u32 fw_coex; /* match with which coex_ver */
  1421. u32 fw;
  1422. u32 mac;
  1423. u32 bb;
  1424. u32 rf;
  1425. };
  1426. struct rtw89_btc_wl_afh_info {
  1427. u8 en;
  1428. u8 ch;
  1429. u8 bw;
  1430. u8 rsvd;
  1431. } __packed;
  1432. struct rtw89_btc_wl_rfk_info {
  1433. u32 state: 2;
  1434. u32 path_map: 4;
  1435. u32 phy_map: 2;
  1436. u32 band: 2;
  1437. u32 type: 8;
  1438. u32 rsvd: 14;
  1439. };
  1440. struct rtw89_btc_bt_smap {
  1441. u32 connect: 1;
  1442. u32 ble_connect: 1;
  1443. u32 acl_busy: 1;
  1444. u32 sco_busy: 1;
  1445. u32 mesh_busy: 1;
  1446. u32 inq_pag: 1;
  1447. };
  1448. union rtw89_btc_bt_state_map {
  1449. u32 val;
  1450. struct rtw89_btc_bt_smap map;
  1451. };
  1452. #define BTC_BT_RSSI_THMAX 4
  1453. #define BTC_BT_AFH_GROUP 12
  1454. #define BTC_BT_AFH_LE_GROUP 5
  1455. struct rtw89_btc_bt_link_info {
  1456. struct rtw89_btc_u8_sta_chg profile_cnt;
  1457. struct rtw89_btc_bool_sta_chg multi_link;
  1458. struct rtw89_btc_bool_sta_chg relink;
  1459. struct rtw89_btc_bt_hfp_desc hfp_desc;
  1460. struct rtw89_btc_bt_hid_desc hid_desc;
  1461. struct rtw89_btc_bt_a2dp_desc a2dp_desc;
  1462. struct rtw89_btc_bt_pan_desc pan_desc;
  1463. union rtw89_btc_bt_state_map status;
  1464. u8 sut_pwr_level[BTC_PROFILE_MAX];
  1465. u8 golden_rx_shift[BTC_PROFILE_MAX];
  1466. u8 rssi_state[BTC_BT_RSSI_THMAX];
  1467. u8 afh_map[BTC_BT_AFH_GROUP];
  1468. u8 afh_map_le[BTC_BT_AFH_LE_GROUP];
  1469. u32 role_sw: 1;
  1470. u32 slave_role: 1;
  1471. u32 afh_update: 1;
  1472. u32 cqddr: 1;
  1473. u32 rssi: 8;
  1474. u32 tx_3m: 1;
  1475. u32 rsvd: 19;
  1476. };
  1477. struct rtw89_btc_3rdcx_info {
  1478. u8 type; /* 0: none, 1:zigbee, 2:LTE */
  1479. u8 hw_coex;
  1480. u16 rsvd;
  1481. };
  1482. struct rtw89_btc_dm_emap {
  1483. u32 init: 1;
  1484. u32 pta_owner: 1;
  1485. u32 wl_rfk_timeout: 1;
  1486. u32 bt_rfk_timeout: 1;
  1487. u32 wl_fw_hang: 1;
  1488. u32 cycle_hang: 1;
  1489. u32 w1_hang: 1;
  1490. u32 b1_hang: 1;
  1491. u32 tdma_no_sync: 1;
  1492. u32 slot_no_sync: 1;
  1493. u32 wl_slot_drift: 1;
  1494. u32 bt_slot_drift: 1;
  1495. u32 role_num_mismatch: 1;
  1496. u32 null1_tx_late: 1;
  1497. u32 bt_afh_conflict: 1;
  1498. u32 bt_leafh_conflict: 1;
  1499. u32 bt_slot_flood: 1;
  1500. u32 wl_e2g_hang: 1;
  1501. u32 wl_ver_mismatch: 1;
  1502. u32 bt_ver_mismatch: 1;
  1503. };
  1504. union rtw89_btc_dm_error_map {
  1505. u32 val;
  1506. struct rtw89_btc_dm_emap map;
  1507. };
  1508. struct rtw89_btc_rf_para {
  1509. u32 tx_pwr_freerun;
  1510. u32 rx_gain_freerun;
  1511. u32 tx_pwr_perpkt;
  1512. u32 rx_gain_perpkt;
  1513. };
  1514. struct rtw89_btc_wl_nhm {
  1515. u8 instant_wl_nhm_dbm;
  1516. u8 instant_wl_nhm_per_mhz;
  1517. u16 valid_record_times;
  1518. s8 record_pwr[16];
  1519. u8 record_ratio[16];
  1520. s8 pwr; /* dbm_per_MHz */
  1521. u8 ratio;
  1522. u8 current_status;
  1523. u8 refresh;
  1524. bool start_flag;
  1525. s8 pwr_max;
  1526. s8 pwr_min;
  1527. };
  1528. struct rtw89_btc_wl_info {
  1529. struct rtw89_btc_wl_link_info link_info[RTW89_PORT_NUM];
  1530. struct rtw89_btc_wl_rfk_info rfk_info;
  1531. struct rtw89_btc_wl_ver_info ver_info;
  1532. struct rtw89_btc_wl_afh_info afh_info;
  1533. struct rtw89_btc_wl_role_info role_info;
  1534. struct rtw89_btc_wl_role_info_v1 role_info_v1;
  1535. struct rtw89_btc_wl_role_info_v2 role_info_v2;
  1536. struct rtw89_btc_wl_scan_info scan_info;
  1537. struct rtw89_btc_wl_dbcc_info dbcc_info;
  1538. struct rtw89_btc_rf_para rf_para;
  1539. struct rtw89_btc_wl_nhm nhm;
  1540. union rtw89_btc_wl_state_map status;
  1541. u8 port_id[RTW89_WIFI_ROLE_MLME_MAX];
  1542. u8 rssi_level;
  1543. u8 cn_report;
  1544. bool scbd_change;
  1545. u32 scbd;
  1546. };
  1547. struct rtw89_btc_module {
  1548. struct rtw89_btc_ant_info ant;
  1549. u8 rfe_type;
  1550. u8 cv;
  1551. u8 bt_solo: 1;
  1552. u8 bt_pos: 1;
  1553. u8 switch_type: 1;
  1554. u8 wa_type: 3;
  1555. u8 kt_ver_adie;
  1556. };
  1557. #define RTW89_BTC_DM_MAXSTEP 30
  1558. #define RTW89_BTC_DM_CNT_MAX (RTW89_BTC_DM_MAXSTEP * 8)
  1559. struct rtw89_btc_dm_step {
  1560. u16 step[RTW89_BTC_DM_MAXSTEP];
  1561. u8 step_pos;
  1562. bool step_ov;
  1563. };
  1564. struct rtw89_btc_init_info {
  1565. struct rtw89_btc_module module;
  1566. u8 wl_guard_ch;
  1567. u8 wl_only: 1;
  1568. u8 wl_init_ok: 1;
  1569. u8 dbcc_en: 1;
  1570. u8 cx_other: 1;
  1571. u8 bt_only: 1;
  1572. u16 rsvd;
  1573. };
  1574. struct rtw89_btc_wl_tx_limit_para {
  1575. u16 enable;
  1576. u32 tx_time; /* unit: us */
  1577. u16 tx_retry;
  1578. };
  1579. enum rtw89_btc_bt_scan_type {
  1580. BTC_SCAN_INQ = 0,
  1581. BTC_SCAN_PAGE,
  1582. BTC_SCAN_BLE,
  1583. BTC_SCAN_INIT,
  1584. BTC_SCAN_TV,
  1585. BTC_SCAN_ADV,
  1586. BTC_SCAN_MAX1,
  1587. };
  1588. enum rtw89_btc_ble_scan_type {
  1589. CXSCAN_BG = 0,
  1590. CXSCAN_INIT,
  1591. CXSCAN_LE,
  1592. CXSCAN_MAX
  1593. };
  1594. #define RTW89_BTC_BTC_SCAN_V1_FLAG_ENABLE BIT(0)
  1595. #define RTW89_BTC_BTC_SCAN_V1_FLAG_INTERLACE BIT(1)
  1596. struct rtw89_btc_bt_scan_info_v1 {
  1597. __le16 win;
  1598. __le16 intvl;
  1599. __le32 flags;
  1600. } __packed;
  1601. struct rtw89_btc_bt_scan_info_v2 {
  1602. __le16 win;
  1603. __le16 intvl;
  1604. } __packed;
  1605. struct rtw89_btc_fbtc_btscan_v1 {
  1606. u8 fver; /* btc_ver::fcxbtscan */
  1607. u8 rsvd;
  1608. __le16 rsvd2;
  1609. struct rtw89_btc_bt_scan_info_v1 scan[BTC_SCAN_MAX1];
  1610. } __packed;
  1611. struct rtw89_btc_fbtc_btscan_v2 {
  1612. u8 fver; /* btc_ver::fcxbtscan */
  1613. u8 type;
  1614. __le16 rsvd2;
  1615. struct rtw89_btc_bt_scan_info_v2 para[CXSCAN_MAX];
  1616. } __packed;
  1617. union rtw89_btc_fbtc_btscan {
  1618. struct rtw89_btc_fbtc_btscan_v1 v1;
  1619. struct rtw89_btc_fbtc_btscan_v2 v2;
  1620. };
  1621. struct rtw89_btc_bt_info {
  1622. struct rtw89_btc_bt_link_info link_info;
  1623. struct rtw89_btc_bt_scan_info_v1 scan_info_v1[BTC_SCAN_MAX1];
  1624. struct rtw89_btc_bt_scan_info_v2 scan_info_v2[CXSCAN_MAX];
  1625. struct rtw89_btc_bt_ver_info ver_info;
  1626. struct rtw89_btc_bool_sta_chg enable;
  1627. struct rtw89_btc_bool_sta_chg inq_pag;
  1628. struct rtw89_btc_rf_para rf_para;
  1629. union rtw89_btc_bt_rfk_info_map rfk_info;
  1630. u8 raw_info[BTC_BTINFO_MAX]; /* raw bt info from mailbox */
  1631. u32 scbd;
  1632. u32 feature;
  1633. u32 mbx_avl: 1;
  1634. u32 whql_test: 1;
  1635. u32 igno_wl: 1;
  1636. u32 reinit: 1;
  1637. u32 ble_scan_en: 1;
  1638. u32 btg_type: 1;
  1639. u32 inq: 1;
  1640. u32 pag: 1;
  1641. u32 run_patch_code: 1;
  1642. u32 hi_lna_rx: 1;
  1643. u32 scan_rx_low_pri: 1;
  1644. u32 scan_info_update: 1;
  1645. u32 rsvd: 20;
  1646. };
  1647. struct rtw89_btc_cx {
  1648. struct rtw89_btc_wl_info wl;
  1649. struct rtw89_btc_bt_info bt;
  1650. struct rtw89_btc_3rdcx_info other;
  1651. u32 state_map;
  1652. u32 cnt_bt[BTC_BCNT_NUM];
  1653. u32 cnt_wl[BTC_WCNT_NUM];
  1654. };
  1655. struct rtw89_btc_fbtc_tdma {
  1656. u8 type; /* btc_ver::fcxtdma */
  1657. u8 rxflctrl;
  1658. u8 txpause;
  1659. u8 wtgle_n;
  1660. u8 leak_n;
  1661. u8 ext_ctrl;
  1662. u8 rxflctrl_role;
  1663. u8 option_ctrl;
  1664. } __packed;
  1665. struct rtw89_btc_fbtc_tdma_v3 {
  1666. u8 fver; /* btc_ver::fcxtdma */
  1667. u8 rsvd;
  1668. __le16 rsvd1;
  1669. struct rtw89_btc_fbtc_tdma tdma;
  1670. } __packed;
  1671. union rtw89_btc_fbtc_tdma_le32 {
  1672. struct rtw89_btc_fbtc_tdma v1;
  1673. struct rtw89_btc_fbtc_tdma_v3 v3;
  1674. };
  1675. #define CXMREG_MAX 30
  1676. #define CXMREG_MAX_V2 20
  1677. #define FCXMAX_STEP 255 /*STEP trace record cnt, Max:65535, default:255*/
  1678. #define BTC_CYCLE_SLOT_MAX 48 /* must be even number, non-zero */
  1679. enum rtw89_btc_bt_sta_counter {
  1680. BTC_BCNT_RFK_REQ = 0,
  1681. BTC_BCNT_RFK_GO = 1,
  1682. BTC_BCNT_RFK_REJECT = 2,
  1683. BTC_BCNT_RFK_FAIL = 3,
  1684. BTC_BCNT_RFK_TIMEOUT = 4,
  1685. BTC_BCNT_HI_TX = 5,
  1686. BTC_BCNT_HI_RX = 6,
  1687. BTC_BCNT_LO_TX = 7,
  1688. BTC_BCNT_LO_RX = 8,
  1689. BTC_BCNT_POLLUTED = 9,
  1690. BTC_BCNT_STA_MAX
  1691. };
  1692. enum rtw89_btc_bt_sta_counter_v105 {
  1693. BTC_BCNT_RFK_REQ_V105 = 0,
  1694. BTC_BCNT_HI_TX_V105 = 1,
  1695. BTC_BCNT_HI_RX_V105 = 2,
  1696. BTC_BCNT_LO_TX_V105 = 3,
  1697. BTC_BCNT_LO_RX_V105 = 4,
  1698. BTC_BCNT_POLLUTED_V105 = 5,
  1699. BTC_BCNT_STA_MAX_V105
  1700. };
  1701. struct rtw89_btc_fbtc_rpt_ctrl_v1 {
  1702. u16 fver; /* btc_ver::fcxbtcrpt */
  1703. u16 rpt_cnt; /* tmr counters */
  1704. u32 wl_fw_coex_ver; /* match which driver's coex version */
  1705. u32 wl_fw_cx_offload;
  1706. u32 wl_fw_ver;
  1707. u32 rpt_enable;
  1708. u32 rpt_para; /* ms */
  1709. u32 mb_send_fail_cnt; /* fw send mailbox fail counter */
  1710. u32 mb_send_ok_cnt; /* fw send mailbox ok counter */
  1711. u32 mb_recv_cnt; /* fw recv mailbox counter */
  1712. u32 mb_a2dp_empty_cnt; /* a2dp empty count */
  1713. u32 mb_a2dp_flct_cnt; /* a2dp empty flow control counter */
  1714. u32 mb_a2dp_full_cnt; /* a2dp empty full counter */
  1715. u32 bt_rfk_cnt[BTC_BCNT_HI_TX];
  1716. u32 c2h_cnt; /* fw send c2h counter */
  1717. u32 h2c_cnt; /* fw recv h2c counter */
  1718. } __packed;
  1719. struct rtw89_btc_fbtc_rpt_ctrl_info {
  1720. __le32 cnt; /* fw report counter */
  1721. __le32 en; /* report map */
  1722. __le32 para; /* not used */
  1723. __le32 cnt_c2h; /* fw send c2h counter */
  1724. __le32 cnt_h2c; /* fw recv h2c counter */
  1725. __le32 len_c2h; /* The total length of the last C2H */
  1726. __le32 cnt_aoac_rf_on; /* rf-on counter for aoac switch notify */
  1727. __le32 cnt_aoac_rf_off; /* rf-off counter for aoac switch notify */
  1728. } __packed;
  1729. struct rtw89_btc_fbtc_rpt_ctrl_info_v5 {
  1730. __le32 cx_ver; /* match which driver's coex version */
  1731. __le32 fw_ver;
  1732. __le32 en; /* report map */
  1733. __le16 cnt; /* fw report counter */
  1734. __le16 cnt_c2h; /* fw send c2h counter */
  1735. __le16 cnt_h2c; /* fw recv h2c counter */
  1736. __le16 len_c2h; /* The total length of the last C2H */
  1737. __le16 cnt_aoac_rf_on; /* rf-on counter for aoac switch notify */
  1738. __le16 cnt_aoac_rf_off; /* rf-off counter for aoac switch notify */
  1739. } __packed;
  1740. struct rtw89_btc_fbtc_rpt_ctrl_wl_fw_info {
  1741. __le32 cx_ver; /* match which driver's coex version */
  1742. __le32 cx_offload;
  1743. __le32 fw_ver;
  1744. } __packed;
  1745. struct rtw89_btc_fbtc_rpt_ctrl_a2dp_empty {
  1746. __le32 cnt_empty; /* a2dp empty count */
  1747. __le32 cnt_flowctrl; /* a2dp empty flow control counter */
  1748. __le32 cnt_tx;
  1749. __le32 cnt_ack;
  1750. __le32 cnt_nack;
  1751. } __packed;
  1752. struct rtw89_btc_fbtc_rpt_ctrl_bt_mailbox {
  1753. __le32 cnt_send_ok; /* fw send mailbox ok counter */
  1754. __le32 cnt_send_fail; /* fw send mailbox fail counter */
  1755. __le32 cnt_recv; /* fw recv mailbox counter */
  1756. struct rtw89_btc_fbtc_rpt_ctrl_a2dp_empty a2dp;
  1757. } __packed;
  1758. struct rtw89_btc_fbtc_rpt_ctrl_v4 {
  1759. u8 fver;
  1760. u8 rsvd;
  1761. __le16 rsvd1;
  1762. struct rtw89_btc_fbtc_rpt_ctrl_info rpt_info;
  1763. struct rtw89_btc_fbtc_rpt_ctrl_wl_fw_info wl_fw_info;
  1764. struct rtw89_btc_fbtc_rpt_ctrl_bt_mailbox bt_mbx_info;
  1765. __le32 bt_cnt[BTC_BCNT_STA_MAX];
  1766. struct rtw89_mac_ax_gnt gnt_val[RTW89_PHY_MAX];
  1767. } __packed;
  1768. struct rtw89_btc_fbtc_rpt_ctrl_v5 {
  1769. u8 fver;
  1770. u8 rsvd;
  1771. __le16 rsvd1;
  1772. u8 gnt_val[RTW89_PHY_MAX][4];
  1773. __le16 bt_cnt[BTC_BCNT_STA_MAX];
  1774. struct rtw89_btc_fbtc_rpt_ctrl_info_v5 rpt_info;
  1775. struct rtw89_btc_fbtc_rpt_ctrl_bt_mailbox bt_mbx_info;
  1776. } __packed;
  1777. struct rtw89_btc_fbtc_rpt_ctrl_v105 {
  1778. u8 fver;
  1779. u8 rsvd;
  1780. __le16 rsvd1;
  1781. u8 gnt_val[RTW89_PHY_MAX][4];
  1782. __le16 bt_cnt[BTC_BCNT_STA_MAX_V105];
  1783. struct rtw89_btc_fbtc_rpt_ctrl_info_v5 rpt_info;
  1784. struct rtw89_btc_fbtc_rpt_ctrl_bt_mailbox bt_mbx_info;
  1785. } __packed;
  1786. union rtw89_btc_fbtc_rpt_ctrl_ver_info {
  1787. struct rtw89_btc_fbtc_rpt_ctrl_v1 v1;
  1788. struct rtw89_btc_fbtc_rpt_ctrl_v4 v4;
  1789. struct rtw89_btc_fbtc_rpt_ctrl_v5 v5;
  1790. struct rtw89_btc_fbtc_rpt_ctrl_v105 v105;
  1791. };
  1792. enum rtw89_fbtc_ext_ctrl_type {
  1793. CXECTL_OFF = 0x0, /* tdma off */
  1794. CXECTL_B2 = 0x1, /* allow B2 (beacon-early) */
  1795. CXECTL_EXT = 0x2,
  1796. CXECTL_MAX
  1797. };
  1798. union rtw89_btc_fbtc_rxflct {
  1799. u8 val;
  1800. u8 type: 3;
  1801. u8 tgln_n: 5;
  1802. };
  1803. enum rtw89_btc_cxst_state {
  1804. CXST_OFF = 0x0,
  1805. CXST_B2W = 0x1,
  1806. CXST_W1 = 0x2,
  1807. CXST_W2 = 0x3,
  1808. CXST_W2B = 0x4,
  1809. CXST_B1 = 0x5,
  1810. CXST_B2 = 0x6,
  1811. CXST_B3 = 0x7,
  1812. CXST_B4 = 0x8,
  1813. CXST_LK = 0x9,
  1814. CXST_BLK = 0xa,
  1815. CXST_E2G = 0xb,
  1816. CXST_E5G = 0xc,
  1817. CXST_EBT = 0xd,
  1818. CXST_ENULL = 0xe,
  1819. CXST_WLK = 0xf,
  1820. CXST_W1FDD = 0x10,
  1821. CXST_B1FDD = 0x11,
  1822. CXST_MAX = 0x12,
  1823. };
  1824. enum rtw89_btc_cxevnt {
  1825. CXEVNT_TDMA_ENTRY = 0x0,
  1826. CXEVNT_WL_TMR,
  1827. CXEVNT_B1_TMR,
  1828. CXEVNT_B2_TMR,
  1829. CXEVNT_B3_TMR,
  1830. CXEVNT_B4_TMR,
  1831. CXEVNT_W2B_TMR,
  1832. CXEVNT_B2W_TMR,
  1833. CXEVNT_BCN_EARLY,
  1834. CXEVNT_A2DP_EMPTY,
  1835. CXEVNT_LK_END,
  1836. CXEVNT_RX_ISR,
  1837. CXEVNT_RX_FC0,
  1838. CXEVNT_RX_FC1,
  1839. CXEVNT_BT_RELINK,
  1840. CXEVNT_BT_RETRY,
  1841. CXEVNT_E2G,
  1842. CXEVNT_E5G,
  1843. CXEVNT_EBT,
  1844. CXEVNT_ENULL,
  1845. CXEVNT_DRV_WLK,
  1846. CXEVNT_BCN_OK,
  1847. CXEVNT_BT_CHANGE,
  1848. CXEVNT_EBT_EXTEND,
  1849. CXEVNT_E2G_NULL1,
  1850. CXEVNT_B1FDD_TMR,
  1851. CXEVNT_MAX
  1852. };
  1853. enum {
  1854. CXBCN_ALL = 0x0,
  1855. CXBCN_ALL_OK,
  1856. CXBCN_BT_SLOT,
  1857. CXBCN_BT_OK,
  1858. CXBCN_MAX
  1859. };
  1860. enum btc_slot_type {
  1861. SLOT_MIX = 0x0, /* accept BT Lower-Pri Tx/Rx request 0x778 = 1 */
  1862. SLOT_ISO = 0x1, /* no accept BT Lower-Pri Tx/Rx request 0x778 = d*/
  1863. CXSTYPE_NUM,
  1864. };
  1865. enum { /* TIME */
  1866. CXT_BT = 0x0,
  1867. CXT_WL = 0x1,
  1868. CXT_MAX
  1869. };
  1870. enum { /* TIME-A2DP */
  1871. CXT_FLCTRL_OFF = 0x0,
  1872. CXT_FLCTRL_ON = 0x1,
  1873. CXT_FLCTRL_MAX
  1874. };
  1875. enum { /* STEP TYPE */
  1876. CXSTEP_NONE = 0x0,
  1877. CXSTEP_EVNT = 0x1,
  1878. CXSTEP_SLOT = 0x2,
  1879. CXSTEP_MAX,
  1880. };
  1881. enum rtw89_btc_afh_map_type { /*AFH MAP TYPE */
  1882. RPT_BT_AFH_SEQ_LEGACY = 0x10,
  1883. RPT_BT_AFH_SEQ_LE = 0x20
  1884. };
  1885. #define BTC_DBG_MAX1 32
  1886. struct rtw89_btc_fbtc_gpio_dbg {
  1887. u8 fver; /* btc_ver::fcxgpiodbg */
  1888. u8 rsvd;
  1889. u16 rsvd2;
  1890. u32 en_map; /* which debug signal (see btc_wl_gpio_debug) is enable */
  1891. u32 pre_state; /* the debug signal is 1 or 0 */
  1892. u8 gpio_map[BTC_DBG_MAX1]; /*the debug signals to GPIO-Position */
  1893. } __packed;
  1894. struct rtw89_btc_fbtc_mreg_val_v1 {
  1895. u8 fver; /* btc_ver::fcxmreg */
  1896. u8 reg_num;
  1897. __le16 rsvd;
  1898. __le32 mreg_val[CXMREG_MAX];
  1899. } __packed;
  1900. struct rtw89_btc_fbtc_mreg_val_v2 {
  1901. u8 fver; /* btc_ver::fcxmreg */
  1902. u8 reg_num;
  1903. __le16 rsvd;
  1904. __le32 mreg_val[CXMREG_MAX_V2];
  1905. } __packed;
  1906. union rtw89_btc_fbtc_mreg_val {
  1907. struct rtw89_btc_fbtc_mreg_val_v1 v1;
  1908. struct rtw89_btc_fbtc_mreg_val_v2 v2;
  1909. };
  1910. #define RTW89_DEF_FBTC_MREG(__type, __bytes, __offset) \
  1911. { .type = cpu_to_le16(__type), .bytes = cpu_to_le16(__bytes), \
  1912. .offset = cpu_to_le32(__offset), }
  1913. struct rtw89_btc_fbtc_mreg {
  1914. __le16 type;
  1915. __le16 bytes;
  1916. __le32 offset;
  1917. } __packed;
  1918. struct rtw89_btc_fbtc_slot {
  1919. __le16 dur;
  1920. __le32 cxtbl;
  1921. __le16 cxtype;
  1922. } __packed;
  1923. struct rtw89_btc_fbtc_slots {
  1924. u8 fver; /* btc_ver::fcxslots */
  1925. u8 tbl_num;
  1926. __le16 rsvd;
  1927. __le32 update_map;
  1928. struct rtw89_btc_fbtc_slot slot[CXST_MAX];
  1929. } __packed;
  1930. struct rtw89_btc_fbtc_step {
  1931. u8 type;
  1932. u8 val;
  1933. __le16 difft;
  1934. } __packed;
  1935. struct rtw89_btc_fbtc_steps_v2 {
  1936. u8 fver; /* btc_ver::fcxstep */
  1937. u8 rsvd;
  1938. __le16 cnt;
  1939. __le16 pos_old;
  1940. __le16 pos_new;
  1941. struct rtw89_btc_fbtc_step step[FCXMAX_STEP];
  1942. } __packed;
  1943. struct rtw89_btc_fbtc_steps_v3 {
  1944. u8 fver;
  1945. u8 en;
  1946. __le16 rsvd;
  1947. __le32 cnt;
  1948. struct rtw89_btc_fbtc_step step[FCXMAX_STEP];
  1949. } __packed;
  1950. union rtw89_btc_fbtc_steps_info {
  1951. struct rtw89_btc_fbtc_steps_v2 v2;
  1952. struct rtw89_btc_fbtc_steps_v3 v3;
  1953. };
  1954. struct rtw89_btc_fbtc_cysta_v2 { /* statistics for cycles */
  1955. u8 fver; /* btc_ver::fcxcysta */
  1956. u8 rsvd;
  1957. __le16 cycles; /* total cycle number */
  1958. __le16 cycles_a2dp[CXT_FLCTRL_MAX];
  1959. __le16 a2dpept; /* a2dp empty cnt */
  1960. __le16 a2dpeptto; /* a2dp empty timeout cnt*/
  1961. __le16 tavg_cycle[CXT_MAX]; /* avg wl/bt cycle time */
  1962. __le16 tmax_cycle[CXT_MAX]; /* max wl/bt cycle time */
  1963. __le16 tmaxdiff_cycle[CXT_MAX]; /* max wl-wl bt-bt cycle diff time */
  1964. __le16 tavg_a2dp[CXT_FLCTRL_MAX]; /* avg a2dp PSTDMA/TDMA time */
  1965. __le16 tmax_a2dp[CXT_FLCTRL_MAX]; /* max a2dp PSTDMA/TDMA time */
  1966. __le16 tavg_a2dpept; /* avg a2dp empty time */
  1967. __le16 tmax_a2dpept; /* max a2dp empty time */
  1968. __le16 tavg_lk; /* avg leak-slot time */
  1969. __le16 tmax_lk; /* max leak-slot time */
  1970. __le32 slot_cnt[CXST_MAX]; /* slot count */
  1971. __le32 bcn_cnt[CXBCN_MAX];
  1972. __le32 leakrx_cnt; /* the rximr occur at leak slot */
  1973. __le32 collision_cnt; /* counter for event/timer occur at same time */
  1974. __le32 skip_cnt;
  1975. __le32 exception;
  1976. __le32 except_cnt;
  1977. __le16 tslot_cycle[BTC_CYCLE_SLOT_MAX];
  1978. } __packed;
  1979. struct rtw89_btc_fbtc_fdd_try_info {
  1980. __le16 cycles[CXT_FLCTRL_MAX];
  1981. __le16 tavg[CXT_FLCTRL_MAX]; /* avg try BT-Slot-TDD/BT-slot-FDD time */
  1982. __le16 tmax[CXT_FLCTRL_MAX]; /* max try BT-Slot-TDD/BT-slot-FDD time */
  1983. } __packed;
  1984. struct rtw89_btc_fbtc_cycle_time_info {
  1985. __le16 tavg[CXT_MAX]; /* avg wl/bt cycle time */
  1986. __le16 tmax[CXT_MAX]; /* max wl/bt cycle time */
  1987. __le16 tmaxdiff[CXT_MAX]; /* max wl-wl bt-bt cycle diff time */
  1988. } __packed;
  1989. struct rtw89_btc_fbtc_cycle_time_info_v5 {
  1990. __le16 tavg[CXT_MAX]; /* avg wl/bt cycle time */
  1991. __le16 tmax[CXT_MAX]; /* max wl/bt cycle time */
  1992. } __packed;
  1993. struct rtw89_btc_fbtc_a2dp_trx_stat {
  1994. u8 empty_cnt;
  1995. u8 retry_cnt;
  1996. u8 tx_rate;
  1997. u8 tx_cnt;
  1998. u8 ack_cnt;
  1999. u8 nack_cnt;
  2000. u8 rsvd1;
  2001. u8 rsvd2;
  2002. } __packed;
  2003. struct rtw89_btc_fbtc_a2dp_trx_stat_v4 {
  2004. u8 empty_cnt;
  2005. u8 retry_cnt;
  2006. u8 tx_rate;
  2007. u8 tx_cnt;
  2008. u8 ack_cnt;
  2009. u8 nack_cnt;
  2010. u8 no_empty_cnt;
  2011. u8 rsvd;
  2012. } __packed;
  2013. struct rtw89_btc_fbtc_cycle_a2dp_empty_info {
  2014. __le16 cnt; /* a2dp empty cnt */
  2015. __le16 cnt_timeout; /* a2dp empty timeout cnt*/
  2016. __le16 tavg; /* avg a2dp empty time */
  2017. __le16 tmax; /* max a2dp empty time */
  2018. } __packed;
  2019. struct rtw89_btc_fbtc_cycle_leak_info {
  2020. __le32 cnt_rximr; /* the rximr occur at leak slot */
  2021. __le16 tavg; /* avg leak-slot time */
  2022. __le16 tmax; /* max leak-slot time */
  2023. } __packed;
  2024. #define RTW89_BTC_FDDT_PHASE_CYCLE GENMASK(9, 0)
  2025. #define RTW89_BTC_FDDT_TRAIN_STEP GENMASK(15, 10)
  2026. struct rtw89_btc_fbtc_cycle_fddt_info {
  2027. __le16 train_cycle;
  2028. __le16 tp;
  2029. s8 tx_power; /* absolute Tx power (dBm), 0xff-> no BTC control */
  2030. s8 bt_tx_power; /* decrease Tx power (dB) */
  2031. s8 bt_rx_gain; /* LNA constrain level */
  2032. u8 no_empty_cnt;
  2033. u8 rssi; /* [7:4] -> bt_rssi_level, [3:0]-> wl_rssi_level */
  2034. u8 cn; /* condition_num */
  2035. u8 train_status; /* [7:4]-> train-state, [3:0]-> train-phase */
  2036. u8 train_result; /* refer to enum btc_fddt_check_map */
  2037. } __packed;
  2038. #define RTW89_BTC_FDDT_CELL_TRAIN_STATE GENMASK(3, 0)
  2039. #define RTW89_BTC_FDDT_CELL_TRAIN_PHASE GENMASK(7, 4)
  2040. struct rtw89_btc_fbtc_cycle_fddt_info_v5 {
  2041. __le16 train_cycle;
  2042. __le16 tp;
  2043. s8 tx_power; /* absolute Tx power (dBm), 0xff-> no BTC control */
  2044. s8 bt_tx_power; /* decrease Tx power (dB) */
  2045. s8 bt_rx_gain; /* LNA constrain level */
  2046. u8 no_empty_cnt;
  2047. u8 rssi; /* [7:4] -> bt_rssi_level, [3:0]-> wl_rssi_level */
  2048. u8 cn; /* condition_num */
  2049. u8 train_status; /* [7:4]-> train-state, [3:0]-> train-phase */
  2050. u8 train_result; /* refer to enum btc_fddt_check_map */
  2051. } __packed;
  2052. struct rtw89_btc_fbtc_fddt_cell_status {
  2053. s8 wl_tx_pwr;
  2054. s8 bt_tx_pwr;
  2055. s8 bt_rx_gain;
  2056. u8 state_phase; /* [0:3] train state, [4:7] train phase */
  2057. } __packed;
  2058. struct rtw89_btc_fbtc_fddt_cell_status_v5 {
  2059. s8 wl_tx_pwr;
  2060. s8 bt_tx_pwr;
  2061. s8 bt_rx_gain;
  2062. } __packed;
  2063. struct rtw89_btc_fbtc_cysta_v3 { /* statistics for cycles */
  2064. u8 fver;
  2065. u8 rsvd;
  2066. __le16 cycles; /* total cycle number */
  2067. __le16 slot_step_time[BTC_CYCLE_SLOT_MAX];
  2068. struct rtw89_btc_fbtc_cycle_time_info cycle_time;
  2069. struct rtw89_btc_fbtc_fdd_try_info fdd_try;
  2070. struct rtw89_btc_fbtc_cycle_a2dp_empty_info a2dp_ept;
  2071. struct rtw89_btc_fbtc_a2dp_trx_stat a2dp_trx[BTC_CYCLE_SLOT_MAX];
  2072. struct rtw89_btc_fbtc_cycle_leak_info leak_slot;
  2073. __le32 slot_cnt[CXST_MAX]; /* slot count */
  2074. __le32 bcn_cnt[CXBCN_MAX];
  2075. __le32 collision_cnt; /* counter for event/timer occur at the same time */
  2076. __le32 skip_cnt;
  2077. __le32 except_cnt;
  2078. __le32 except_map;
  2079. } __packed;
  2080. #define FDD_TRAIN_WL_DIRECTION 2
  2081. #define FDD_TRAIN_WL_RSSI_LEVEL 5
  2082. #define FDD_TRAIN_BT_RSSI_LEVEL 5
  2083. struct rtw89_btc_fbtc_cysta_v4 { /* statistics for cycles */
  2084. u8 fver;
  2085. u8 rsvd;
  2086. u8 collision_cnt; /* counter for event/timer occur at the same time */
  2087. u8 except_cnt;
  2088. __le16 skip_cnt;
  2089. __le16 cycles; /* total cycle number */
  2090. __le16 slot_step_time[BTC_CYCLE_SLOT_MAX]; /* record the wl/bt slot time */
  2091. __le16 slot_cnt[CXST_MAX]; /* slot count */
  2092. __le16 bcn_cnt[CXBCN_MAX];
  2093. struct rtw89_btc_fbtc_cycle_time_info cycle_time;
  2094. struct rtw89_btc_fbtc_cycle_leak_info leak_slot;
  2095. struct rtw89_btc_fbtc_cycle_a2dp_empty_info a2dp_ept;
  2096. struct rtw89_btc_fbtc_a2dp_trx_stat_v4 a2dp_trx[BTC_CYCLE_SLOT_MAX];
  2097. struct rtw89_btc_fbtc_cycle_fddt_info fddt_trx[BTC_CYCLE_SLOT_MAX];
  2098. struct rtw89_btc_fbtc_fddt_cell_status fddt_cells[FDD_TRAIN_WL_DIRECTION]
  2099. [FDD_TRAIN_WL_RSSI_LEVEL]
  2100. [FDD_TRAIN_BT_RSSI_LEVEL];
  2101. __le32 except_map;
  2102. } __packed;
  2103. struct rtw89_btc_fbtc_cysta_v5 { /* statistics for cycles */
  2104. u8 fver;
  2105. u8 rsvd;
  2106. u8 collision_cnt; /* counter for event/timer occur at the same time */
  2107. u8 except_cnt;
  2108. u8 wl_rx_err_ratio[BTC_CYCLE_SLOT_MAX];
  2109. __le16 skip_cnt;
  2110. __le16 cycles; /* total cycle number */
  2111. __le16 slot_step_time[BTC_CYCLE_SLOT_MAX]; /* record the wl/bt slot time */
  2112. __le16 slot_cnt[CXST_MAX]; /* slot count */
  2113. __le16 bcn_cnt[CXBCN_MAX];
  2114. struct rtw89_btc_fbtc_cycle_time_info_v5 cycle_time;
  2115. struct rtw89_btc_fbtc_cycle_leak_info leak_slot;
  2116. struct rtw89_btc_fbtc_cycle_a2dp_empty_info a2dp_ept;
  2117. struct rtw89_btc_fbtc_a2dp_trx_stat_v4 a2dp_trx[BTC_CYCLE_SLOT_MAX];
  2118. struct rtw89_btc_fbtc_cycle_fddt_info_v5 fddt_trx[BTC_CYCLE_SLOT_MAX];
  2119. struct rtw89_btc_fbtc_fddt_cell_status_v5 fddt_cells[FDD_TRAIN_WL_DIRECTION]
  2120. [FDD_TRAIN_WL_RSSI_LEVEL]
  2121. [FDD_TRAIN_BT_RSSI_LEVEL];
  2122. __le32 except_map;
  2123. } __packed;
  2124. union rtw89_btc_fbtc_cysta_info {
  2125. struct rtw89_btc_fbtc_cysta_v2 v2;
  2126. struct rtw89_btc_fbtc_cysta_v3 v3;
  2127. struct rtw89_btc_fbtc_cysta_v4 v4;
  2128. struct rtw89_btc_fbtc_cysta_v5 v5;
  2129. };
  2130. struct rtw89_btc_fbtc_cynullsta_v1 { /* cycle null statistics */
  2131. u8 fver; /* btc_ver::fcxnullsta */
  2132. u8 rsvd;
  2133. __le16 rsvd2;
  2134. __le32 max_t[2]; /* max_t for 0:null0/1:null1 */
  2135. __le32 avg_t[2]; /* avg_t for 0:null0/1:null1 */
  2136. __le32 result[2][4]; /* 0:fail, 1:ok, 2:on_time, 3:retry */
  2137. } __packed;
  2138. struct rtw89_btc_fbtc_cynullsta_v2 { /* cycle null statistics */
  2139. u8 fver; /* btc_ver::fcxnullsta */
  2140. u8 rsvd;
  2141. __le16 rsvd2;
  2142. __le32 max_t[2]; /* max_t for 0:null0/1:null1 */
  2143. __le32 avg_t[2]; /* avg_t for 0:null0/1:null1 */
  2144. __le32 result[2][5]; /* 0:fail, 1:ok, 2:on_time, 3:retry, 4:tx */
  2145. } __packed;
  2146. union rtw89_btc_fbtc_cynullsta_info {
  2147. struct rtw89_btc_fbtc_cynullsta_v1 v1; /* info from fw */
  2148. struct rtw89_btc_fbtc_cynullsta_v2 v2;
  2149. };
  2150. struct rtw89_btc_fbtc_btver {
  2151. u8 fver; /* btc_ver::fcxbtver */
  2152. u8 rsvd;
  2153. __le16 rsvd2;
  2154. __le32 coex_ver; /*bit[15:8]->shared, bit[7:0]->non-shared */
  2155. __le32 fw_ver;
  2156. __le32 feature;
  2157. } __packed;
  2158. struct rtw89_btc_fbtc_btafh {
  2159. u8 fver; /* btc_ver::fcxbtafh */
  2160. u8 rsvd;
  2161. __le16 rsvd2;
  2162. u8 afh_l[4]; /*bit0:2402, bit1: 2403.... bit31:2433 */
  2163. u8 afh_m[4]; /*bit0:2434, bit1: 2435.... bit31:2465 */
  2164. u8 afh_h[4]; /*bit0:2466, bit1:2467......bit14:2480 */
  2165. } __packed;
  2166. struct rtw89_btc_fbtc_btafh_v2 {
  2167. u8 fver; /* btc_ver::fcxbtafh */
  2168. u8 rsvd;
  2169. u8 rsvd2;
  2170. u8 map_type;
  2171. u8 afh_l[4];
  2172. u8 afh_m[4];
  2173. u8 afh_h[4];
  2174. u8 afh_le_a[4];
  2175. u8 afh_le_b[4];
  2176. } __packed;
  2177. struct rtw89_btc_fbtc_btdevinfo {
  2178. u8 fver; /* btc_ver::fcxbtdevinfo */
  2179. u8 rsvd;
  2180. __le16 vendor_id;
  2181. __le32 dev_name; /* only 24 bits valid */
  2182. __le32 flush_time;
  2183. } __packed;
  2184. #define RTW89_BTC_WL_DEF_TX_PWR GENMASK(7, 0)
  2185. struct rtw89_btc_rf_trx_para {
  2186. u32 wl_tx_power; /* absolute Tx power (dBm), 0xff-> no BTC control */
  2187. u32 wl_rx_gain; /* rx gain table index (TBD.) */
  2188. u8 bt_tx_power; /* decrease Tx power (dB) */
  2189. u8 bt_rx_gain; /* LNA constrain level */
  2190. };
  2191. struct rtw89_btc_trx_info {
  2192. u8 tx_lvl;
  2193. u8 rx_lvl;
  2194. u8 wl_rssi;
  2195. u8 bt_rssi;
  2196. s8 tx_power; /* absolute Tx power (dBm), 0xff-> no BTC control */
  2197. s8 rx_gain; /* rx gain table index (TBD.) */
  2198. s8 bt_tx_power; /* decrease Tx power (dB) */
  2199. s8 bt_rx_gain; /* LNA constrain level */
  2200. u8 cn; /* condition_num */
  2201. s8 nhm;
  2202. u8 bt_profile;
  2203. u8 rsvd2;
  2204. u16 tx_rate;
  2205. u16 rx_rate;
  2206. u32 tx_tp;
  2207. u32 rx_tp;
  2208. u32 rx_err_ratio;
  2209. };
  2210. struct rtw89_btc_dm {
  2211. struct rtw89_btc_fbtc_slot slot[CXST_MAX];
  2212. struct rtw89_btc_fbtc_slot slot_now[CXST_MAX];
  2213. struct rtw89_btc_fbtc_tdma tdma;
  2214. struct rtw89_btc_fbtc_tdma tdma_now;
  2215. struct rtw89_mac_ax_coex_gnt gnt;
  2216. struct rtw89_btc_init_info init_info; /* pass to wl_fw if offload */
  2217. struct rtw89_btc_rf_trx_para rf_trx_para;
  2218. struct rtw89_btc_wl_tx_limit_para wl_tx_limit;
  2219. struct rtw89_btc_dm_step dm_step;
  2220. struct rtw89_btc_wl_scc_ctrl wl_scc;
  2221. struct rtw89_btc_trx_info trx_info;
  2222. union rtw89_btc_dm_error_map error;
  2223. u32 cnt_dm[BTC_DCNT_NUM];
  2224. u32 cnt_notify[BTC_NCNT_NUM];
  2225. u32 update_slot_map;
  2226. u32 set_ant_path;
  2227. u32 wl_only: 1;
  2228. u32 wl_fw_cx_offload: 1;
  2229. u32 freerun: 1;
  2230. u32 fddt_train: 1;
  2231. u32 wl_ps_ctrl: 2;
  2232. u32 wl_mimo_ps: 1;
  2233. u32 leak_ap: 1;
  2234. u32 noisy_level: 3;
  2235. u32 coex_info_map: 8;
  2236. u32 bt_only: 1;
  2237. u32 wl_btg_rx: 1;
  2238. u32 trx_para_level: 8;
  2239. u32 wl_stb_chg: 1;
  2240. u32 pta_owner: 1;
  2241. u32 tdma_instant_excute: 1;
  2242. u16 slot_dur[CXST_MAX];
  2243. u8 run_reason;
  2244. u8 run_action;
  2245. u8 wl_lna2: 1;
  2246. };
  2247. struct rtw89_btc_ctrl {
  2248. u32 manual: 1;
  2249. u32 igno_bt: 1;
  2250. u32 always_freerun: 1;
  2251. u32 trace_step: 16;
  2252. u32 rsvd: 12;
  2253. };
  2254. struct rtw89_btc_dbg {
  2255. /* cmd "rb" */
  2256. bool rb_done;
  2257. u32 rb_val;
  2258. };
  2259. enum rtw89_btc_btf_fw_event {
  2260. BTF_EVNT_RPT = 0,
  2261. BTF_EVNT_BT_INFO = 1,
  2262. BTF_EVNT_BT_SCBD = 2,
  2263. BTF_EVNT_BT_REG = 3,
  2264. BTF_EVNT_CX_RUNINFO = 4,
  2265. BTF_EVNT_BT_PSD = 5,
  2266. BTF_EVNT_BUF_OVERFLOW,
  2267. BTF_EVNT_C2H_LOOPBACK,
  2268. BTF_EVNT_MAX,
  2269. };
  2270. enum btf_fw_event_report {
  2271. BTC_RPT_TYPE_CTRL = 0x0,
  2272. BTC_RPT_TYPE_TDMA,
  2273. BTC_RPT_TYPE_SLOT,
  2274. BTC_RPT_TYPE_CYSTA,
  2275. BTC_RPT_TYPE_STEP,
  2276. BTC_RPT_TYPE_NULLSTA,
  2277. BTC_RPT_TYPE_MREG,
  2278. BTC_RPT_TYPE_GPIO_DBG,
  2279. BTC_RPT_TYPE_BT_VER,
  2280. BTC_RPT_TYPE_BT_SCAN,
  2281. BTC_RPT_TYPE_BT_AFH,
  2282. BTC_RPT_TYPE_BT_DEVICE,
  2283. BTC_RPT_TYPE_TEST,
  2284. BTC_RPT_TYPE_MAX = 31
  2285. };
  2286. enum rtw_btc_btf_reg_type {
  2287. REG_MAC = 0x0,
  2288. REG_BB = 0x1,
  2289. REG_RF = 0x2,
  2290. REG_BT_RF = 0x3,
  2291. REG_BT_MODEM = 0x4,
  2292. REG_BT_BLUEWIZE = 0x5,
  2293. REG_BT_VENDOR = 0x6,
  2294. REG_BT_LE = 0x7,
  2295. REG_MAX_TYPE,
  2296. };
  2297. struct rtw89_btc_rpt_cmn_info {
  2298. u32 rx_cnt;
  2299. u32 rx_len;
  2300. u32 req_len; /* expected rsp len */
  2301. u8 req_fver; /* expected rsp fver */
  2302. u8 rsp_fver; /* fver from fw */
  2303. u8 valid;
  2304. } __packed;
  2305. union rtw89_btc_fbtc_btafh_info {
  2306. struct rtw89_btc_fbtc_btafh v1;
  2307. struct rtw89_btc_fbtc_btafh_v2 v2;
  2308. };
  2309. struct rtw89_btc_report_ctrl_state {
  2310. struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */
  2311. union rtw89_btc_fbtc_rpt_ctrl_ver_info finfo;
  2312. };
  2313. struct rtw89_btc_rpt_fbtc_tdma {
  2314. struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */
  2315. union rtw89_btc_fbtc_tdma_le32 finfo;
  2316. };
  2317. struct rtw89_btc_rpt_fbtc_slots {
  2318. struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */
  2319. struct rtw89_btc_fbtc_slots finfo; /* info from fw */
  2320. };
  2321. struct rtw89_btc_rpt_fbtc_cysta {
  2322. struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */
  2323. union rtw89_btc_fbtc_cysta_info finfo;
  2324. };
  2325. struct rtw89_btc_rpt_fbtc_step {
  2326. struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */
  2327. union rtw89_btc_fbtc_steps_info finfo; /* info from fw */
  2328. };
  2329. struct rtw89_btc_rpt_fbtc_nullsta {
  2330. struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */
  2331. union rtw89_btc_fbtc_cynullsta_info finfo;
  2332. };
  2333. struct rtw89_btc_rpt_fbtc_mreg {
  2334. struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */
  2335. union rtw89_btc_fbtc_mreg_val finfo; /* info from fw */
  2336. };
  2337. struct rtw89_btc_rpt_fbtc_gpio_dbg {
  2338. struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */
  2339. struct rtw89_btc_fbtc_gpio_dbg finfo; /* info from fw */
  2340. };
  2341. struct rtw89_btc_rpt_fbtc_btver {
  2342. struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */
  2343. struct rtw89_btc_fbtc_btver finfo; /* info from fw */
  2344. };
  2345. struct rtw89_btc_rpt_fbtc_btscan {
  2346. struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */
  2347. union rtw89_btc_fbtc_btscan finfo; /* info from fw */
  2348. };
  2349. struct rtw89_btc_rpt_fbtc_btafh {
  2350. struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */
  2351. union rtw89_btc_fbtc_btafh_info finfo;
  2352. };
  2353. struct rtw89_btc_rpt_fbtc_btdev {
  2354. struct rtw89_btc_rpt_cmn_info cinfo; /* common info, by driver */
  2355. struct rtw89_btc_fbtc_btdevinfo finfo; /* info from fw */
  2356. };
  2357. enum rtw89_btc_btfre_type {
  2358. BTFRE_INVALID_INPUT = 0x0, /* invalid input parameters */
  2359. BTFRE_UNDEF_TYPE,
  2360. BTFRE_EXCEPTION,
  2361. BTFRE_MAX,
  2362. };
  2363. struct rtw89_btc_btf_fwinfo {
  2364. u32 cnt_c2h;
  2365. u32 cnt_h2c;
  2366. u32 cnt_h2c_fail;
  2367. u32 event[BTF_EVNT_MAX];
  2368. u32 err[BTFRE_MAX];
  2369. u32 len_mismch;
  2370. u32 fver_mismch;
  2371. u32 rpt_en_map;
  2372. struct rtw89_btc_report_ctrl_state rpt_ctrl;
  2373. struct rtw89_btc_rpt_fbtc_tdma rpt_fbtc_tdma;
  2374. struct rtw89_btc_rpt_fbtc_slots rpt_fbtc_slots;
  2375. struct rtw89_btc_rpt_fbtc_cysta rpt_fbtc_cysta;
  2376. struct rtw89_btc_rpt_fbtc_step rpt_fbtc_step;
  2377. struct rtw89_btc_rpt_fbtc_nullsta rpt_fbtc_nullsta;
  2378. struct rtw89_btc_rpt_fbtc_mreg rpt_fbtc_mregval;
  2379. struct rtw89_btc_rpt_fbtc_gpio_dbg rpt_fbtc_gpio_dbg;
  2380. struct rtw89_btc_rpt_fbtc_btver rpt_fbtc_btver;
  2381. struct rtw89_btc_rpt_fbtc_btscan rpt_fbtc_btscan;
  2382. struct rtw89_btc_rpt_fbtc_btafh rpt_fbtc_btafh;
  2383. struct rtw89_btc_rpt_fbtc_btdev rpt_fbtc_btdev;
  2384. };
  2385. struct rtw89_btc_ver {
  2386. enum rtw89_core_chip_id chip_id;
  2387. u32 fw_ver_code;
  2388. u8 fcxbtcrpt;
  2389. u8 fcxtdma;
  2390. u8 fcxslots;
  2391. u8 fcxcysta;
  2392. u8 fcxstep;
  2393. u8 fcxnullsta;
  2394. u8 fcxmreg;
  2395. u8 fcxgpiodbg;
  2396. u8 fcxbtver;
  2397. u8 fcxbtscan;
  2398. u8 fcxbtafh;
  2399. u8 fcxbtdevinfo;
  2400. u8 fwlrole;
  2401. u8 frptmap;
  2402. u8 fcxctrl;
  2403. u16 info_buf;
  2404. u8 max_role_num;
  2405. };
  2406. #define RTW89_BTC_POLICY_MAXLEN 512
  2407. struct rtw89_btc {
  2408. const struct rtw89_btc_ver *ver;
  2409. struct rtw89_btc_cx cx;
  2410. struct rtw89_btc_dm dm;
  2411. struct rtw89_btc_ctrl ctrl;
  2412. struct rtw89_btc_module mdinfo;
  2413. struct rtw89_btc_btf_fwinfo fwinfo;
  2414. struct rtw89_btc_dbg dbg;
  2415. struct work_struct eapol_notify_work;
  2416. struct work_struct arp_notify_work;
  2417. struct work_struct dhcp_notify_work;
  2418. struct work_struct icmp_notify_work;
  2419. u32 bt_req_len;
  2420. u8 policy[RTW89_BTC_POLICY_MAXLEN];
  2421. u16 policy_len;
  2422. u16 policy_type;
  2423. bool bt_req_en;
  2424. bool update_policy_force;
  2425. bool lps;
  2426. };
  2427. enum rtw89_btc_hmsg {
  2428. RTW89_BTC_HMSG_TMR_EN = 0x0,
  2429. RTW89_BTC_HMSG_BT_REG_READBACK = 0x1,
  2430. RTW89_BTC_HMSG_SET_BT_REQ_SLOT = 0x2,
  2431. RTW89_BTC_HMSG_FW_EV = 0x3,
  2432. RTW89_BTC_HMSG_BT_LINK_CHG = 0x4,
  2433. RTW89_BTC_HMSG_SET_BT_REQ_STBC = 0x5,
  2434. NUM_OF_RTW89_BTC_HMSG,
  2435. };
  2436. enum rtw89_ra_mode {
  2437. RTW89_RA_MODE_CCK = BIT(0),
  2438. RTW89_RA_MODE_OFDM = BIT(1),
  2439. RTW89_RA_MODE_HT = BIT(2),
  2440. RTW89_RA_MODE_VHT = BIT(3),
  2441. RTW89_RA_MODE_HE = BIT(4),
  2442. };
  2443. enum rtw89_ra_report_mode {
  2444. RTW89_RA_RPT_MODE_LEGACY,
  2445. RTW89_RA_RPT_MODE_HT,
  2446. RTW89_RA_RPT_MODE_VHT,
  2447. RTW89_RA_RPT_MODE_HE,
  2448. };
  2449. enum rtw89_dig_noisy_level {
  2450. RTW89_DIG_NOISY_LEVEL0 = -1,
  2451. RTW89_DIG_NOISY_LEVEL1 = 0,
  2452. RTW89_DIG_NOISY_LEVEL2 = 1,
  2453. RTW89_DIG_NOISY_LEVEL3 = 2,
  2454. RTW89_DIG_NOISY_LEVEL_MAX = 3,
  2455. };
  2456. enum rtw89_gi_ltf {
  2457. RTW89_GILTF_LGI_4XHE32 = 0,
  2458. RTW89_GILTF_SGI_4XHE08 = 1,
  2459. RTW89_GILTF_2XHE16 = 2,
  2460. RTW89_GILTF_2XHE08 = 3,
  2461. RTW89_GILTF_1XHE16 = 4,
  2462. RTW89_GILTF_1XHE08 = 5,
  2463. RTW89_GILTF_MAX
  2464. };
  2465. enum rtw89_rx_frame_type {
  2466. RTW89_RX_TYPE_MGNT = 0,
  2467. RTW89_RX_TYPE_CTRL = 1,
  2468. RTW89_RX_TYPE_DATA = 2,
  2469. RTW89_RX_TYPE_RSVD = 3,
  2470. };
  2471. struct rtw89_ra_info {
  2472. u8 is_dis_ra:1;
  2473. /* Bit0 : CCK
  2474. * Bit1 : OFDM
  2475. * Bit2 : HT
  2476. * Bit3 : VHT
  2477. * Bit4 : HE
  2478. * Bit5 : EHT
  2479. */
  2480. u8 mode_ctrl:6;
  2481. u8 bw_cap:3; /* enum rtw89_bandwidth */
  2482. u8 macid;
  2483. u8 dcm_cap:1;
  2484. u8 er_cap:1;
  2485. u8 init_rate_lv:2;
  2486. u8 upd_all:1;
  2487. u8 en_sgi:1;
  2488. u8 ldpc_cap:1;
  2489. u8 stbc_cap:1;
  2490. u8 ss_num:3;
  2491. u8 giltf:3;
  2492. u8 upd_bw_nss_mask:1;
  2493. u8 upd_mask:1;
  2494. u64 ra_mask; /* 63 bits ra_mask + 1 bit CSI ctrl */
  2495. /* BFee CSI */
  2496. u8 band_num;
  2497. u8 ra_csi_rate_en:1;
  2498. u8 fixed_csi_rate_en:1;
  2499. u8 cr_tbl_sel:1;
  2500. u8 fix_giltf_en:1;
  2501. u8 fix_giltf:3;
  2502. u8 rsvd2:1;
  2503. u8 csi_mcs_ss_idx;
  2504. u8 csi_mode:2;
  2505. u8 csi_gi_ltf:3;
  2506. u8 csi_bw:3;
  2507. };
  2508. #define RTW89_PPDU_MAX_USR 4
  2509. #define RTW89_PPDU_MAC_INFO_USR_SIZE 4
  2510. #define RTW89_PPDU_MAC_INFO_SIZE 8
  2511. #define RTW89_PPDU_MAC_RX_CNT_SIZE 96
  2512. #define RTW89_MAX_RX_AGG_NUM 64
  2513. #define RTW89_MAX_TX_AGG_NUM 128
  2514. struct rtw89_ampdu_params {
  2515. u16 agg_num;
  2516. bool amsdu;
  2517. };
  2518. struct rtw89_ra_report {
  2519. struct rate_info txrate;
  2520. u32 bit_rate;
  2521. u16 hw_rate;
  2522. bool might_fallback_legacy;
  2523. };
  2524. DECLARE_EWMA(rssi, 10, 16);
  2525. DECLARE_EWMA(evm, 10, 16);
  2526. DECLARE_EWMA(snr, 10, 16);
  2527. struct rtw89_ba_cam_entry {
  2528. struct list_head list;
  2529. u8 tid;
  2530. };
  2531. #define RTW89_MAX_ADDR_CAM_NUM 128
  2532. #define RTW89_MAX_BSSID_CAM_NUM 20
  2533. #define RTW89_MAX_SEC_CAM_NUM 128
  2534. #define RTW89_MAX_BA_CAM_NUM 8
  2535. #define RTW89_SEC_CAM_IN_ADDR_CAM 7
  2536. struct rtw89_addr_cam_entry {
  2537. u8 addr_cam_idx;
  2538. u8 offset;
  2539. u8 len;
  2540. u8 valid : 1;
  2541. u8 addr_mask : 6;
  2542. u8 wapi : 1;
  2543. u8 mask_sel : 2;
  2544. u8 bssid_cam_idx: 6;
  2545. u8 sec_ent_mode;
  2546. DECLARE_BITMAP(sec_cam_map, RTW89_SEC_CAM_IN_ADDR_CAM);
  2547. u8 sec_ent_keyid[RTW89_SEC_CAM_IN_ADDR_CAM];
  2548. u8 sec_ent[RTW89_SEC_CAM_IN_ADDR_CAM];
  2549. struct rtw89_sec_cam_entry *sec_entries[RTW89_SEC_CAM_IN_ADDR_CAM];
  2550. };
  2551. struct rtw89_bssid_cam_entry {
  2552. u8 bssid[ETH_ALEN];
  2553. u8 phy_idx;
  2554. u8 bssid_cam_idx;
  2555. u8 offset;
  2556. u8 len;
  2557. u8 valid : 1;
  2558. u8 num;
  2559. };
  2560. struct rtw89_sec_cam_entry {
  2561. u8 sec_cam_idx;
  2562. u8 offset;
  2563. u8 len;
  2564. u8 type : 4;
  2565. u8 ext_key : 1;
  2566. u8 spp_mode : 1;
  2567. /* 256 bits */
  2568. u8 key[32];
  2569. };
  2570. struct rtw89_sta {
  2571. u8 mac_id;
  2572. bool disassoc;
  2573. bool er_cap;
  2574. struct rtw89_dev *rtwdev;
  2575. struct rtw89_vif *rtwvif;
  2576. struct rtw89_ra_info ra;
  2577. struct rtw89_ra_report ra_report;
  2578. int max_agg_wait;
  2579. u8 prev_rssi;
  2580. struct ewma_rssi avg_rssi;
  2581. struct ewma_rssi rssi[RF_PATH_MAX];
  2582. struct ewma_snr avg_snr;
  2583. struct ewma_evm evm_min[RF_PATH_MAX];
  2584. struct ewma_evm evm_max[RF_PATH_MAX];
  2585. struct rtw89_ampdu_params ampdu_params[IEEE80211_NUM_TIDS];
  2586. struct ieee80211_rx_status rx_status;
  2587. u16 rx_hw_rate;
  2588. __le32 htc_template;
  2589. struct rtw89_addr_cam_entry addr_cam; /* AP mode or TDLS peer only */
  2590. struct rtw89_bssid_cam_entry bssid_cam; /* TDLS peer only */
  2591. struct list_head ba_cam_list;
  2592. struct sk_buff_head roc_queue;
  2593. bool use_cfg_mask;
  2594. struct cfg80211_bitrate_mask mask;
  2595. bool cctl_tx_time;
  2596. u32 ampdu_max_time:4;
  2597. bool cctl_tx_retry_limit;
  2598. u32 data_tx_cnt_lmt:6;
  2599. };
  2600. struct rtw89_efuse {
  2601. bool valid;
  2602. bool power_k_valid;
  2603. u8 xtal_cap;
  2604. u8 addr[ETH_ALEN];
  2605. u8 rfe_type;
  2606. char country_code[2];
  2607. };
  2608. struct rtw89_phy_rate_pattern {
  2609. u64 ra_mask;
  2610. u16 rate;
  2611. u8 ra_mode;
  2612. bool enable;
  2613. };
  2614. struct rtw89_tx_wait_info {
  2615. struct rcu_head rcu_head;
  2616. struct completion completion;
  2617. bool tx_done;
  2618. };
  2619. struct rtw89_tx_skb_data {
  2620. struct rtw89_tx_wait_info __rcu *wait;
  2621. u8 hci_priv[];
  2622. };
  2623. #define RTW89_ROC_IDLE_TIMEOUT 500
  2624. #define RTW89_ROC_TX_TIMEOUT 30
  2625. enum rtw89_roc_state {
  2626. RTW89_ROC_IDLE,
  2627. RTW89_ROC_NORMAL,
  2628. RTW89_ROC_MGMT,
  2629. };
  2630. struct rtw89_roc {
  2631. struct ieee80211_channel chan;
  2632. struct delayed_work roc_work;
  2633. enum ieee80211_roc_type type;
  2634. enum rtw89_roc_state state;
  2635. int duration;
  2636. };
  2637. #define RTW89_P2P_MAX_NOA_NUM 2
  2638. struct rtw89_p2p_ie_head {
  2639. u8 eid;
  2640. u8 ie_len;
  2641. u8 oui[3];
  2642. u8 oui_type;
  2643. } __packed;
  2644. struct rtw89_noa_attr_head {
  2645. u8 attr_type;
  2646. __le16 attr_len;
  2647. u8 index;
  2648. u8 oppps_ctwindow;
  2649. } __packed;
  2650. struct rtw89_p2p_noa_ie {
  2651. struct rtw89_p2p_ie_head p2p_head;
  2652. struct rtw89_noa_attr_head noa_head;
  2653. struct ieee80211_p2p_noa_desc noa_desc[RTW89_P2P_MAX_NOA_NUM];
  2654. } __packed;
  2655. struct rtw89_p2p_noa_setter {
  2656. struct rtw89_p2p_noa_ie ie;
  2657. u8 noa_count;
  2658. u8 noa_index;
  2659. };
  2660. struct rtw89_vif {
  2661. struct list_head list;
  2662. struct rtw89_dev *rtwdev;
  2663. struct rtw89_roc roc;
  2664. bool chanctx_assigned; /* only valid when running with chanctx_ops */
  2665. enum rtw89_sub_entity_idx sub_entity_idx;
  2666. enum rtw89_reg_6ghz_power reg_6ghz_power;
  2667. u8 mac_id;
  2668. u8 port;
  2669. u8 mac_addr[ETH_ALEN];
  2670. u8 bssid[ETH_ALEN];
  2671. u8 phy_idx;
  2672. u8 mac_idx;
  2673. u8 net_type;
  2674. u8 wifi_role;
  2675. u8 self_role;
  2676. u8 wmm;
  2677. u8 bcn_hit_cond;
  2678. u8 hit_rule;
  2679. u8 last_noa_nr;
  2680. bool offchan;
  2681. bool trigger;
  2682. bool lsig_txop;
  2683. u8 tgt_ind;
  2684. u8 frm_tgt_ind;
  2685. bool wowlan_pattern;
  2686. bool wowlan_uc;
  2687. bool wowlan_magic;
  2688. bool is_hesta;
  2689. bool last_a_ctrl;
  2690. bool dyn_tb_bedge_en;
  2691. bool pre_pwr_diff_en;
  2692. bool pwr_diff_en;
  2693. u8 def_tri_idx;
  2694. u32 tdls_peer;
  2695. struct work_struct update_beacon_work;
  2696. struct rtw89_addr_cam_entry addr_cam;
  2697. struct rtw89_bssid_cam_entry bssid_cam;
  2698. struct ieee80211_tx_queue_params tx_params[IEEE80211_NUM_ACS];
  2699. struct rtw89_traffic_stats stats;
  2700. struct rtw89_phy_rate_pattern rate_pattern;
  2701. struct cfg80211_scan_request *scan_req;
  2702. struct ieee80211_scan_ies *scan_ies;
  2703. struct list_head general_pkt_list;
  2704. struct rtw89_p2p_noa_setter p2p_noa;
  2705. };
  2706. enum rtw89_lv1_rcvy_step {
  2707. RTW89_LV1_RCVY_STEP_1,
  2708. RTW89_LV1_RCVY_STEP_2,
  2709. };
  2710. struct rtw89_hci_ops {
  2711. int (*tx_write)(struct rtw89_dev *rtwdev, struct rtw89_core_tx_request *tx_req);
  2712. void (*tx_kick_off)(struct rtw89_dev *rtwdev, u8 txch);
  2713. void (*flush_queues)(struct rtw89_dev *rtwdev, u32 queues, bool drop);
  2714. void (*reset)(struct rtw89_dev *rtwdev);
  2715. int (*start)(struct rtw89_dev *rtwdev);
  2716. void (*stop)(struct rtw89_dev *rtwdev);
  2717. void (*pause)(struct rtw89_dev *rtwdev, bool pause);
  2718. void (*switch_mode)(struct rtw89_dev *rtwdev, bool low_power);
  2719. void (*recalc_int_mit)(struct rtw89_dev *rtwdev);
  2720. u8 (*read8)(struct rtw89_dev *rtwdev, u32 addr);
  2721. u16 (*read16)(struct rtw89_dev *rtwdev, u32 addr);
  2722. u32 (*read32)(struct rtw89_dev *rtwdev, u32 addr);
  2723. void (*write8)(struct rtw89_dev *rtwdev, u32 addr, u8 data);
  2724. void (*write16)(struct rtw89_dev *rtwdev, u32 addr, u16 data);
  2725. void (*write32)(struct rtw89_dev *rtwdev, u32 addr, u32 data);
  2726. int (*mac_pre_init)(struct rtw89_dev *rtwdev);
  2727. int (*mac_post_init)(struct rtw89_dev *rtwdev);
  2728. int (*deinit)(struct rtw89_dev *rtwdev);
  2729. u32 (*check_and_reclaim_tx_resource)(struct rtw89_dev *rtwdev, u8 txch);
  2730. int (*mac_lv1_rcvy)(struct rtw89_dev *rtwdev, enum rtw89_lv1_rcvy_step step);
  2731. void (*dump_err_status)(struct rtw89_dev *rtwdev);
  2732. int (*napi_poll)(struct napi_struct *napi, int budget);
  2733. /* Deal with locks inside recovery_start and recovery_complete callbacks
  2734. * by hci instance, and handle things which need to consider under SER.
  2735. * e.g. turn on/off interrupts except for the one for halt notification.
  2736. */
  2737. void (*recovery_start)(struct rtw89_dev *rtwdev);
  2738. void (*recovery_complete)(struct rtw89_dev *rtwdev);
  2739. void (*ctrl_txdma_ch)(struct rtw89_dev *rtwdev, bool enable);
  2740. void (*ctrl_txdma_fw_ch)(struct rtw89_dev *rtwdev, bool enable);
  2741. void (*ctrl_trxhci)(struct rtw89_dev *rtwdev, bool enable);
  2742. int (*poll_txdma_ch)(struct rtw89_dev *rtwdev);
  2743. void (*clr_idx_all)(struct rtw89_dev *rtwdev);
  2744. void (*clear)(struct rtw89_dev *rtwdev, struct pci_dev *pdev);
  2745. void (*disable_intr)(struct rtw89_dev *rtwdev);
  2746. void (*enable_intr)(struct rtw89_dev *rtwdev);
  2747. int (*rst_bdram)(struct rtw89_dev *rtwdev);
  2748. };
  2749. struct rtw89_hci_info {
  2750. const struct rtw89_hci_ops *ops;
  2751. enum rtw89_hci_type type;
  2752. u32 rpwm_addr;
  2753. u32 cpwm_addr;
  2754. bool paused;
  2755. };
  2756. struct rtw89_chip_ops {
  2757. int (*enable_bb_rf)(struct rtw89_dev *rtwdev);
  2758. int (*disable_bb_rf)(struct rtw89_dev *rtwdev);
  2759. void (*bb_preinit)(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy_idx);
  2760. void (*bb_reset)(struct rtw89_dev *rtwdev,
  2761. enum rtw89_phy_idx phy_idx);
  2762. void (*bb_sethw)(struct rtw89_dev *rtwdev);
  2763. u32 (*read_rf)(struct rtw89_dev *rtwdev, enum rtw89_rf_path rf_path,
  2764. u32 addr, u32 mask);
  2765. bool (*write_rf)(struct rtw89_dev *rtwdev, enum rtw89_rf_path rf_path,
  2766. u32 addr, u32 mask, u32 data);
  2767. void (*set_channel)(struct rtw89_dev *rtwdev,
  2768. const struct rtw89_chan *chan,
  2769. enum rtw89_mac_idx mac_idx,
  2770. enum rtw89_phy_idx phy_idx);
  2771. void (*set_channel_help)(struct rtw89_dev *rtwdev, bool enter,
  2772. struct rtw89_channel_help_params *p,
  2773. const struct rtw89_chan *chan,
  2774. enum rtw89_mac_idx mac_idx,
  2775. enum rtw89_phy_idx phy_idx);
  2776. int (*read_efuse)(struct rtw89_dev *rtwdev, u8 *log_map);
  2777. int (*read_phycap)(struct rtw89_dev *rtwdev, u8 *phycap_map);
  2778. void (*fem_setup)(struct rtw89_dev *rtwdev);
  2779. void (*rfe_gpio)(struct rtw89_dev *rtwdev);
  2780. void (*rfk_init)(struct rtw89_dev *rtwdev);
  2781. void (*rfk_channel)(struct rtw89_dev *rtwdev);
  2782. void (*rfk_band_changed)(struct rtw89_dev *rtwdev,
  2783. enum rtw89_phy_idx phy_idx);
  2784. void (*rfk_scan)(struct rtw89_dev *rtwdev, bool start);
  2785. void (*rfk_track)(struct rtw89_dev *rtwdev);
  2786. void (*power_trim)(struct rtw89_dev *rtwdev);
  2787. void (*set_txpwr)(struct rtw89_dev *rtwdev,
  2788. const struct rtw89_chan *chan,
  2789. enum rtw89_phy_idx phy_idx);
  2790. void (*set_txpwr_ctrl)(struct rtw89_dev *rtwdev,
  2791. enum rtw89_phy_idx phy_idx);
  2792. int (*init_txpwr_unit)(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy_idx);
  2793. u8 (*get_thermal)(struct rtw89_dev *rtwdev, enum rtw89_rf_path rf_path);
  2794. void (*ctrl_btg)(struct rtw89_dev *rtwdev, bool btg);
  2795. void (*query_ppdu)(struct rtw89_dev *rtwdev,
  2796. struct rtw89_rx_phy_ppdu *phy_ppdu,
  2797. struct ieee80211_rx_status *status);
  2798. void (*bb_ctrl_btc_preagc)(struct rtw89_dev *rtwdev, bool bt_en);
  2799. void (*cfg_txrx_path)(struct rtw89_dev *rtwdev);
  2800. void (*set_txpwr_ul_tb_offset)(struct rtw89_dev *rtwdev,
  2801. s8 pw_ofst, enum rtw89_mac_idx mac_idx);
  2802. int (*pwr_on_func)(struct rtw89_dev *rtwdev);
  2803. int (*pwr_off_func)(struct rtw89_dev *rtwdev);
  2804. void (*query_rxdesc)(struct rtw89_dev *rtwdev,
  2805. struct rtw89_rx_desc_info *desc_info,
  2806. u8 *data, u32 data_offset);
  2807. void (*fill_txdesc)(struct rtw89_dev *rtwdev,
  2808. struct rtw89_tx_desc_info *desc_info,
  2809. void *txdesc);
  2810. void (*fill_txdesc_fwcmd)(struct rtw89_dev *rtwdev,
  2811. struct rtw89_tx_desc_info *desc_info,
  2812. void *txdesc);
  2813. int (*cfg_ctrl_path)(struct rtw89_dev *rtwdev, bool wl);
  2814. int (*mac_cfg_gnt)(struct rtw89_dev *rtwdev,
  2815. const struct rtw89_mac_ax_coex_gnt *gnt_cfg);
  2816. int (*stop_sch_tx)(struct rtw89_dev *rtwdev, u8 mac_idx,
  2817. u32 *tx_en, enum rtw89_sch_tx_sel sel);
  2818. int (*resume_sch_tx)(struct rtw89_dev *rtwdev, u8 mac_idx, u32 tx_en);
  2819. int (*h2c_dctl_sec_cam)(struct rtw89_dev *rtwdev,
  2820. struct rtw89_vif *rtwvif,
  2821. struct rtw89_sta *rtwsta);
  2822. void (*btc_set_rfe)(struct rtw89_dev *rtwdev);
  2823. void (*btc_init_cfg)(struct rtw89_dev *rtwdev);
  2824. void (*btc_set_wl_pri)(struct rtw89_dev *rtwdev, u8 map, bool state);
  2825. void (*btc_set_wl_txpwr_ctrl)(struct rtw89_dev *rtwdev, u32 txpwr_val);
  2826. s8 (*btc_get_bt_rssi)(struct rtw89_dev *rtwdev, s8 val);
  2827. void (*btc_update_bt_cnt)(struct rtw89_dev *rtwdev);
  2828. void (*btc_wl_s1_standby)(struct rtw89_dev *rtwdev, bool state);
  2829. void (*btc_set_policy)(struct rtw89_dev *rtwdev, u16 policy_type);
  2830. void (*btc_set_wl_rx_gain)(struct rtw89_dev *rtwdev, u32 level);
  2831. };
  2832. enum rtw89_dma_ch {
  2833. RTW89_DMA_ACH0 = 0,
  2834. RTW89_DMA_ACH1 = 1,
  2835. RTW89_DMA_ACH2 = 2,
  2836. RTW89_DMA_ACH3 = 3,
  2837. RTW89_DMA_ACH4 = 4,
  2838. RTW89_DMA_ACH5 = 5,
  2839. RTW89_DMA_ACH6 = 6,
  2840. RTW89_DMA_ACH7 = 7,
  2841. RTW89_DMA_B0MG = 8,
  2842. RTW89_DMA_B0HI = 9,
  2843. RTW89_DMA_B1MG = 10,
  2844. RTW89_DMA_B1HI = 11,
  2845. RTW89_DMA_H2C = 12,
  2846. RTW89_DMA_CH_NUM = 13
  2847. };
  2848. enum rtw89_qta_mode {
  2849. RTW89_QTA_SCC,
  2850. RTW89_QTA_DLFW,
  2851. RTW89_QTA_WOW,
  2852. /* keep last */
  2853. RTW89_QTA_INVALID,
  2854. };
  2855. struct rtw89_hfc_ch_cfg {
  2856. u16 min;
  2857. u16 max;
  2858. #define grp_0 0
  2859. #define grp_1 1
  2860. #define grp_num 2
  2861. u8 grp;
  2862. };
  2863. struct rtw89_hfc_ch_info {
  2864. u16 aval;
  2865. u16 used;
  2866. };
  2867. struct rtw89_hfc_pub_cfg {
  2868. u16 grp0;
  2869. u16 grp1;
  2870. u16 pub_max;
  2871. u16 wp_thrd;
  2872. };
  2873. struct rtw89_hfc_pub_info {
  2874. u16 g0_used;
  2875. u16 g1_used;
  2876. u16 g0_aval;
  2877. u16 g1_aval;
  2878. u16 pub_aval;
  2879. u16 wp_aval;
  2880. };
  2881. struct rtw89_hfc_prec_cfg {
  2882. u16 ch011_prec;
  2883. u16 h2c_prec;
  2884. u16 wp_ch07_prec;
  2885. u16 wp_ch811_prec;
  2886. u8 ch011_full_cond;
  2887. u8 h2c_full_cond;
  2888. u8 wp_ch07_full_cond;
  2889. u8 wp_ch811_full_cond;
  2890. };
  2891. struct rtw89_hfc_param {
  2892. bool en;
  2893. bool h2c_en;
  2894. u8 mode;
  2895. const struct rtw89_hfc_ch_cfg *ch_cfg;
  2896. struct rtw89_hfc_ch_info ch_info[RTW89_DMA_CH_NUM];
  2897. struct rtw89_hfc_pub_cfg pub_cfg;
  2898. struct rtw89_hfc_pub_info pub_info;
  2899. struct rtw89_hfc_prec_cfg prec_cfg;
  2900. };
  2901. struct rtw89_hfc_param_ini {
  2902. const struct rtw89_hfc_ch_cfg *ch_cfg;
  2903. const struct rtw89_hfc_pub_cfg *pub_cfg;
  2904. const struct rtw89_hfc_prec_cfg *prec_cfg;
  2905. u8 mode;
  2906. };
  2907. struct rtw89_dle_size {
  2908. u16 pge_size;
  2909. u16 lnk_pge_num;
  2910. u16 unlnk_pge_num;
  2911. };
  2912. struct rtw89_wde_quota {
  2913. u16 hif;
  2914. u16 wcpu;
  2915. u16 pkt_in;
  2916. u16 cpu_io;
  2917. };
  2918. struct rtw89_ple_quota {
  2919. u16 cma0_tx;
  2920. u16 cma1_tx;
  2921. u16 c2h;
  2922. u16 h2c;
  2923. u16 wcpu;
  2924. u16 mpdu_proc;
  2925. u16 cma0_dma;
  2926. u16 cma1_dma;
  2927. u16 bb_rpt;
  2928. u16 wd_rel;
  2929. u16 cpu_io;
  2930. u16 tx_rpt;
  2931. };
  2932. struct rtw89_dle_mem {
  2933. enum rtw89_qta_mode mode;
  2934. const struct rtw89_dle_size *wde_size;
  2935. const struct rtw89_dle_size *ple_size;
  2936. const struct rtw89_wde_quota *wde_min_qt;
  2937. const struct rtw89_wde_quota *wde_max_qt;
  2938. const struct rtw89_ple_quota *ple_min_qt;
  2939. const struct rtw89_ple_quota *ple_max_qt;
  2940. };
  2941. struct rtw89_reg_def {
  2942. u32 addr;
  2943. u32 mask;
  2944. };
  2945. struct rtw89_reg2_def {
  2946. u32 addr;
  2947. u32 data;
  2948. };
  2949. struct rtw89_reg3_def {
  2950. u32 addr;
  2951. u32 mask;
  2952. u32 data;
  2953. };
  2954. struct rtw89_reg5_def {
  2955. u8 flag; /* recognized by parsers */
  2956. u8 path;
  2957. u32 addr;
  2958. u32 mask;
  2959. u32 data;
  2960. };
  2961. struct rtw89_phy_table {
  2962. const struct rtw89_reg2_def *regs;
  2963. u32 n_regs;
  2964. enum rtw89_rf_path rf_path;
  2965. void (*config)(struct rtw89_dev *rtwdev, const struct rtw89_reg2_def *reg,
  2966. enum rtw89_rf_path rf_path, void *data);
  2967. };
  2968. struct rtw89_txpwr_table {
  2969. const void *data;
  2970. u32 size;
  2971. void (*load)(struct rtw89_dev *rtwdev,
  2972. const struct rtw89_txpwr_table *tbl);
  2973. };
  2974. struct rtw89_txpwr_rule_2ghz {
  2975. const s8 (*lmt)[RTW89_2G_BW_NUM][RTW89_NTX_NUM]
  2976. [RTW89_RS_LMT_NUM][RTW89_BF_NUM]
  2977. [RTW89_REGD_NUM][RTW89_2G_CH_NUM];
  2978. const s8 (*lmt_ru)[RTW89_RU_NUM][RTW89_NTX_NUM]
  2979. [RTW89_REGD_NUM][RTW89_2G_CH_NUM];
  2980. };
  2981. struct rtw89_txpwr_rule_5ghz {
  2982. const s8 (*lmt)[RTW89_5G_BW_NUM][RTW89_NTX_NUM]
  2983. [RTW89_RS_LMT_NUM][RTW89_BF_NUM]
  2984. [RTW89_REGD_NUM][RTW89_5G_CH_NUM];
  2985. const s8 (*lmt_ru)[RTW89_RU_NUM][RTW89_NTX_NUM]
  2986. [RTW89_REGD_NUM][RTW89_5G_CH_NUM];
  2987. };
  2988. struct rtw89_txpwr_rule_6ghz {
  2989. const s8 (*lmt)[RTW89_6G_BW_NUM][RTW89_NTX_NUM]
  2990. [RTW89_RS_LMT_NUM][RTW89_BF_NUM]
  2991. [RTW89_REGD_NUM][NUM_OF_RTW89_REG_6GHZ_POWER]
  2992. [RTW89_6G_CH_NUM];
  2993. const s8 (*lmt_ru)[RTW89_RU_NUM][RTW89_NTX_NUM]
  2994. [RTW89_REGD_NUM][NUM_OF_RTW89_REG_6GHZ_POWER]
  2995. [RTW89_6G_CH_NUM];
  2996. };
  2997. struct rtw89_tx_shape {
  2998. const u8 (*lmt)[RTW89_BAND_NUM][RTW89_RS_TX_SHAPE_NUM][RTW89_REGD_NUM];
  2999. const u8 (*lmt_ru)[RTW89_BAND_NUM][RTW89_REGD_NUM];
  3000. };
  3001. struct rtw89_rfe_parms {
  3002. const struct rtw89_txpwr_table *byr_tbl;
  3003. struct rtw89_txpwr_rule_2ghz rule_2ghz;
  3004. struct rtw89_txpwr_rule_5ghz rule_5ghz;
  3005. struct rtw89_txpwr_rule_6ghz rule_6ghz;
  3006. struct rtw89_tx_shape tx_shape;
  3007. };
  3008. struct rtw89_rfe_parms_conf {
  3009. const struct rtw89_rfe_parms *rfe_parms;
  3010. u8 rfe_type;
  3011. };
  3012. #define RTW89_TXPWR_CONF_DFLT_RFE_TYPE 0x0
  3013. struct rtw89_txpwr_conf {
  3014. u8 rfe_type;
  3015. u8 ent_sz;
  3016. u32 num_ents;
  3017. const void *data;
  3018. };
  3019. #define rtw89_txpwr_conf_valid(conf) (!!(conf)->data)
  3020. #define rtw89_for_each_in_txpwr_conf(entry, cursor, conf) \
  3021. for (typecheck(const void *, cursor), (cursor) = (conf)->data, \
  3022. memcpy(&(entry), cursor, \
  3023. min_t(u8, sizeof(entry), (conf)->ent_sz)); \
  3024. (cursor) < (conf)->data + (conf)->num_ents * (conf)->ent_sz; \
  3025. (cursor) += (conf)->ent_sz, \
  3026. memcpy(&(entry), cursor, \
  3027. min_t(u8, sizeof(entry), (conf)->ent_sz)))
  3028. struct rtw89_txpwr_byrate_data {
  3029. struct rtw89_txpwr_conf conf;
  3030. struct rtw89_txpwr_table tbl;
  3031. };
  3032. struct rtw89_txpwr_lmt_2ghz_data {
  3033. struct rtw89_txpwr_conf conf;
  3034. s8 v[RTW89_2G_BW_NUM][RTW89_NTX_NUM]
  3035. [RTW89_RS_LMT_NUM][RTW89_BF_NUM]
  3036. [RTW89_REGD_NUM][RTW89_2G_CH_NUM];
  3037. };
  3038. struct rtw89_txpwr_lmt_5ghz_data {
  3039. struct rtw89_txpwr_conf conf;
  3040. s8 v[RTW89_5G_BW_NUM][RTW89_NTX_NUM]
  3041. [RTW89_RS_LMT_NUM][RTW89_BF_NUM]
  3042. [RTW89_REGD_NUM][RTW89_5G_CH_NUM];
  3043. };
  3044. struct rtw89_txpwr_lmt_6ghz_data {
  3045. struct rtw89_txpwr_conf conf;
  3046. s8 v[RTW89_6G_BW_NUM][RTW89_NTX_NUM]
  3047. [RTW89_RS_LMT_NUM][RTW89_BF_NUM]
  3048. [RTW89_REGD_NUM][NUM_OF_RTW89_REG_6GHZ_POWER]
  3049. [RTW89_6G_CH_NUM];
  3050. };
  3051. struct rtw89_txpwr_lmt_ru_2ghz_data {
  3052. struct rtw89_txpwr_conf conf;
  3053. s8 v[RTW89_RU_NUM][RTW89_NTX_NUM]
  3054. [RTW89_REGD_NUM][RTW89_2G_CH_NUM];
  3055. };
  3056. struct rtw89_txpwr_lmt_ru_5ghz_data {
  3057. struct rtw89_txpwr_conf conf;
  3058. s8 v[RTW89_RU_NUM][RTW89_NTX_NUM]
  3059. [RTW89_REGD_NUM][RTW89_5G_CH_NUM];
  3060. };
  3061. struct rtw89_txpwr_lmt_ru_6ghz_data {
  3062. struct rtw89_txpwr_conf conf;
  3063. s8 v[RTW89_RU_NUM][RTW89_NTX_NUM]
  3064. [RTW89_REGD_NUM][NUM_OF_RTW89_REG_6GHZ_POWER]
  3065. [RTW89_6G_CH_NUM];
  3066. };
  3067. struct rtw89_tx_shape_lmt_data {
  3068. struct rtw89_txpwr_conf conf;
  3069. u8 v[RTW89_BAND_NUM][RTW89_RS_TX_SHAPE_NUM][RTW89_REGD_NUM];
  3070. };
  3071. struct rtw89_tx_shape_lmt_ru_data {
  3072. struct rtw89_txpwr_conf conf;
  3073. u8 v[RTW89_BAND_NUM][RTW89_REGD_NUM];
  3074. };
  3075. struct rtw89_rfe_data {
  3076. struct rtw89_txpwr_byrate_data byrate;
  3077. struct rtw89_txpwr_lmt_2ghz_data lmt_2ghz;
  3078. struct rtw89_txpwr_lmt_5ghz_data lmt_5ghz;
  3079. struct rtw89_txpwr_lmt_6ghz_data lmt_6ghz;
  3080. struct rtw89_txpwr_lmt_ru_2ghz_data lmt_ru_2ghz;
  3081. struct rtw89_txpwr_lmt_ru_5ghz_data lmt_ru_5ghz;
  3082. struct rtw89_txpwr_lmt_ru_6ghz_data lmt_ru_6ghz;
  3083. struct rtw89_tx_shape_lmt_data tx_shape_lmt;
  3084. struct rtw89_tx_shape_lmt_ru_data tx_shape_lmt_ru;
  3085. struct rtw89_rfe_parms rfe_parms;
  3086. };
  3087. struct rtw89_page_regs {
  3088. u32 hci_fc_ctrl;
  3089. u32 ch_page_ctrl;
  3090. u32 ach_page_ctrl;
  3091. u32 ach_page_info;
  3092. u32 pub_page_info3;
  3093. u32 pub_page_ctrl1;
  3094. u32 pub_page_ctrl2;
  3095. u32 pub_page_info1;
  3096. u32 pub_page_info2;
  3097. u32 wp_page_ctrl1;
  3098. u32 wp_page_ctrl2;
  3099. u32 wp_page_info1;
  3100. };
  3101. struct rtw89_imr_info {
  3102. u32 wdrls_imr_set;
  3103. u32 wsec_imr_reg;
  3104. u32 wsec_imr_set;
  3105. u32 mpdu_tx_imr_set;
  3106. u32 mpdu_rx_imr_set;
  3107. u32 sta_sch_imr_set;
  3108. u32 txpktctl_imr_b0_reg;
  3109. u32 txpktctl_imr_b0_clr;
  3110. u32 txpktctl_imr_b0_set;
  3111. u32 txpktctl_imr_b1_reg;
  3112. u32 txpktctl_imr_b1_clr;
  3113. u32 txpktctl_imr_b1_set;
  3114. u32 wde_imr_clr;
  3115. u32 wde_imr_set;
  3116. u32 ple_imr_clr;
  3117. u32 ple_imr_set;
  3118. u32 host_disp_imr_clr;
  3119. u32 host_disp_imr_set;
  3120. u32 cpu_disp_imr_clr;
  3121. u32 cpu_disp_imr_set;
  3122. u32 other_disp_imr_clr;
  3123. u32 other_disp_imr_set;
  3124. u32 bbrpt_com_err_imr_reg;
  3125. u32 bbrpt_chinfo_err_imr_reg;
  3126. u32 bbrpt_err_imr_set;
  3127. u32 bbrpt_dfs_err_imr_reg;
  3128. u32 ptcl_imr_clr;
  3129. u32 ptcl_imr_set;
  3130. u32 cdma_imr_0_reg;
  3131. u32 cdma_imr_0_clr;
  3132. u32 cdma_imr_0_set;
  3133. u32 cdma_imr_1_reg;
  3134. u32 cdma_imr_1_clr;
  3135. u32 cdma_imr_1_set;
  3136. u32 phy_intf_imr_reg;
  3137. u32 phy_intf_imr_clr;
  3138. u32 phy_intf_imr_set;
  3139. u32 rmac_imr_reg;
  3140. u32 rmac_imr_clr;
  3141. u32 rmac_imr_set;
  3142. u32 tmac_imr_reg;
  3143. u32 tmac_imr_clr;
  3144. u32 tmac_imr_set;
  3145. };
  3146. struct rtw89_xtal_info {
  3147. u32 xcap_reg;
  3148. u32 sc_xo_mask;
  3149. u32 sc_xi_mask;
  3150. };
  3151. struct rtw89_rrsr_cfgs {
  3152. struct rtw89_reg3_def ref_rate;
  3153. struct rtw89_reg3_def rsc;
  3154. };
  3155. struct rtw89_dig_regs {
  3156. u32 seg0_pd_reg;
  3157. u32 pd_lower_bound_mask;
  3158. u32 pd_spatial_reuse_en;
  3159. u32 bmode_pd_reg;
  3160. u32 bmode_cca_rssi_limit_en;
  3161. u32 bmode_pd_lower_bound_reg;
  3162. u32 bmode_rssi_nocca_low_th_mask;
  3163. struct rtw89_reg_def p0_lna_init;
  3164. struct rtw89_reg_def p1_lna_init;
  3165. struct rtw89_reg_def p0_tia_init;
  3166. struct rtw89_reg_def p1_tia_init;
  3167. struct rtw89_reg_def p0_rxb_init;
  3168. struct rtw89_reg_def p1_rxb_init;
  3169. struct rtw89_reg_def p0_p20_pagcugc_en;
  3170. struct rtw89_reg_def p0_s20_pagcugc_en;
  3171. struct rtw89_reg_def p1_p20_pagcugc_en;
  3172. struct rtw89_reg_def p1_s20_pagcugc_en;
  3173. };
  3174. struct rtw89_phy_ul_tb_info {
  3175. bool dyn_tb_tri_en;
  3176. u8 def_if_bandedge;
  3177. };
  3178. struct rtw89_antdiv_stats {
  3179. struct ewma_rssi cck_rssi_avg;
  3180. struct ewma_rssi ofdm_rssi_avg;
  3181. struct ewma_rssi non_legacy_rssi_avg;
  3182. u16 pkt_cnt_cck;
  3183. u16 pkt_cnt_ofdm;
  3184. u16 pkt_cnt_non_legacy;
  3185. u32 evm;
  3186. };
  3187. struct rtw89_antdiv_info {
  3188. struct rtw89_antdiv_stats target_stats;
  3189. struct rtw89_antdiv_stats main_stats;
  3190. struct rtw89_antdiv_stats aux_stats;
  3191. u8 training_count;
  3192. u8 rssi_pre;
  3193. bool get_stats;
  3194. };
  3195. enum rtw89_chanctx_state {
  3196. RTW89_CHANCTX_STATE_MCC_START,
  3197. RTW89_CHANCTX_STATE_MCC_STOP,
  3198. };
  3199. enum rtw89_chanctx_callbacks {
  3200. RTW89_CHANCTX_CALLBACK_PLACEHOLDER,
  3201. RTW89_CHANCTX_CALLBACK_RFK,
  3202. NUM_OF_RTW89_CHANCTX_CALLBACKS,
  3203. };
  3204. struct rtw89_chanctx_listener {
  3205. void (*callbacks[NUM_OF_RTW89_CHANCTX_CALLBACKS])
  3206. (struct rtw89_dev *rtwdev, enum rtw89_chanctx_state state);
  3207. };
  3208. struct rtw89_chip_info {
  3209. enum rtw89_core_chip_id chip_id;
  3210. enum rtw89_chip_gen chip_gen;
  3211. const struct rtw89_chip_ops *ops;
  3212. const struct rtw89_mac_gen_def *mac_def;
  3213. const struct rtw89_phy_gen_def *phy_def;
  3214. const char *fw_basename;
  3215. u8 fw_format_max;
  3216. bool try_ce_fw;
  3217. u8 bbmcu_nr;
  3218. u32 needed_fw_elms;
  3219. u32 fifo_size;
  3220. bool small_fifo_size;
  3221. u32 dle_scc_rsvd_size;
  3222. u16 max_amsdu_limit;
  3223. bool dis_2g_40m_ul_ofdma;
  3224. u32 rsvd_ple_ofst;
  3225. const struct rtw89_hfc_param_ini *hfc_param_ini;
  3226. const struct rtw89_dle_mem *dle_mem;
  3227. u8 wde_qempty_acq_num;
  3228. u8 wde_qempty_mgq_sel;
  3229. u32 rf_base_addr[2];
  3230. u8 support_chanctx_num;
  3231. u8 support_bands;
  3232. bool support_bw160;
  3233. bool support_unii4;
  3234. bool ul_tb_waveform_ctrl;
  3235. bool ul_tb_pwr_diff;
  3236. bool hw_sec_hdr;
  3237. u8 rf_path_num;
  3238. u8 tx_nss;
  3239. u8 rx_nss;
  3240. u8 acam_num;
  3241. u8 bcam_num;
  3242. u8 scam_num;
  3243. u8 bacam_num;
  3244. u8 bacam_dynamic_num;
  3245. enum rtw89_bacam_ver bacam_ver;
  3246. u8 sec_ctrl_efuse_size;
  3247. u32 physical_efuse_size;
  3248. u32 logical_efuse_size;
  3249. u32 limit_efuse_size;
  3250. u32 dav_phy_efuse_size;
  3251. u32 dav_log_efuse_size;
  3252. u32 phycap_addr;
  3253. u32 phycap_size;
  3254. const struct rtw89_pwr_cfg * const *pwr_on_seq;
  3255. const struct rtw89_pwr_cfg * const *pwr_off_seq;
  3256. const struct rtw89_phy_table *bb_table;
  3257. const struct rtw89_phy_table *bb_gain_table;
  3258. const struct rtw89_phy_table *rf_table[RF_PATH_MAX];
  3259. const struct rtw89_phy_table *nctl_table;
  3260. const struct rtw89_rfk_tbl *nctl_post_table;
  3261. const struct rtw89_phy_dig_gain_table *dig_table;
  3262. const struct rtw89_dig_regs *dig_regs;
  3263. const struct rtw89_phy_tssi_dbw_table *tssi_dbw_table;
  3264. /* NULL if no rfe-specific, or a null-terminated array by rfe_parms */
  3265. const struct rtw89_rfe_parms_conf *rfe_parms_conf;
  3266. const struct rtw89_rfe_parms *dflt_parms;
  3267. const struct rtw89_chanctx_listener *chanctx_listener;
  3268. u8 txpwr_factor_rf;
  3269. u8 txpwr_factor_mac;
  3270. u32 para_ver;
  3271. u32 wlcx_desired;
  3272. u8 btcx_desired;
  3273. u8 scbd;
  3274. u8 mailbox;
  3275. u8 afh_guard_ch;
  3276. const u8 *wl_rssi_thres;
  3277. const u8 *bt_rssi_thres;
  3278. u8 rssi_tol;
  3279. u8 mon_reg_num;
  3280. const struct rtw89_btc_fbtc_mreg *mon_reg;
  3281. u8 rf_para_ulink_num;
  3282. const struct rtw89_btc_rf_trx_para *rf_para_ulink;
  3283. u8 rf_para_dlink_num;
  3284. const struct rtw89_btc_rf_trx_para *rf_para_dlink;
  3285. u8 ps_mode_supported;
  3286. u8 low_power_hci_modes;
  3287. u32 h2c_cctl_func_id;
  3288. u32 hci_func_en_addr;
  3289. u32 h2c_desc_size;
  3290. u32 txwd_body_size;
  3291. u32 txwd_info_size;
  3292. u32 h2c_ctrl_reg;
  3293. const u32 *h2c_regs;
  3294. struct rtw89_reg_def h2c_counter_reg;
  3295. u32 c2h_ctrl_reg;
  3296. const u32 *c2h_regs;
  3297. struct rtw89_reg_def c2h_counter_reg;
  3298. const struct rtw89_page_regs *page_regs;
  3299. bool cfo_src_fd;
  3300. bool cfo_hw_comp;
  3301. const struct rtw89_reg_def *dcfo_comp;
  3302. u8 dcfo_comp_sft;
  3303. const struct rtw89_imr_info *imr_info;
  3304. const struct rtw89_rrsr_cfgs *rrsr_cfgs;
  3305. u32 bss_clr_map_reg;
  3306. u32 dma_ch_mask;
  3307. u32 edcca_lvl_reg;
  3308. const struct wiphy_wowlan_support *wowlan_stub;
  3309. const struct rtw89_xtal_info *xtal_info;
  3310. };
  3311. union rtw89_bus_info {
  3312. const struct rtw89_pci_info *pci;
  3313. };
  3314. struct rtw89_driver_info {
  3315. const struct rtw89_chip_info *chip;
  3316. union rtw89_bus_info bus;
  3317. };
  3318. enum rtw89_hcifc_mode {
  3319. RTW89_HCIFC_POH = 0,
  3320. RTW89_HCIFC_STF = 1,
  3321. RTW89_HCIFC_SDIO = 2,
  3322. /* keep last */
  3323. RTW89_HCIFC_MODE_INVALID,
  3324. };
  3325. struct rtw89_dle_info {
  3326. enum rtw89_qta_mode qta_mode;
  3327. u16 ple_pg_size;
  3328. u16 c0_rx_qta;
  3329. u16 c1_rx_qta;
  3330. };
  3331. enum rtw89_host_rpr_mode {
  3332. RTW89_RPR_MODE_POH = 0,
  3333. RTW89_RPR_MODE_STF
  3334. };
  3335. #define RTW89_COMPLETION_BUF_SIZE 24
  3336. #define RTW89_WAIT_COND_IDLE UINT_MAX
  3337. struct rtw89_completion_data {
  3338. bool err;
  3339. u8 buf[RTW89_COMPLETION_BUF_SIZE];
  3340. };
  3341. struct rtw89_wait_info {
  3342. atomic_t cond;
  3343. struct completion completion;
  3344. struct rtw89_completion_data data;
  3345. };
  3346. #define RTW89_WAIT_FOR_COND_TIMEOUT msecs_to_jiffies(100)
  3347. static inline void rtw89_init_wait(struct rtw89_wait_info *wait)
  3348. {
  3349. init_completion(&wait->completion);
  3350. atomic_set(&wait->cond, RTW89_WAIT_COND_IDLE);
  3351. }
  3352. struct rtw89_mac_info {
  3353. struct rtw89_dle_info dle_info;
  3354. struct rtw89_hfc_param hfc_param;
  3355. enum rtw89_qta_mode qta_mode;
  3356. u8 rpwm_seq_num;
  3357. u8 cpwm_seq_num;
  3358. /* see RTW89_FW_OFLD_WAIT_COND series for wait condition */
  3359. struct rtw89_wait_info fw_ofld_wait;
  3360. };
  3361. enum rtw89_fwdl_check_type {
  3362. RTW89_FWDL_CHECK_FREERTOS_DONE,
  3363. RTW89_FWDL_CHECK_WCPU_FWDL_DONE,
  3364. RTW89_FWDL_CHECK_DCPU_FWDL_DONE,
  3365. RTW89_FWDL_CHECK_BB0_FWDL_DONE,
  3366. RTW89_FWDL_CHECK_BB1_FWDL_DONE,
  3367. };
  3368. enum rtw89_fw_type {
  3369. RTW89_FW_NORMAL = 1,
  3370. RTW89_FW_WOWLAN = 3,
  3371. RTW89_FW_NORMAL_CE = 5,
  3372. RTW89_FW_BBMCU0 = 64,
  3373. RTW89_FW_BBMCU1 = 65,
  3374. RTW89_FW_LOGFMT = 255,
  3375. };
  3376. enum rtw89_fw_feature {
  3377. RTW89_FW_FEATURE_OLD_HT_RA_FORMAT,
  3378. RTW89_FW_FEATURE_SCAN_OFFLOAD,
  3379. RTW89_FW_FEATURE_TX_WAKE,
  3380. RTW89_FW_FEATURE_CRASH_TRIGGER,
  3381. RTW89_FW_FEATURE_NO_PACKET_DROP,
  3382. RTW89_FW_FEATURE_NO_DEEP_PS,
  3383. RTW89_FW_FEATURE_NO_LPS_PG,
  3384. RTW89_FW_FEATURE_BEACON_FILTER,
  3385. };
  3386. struct rtw89_fw_suit {
  3387. enum rtw89_fw_type type;
  3388. const u8 *data;
  3389. u32 size;
  3390. u8 major_ver;
  3391. u8 minor_ver;
  3392. u8 sub_ver;
  3393. u8 sub_idex;
  3394. u16 build_year;
  3395. u16 build_mon;
  3396. u16 build_date;
  3397. u16 build_hour;
  3398. u16 build_min;
  3399. u8 cmd_ver;
  3400. u8 hdr_ver;
  3401. u32 commitid;
  3402. };
  3403. #define RTW89_FW_VER_CODE(major, minor, sub, idx) \
  3404. (((major) << 24) | ((minor) << 16) | ((sub) << 8) | (idx))
  3405. #define RTW89_FW_SUIT_VER_CODE(s) \
  3406. RTW89_FW_VER_CODE((s)->major_ver, (s)->minor_ver, (s)->sub_ver, (s)->sub_idex)
  3407. #define RTW89_MFW_HDR_VER_CODE(mfw_hdr) \
  3408. RTW89_FW_VER_CODE((mfw_hdr)->ver.major, \
  3409. (mfw_hdr)->ver.minor, \
  3410. (mfw_hdr)->ver.sub, \
  3411. (mfw_hdr)->ver.idx)
  3412. #define RTW89_FW_HDR_VER_CODE(fw_hdr) \
  3413. RTW89_FW_VER_CODE(le32_get_bits((fw_hdr)->w1, FW_HDR_W1_MAJOR_VERSION), \
  3414. le32_get_bits((fw_hdr)->w1, FW_HDR_W1_MINOR_VERSION), \
  3415. le32_get_bits((fw_hdr)->w1, FW_HDR_W1_SUBVERSION), \
  3416. le32_get_bits((fw_hdr)->w1, FW_HDR_W1_SUBINDEX))
  3417. struct rtw89_fw_req_info {
  3418. const struct firmware *firmware;
  3419. struct completion completion;
  3420. };
  3421. struct rtw89_fw_log {
  3422. struct rtw89_fw_suit suit;
  3423. bool enable;
  3424. u32 last_fmt_id;
  3425. u32 fmt_count;
  3426. const __le32 *fmt_ids;
  3427. const char *(*fmts)[];
  3428. };
  3429. struct rtw89_fw_elm_info {
  3430. struct rtw89_phy_table *bb_tbl;
  3431. struct rtw89_phy_table *bb_gain;
  3432. struct rtw89_phy_table *rf_radio[RF_PATH_MAX];
  3433. struct rtw89_phy_table *rf_nctl;
  3434. };
  3435. struct rtw89_fw_info {
  3436. struct rtw89_fw_req_info req;
  3437. int fw_format;
  3438. u8 h2c_seq;
  3439. u8 rec_seq;
  3440. u8 h2c_counter;
  3441. u8 c2h_counter;
  3442. struct rtw89_fw_suit normal;
  3443. struct rtw89_fw_suit wowlan;
  3444. struct rtw89_fw_suit bbmcu0;
  3445. struct rtw89_fw_suit bbmcu1;
  3446. struct rtw89_fw_log log;
  3447. u32 feature_map;
  3448. struct rtw89_fw_elm_info elm_info;
  3449. };
  3450. #define RTW89_CHK_FW_FEATURE(_feat, _fw) \
  3451. (!!((_fw)->feature_map & BIT(RTW89_FW_FEATURE_ ## _feat)))
  3452. #define RTW89_SET_FW_FEATURE(_fw_feature, _fw) \
  3453. ((_fw)->feature_map |= BIT(_fw_feature))
  3454. struct rtw89_cam_info {
  3455. DECLARE_BITMAP(addr_cam_map, RTW89_MAX_ADDR_CAM_NUM);
  3456. DECLARE_BITMAP(bssid_cam_map, RTW89_MAX_BSSID_CAM_NUM);
  3457. DECLARE_BITMAP(sec_cam_map, RTW89_MAX_SEC_CAM_NUM);
  3458. DECLARE_BITMAP(ba_cam_map, RTW89_MAX_BA_CAM_NUM);
  3459. struct rtw89_ba_cam_entry ba_cam_entry[RTW89_MAX_BA_CAM_NUM];
  3460. };
  3461. enum rtw89_sar_sources {
  3462. RTW89_SAR_SOURCE_NONE,
  3463. RTW89_SAR_SOURCE_COMMON,
  3464. RTW89_SAR_SOURCE_NR,
  3465. };
  3466. enum rtw89_sar_subband {
  3467. RTW89_SAR_2GHZ_SUBBAND,
  3468. RTW89_SAR_5GHZ_SUBBAND_1_2, /* U-NII-1 and U-NII-2 */
  3469. RTW89_SAR_5GHZ_SUBBAND_2_E, /* U-NII-2-Extended */
  3470. RTW89_SAR_5GHZ_SUBBAND_3, /* U-NII-3 */
  3471. RTW89_SAR_6GHZ_SUBBAND_5_L, /* U-NII-5 lower part */
  3472. RTW89_SAR_6GHZ_SUBBAND_5_H, /* U-NII-5 higher part */
  3473. RTW89_SAR_6GHZ_SUBBAND_6, /* U-NII-6 */
  3474. RTW89_SAR_6GHZ_SUBBAND_7_L, /* U-NII-7 lower part */
  3475. RTW89_SAR_6GHZ_SUBBAND_7_H, /* U-NII-7 higher part */
  3476. RTW89_SAR_6GHZ_SUBBAND_8, /* U-NII-8 */
  3477. RTW89_SAR_SUBBAND_NR,
  3478. };
  3479. struct rtw89_sar_cfg_common {
  3480. bool set[RTW89_SAR_SUBBAND_NR];
  3481. s32 cfg[RTW89_SAR_SUBBAND_NR];
  3482. };
  3483. struct rtw89_sar_info {
  3484. /* used to decide how to acces SAR cfg union */
  3485. enum rtw89_sar_sources src;
  3486. /* reserved for different knids of SAR cfg struct.
  3487. * supposed that a single cfg struct cannot handle various SAR sources.
  3488. */
  3489. union {
  3490. struct rtw89_sar_cfg_common cfg_common;
  3491. };
  3492. };
  3493. enum rtw89_tas_state {
  3494. RTW89_TAS_STATE_DPR_OFF,
  3495. RTW89_TAS_STATE_DPR_ON,
  3496. RTW89_TAS_STATE_DPR_FORBID,
  3497. };
  3498. #define RTW89_TAS_MAX_WINDOW 50
  3499. struct rtw89_tas_info {
  3500. s16 txpwr_history[RTW89_TAS_MAX_WINDOW];
  3501. s32 total_txpwr;
  3502. u8 cur_idx;
  3503. s8 dpr_gap;
  3504. s8 delta;
  3505. enum rtw89_tas_state state;
  3506. bool enable;
  3507. };
  3508. struct rtw89_chanctx_cfg {
  3509. enum rtw89_sub_entity_idx idx;
  3510. };
  3511. enum rtw89_chanctx_changes {
  3512. RTW89_CHANCTX_REMOTE_STA_CHANGE,
  3513. RTW89_CHANCTX_BCN_OFFSET_CHANGE,
  3514. RTW89_CHANCTX_P2P_PS_CHANGE,
  3515. RTW89_CHANCTX_BT_SLOT_CHANGE,
  3516. RTW89_CHANCTX_TSF32_TOGGLE_CHANGE,
  3517. NUM_OF_RTW89_CHANCTX_CHANGES,
  3518. RTW89_CHANCTX_CHANGE_DFLT = NUM_OF_RTW89_CHANCTX_CHANGES,
  3519. };
  3520. enum rtw89_entity_mode {
  3521. RTW89_ENTITY_MODE_SCC,
  3522. RTW89_ENTITY_MODE_MCC_PREPARE,
  3523. RTW89_ENTITY_MODE_MCC,
  3524. NUM_OF_RTW89_ENTITY_MODE,
  3525. RTW89_ENTITY_MODE_INVALID = NUM_OF_RTW89_ENTITY_MODE,
  3526. };
  3527. struct rtw89_sub_entity {
  3528. struct cfg80211_chan_def chandef;
  3529. struct rtw89_chan chan;
  3530. struct rtw89_chan_rcd rcd;
  3531. struct rtw89_chanctx_cfg *cfg;
  3532. };
  3533. struct rtw89_hal {
  3534. u32 rx_fltr;
  3535. u8 cv;
  3536. u8 acv;
  3537. u32 antenna_tx;
  3538. u32 antenna_rx;
  3539. u8 tx_nss;
  3540. u8 rx_nss;
  3541. bool tx_path_diversity;
  3542. bool ant_diversity;
  3543. bool ant_diversity_fixed;
  3544. bool support_cckpd;
  3545. bool support_igi;
  3546. atomic_t roc_entity_idx;
  3547. DECLARE_BITMAP(changes, NUM_OF_RTW89_CHANCTX_CHANGES);
  3548. DECLARE_BITMAP(entity_map, NUM_OF_RTW89_SUB_ENTITY);
  3549. struct rtw89_sub_entity sub[NUM_OF_RTW89_SUB_ENTITY];
  3550. struct cfg80211_chan_def roc_chandef;
  3551. bool entity_active;
  3552. bool entity_pause;
  3553. enum rtw89_entity_mode entity_mode;
  3554. u32 edcca_bak;
  3555. };
  3556. #define RTW89_MAX_MAC_ID_NUM 128
  3557. #define RTW89_MAX_PKT_OFLD_NUM 255
  3558. enum rtw89_flags {
  3559. RTW89_FLAG_POWERON,
  3560. RTW89_FLAG_FW_RDY,
  3561. RTW89_FLAG_RUNNING,
  3562. RTW89_FLAG_BFEE_MON,
  3563. RTW89_FLAG_BFEE_EN,
  3564. RTW89_FLAG_BFEE_TIMER_KEEP,
  3565. RTW89_FLAG_NAPI_RUNNING,
  3566. RTW89_FLAG_LEISURE_PS,
  3567. RTW89_FLAG_LOW_POWER_MODE,
  3568. RTW89_FLAG_INACTIVE_PS,
  3569. RTW89_FLAG_CRASH_SIMULATING,
  3570. RTW89_FLAG_SER_HANDLING,
  3571. RTW89_FLAG_WOWLAN,
  3572. RTW89_FLAG_FORBIDDEN_TRACK_WROK,
  3573. RTW89_FLAG_CHANGING_INTERFACE,
  3574. NUM_OF_RTW89_FLAGS,
  3575. };
  3576. enum rtw89_pkt_drop_sel {
  3577. RTW89_PKT_DROP_SEL_MACID_BE_ONCE,
  3578. RTW89_PKT_DROP_SEL_MACID_BK_ONCE,
  3579. RTW89_PKT_DROP_SEL_MACID_VI_ONCE,
  3580. RTW89_PKT_DROP_SEL_MACID_VO_ONCE,
  3581. RTW89_PKT_DROP_SEL_MACID_ALL,
  3582. RTW89_PKT_DROP_SEL_MG0_ONCE,
  3583. RTW89_PKT_DROP_SEL_HIQ_ONCE,
  3584. RTW89_PKT_DROP_SEL_HIQ_PORT,
  3585. RTW89_PKT_DROP_SEL_HIQ_MBSSID,
  3586. RTW89_PKT_DROP_SEL_BAND,
  3587. RTW89_PKT_DROP_SEL_BAND_ONCE,
  3588. RTW89_PKT_DROP_SEL_REL_MACID,
  3589. RTW89_PKT_DROP_SEL_REL_HIQ_PORT,
  3590. RTW89_PKT_DROP_SEL_REL_HIQ_MBSSID,
  3591. };
  3592. struct rtw89_pkt_drop_params {
  3593. enum rtw89_pkt_drop_sel sel;
  3594. enum rtw89_mac_idx mac_band;
  3595. u8 macid;
  3596. u8 port;
  3597. u8 mbssid;
  3598. bool tf_trs;
  3599. u32 macid_band_sel[4];
  3600. };
  3601. struct rtw89_pkt_stat {
  3602. u16 beacon_nr;
  3603. u32 rx_rate_cnt[RTW89_HW_RATE_NR];
  3604. };
  3605. DECLARE_EWMA(thermal, 4, 4);
  3606. struct rtw89_phy_stat {
  3607. struct ewma_thermal avg_thermal[RF_PATH_MAX];
  3608. struct rtw89_pkt_stat cur_pkt_stat;
  3609. struct rtw89_pkt_stat last_pkt_stat;
  3610. };
  3611. #define RTW89_DACK_PATH_NR 2
  3612. #define RTW89_DACK_IDX_NR 2
  3613. #define RTW89_DACK_MSBK_NR 16
  3614. struct rtw89_dack_info {
  3615. bool dack_done;
  3616. u8 msbk_d[RTW89_DACK_PATH_NR][RTW89_DACK_IDX_NR][RTW89_DACK_MSBK_NR];
  3617. u8 dadck_d[RTW89_DACK_PATH_NR][RTW89_DACK_IDX_NR];
  3618. u16 addck_d[RTW89_DACK_PATH_NR][RTW89_DACK_IDX_NR];
  3619. u16 biask_d[RTW89_DACK_PATH_NR][RTW89_DACK_IDX_NR];
  3620. u32 dack_cnt;
  3621. bool addck_timeout[RTW89_DACK_PATH_NR];
  3622. bool dadck_timeout[RTW89_DACK_PATH_NR];
  3623. bool msbk_timeout[RTW89_DACK_PATH_NR];
  3624. };
  3625. #define RTW89_IQK_CHS_NR 2
  3626. #define RTW89_IQK_PATH_NR 4
  3627. struct rtw89_rfk_mcc_info {
  3628. u8 ch[RTW89_IQK_CHS_NR];
  3629. u8 band[RTW89_IQK_CHS_NR];
  3630. u8 table_idx;
  3631. };
  3632. struct rtw89_lck_info {
  3633. u8 thermal[RF_PATH_MAX];
  3634. };
  3635. struct rtw89_rx_dck_info {
  3636. u8 thermal[RF_PATH_MAX];
  3637. };
  3638. struct rtw89_iqk_info {
  3639. bool lok_cor_fail[RTW89_IQK_CHS_NR][RTW89_IQK_PATH_NR];
  3640. bool lok_fin_fail[RTW89_IQK_CHS_NR][RTW89_IQK_PATH_NR];
  3641. bool lok_fail[RTW89_IQK_PATH_NR];
  3642. bool iqk_tx_fail[RTW89_IQK_CHS_NR][RTW89_IQK_PATH_NR];
  3643. bool iqk_rx_fail[RTW89_IQK_CHS_NR][RTW89_IQK_PATH_NR];
  3644. u32 iqk_fail_cnt;
  3645. bool is_iqk_init;
  3646. u32 iqk_channel[RTW89_IQK_CHS_NR];
  3647. u8 iqk_band[RTW89_IQK_PATH_NR];
  3648. u8 iqk_ch[RTW89_IQK_PATH_NR];
  3649. u8 iqk_bw[RTW89_IQK_PATH_NR];
  3650. u8 iqk_times;
  3651. u8 version;
  3652. u32 nb_txcfir[RTW89_IQK_PATH_NR];
  3653. u32 nb_rxcfir[RTW89_IQK_PATH_NR];
  3654. u32 bp_txkresult[RTW89_IQK_PATH_NR];
  3655. u32 bp_rxkresult[RTW89_IQK_PATH_NR];
  3656. u32 bp_iqkenable[RTW89_IQK_PATH_NR];
  3657. bool is_wb_txiqk[RTW89_IQK_PATH_NR];
  3658. bool is_wb_rxiqk[RTW89_IQK_PATH_NR];
  3659. bool is_nbiqk;
  3660. bool iqk_fft_en;
  3661. bool iqk_xym_en;
  3662. bool iqk_sram_en;
  3663. bool iqk_cfir_en;
  3664. u32 syn1to2;
  3665. u8 iqk_mcc_ch[RTW89_IQK_CHS_NR][RTW89_IQK_PATH_NR];
  3666. u8 iqk_table_idx[RTW89_IQK_PATH_NR];
  3667. u32 lok_idac[RTW89_IQK_CHS_NR][RTW89_IQK_PATH_NR];
  3668. u32 lok_vbuf[RTW89_IQK_CHS_NR][RTW89_IQK_PATH_NR];
  3669. };
  3670. #define RTW89_DPK_RF_PATH 2
  3671. #define RTW89_DPK_AVG_THERMAL_NUM 8
  3672. #define RTW89_DPK_BKUP_NUM 2
  3673. struct rtw89_dpk_bkup_para {
  3674. enum rtw89_band band;
  3675. enum rtw89_bandwidth bw;
  3676. u8 ch;
  3677. bool path_ok;
  3678. u8 mdpd_en;
  3679. u8 txagc_dpk;
  3680. u8 ther_dpk;
  3681. u8 gs;
  3682. u16 pwsf;
  3683. };
  3684. struct rtw89_dpk_info {
  3685. bool is_dpk_enable;
  3686. bool is_dpk_reload_en;
  3687. u8 dpk_gs[RTW89_PHY_MAX];
  3688. u16 dc_i[RTW89_DPK_RF_PATH][RTW89_DPK_BKUP_NUM];
  3689. u16 dc_q[RTW89_DPK_RF_PATH][RTW89_DPK_BKUP_NUM];
  3690. u8 corr_val[RTW89_DPK_RF_PATH][RTW89_DPK_BKUP_NUM];
  3691. u8 corr_idx[RTW89_DPK_RF_PATH][RTW89_DPK_BKUP_NUM];
  3692. u8 cur_idx[RTW89_DPK_RF_PATH];
  3693. u8 cur_k_set;
  3694. struct rtw89_dpk_bkup_para bp[RTW89_DPK_RF_PATH][RTW89_DPK_BKUP_NUM];
  3695. };
  3696. struct rtw89_fem_info {
  3697. bool elna_2g;
  3698. bool elna_5g;
  3699. bool epa_2g;
  3700. bool epa_5g;
  3701. bool epa_6g;
  3702. };
  3703. struct rtw89_phy_ch_info {
  3704. u8 rssi_min;
  3705. u16 rssi_min_macid;
  3706. u8 pre_rssi_min;
  3707. u8 rssi_max;
  3708. u16 rssi_max_macid;
  3709. u8 rxsc_160;
  3710. u8 rxsc_80;
  3711. u8 rxsc_40;
  3712. u8 rxsc_20;
  3713. u8 rxsc_l;
  3714. u8 is_noisy;
  3715. };
  3716. struct rtw89_agc_gaincode_set {
  3717. u8 lna_idx;
  3718. u8 tia_idx;
  3719. u8 rxb_idx;
  3720. };
  3721. #define IGI_RSSI_TH_NUM 5
  3722. #define FA_TH_NUM 4
  3723. #define LNA_GAIN_NUM 7
  3724. #define TIA_GAIN_NUM 2
  3725. struct rtw89_dig_info {
  3726. struct rtw89_agc_gaincode_set cur_gaincode;
  3727. bool force_gaincode_idx_en;
  3728. struct rtw89_agc_gaincode_set force_gaincode;
  3729. u8 igi_rssi_th[IGI_RSSI_TH_NUM];
  3730. u16 fa_th[FA_TH_NUM];
  3731. u8 igi_rssi;
  3732. u8 igi_fa_rssi;
  3733. u8 fa_rssi_ofst;
  3734. u8 dyn_igi_max;
  3735. u8 dyn_igi_min;
  3736. bool dyn_pd_th_en;
  3737. u8 dyn_pd_th_max;
  3738. u8 pd_low_th_ofst;
  3739. u8 ib_pbk;
  3740. s8 ib_pkpwr;
  3741. s8 lna_gain_a[LNA_GAIN_NUM];
  3742. s8 lna_gain_g[LNA_GAIN_NUM];
  3743. s8 *lna_gain;
  3744. s8 tia_gain_a[TIA_GAIN_NUM];
  3745. s8 tia_gain_g[TIA_GAIN_NUM];
  3746. s8 *tia_gain;
  3747. bool is_linked_pre;
  3748. bool bypass_dig;
  3749. };
  3750. enum rtw89_multi_cfo_mode {
  3751. RTW89_PKT_BASED_AVG_MODE = 0,
  3752. RTW89_ENTRY_BASED_AVG_MODE = 1,
  3753. RTW89_TP_BASED_AVG_MODE = 2,
  3754. };
  3755. enum rtw89_phy_cfo_status {
  3756. RTW89_PHY_DCFO_STATE_NORMAL = 0,
  3757. RTW89_PHY_DCFO_STATE_ENHANCE = 1,
  3758. RTW89_PHY_DCFO_STATE_HOLD = 2,
  3759. RTW89_PHY_DCFO_STATE_MAX
  3760. };
  3761. enum rtw89_phy_cfo_ul_ofdma_acc_mode {
  3762. RTW89_CFO_UL_OFDMA_ACC_DISABLE = 0,
  3763. RTW89_CFO_UL_OFDMA_ACC_ENABLE = 1
  3764. };
  3765. struct rtw89_cfo_tracking_info {
  3766. u16 cfo_timer_ms;
  3767. bool cfo_trig_by_timer_en;
  3768. enum rtw89_phy_cfo_status phy_cfo_status;
  3769. enum rtw89_phy_cfo_ul_ofdma_acc_mode cfo_ul_ofdma_acc_mode;
  3770. u8 phy_cfo_trk_cnt;
  3771. bool is_adjust;
  3772. enum rtw89_multi_cfo_mode rtw89_multi_cfo_mode;
  3773. bool apply_compensation;
  3774. u8 crystal_cap;
  3775. u8 crystal_cap_default;
  3776. u8 def_x_cap;
  3777. s8 x_cap_ofst;
  3778. u32 sta_cfo_tolerance;
  3779. s32 cfo_tail[CFO_TRACK_MAX_USER];
  3780. u16 cfo_cnt[CFO_TRACK_MAX_USER];
  3781. s32 cfo_avg_pre;
  3782. s32 cfo_avg[CFO_TRACK_MAX_USER];
  3783. s32 pre_cfo_avg[CFO_TRACK_MAX_USER];
  3784. s32 dcfo_avg;
  3785. s32 dcfo_avg_pre;
  3786. u32 packet_count;
  3787. u32 packet_count_pre;
  3788. s32 residual_cfo_acc;
  3789. u8 phy_cfotrk_state;
  3790. u8 phy_cfotrk_cnt;
  3791. bool divergence_lock_en;
  3792. u8 x_cap_lb;
  3793. u8 x_cap_ub;
  3794. u8 lock_cnt;
  3795. };
  3796. enum rtw89_tssi_alimk_band {
  3797. TSSI_ALIMK_2G = 0,
  3798. TSSI_ALIMK_5GL,
  3799. TSSI_ALIMK_5GM,
  3800. TSSI_ALIMK_5GH,
  3801. TSSI_ALIMK_MAX
  3802. };
  3803. /* 2GL, 2GH, 5GL1, 5GH1, 5GM1, 5GM2, 5GH1, 5GH2 */
  3804. #define TSSI_TRIM_CH_GROUP_NUM 8
  3805. #define TSSI_TRIM_CH_GROUP_NUM_6G 16
  3806. #define TSSI_CCK_CH_GROUP_NUM 6
  3807. #define TSSI_MCS_2G_CH_GROUP_NUM 5
  3808. #define TSSI_MCS_5G_CH_GROUP_NUM 14
  3809. #define TSSI_MCS_6G_CH_GROUP_NUM 32
  3810. #define TSSI_MCS_CH_GROUP_NUM \
  3811. (TSSI_MCS_2G_CH_GROUP_NUM + TSSI_MCS_5G_CH_GROUP_NUM)
  3812. #define TSSI_MAX_CH_NUM 67
  3813. #define TSSI_ALIMK_VALUE_NUM 8
  3814. struct rtw89_tssi_info {
  3815. u8 thermal[RF_PATH_MAX];
  3816. s8 tssi_trim[RF_PATH_MAX][TSSI_TRIM_CH_GROUP_NUM];
  3817. s8 tssi_trim_6g[RF_PATH_MAX][TSSI_TRIM_CH_GROUP_NUM_6G];
  3818. s8 tssi_cck[RF_PATH_MAX][TSSI_CCK_CH_GROUP_NUM];
  3819. s8 tssi_mcs[RF_PATH_MAX][TSSI_MCS_CH_GROUP_NUM];
  3820. s8 tssi_6g_mcs[RF_PATH_MAX][TSSI_MCS_6G_CH_GROUP_NUM];
  3821. s8 extra_ofst[RF_PATH_MAX];
  3822. bool tssi_tracking_check[RF_PATH_MAX];
  3823. u8 default_txagc_offset[RF_PATH_MAX];
  3824. u32 base_thermal[RF_PATH_MAX];
  3825. bool check_backup_aligmk[RF_PATH_MAX][TSSI_MAX_CH_NUM];
  3826. u32 alignment_backup_by_ch[RF_PATH_MAX][TSSI_MAX_CH_NUM][TSSI_ALIMK_VALUE_NUM];
  3827. u32 alignment_value[RF_PATH_MAX][TSSI_ALIMK_MAX][TSSI_ALIMK_VALUE_NUM];
  3828. bool alignment_done[RF_PATH_MAX][TSSI_ALIMK_MAX];
  3829. u32 tssi_alimk_time;
  3830. };
  3831. struct rtw89_power_trim_info {
  3832. bool pg_thermal_trim;
  3833. bool pg_pa_bias_trim;
  3834. u8 thermal_trim[RF_PATH_MAX];
  3835. u8 pa_bias_trim[RF_PATH_MAX];
  3836. };
  3837. struct rtw89_regd {
  3838. char alpha2[3];
  3839. u8 txpwr_regd[RTW89_BAND_NUM];
  3840. };
  3841. struct rtw89_regulatory_info {
  3842. const struct rtw89_regd *regd;
  3843. enum rtw89_reg_6ghz_power reg_6ghz_power;
  3844. };
  3845. enum rtw89_ifs_clm_application {
  3846. RTW89_IFS_CLM_INIT = 0,
  3847. RTW89_IFS_CLM_BACKGROUND = 1,
  3848. RTW89_IFS_CLM_ACS = 2,
  3849. RTW89_IFS_CLM_DIG = 3,
  3850. RTW89_IFS_CLM_TDMA_DIG = 4,
  3851. RTW89_IFS_CLM_DBG = 5,
  3852. RTW89_IFS_CLM_DBG_MANUAL = 6
  3853. };
  3854. enum rtw89_env_racing_lv {
  3855. RTW89_RAC_RELEASE = 0,
  3856. RTW89_RAC_LV_1 = 1,
  3857. RTW89_RAC_LV_2 = 2,
  3858. RTW89_RAC_LV_3 = 3,
  3859. RTW89_RAC_LV_4 = 4,
  3860. RTW89_RAC_MAX_NUM = 5
  3861. };
  3862. struct rtw89_ccx_para_info {
  3863. enum rtw89_env_racing_lv rac_lv;
  3864. u16 mntr_time;
  3865. u8 nhm_manual_th_ofst;
  3866. u8 nhm_manual_th0;
  3867. enum rtw89_ifs_clm_application ifs_clm_app;
  3868. u32 ifs_clm_manual_th_times;
  3869. u32 ifs_clm_manual_th0;
  3870. u8 fahm_manual_th_ofst;
  3871. u8 fahm_manual_th0;
  3872. u8 fahm_numer_opt;
  3873. u8 fahm_denom_opt;
  3874. };
  3875. enum rtw89_ccx_edcca_opt_sc_idx {
  3876. RTW89_CCX_EDCCA_SEG0_P0 = 0,
  3877. RTW89_CCX_EDCCA_SEG0_S1 = 1,
  3878. RTW89_CCX_EDCCA_SEG0_S2 = 2,
  3879. RTW89_CCX_EDCCA_SEG0_S3 = 3,
  3880. RTW89_CCX_EDCCA_SEG1_P0 = 4,
  3881. RTW89_CCX_EDCCA_SEG1_S1 = 5,
  3882. RTW89_CCX_EDCCA_SEG1_S2 = 6,
  3883. RTW89_CCX_EDCCA_SEG1_S3 = 7
  3884. };
  3885. enum rtw89_ccx_edcca_opt_bw_idx {
  3886. RTW89_CCX_EDCCA_BW20_0 = 0,
  3887. RTW89_CCX_EDCCA_BW20_1 = 1,
  3888. RTW89_CCX_EDCCA_BW20_2 = 2,
  3889. RTW89_CCX_EDCCA_BW20_3 = 3,
  3890. RTW89_CCX_EDCCA_BW20_4 = 4,
  3891. RTW89_CCX_EDCCA_BW20_5 = 5,
  3892. RTW89_CCX_EDCCA_BW20_6 = 6,
  3893. RTW89_CCX_EDCCA_BW20_7 = 7
  3894. };
  3895. #define RTW89_NHM_TH_NUM 11
  3896. #define RTW89_FAHM_TH_NUM 11
  3897. #define RTW89_NHM_RPT_NUM 12
  3898. #define RTW89_FAHM_RPT_NUM 12
  3899. #define RTW89_IFS_CLM_NUM 4
  3900. struct rtw89_env_monitor_info {
  3901. u8 ccx_watchdog_result;
  3902. bool ccx_ongoing;
  3903. u8 ccx_rac_lv;
  3904. bool ccx_manual_ctrl;
  3905. u16 ifs_clm_mntr_time;
  3906. enum rtw89_ifs_clm_application ifs_clm_app;
  3907. u16 ccx_period;
  3908. u8 ccx_unit_idx;
  3909. u16 ifs_clm_th_l[RTW89_IFS_CLM_NUM];
  3910. u16 ifs_clm_th_h[RTW89_IFS_CLM_NUM];
  3911. u16 ifs_clm_tx;
  3912. u16 ifs_clm_edcca_excl_cca;
  3913. u16 ifs_clm_ofdmfa;
  3914. u16 ifs_clm_ofdmcca_excl_fa;
  3915. u16 ifs_clm_cckfa;
  3916. u16 ifs_clm_cckcca_excl_fa;
  3917. u16 ifs_clm_total_ifs;
  3918. u8 ifs_clm_his[RTW89_IFS_CLM_NUM];
  3919. u16 ifs_clm_avg[RTW89_IFS_CLM_NUM];
  3920. u16 ifs_clm_cca[RTW89_IFS_CLM_NUM];
  3921. u8 ifs_clm_tx_ratio;
  3922. u8 ifs_clm_edcca_excl_cca_ratio;
  3923. u8 ifs_clm_cck_fa_ratio;
  3924. u8 ifs_clm_ofdm_fa_ratio;
  3925. u8 ifs_clm_cck_cca_excl_fa_ratio;
  3926. u8 ifs_clm_ofdm_cca_excl_fa_ratio;
  3927. u16 ifs_clm_cck_fa_permil;
  3928. u16 ifs_clm_ofdm_fa_permil;
  3929. u32 ifs_clm_ifs_avg[RTW89_IFS_CLM_NUM];
  3930. u32 ifs_clm_cca_avg[RTW89_IFS_CLM_NUM];
  3931. };
  3932. enum rtw89_ser_rcvy_step {
  3933. RTW89_SER_DRV_STOP_TX,
  3934. RTW89_SER_DRV_STOP_RX,
  3935. RTW89_SER_DRV_STOP_RUN,
  3936. RTW89_SER_HAL_STOP_DMA,
  3937. RTW89_SER_SUPPRESS_LOG,
  3938. RTW89_NUM_OF_SER_FLAGS
  3939. };
  3940. struct rtw89_ser {
  3941. u8 state;
  3942. u8 alarm_event;
  3943. bool prehandle_l1;
  3944. struct work_struct ser_hdl_work;
  3945. struct delayed_work ser_alarm_work;
  3946. const struct state_ent *st_tbl;
  3947. const struct event_ent *ev_tbl;
  3948. struct list_head msg_q;
  3949. spinlock_t msg_q_lock; /* lock when read/write ser msg */
  3950. DECLARE_BITMAP(flags, RTW89_NUM_OF_SER_FLAGS);
  3951. };
  3952. enum rtw89_mac_ax_ps_mode {
  3953. RTW89_MAC_AX_PS_MODE_ACTIVE = 0,
  3954. RTW89_MAC_AX_PS_MODE_LEGACY = 1,
  3955. RTW89_MAC_AX_PS_MODE_WMMPS = 2,
  3956. RTW89_MAC_AX_PS_MODE_MAX = 3,
  3957. };
  3958. enum rtw89_last_rpwm_mode {
  3959. RTW89_LAST_RPWM_PS = 0x0,
  3960. RTW89_LAST_RPWM_ACTIVE = 0x6,
  3961. };
  3962. struct rtw89_lps_parm {
  3963. u8 macid;
  3964. u8 psmode; /* enum rtw89_mac_ax_ps_mode */
  3965. u8 lastrpwm; /* enum rtw89_last_rpwm_mode */
  3966. };
  3967. struct rtw89_ppdu_sts_info {
  3968. struct sk_buff_head rx_queue[RTW89_PHY_MAX];
  3969. u8 curr_rx_ppdu_cnt[RTW89_PHY_MAX];
  3970. };
  3971. struct rtw89_early_h2c {
  3972. struct list_head list;
  3973. u8 *h2c;
  3974. u16 h2c_len;
  3975. };
  3976. struct rtw89_hw_scan_info {
  3977. struct ieee80211_vif *scanning_vif;
  3978. struct list_head pkt_list[NUM_NL80211_BANDS];
  3979. struct rtw89_chan op_chan;
  3980. u32 last_chan_idx;
  3981. };
  3982. enum rtw89_phy_bb_gain_band {
  3983. RTW89_BB_GAIN_BAND_2G = 0,
  3984. RTW89_BB_GAIN_BAND_5G_L = 1,
  3985. RTW89_BB_GAIN_BAND_5G_M = 2,
  3986. RTW89_BB_GAIN_BAND_5G_H = 3,
  3987. RTW89_BB_GAIN_BAND_6G_L = 4,
  3988. RTW89_BB_GAIN_BAND_6G_M = 5,
  3989. RTW89_BB_GAIN_BAND_6G_H = 6,
  3990. RTW89_BB_GAIN_BAND_6G_UH = 7,
  3991. RTW89_BB_GAIN_BAND_NR,
  3992. };
  3993. enum rtw89_phy_bb_rxsc_num {
  3994. RTW89_BB_RXSC_NUM_40 = 9, /* SC: 0, 1~8 */
  3995. RTW89_BB_RXSC_NUM_80 = 13, /* SC: 0, 1~8, 9~12 */
  3996. RTW89_BB_RXSC_NUM_160 = 15, /* SC: 0, 1~8, 9~12, 13~14 */
  3997. };
  3998. struct rtw89_phy_bb_gain_info {
  3999. s8 lna_gain[RTW89_BB_GAIN_BAND_NR][RF_PATH_MAX][LNA_GAIN_NUM];
  4000. s8 tia_gain[RTW89_BB_GAIN_BAND_NR][RF_PATH_MAX][TIA_GAIN_NUM];
  4001. s8 lna_gain_bypass[RTW89_BB_GAIN_BAND_NR][RF_PATH_MAX][LNA_GAIN_NUM];
  4002. s8 lna_op1db[RTW89_BB_GAIN_BAND_NR][RF_PATH_MAX][LNA_GAIN_NUM];
  4003. s8 tia_lna_op1db[RTW89_BB_GAIN_BAND_NR][RF_PATH_MAX]
  4004. [LNA_GAIN_NUM + 1]; /* TIA0_LNA0~6 + TIA1_LNA6 */
  4005. s8 rpl_ofst_20[RTW89_BB_GAIN_BAND_NR][RF_PATH_MAX];
  4006. s8 rpl_ofst_40[RTW89_BB_GAIN_BAND_NR][RF_PATH_MAX]
  4007. [RTW89_BB_RXSC_NUM_40];
  4008. s8 rpl_ofst_80[RTW89_BB_GAIN_BAND_NR][RF_PATH_MAX]
  4009. [RTW89_BB_RXSC_NUM_80];
  4010. s8 rpl_ofst_160[RTW89_BB_GAIN_BAND_NR][RF_PATH_MAX]
  4011. [RTW89_BB_RXSC_NUM_160];
  4012. };
  4013. struct rtw89_phy_efuse_gain {
  4014. bool offset_valid;
  4015. bool comp_valid;
  4016. s8 offset[RF_PATH_MAX][RTW89_GAIN_OFFSET_NR]; /* S(8, 0) */
  4017. s8 offset_base[RTW89_PHY_MAX]; /* S(8, 4) */
  4018. s8 rssi_base[RTW89_PHY_MAX]; /* S(8, 4) */
  4019. s8 comp[RF_PATH_MAX][RTW89_SUBBAND_NR]; /* S(8, 0) */
  4020. };
  4021. #define RTW89_MAX_PATTERN_NUM 18
  4022. #define RTW89_MAX_PATTERN_MASK_SIZE 4
  4023. #define RTW89_MAX_PATTERN_SIZE 128
  4024. struct rtw89_wow_cam_info {
  4025. bool r_w;
  4026. u8 idx;
  4027. u32 mask[RTW89_MAX_PATTERN_MASK_SIZE];
  4028. u16 crc;
  4029. bool negative_pattern_match;
  4030. bool skip_mac_hdr;
  4031. bool uc;
  4032. bool mc;
  4033. bool bc;
  4034. bool valid;
  4035. };
  4036. struct rtw89_wow_param {
  4037. struct ieee80211_vif *wow_vif;
  4038. DECLARE_BITMAP(flags, RTW89_WOW_FLAG_NUM);
  4039. struct rtw89_wow_cam_info patterns[RTW89_MAX_PATTERN_NUM];
  4040. u8 pattern_cnt;
  4041. };
  4042. struct rtw89_mcc_limit {
  4043. bool enable;
  4044. u16 max_tob; /* TU; max time offset behind */
  4045. u16 max_toa; /* TU; max time offset ahead */
  4046. u16 max_dur; /* TU */
  4047. };
  4048. struct rtw89_mcc_policy {
  4049. u8 c2h_rpt;
  4050. u8 tx_null_early;
  4051. u8 dis_tx_null;
  4052. u8 in_curr_ch;
  4053. u8 dis_sw_retry;
  4054. u8 sw_retry_count;
  4055. };
  4056. struct rtw89_mcc_role {
  4057. struct rtw89_vif *rtwvif;
  4058. struct rtw89_mcc_policy policy;
  4059. struct rtw89_mcc_limit limit;
  4060. /* byte-array in LE order for FW */
  4061. u8 macid_bitmap[BITS_TO_BYTES(RTW89_MAX_MAC_ID_NUM)];
  4062. u16 duration; /* TU */
  4063. u16 beacon_interval; /* TU */
  4064. bool is_2ghz;
  4065. bool is_go;
  4066. bool is_gc;
  4067. };
  4068. struct rtw89_mcc_bt_role {
  4069. u16 duration; /* TU */
  4070. };
  4071. struct rtw89_mcc_courtesy {
  4072. bool enable;
  4073. u8 slot_num;
  4074. u8 macid_src;
  4075. u8 macid_tgt;
  4076. };
  4077. enum rtw89_mcc_plan {
  4078. RTW89_MCC_PLAN_TAIL_BT,
  4079. RTW89_MCC_PLAN_MID_BT,
  4080. RTW89_MCC_PLAN_NO_BT,
  4081. NUM_OF_RTW89_MCC_PLAN,
  4082. };
  4083. struct rtw89_mcc_pattern {
  4084. s16 tob_ref; /* TU; time offset behind of reference role */
  4085. s16 toa_ref; /* TU; time offset ahead of reference role */
  4086. s16 tob_aux; /* TU; time offset behind of auxiliary role */
  4087. s16 toa_aux; /* TU; time offset ahead of auxiliary role */
  4088. enum rtw89_mcc_plan plan;
  4089. struct rtw89_mcc_courtesy courtesy;
  4090. };
  4091. struct rtw89_mcc_sync {
  4092. bool enable;
  4093. u16 offset; /* TU */
  4094. u8 macid_src;
  4095. u8 macid_tgt;
  4096. };
  4097. struct rtw89_mcc_config {
  4098. struct rtw89_mcc_pattern pattern;
  4099. struct rtw89_mcc_sync sync;
  4100. u64 start_tsf;
  4101. u16 mcc_interval; /* TU */
  4102. u16 beacon_offset; /* TU */
  4103. };
  4104. enum rtw89_mcc_mode {
  4105. RTW89_MCC_MODE_GO_STA,
  4106. RTW89_MCC_MODE_GC_STA,
  4107. };
  4108. struct rtw89_mcc_info {
  4109. struct rtw89_wait_info wait;
  4110. u8 group;
  4111. enum rtw89_mcc_mode mode;
  4112. struct rtw89_mcc_role role_ref; /* reference role */
  4113. struct rtw89_mcc_role role_aux; /* auxiliary role */
  4114. struct rtw89_mcc_bt_role bt_role;
  4115. struct rtw89_mcc_config config;
  4116. };
  4117. struct rtw89_dev {
  4118. struct ieee80211_hw *hw;
  4119. struct device *dev;
  4120. const struct ieee80211_ops *ops;
  4121. bool dbcc_en;
  4122. struct rtw89_hw_scan_info scan_info;
  4123. const struct rtw89_chip_info *chip;
  4124. const struct rtw89_pci_info *pci_info;
  4125. const struct rtw89_rfe_parms *rfe_parms;
  4126. struct rtw89_hal hal;
  4127. struct rtw89_mcc_info mcc;
  4128. struct rtw89_mac_info mac;
  4129. struct rtw89_fw_info fw;
  4130. struct rtw89_hci_info hci;
  4131. struct rtw89_efuse efuse;
  4132. struct rtw89_traffic_stats stats;
  4133. struct rtw89_rfe_data *rfe_data;
  4134. /* ensures exclusive access from mac80211 callbacks */
  4135. struct mutex mutex;
  4136. struct list_head rtwvifs_list;
  4137. /* used to protect rf read write */
  4138. struct mutex rf_mutex;
  4139. struct workqueue_struct *txq_wq;
  4140. struct work_struct txq_work;
  4141. struct delayed_work txq_reinvoke_work;
  4142. /* used to protect ba_list and forbid_ba_list */
  4143. spinlock_t ba_lock;
  4144. /* txqs to setup ba session */
  4145. struct list_head ba_list;
  4146. /* txqs to forbid ba session */
  4147. struct list_head forbid_ba_list;
  4148. struct work_struct ba_work;
  4149. /* used to protect rpwm */
  4150. spinlock_t rpwm_lock;
  4151. struct rtw89_cam_info cam_info;
  4152. struct sk_buff_head c2h_queue;
  4153. struct work_struct c2h_work;
  4154. struct work_struct ips_work;
  4155. struct work_struct load_firmware_work;
  4156. struct work_struct cancel_6ghz_probe_work;
  4157. struct list_head early_h2c_list;
  4158. struct rtw89_ser ser;
  4159. DECLARE_BITMAP(hw_port, RTW89_PORT_NUM);
  4160. DECLARE_BITMAP(mac_id_map, RTW89_MAX_MAC_ID_NUM);
  4161. DECLARE_BITMAP(flags, NUM_OF_RTW89_FLAGS);
  4162. DECLARE_BITMAP(pkt_offload, RTW89_MAX_PKT_OFLD_NUM);
  4163. struct rtw89_phy_stat phystat;
  4164. struct rtw89_dack_info dack;
  4165. struct rtw89_iqk_info iqk;
  4166. struct rtw89_dpk_info dpk;
  4167. struct rtw89_rfk_mcc_info rfk_mcc;
  4168. struct rtw89_lck_info lck;
  4169. struct rtw89_rx_dck_info rx_dck;
  4170. bool is_tssi_mode[RF_PATH_MAX];
  4171. bool is_bt_iqk_timeout;
  4172. struct rtw89_fem_info fem;
  4173. struct rtw89_txpwr_byrate byr[RTW89_BAND_NUM][RTW89_BYR_BW_NUM];
  4174. struct rtw89_tssi_info tssi;
  4175. struct rtw89_power_trim_info pwr_trim;
  4176. struct rtw89_cfo_tracking_info cfo_tracking;
  4177. struct rtw89_env_monitor_info env_monitor;
  4178. struct rtw89_dig_info dig;
  4179. struct rtw89_phy_ch_info ch_info;
  4180. struct rtw89_phy_bb_gain_info bb_gain;
  4181. struct rtw89_phy_efuse_gain efuse_gain;
  4182. struct rtw89_phy_ul_tb_info ul_tb_info;
  4183. struct rtw89_antdiv_info antdiv;
  4184. struct delayed_work track_work;
  4185. struct delayed_work chanctx_work;
  4186. struct delayed_work coex_act1_work;
  4187. struct delayed_work coex_bt_devinfo_work;
  4188. struct delayed_work coex_rfk_chk_work;
  4189. struct delayed_work cfo_track_work;
  4190. struct delayed_work forbid_ba_work;
  4191. struct delayed_work roc_work;
  4192. struct delayed_work antdiv_work;
  4193. struct rtw89_ppdu_sts_info ppdu_sts;
  4194. u8 total_sta_assoc;
  4195. bool scanning;
  4196. struct rtw89_regulatory_info regulatory;
  4197. struct rtw89_sar_info sar;
  4198. struct rtw89_tas_info tas;
  4199. struct rtw89_btc btc;
  4200. enum rtw89_ps_mode ps_mode;
  4201. bool lps_enabled;
  4202. struct rtw89_wow_param wow;
  4203. /* napi structure */
  4204. struct net_device netdev;
  4205. struct napi_struct napi;
  4206. int napi_budget_countdown;
  4207. /* HCI related data, keep last */
  4208. u8 priv[] __aligned(sizeof(void *));
  4209. };
  4210. static inline int rtw89_hci_tx_write(struct rtw89_dev *rtwdev,
  4211. struct rtw89_core_tx_request *tx_req)
  4212. {
  4213. return rtwdev->hci.ops->tx_write(rtwdev, tx_req);
  4214. }
  4215. static inline void rtw89_hci_reset(struct rtw89_dev *rtwdev)
  4216. {
  4217. rtwdev->hci.ops->reset(rtwdev);
  4218. }
  4219. static inline int rtw89_hci_start(struct rtw89_dev *rtwdev)
  4220. {
  4221. return rtwdev->hci.ops->start(rtwdev);
  4222. }
  4223. static inline void rtw89_hci_stop(struct rtw89_dev *rtwdev)
  4224. {
  4225. rtwdev->hci.ops->stop(rtwdev);
  4226. }
  4227. static inline int rtw89_hci_deinit(struct rtw89_dev *rtwdev)
  4228. {
  4229. return rtwdev->hci.ops->deinit(rtwdev);
  4230. }
  4231. static inline void rtw89_hci_pause(struct rtw89_dev *rtwdev, bool pause)
  4232. {
  4233. rtwdev->hci.ops->pause(rtwdev, pause);
  4234. }
  4235. static inline void rtw89_hci_switch_mode(struct rtw89_dev *rtwdev, bool low_power)
  4236. {
  4237. rtwdev->hci.ops->switch_mode(rtwdev, low_power);
  4238. }
  4239. static inline void rtw89_hci_recalc_int_mit(struct rtw89_dev *rtwdev)
  4240. {
  4241. rtwdev->hci.ops->recalc_int_mit(rtwdev);
  4242. }
  4243. static inline u32 rtw89_hci_check_and_reclaim_tx_resource(struct rtw89_dev *rtwdev, u8 txch)
  4244. {
  4245. return rtwdev->hci.ops->check_and_reclaim_tx_resource(rtwdev, txch);
  4246. }
  4247. static inline void rtw89_hci_tx_kick_off(struct rtw89_dev *rtwdev, u8 txch)
  4248. {
  4249. return rtwdev->hci.ops->tx_kick_off(rtwdev, txch);
  4250. }
  4251. static inline void rtw89_hci_flush_queues(struct rtw89_dev *rtwdev, u32 queues,
  4252. bool drop)
  4253. {
  4254. if (!test_bit(RTW89_FLAG_POWERON, rtwdev->flags))
  4255. return;
  4256. if (rtwdev->hci.ops->flush_queues)
  4257. return rtwdev->hci.ops->flush_queues(rtwdev, queues, drop);
  4258. }
  4259. static inline void rtw89_hci_recovery_start(struct rtw89_dev *rtwdev)
  4260. {
  4261. if (rtwdev->hci.ops->recovery_start)
  4262. rtwdev->hci.ops->recovery_start(rtwdev);
  4263. }
  4264. static inline void rtw89_hci_recovery_complete(struct rtw89_dev *rtwdev)
  4265. {
  4266. if (rtwdev->hci.ops->recovery_complete)
  4267. rtwdev->hci.ops->recovery_complete(rtwdev);
  4268. }
  4269. static inline void rtw89_hci_enable_intr(struct rtw89_dev *rtwdev)
  4270. {
  4271. if (rtwdev->hci.ops->enable_intr)
  4272. rtwdev->hci.ops->enable_intr(rtwdev);
  4273. }
  4274. static inline void rtw89_hci_disable_intr(struct rtw89_dev *rtwdev)
  4275. {
  4276. if (rtwdev->hci.ops->disable_intr)
  4277. rtwdev->hci.ops->disable_intr(rtwdev);
  4278. }
  4279. static inline void rtw89_hci_ctrl_txdma_ch(struct rtw89_dev *rtwdev, bool enable)
  4280. {
  4281. if (rtwdev->hci.ops->ctrl_txdma_ch)
  4282. rtwdev->hci.ops->ctrl_txdma_ch(rtwdev, enable);
  4283. }
  4284. static inline void rtw89_hci_ctrl_txdma_fw_ch(struct rtw89_dev *rtwdev, bool enable)
  4285. {
  4286. if (rtwdev->hci.ops->ctrl_txdma_fw_ch)
  4287. rtwdev->hci.ops->ctrl_txdma_fw_ch(rtwdev, enable);
  4288. }
  4289. static inline void rtw89_hci_ctrl_trxhci(struct rtw89_dev *rtwdev, bool enable)
  4290. {
  4291. if (rtwdev->hci.ops->ctrl_trxhci)
  4292. rtwdev->hci.ops->ctrl_trxhci(rtwdev, enable);
  4293. }
  4294. static inline int rtw89_hci_poll_txdma_ch(struct rtw89_dev *rtwdev)
  4295. {
  4296. int ret = 0;
  4297. if (rtwdev->hci.ops->poll_txdma_ch)
  4298. ret = rtwdev->hci.ops->poll_txdma_ch(rtwdev);
  4299. return ret;
  4300. }
  4301. static inline void rtw89_hci_clr_idx_all(struct rtw89_dev *rtwdev)
  4302. {
  4303. if (rtwdev->hci.ops->clr_idx_all)
  4304. rtwdev->hci.ops->clr_idx_all(rtwdev);
  4305. }
  4306. static inline int rtw89_hci_rst_bdram(struct rtw89_dev *rtwdev)
  4307. {
  4308. int ret = 0;
  4309. if (rtwdev->hci.ops->rst_bdram)
  4310. ret = rtwdev->hci.ops->rst_bdram(rtwdev);
  4311. return ret;
  4312. }
  4313. static inline void rtw89_hci_clear(struct rtw89_dev *rtwdev, struct pci_dev *pdev)
  4314. {
  4315. if (rtwdev->hci.ops->clear)
  4316. rtwdev->hci.ops->clear(rtwdev, pdev);
  4317. }
  4318. static inline
  4319. struct rtw89_tx_skb_data *RTW89_TX_SKB_CB(struct sk_buff *skb)
  4320. {
  4321. struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
  4322. return (struct rtw89_tx_skb_data *)info->status.status_driver_data;
  4323. }
  4324. static inline u8 rtw89_read8(struct rtw89_dev *rtwdev, u32 addr)
  4325. {
  4326. return rtwdev->hci.ops->read8(rtwdev, addr);
  4327. }
  4328. static inline u16 rtw89_read16(struct rtw89_dev *rtwdev, u32 addr)
  4329. {
  4330. return rtwdev->hci.ops->read16(rtwdev, addr);
  4331. }
  4332. static inline u32 rtw89_read32(struct rtw89_dev *rtwdev, u32 addr)
  4333. {
  4334. return rtwdev->hci.ops->read32(rtwdev, addr);
  4335. }
  4336. static inline void rtw89_write8(struct rtw89_dev *rtwdev, u32 addr, u8 data)
  4337. {
  4338. rtwdev->hci.ops->write8(rtwdev, addr, data);
  4339. }
  4340. static inline void rtw89_write16(struct rtw89_dev *rtwdev, u32 addr, u16 data)
  4341. {
  4342. rtwdev->hci.ops->write16(rtwdev, addr, data);
  4343. }
  4344. static inline void rtw89_write32(struct rtw89_dev *rtwdev, u32 addr, u32 data)
  4345. {
  4346. rtwdev->hci.ops->write32(rtwdev, addr, data);
  4347. }
  4348. static inline void
  4349. rtw89_write8_set(struct rtw89_dev *rtwdev, u32 addr, u8 bit)
  4350. {
  4351. u8 val;
  4352. val = rtw89_read8(rtwdev, addr);
  4353. rtw89_write8(rtwdev, addr, val | bit);
  4354. }
  4355. static inline void
  4356. rtw89_write16_set(struct rtw89_dev *rtwdev, u32 addr, u16 bit)
  4357. {
  4358. u16 val;
  4359. val = rtw89_read16(rtwdev, addr);
  4360. rtw89_write16(rtwdev, addr, val | bit);
  4361. }
  4362. static inline void
  4363. rtw89_write32_set(struct rtw89_dev *rtwdev, u32 addr, u32 bit)
  4364. {
  4365. u32 val;
  4366. val = rtw89_read32(rtwdev, addr);
  4367. rtw89_write32(rtwdev, addr, val | bit);
  4368. }
  4369. static inline void
  4370. rtw89_write8_clr(struct rtw89_dev *rtwdev, u32 addr, u8 bit)
  4371. {
  4372. u8 val;
  4373. val = rtw89_read8(rtwdev, addr);
  4374. rtw89_write8(rtwdev, addr, val & ~bit);
  4375. }
  4376. static inline void
  4377. rtw89_write16_clr(struct rtw89_dev *rtwdev, u32 addr, u16 bit)
  4378. {
  4379. u16 val;
  4380. val = rtw89_read16(rtwdev, addr);
  4381. rtw89_write16(rtwdev, addr, val & ~bit);
  4382. }
  4383. static inline void
  4384. rtw89_write32_clr(struct rtw89_dev *rtwdev, u32 addr, u32 bit)
  4385. {
  4386. u32 val;
  4387. val = rtw89_read32(rtwdev, addr);
  4388. rtw89_write32(rtwdev, addr, val & ~bit);
  4389. }
  4390. static inline u32
  4391. rtw89_read32_mask(struct rtw89_dev *rtwdev, u32 addr, u32 mask)
  4392. {
  4393. u32 shift = __ffs(mask);
  4394. u32 orig;
  4395. u32 ret;
  4396. orig = rtw89_read32(rtwdev, addr);
  4397. ret = (orig & mask) >> shift;
  4398. return ret;
  4399. }
  4400. static inline u16
  4401. rtw89_read16_mask(struct rtw89_dev *rtwdev, u32 addr, u32 mask)
  4402. {
  4403. u32 shift = __ffs(mask);
  4404. u32 orig;
  4405. u32 ret;
  4406. orig = rtw89_read16(rtwdev, addr);
  4407. ret = (orig & mask) >> shift;
  4408. return ret;
  4409. }
  4410. static inline u8
  4411. rtw89_read8_mask(struct rtw89_dev *rtwdev, u32 addr, u32 mask)
  4412. {
  4413. u32 shift = __ffs(mask);
  4414. u32 orig;
  4415. u32 ret;
  4416. orig = rtw89_read8(rtwdev, addr);
  4417. ret = (orig & mask) >> shift;
  4418. return ret;
  4419. }
  4420. static inline void
  4421. rtw89_write32_mask(struct rtw89_dev *rtwdev, u32 addr, u32 mask, u32 data)
  4422. {
  4423. u32 shift = __ffs(mask);
  4424. u32 orig;
  4425. u32 set;
  4426. WARN(addr & 0x3, "should be 4-byte aligned, addr = 0x%08x\n", addr);
  4427. orig = rtw89_read32(rtwdev, addr);
  4428. set = (orig & ~mask) | ((data << shift) & mask);
  4429. rtw89_write32(rtwdev, addr, set);
  4430. }
  4431. static inline void
  4432. rtw89_write16_mask(struct rtw89_dev *rtwdev, u32 addr, u32 mask, u16 data)
  4433. {
  4434. u32 shift;
  4435. u16 orig, set;
  4436. mask &= 0xffff;
  4437. shift = __ffs(mask);
  4438. orig = rtw89_read16(rtwdev, addr);
  4439. set = (orig & ~mask) | ((data << shift) & mask);
  4440. rtw89_write16(rtwdev, addr, set);
  4441. }
  4442. static inline void
  4443. rtw89_write8_mask(struct rtw89_dev *rtwdev, u32 addr, u32 mask, u8 data)
  4444. {
  4445. u32 shift;
  4446. u8 orig, set;
  4447. mask &= 0xff;
  4448. shift = __ffs(mask);
  4449. orig = rtw89_read8(rtwdev, addr);
  4450. set = (orig & ~mask) | ((data << shift) & mask);
  4451. rtw89_write8(rtwdev, addr, set);
  4452. }
  4453. static inline u32
  4454. rtw89_read_rf(struct rtw89_dev *rtwdev, enum rtw89_rf_path rf_path,
  4455. u32 addr, u32 mask)
  4456. {
  4457. u32 val;
  4458. mutex_lock(&rtwdev->rf_mutex);
  4459. val = rtwdev->chip->ops->read_rf(rtwdev, rf_path, addr, mask);
  4460. mutex_unlock(&rtwdev->rf_mutex);
  4461. return val;
  4462. }
  4463. static inline void
  4464. rtw89_write_rf(struct rtw89_dev *rtwdev, enum rtw89_rf_path rf_path,
  4465. u32 addr, u32 mask, u32 data)
  4466. {
  4467. mutex_lock(&rtwdev->rf_mutex);
  4468. rtwdev->chip->ops->write_rf(rtwdev, rf_path, addr, mask, data);
  4469. mutex_unlock(&rtwdev->rf_mutex);
  4470. }
  4471. static inline struct ieee80211_txq *rtw89_txq_to_txq(struct rtw89_txq *rtwtxq)
  4472. {
  4473. void *p = rtwtxq;
  4474. return container_of(p, struct ieee80211_txq, drv_priv);
  4475. }
  4476. static inline void rtw89_core_txq_init(struct rtw89_dev *rtwdev,
  4477. struct ieee80211_txq *txq)
  4478. {
  4479. struct rtw89_txq *rtwtxq;
  4480. if (!txq)
  4481. return;
  4482. rtwtxq = (struct rtw89_txq *)txq->drv_priv;
  4483. INIT_LIST_HEAD(&rtwtxq->list);
  4484. }
  4485. static inline struct ieee80211_vif *rtwvif_to_vif(struct rtw89_vif *rtwvif)
  4486. {
  4487. void *p = rtwvif;
  4488. return container_of(p, struct ieee80211_vif, drv_priv);
  4489. }
  4490. static inline struct ieee80211_vif *rtwvif_to_vif_safe(struct rtw89_vif *rtwvif)
  4491. {
  4492. return rtwvif ? rtwvif_to_vif(rtwvif) : NULL;
  4493. }
  4494. static inline struct rtw89_vif *vif_to_rtwvif_safe(struct ieee80211_vif *vif)
  4495. {
  4496. return vif ? (struct rtw89_vif *)vif->drv_priv : NULL;
  4497. }
  4498. static inline struct ieee80211_sta *rtwsta_to_sta(struct rtw89_sta *rtwsta)
  4499. {
  4500. void *p = rtwsta;
  4501. return container_of(p, struct ieee80211_sta, drv_priv);
  4502. }
  4503. static inline struct ieee80211_sta *rtwsta_to_sta_safe(struct rtw89_sta *rtwsta)
  4504. {
  4505. return rtwsta ? rtwsta_to_sta(rtwsta) : NULL;
  4506. }
  4507. static inline struct rtw89_sta *sta_to_rtwsta_safe(struct ieee80211_sta *sta)
  4508. {
  4509. return sta ? (struct rtw89_sta *)sta->drv_priv : NULL;
  4510. }
  4511. static inline u8 rtw89_hw_to_rate_info_bw(enum rtw89_bandwidth hw_bw)
  4512. {
  4513. if (hw_bw == RTW89_CHANNEL_WIDTH_160)
  4514. return RATE_INFO_BW_160;
  4515. else if (hw_bw == RTW89_CHANNEL_WIDTH_80)
  4516. return RATE_INFO_BW_80;
  4517. else if (hw_bw == RTW89_CHANNEL_WIDTH_40)
  4518. return RATE_INFO_BW_40;
  4519. else
  4520. return RATE_INFO_BW_20;
  4521. }
  4522. static inline
  4523. enum nl80211_band rtw89_hw_to_nl80211_band(enum rtw89_band hw_band)
  4524. {
  4525. switch (hw_band) {
  4526. default:
  4527. case RTW89_BAND_2G:
  4528. return NL80211_BAND_2GHZ;
  4529. case RTW89_BAND_5G:
  4530. return NL80211_BAND_5GHZ;
  4531. #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0)
  4532. case RTW89_BAND_6G:
  4533. return NL80211_BAND_6GHZ;
  4534. #endif
  4535. }
  4536. }
  4537. static inline
  4538. enum rtw89_band rtw89_nl80211_to_hw_band(enum nl80211_band nl_band)
  4539. {
  4540. switch (nl_band) {
  4541. default:
  4542. case NL80211_BAND_2GHZ:
  4543. return RTW89_BAND_2G;
  4544. case NL80211_BAND_5GHZ:
  4545. return RTW89_BAND_5G;
  4546. case NL80211_BAND_6GHZ:
  4547. return RTW89_BAND_6G;
  4548. }
  4549. }
  4550. static inline
  4551. enum rtw89_bandwidth nl_to_rtw89_bandwidth(enum nl80211_chan_width width)
  4552. {
  4553. switch (width) {
  4554. default:
  4555. WARN(1, "Not support bandwidth %d\n", width);
  4556. fallthrough;
  4557. case NL80211_CHAN_WIDTH_20_NOHT:
  4558. case NL80211_CHAN_WIDTH_20:
  4559. return RTW89_CHANNEL_WIDTH_20;
  4560. case NL80211_CHAN_WIDTH_40:
  4561. return RTW89_CHANNEL_WIDTH_40;
  4562. case NL80211_CHAN_WIDTH_80:
  4563. return RTW89_CHANNEL_WIDTH_80;
  4564. case NL80211_CHAN_WIDTH_160:
  4565. return RTW89_CHANNEL_WIDTH_160;
  4566. }
  4567. }
  4568. static inline
  4569. enum nl80211_he_ru_alloc rtw89_he_rua_to_ru_alloc(u16 rua)
  4570. {
  4571. switch (rua) {
  4572. default:
  4573. WARN(1, "Invalid RU allocation: %d\n", rua);
  4574. fallthrough;
  4575. case 0 ... 36:
  4576. return NL80211_RATE_INFO_HE_RU_ALLOC_26;
  4577. case 37 ... 52:
  4578. return NL80211_RATE_INFO_HE_RU_ALLOC_52;
  4579. case 53 ... 60:
  4580. return NL80211_RATE_INFO_HE_RU_ALLOC_106;
  4581. case 61 ... 64:
  4582. return NL80211_RATE_INFO_HE_RU_ALLOC_242;
  4583. case 65 ... 66:
  4584. return NL80211_RATE_INFO_HE_RU_ALLOC_484;
  4585. case 67:
  4586. return NL80211_RATE_INFO_HE_RU_ALLOC_996;
  4587. case 68:
  4588. return NL80211_RATE_INFO_HE_RU_ALLOC_2x996;
  4589. }
  4590. }
  4591. static inline
  4592. struct rtw89_addr_cam_entry *rtw89_get_addr_cam_of(struct rtw89_vif *rtwvif,
  4593. struct rtw89_sta *rtwsta)
  4594. {
  4595. if (rtwsta) {
  4596. struct ieee80211_sta *sta = rtwsta_to_sta(rtwsta);
  4597. if (rtwvif->net_type == RTW89_NET_TYPE_AP_MODE || sta->tdls)
  4598. return &rtwsta->addr_cam;
  4599. }
  4600. return &rtwvif->addr_cam;
  4601. }
  4602. static inline
  4603. struct rtw89_bssid_cam_entry *rtw89_get_bssid_cam_of(struct rtw89_vif *rtwvif,
  4604. struct rtw89_sta *rtwsta)
  4605. {
  4606. if (rtwsta) {
  4607. struct ieee80211_sta *sta = rtwsta_to_sta(rtwsta);
  4608. if (sta->tdls)
  4609. return &rtwsta->bssid_cam;
  4610. }
  4611. return &rtwvif->bssid_cam;
  4612. }
  4613. static inline
  4614. void rtw89_chip_set_channel_prepare(struct rtw89_dev *rtwdev,
  4615. struct rtw89_channel_help_params *p,
  4616. const struct rtw89_chan *chan,
  4617. enum rtw89_mac_idx mac_idx,
  4618. enum rtw89_phy_idx phy_idx)
  4619. {
  4620. rtwdev->chip->ops->set_channel_help(rtwdev, true, p, chan,
  4621. mac_idx, phy_idx);
  4622. }
  4623. static inline
  4624. void rtw89_chip_set_channel_done(struct rtw89_dev *rtwdev,
  4625. struct rtw89_channel_help_params *p,
  4626. const struct rtw89_chan *chan,
  4627. enum rtw89_mac_idx mac_idx,
  4628. enum rtw89_phy_idx phy_idx)
  4629. {
  4630. rtwdev->chip->ops->set_channel_help(rtwdev, false, p, chan,
  4631. mac_idx, phy_idx);
  4632. }
  4633. static inline
  4634. const struct cfg80211_chan_def *rtw89_chandef_get(struct rtw89_dev *rtwdev,
  4635. enum rtw89_sub_entity_idx idx)
  4636. {
  4637. struct rtw89_hal *hal = &rtwdev->hal;
  4638. enum rtw89_sub_entity_idx roc_idx = atomic_read(&hal->roc_entity_idx);
  4639. if (roc_idx == idx)
  4640. return &hal->roc_chandef;
  4641. return &hal->sub[idx].chandef;
  4642. }
  4643. static inline
  4644. const struct rtw89_chan *rtw89_chan_get(struct rtw89_dev *rtwdev,
  4645. enum rtw89_sub_entity_idx idx)
  4646. {
  4647. struct rtw89_hal *hal = &rtwdev->hal;
  4648. return &hal->sub[idx].chan;
  4649. }
  4650. static inline
  4651. const struct rtw89_chan_rcd *rtw89_chan_rcd_get(struct rtw89_dev *rtwdev,
  4652. enum rtw89_sub_entity_idx idx)
  4653. {
  4654. struct rtw89_hal *hal = &rtwdev->hal;
  4655. return &hal->sub[idx].rcd;
  4656. }
  4657. static inline
  4658. const struct rtw89_chan *rtw89_scan_chan_get(struct rtw89_dev *rtwdev)
  4659. {
  4660. struct ieee80211_vif *vif = rtwdev->scan_info.scanning_vif;
  4661. struct rtw89_vif *rtwvif = vif_to_rtwvif_safe(vif);
  4662. if (rtwvif)
  4663. return rtw89_chan_get(rtwdev, rtwvif->sub_entity_idx);
  4664. else
  4665. return rtw89_chan_get(rtwdev, RTW89_SUB_ENTITY_0);
  4666. }
  4667. static inline void rtw89_chip_fem_setup(struct rtw89_dev *rtwdev)
  4668. {
  4669. const struct rtw89_chip_info *chip = rtwdev->chip;
  4670. if (chip->ops->fem_setup)
  4671. chip->ops->fem_setup(rtwdev);
  4672. }
  4673. static inline void rtw89_chip_rfe_gpio(struct rtw89_dev *rtwdev)
  4674. {
  4675. const struct rtw89_chip_info *chip = rtwdev->chip;
  4676. if (chip->ops->rfe_gpio)
  4677. chip->ops->rfe_gpio(rtwdev);
  4678. }
  4679. static inline
  4680. void rtw89_chip_bb_preinit(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy_idx)
  4681. {
  4682. const struct rtw89_chip_info *chip = rtwdev->chip;
  4683. if (chip->ops->bb_preinit)
  4684. chip->ops->bb_preinit(rtwdev, phy_idx);
  4685. }
  4686. static inline void rtw89_chip_bb_sethw(struct rtw89_dev *rtwdev)
  4687. {
  4688. const struct rtw89_chip_info *chip = rtwdev->chip;
  4689. if (chip->ops->bb_sethw)
  4690. chip->ops->bb_sethw(rtwdev);
  4691. }
  4692. static inline void rtw89_chip_rfk_init(struct rtw89_dev *rtwdev)
  4693. {
  4694. const struct rtw89_chip_info *chip = rtwdev->chip;
  4695. if (chip->ops->rfk_init)
  4696. chip->ops->rfk_init(rtwdev);
  4697. }
  4698. static inline void rtw89_chip_rfk_channel(struct rtw89_dev *rtwdev)
  4699. {
  4700. const struct rtw89_chip_info *chip = rtwdev->chip;
  4701. if (chip->ops->rfk_channel)
  4702. chip->ops->rfk_channel(rtwdev);
  4703. }
  4704. static inline void rtw89_chip_rfk_band_changed(struct rtw89_dev *rtwdev,
  4705. enum rtw89_phy_idx phy_idx)
  4706. {
  4707. const struct rtw89_chip_info *chip = rtwdev->chip;
  4708. if (chip->ops->rfk_band_changed)
  4709. chip->ops->rfk_band_changed(rtwdev, phy_idx);
  4710. }
  4711. static inline void rtw89_chip_rfk_scan(struct rtw89_dev *rtwdev, bool start)
  4712. {
  4713. const struct rtw89_chip_info *chip = rtwdev->chip;
  4714. if (chip->ops->rfk_scan)
  4715. chip->ops->rfk_scan(rtwdev, start);
  4716. }
  4717. static inline void rtw89_chip_rfk_track(struct rtw89_dev *rtwdev)
  4718. {
  4719. const struct rtw89_chip_info *chip = rtwdev->chip;
  4720. if (chip->ops->rfk_track)
  4721. chip->ops->rfk_track(rtwdev);
  4722. }
  4723. static inline void rtw89_chip_set_txpwr_ctrl(struct rtw89_dev *rtwdev)
  4724. {
  4725. const struct rtw89_chip_info *chip = rtwdev->chip;
  4726. if (chip->ops->set_txpwr_ctrl)
  4727. chip->ops->set_txpwr_ctrl(rtwdev, RTW89_PHY_0);
  4728. }
  4729. static inline void rtw89_chip_power_trim(struct rtw89_dev *rtwdev)
  4730. {
  4731. const struct rtw89_chip_info *chip = rtwdev->chip;
  4732. if (chip->ops->power_trim)
  4733. chip->ops->power_trim(rtwdev);
  4734. }
  4735. static inline void rtw89_chip_init_txpwr_unit(struct rtw89_dev *rtwdev,
  4736. enum rtw89_phy_idx phy_idx)
  4737. {
  4738. const struct rtw89_chip_info *chip = rtwdev->chip;
  4739. if (chip->ops->init_txpwr_unit)
  4740. chip->ops->init_txpwr_unit(rtwdev, phy_idx);
  4741. }
  4742. static inline u8 rtw89_chip_get_thermal(struct rtw89_dev *rtwdev,
  4743. enum rtw89_rf_path rf_path)
  4744. {
  4745. const struct rtw89_chip_info *chip = rtwdev->chip;
  4746. if (!chip->ops->get_thermal)
  4747. return 0x10;
  4748. return chip->ops->get_thermal(rtwdev, rf_path);
  4749. }
  4750. static inline void rtw89_chip_query_ppdu(struct rtw89_dev *rtwdev,
  4751. struct rtw89_rx_phy_ppdu *phy_ppdu,
  4752. struct ieee80211_rx_status *status)
  4753. {
  4754. const struct rtw89_chip_info *chip = rtwdev->chip;
  4755. if (chip->ops->query_ppdu)
  4756. chip->ops->query_ppdu(rtwdev, phy_ppdu, status);
  4757. }
  4758. static inline void rtw89_chip_bb_ctrl_btc_preagc(struct rtw89_dev *rtwdev,
  4759. bool bt_en)
  4760. {
  4761. const struct rtw89_chip_info *chip = rtwdev->chip;
  4762. if (chip->ops->bb_ctrl_btc_preagc)
  4763. chip->ops->bb_ctrl_btc_preagc(rtwdev, bt_en);
  4764. }
  4765. static inline void rtw89_chip_cfg_txrx_path(struct rtw89_dev *rtwdev)
  4766. {
  4767. const struct rtw89_chip_info *chip = rtwdev->chip;
  4768. if (chip->ops->cfg_txrx_path)
  4769. chip->ops->cfg_txrx_path(rtwdev);
  4770. }
  4771. static inline
  4772. void rtw89_chip_cfg_txpwr_ul_tb_offset(struct rtw89_dev *rtwdev,
  4773. struct ieee80211_vif *vif)
  4774. {
  4775. struct rtw89_vif *rtwvif = (struct rtw89_vif *)vif->drv_priv;
  4776. const struct rtw89_chip_info *chip = rtwdev->chip;
  4777. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 0, 0))
  4778. if (!vif->bss_conf.he_support || !vif->cfg.assoc)
  4779. #else
  4780. if (!vif->bss_conf.he_support || !vif->bss_conf.assoc)
  4781. #endif
  4782. return;
  4783. if (chip->ops->set_txpwr_ul_tb_offset)
  4784. chip->ops->set_txpwr_ul_tb_offset(rtwdev, 0, rtwvif->mac_idx);
  4785. }
  4786. static inline void rtw89_load_txpwr_table(struct rtw89_dev *rtwdev,
  4787. const struct rtw89_txpwr_table *tbl)
  4788. {
  4789. tbl->load(rtwdev, tbl);
  4790. }
  4791. static inline u8 rtw89_regd_get(struct rtw89_dev *rtwdev, u8 band)
  4792. {
  4793. const struct rtw89_regd *regd = rtwdev->regulatory.regd;
  4794. return regd->txpwr_regd[band];
  4795. }
  4796. static inline void rtw89_ctrl_btg(struct rtw89_dev *rtwdev, bool btg)
  4797. {
  4798. const struct rtw89_chip_info *chip = rtwdev->chip;
  4799. if (chip->ops->ctrl_btg)
  4800. chip->ops->ctrl_btg(rtwdev, btg);
  4801. }
  4802. static inline
  4803. void rtw89_chip_query_rxdesc(struct rtw89_dev *rtwdev,
  4804. struct rtw89_rx_desc_info *desc_info,
  4805. u8 *data, u32 data_offset)
  4806. {
  4807. const struct rtw89_chip_info *chip = rtwdev->chip;
  4808. chip->ops->query_rxdesc(rtwdev, desc_info, data, data_offset);
  4809. }
  4810. static inline
  4811. void rtw89_chip_fill_txdesc(struct rtw89_dev *rtwdev,
  4812. struct rtw89_tx_desc_info *desc_info,
  4813. void *txdesc)
  4814. {
  4815. const struct rtw89_chip_info *chip = rtwdev->chip;
  4816. chip->ops->fill_txdesc(rtwdev, desc_info, txdesc);
  4817. }
  4818. static inline
  4819. void rtw89_chip_fill_txdesc_fwcmd(struct rtw89_dev *rtwdev,
  4820. struct rtw89_tx_desc_info *desc_info,
  4821. void *txdesc)
  4822. {
  4823. const struct rtw89_chip_info *chip = rtwdev->chip;
  4824. chip->ops->fill_txdesc_fwcmd(rtwdev, desc_info, txdesc);
  4825. }
  4826. static inline
  4827. void rtw89_chip_mac_cfg_gnt(struct rtw89_dev *rtwdev,
  4828. const struct rtw89_mac_ax_coex_gnt *gnt_cfg)
  4829. {
  4830. const struct rtw89_chip_info *chip = rtwdev->chip;
  4831. chip->ops->mac_cfg_gnt(rtwdev, gnt_cfg);
  4832. }
  4833. static inline void rtw89_chip_cfg_ctrl_path(struct rtw89_dev *rtwdev, bool wl)
  4834. {
  4835. const struct rtw89_chip_info *chip = rtwdev->chip;
  4836. chip->ops->cfg_ctrl_path(rtwdev, wl);
  4837. }
  4838. static inline
  4839. int rtw89_chip_stop_sch_tx(struct rtw89_dev *rtwdev, u8 mac_idx,
  4840. u32 *tx_en, enum rtw89_sch_tx_sel sel)
  4841. {
  4842. const struct rtw89_chip_info *chip = rtwdev->chip;
  4843. return chip->ops->stop_sch_tx(rtwdev, mac_idx, tx_en, sel);
  4844. }
  4845. static inline
  4846. int rtw89_chip_resume_sch_tx(struct rtw89_dev *rtwdev, u8 mac_idx, u32 tx_en)
  4847. {
  4848. const struct rtw89_chip_info *chip = rtwdev->chip;
  4849. return chip->ops->resume_sch_tx(rtwdev, mac_idx, tx_en);
  4850. }
  4851. static inline
  4852. int rtw89_chip_h2c_dctl_sec_cam(struct rtw89_dev *rtwdev,
  4853. struct rtw89_vif *rtwvif,
  4854. struct rtw89_sta *rtwsta)
  4855. {
  4856. const struct rtw89_chip_info *chip = rtwdev->chip;
  4857. if (!chip->ops->h2c_dctl_sec_cam)
  4858. return 0;
  4859. return chip->ops->h2c_dctl_sec_cam(rtwdev, rtwvif, rtwsta);
  4860. }
  4861. static inline u8 *get_hdr_bssid(struct ieee80211_hdr *hdr)
  4862. {
  4863. __le16 fc = hdr->frame_control;
  4864. if (ieee80211_has_tods(fc))
  4865. return hdr->addr1;
  4866. else if (ieee80211_has_fromds(fc))
  4867. return hdr->addr2;
  4868. else
  4869. return hdr->addr3;
  4870. }
  4871. static inline bool rtw89_sta_has_beamformer_cap(struct ieee80211_sta *sta)
  4872. {
  4873. #if LINUX_VERSION_CODE < KERNEL_VERSION(5,19,0)
  4874. if ((sta->vht_cap.cap & IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE) ||
  4875. (sta->vht_cap.cap & IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE) ||
  4876. (sta->he_cap.he_cap_elem.phy_cap_info[3] & IEEE80211_HE_PHY_CAP3_SU_BEAMFORMER) ||
  4877. (sta->he_cap.he_cap_elem.phy_cap_info[4] & IEEE80211_HE_PHY_CAP4_MU_BEAMFORMER))
  4878. return true;
  4879. #else
  4880. if ((sta->deflink.vht_cap.cap & IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE) ||
  4881. (sta->deflink.vht_cap.cap & IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE) ||
  4882. (sta->deflink.he_cap.he_cap_elem.phy_cap_info[3] &
  4883. IEEE80211_HE_PHY_CAP3_SU_BEAMFORMER) ||
  4884. (sta->deflink.he_cap.he_cap_elem.phy_cap_info[4] &
  4885. IEEE80211_HE_PHY_CAP4_MU_BEAMFORMER))
  4886. return true;
  4887. #endif
  4888. return false;
  4889. }
  4890. static inline struct rtw89_fw_suit *rtw89_fw_suit_get(struct rtw89_dev *rtwdev,
  4891. enum rtw89_fw_type type)
  4892. {
  4893. struct rtw89_fw_info *fw_info = &rtwdev->fw;
  4894. switch (type) {
  4895. case RTW89_FW_WOWLAN:
  4896. return &fw_info->wowlan;
  4897. case RTW89_FW_LOGFMT:
  4898. return &fw_info->log.suit;
  4899. case RTW89_FW_BBMCU0:
  4900. return &fw_info->bbmcu0;
  4901. case RTW89_FW_BBMCU1:
  4902. return &fw_info->bbmcu1;
  4903. default:
  4904. break;
  4905. }
  4906. return &fw_info->normal;
  4907. }
  4908. static inline struct sk_buff *rtw89_alloc_skb_for_rx(struct rtw89_dev *rtwdev,
  4909. unsigned int length)
  4910. {
  4911. struct sk_buff *skb;
  4912. if (rtwdev->hw->conf.flags & IEEE80211_CONF_MONITOR) {
  4913. skb = dev_alloc_skb(length + RTW89_RADIOTAP_ROOM);
  4914. if (!skb)
  4915. return NULL;
  4916. skb_reserve(skb, RTW89_RADIOTAP_ROOM);
  4917. return skb;
  4918. }
  4919. return dev_alloc_skb(length);
  4920. }
  4921. static inline void rtw89_core_tx_wait_complete(struct rtw89_dev *rtwdev,
  4922. struct rtw89_tx_skb_data *skb_data,
  4923. bool tx_done)
  4924. {
  4925. struct rtw89_tx_wait_info *wait;
  4926. rcu_read_lock();
  4927. wait = rcu_dereference(skb_data->wait);
  4928. if (!wait)
  4929. goto out;
  4930. wait->tx_done = tx_done;
  4931. complete(&wait->completion);
  4932. out:
  4933. rcu_read_unlock();
  4934. }
  4935. int rtw89_core_tx_write(struct rtw89_dev *rtwdev, struct ieee80211_vif *vif,
  4936. struct ieee80211_sta *sta, struct sk_buff *skb, int *qsel);
  4937. int rtw89_h2c_tx(struct rtw89_dev *rtwdev,
  4938. struct sk_buff *skb, bool fwdl);
  4939. void rtw89_core_tx_kick_off(struct rtw89_dev *rtwdev, u8 qsel);
  4940. int rtw89_core_tx_kick_off_and_wait(struct rtw89_dev *rtwdev, struct sk_buff *skb,
  4941. int qsel, unsigned int timeout);
  4942. void rtw89_core_fill_txdesc(struct rtw89_dev *rtwdev,
  4943. struct rtw89_tx_desc_info *desc_info,
  4944. void *txdesc);
  4945. void rtw89_core_fill_txdesc_v1(struct rtw89_dev *rtwdev,
  4946. struct rtw89_tx_desc_info *desc_info,
  4947. void *txdesc);
  4948. void rtw89_core_fill_txdesc_v2(struct rtw89_dev *rtwdev,
  4949. struct rtw89_tx_desc_info *desc_info,
  4950. void *txdesc);
  4951. void rtw89_core_fill_txdesc_fwcmd_v1(struct rtw89_dev *rtwdev,
  4952. struct rtw89_tx_desc_info *desc_info,
  4953. void *txdesc);
  4954. void rtw89_core_fill_txdesc_fwcmd_v2(struct rtw89_dev *rtwdev,
  4955. struct rtw89_tx_desc_info *desc_info,
  4956. void *txdesc);
  4957. void rtw89_core_rx(struct rtw89_dev *rtwdev,
  4958. struct rtw89_rx_desc_info *desc_info,
  4959. struct sk_buff *skb);
  4960. void rtw89_core_query_rxdesc(struct rtw89_dev *rtwdev,
  4961. struct rtw89_rx_desc_info *desc_info,
  4962. u8 *data, u32 data_offset);
  4963. void rtw89_core_query_rxdesc_v2(struct rtw89_dev *rtwdev,
  4964. struct rtw89_rx_desc_info *desc_info,
  4965. u8 *data, u32 data_offset);
  4966. void rtw89_core_napi_start(struct rtw89_dev *rtwdev);
  4967. void rtw89_core_napi_stop(struct rtw89_dev *rtwdev);
  4968. void rtw89_core_napi_init(struct rtw89_dev *rtwdev);
  4969. void rtw89_core_napi_deinit(struct rtw89_dev *rtwdev);
  4970. int rtw89_core_sta_add(struct rtw89_dev *rtwdev,
  4971. struct ieee80211_vif *vif,
  4972. struct ieee80211_sta *sta);
  4973. int rtw89_core_sta_assoc(struct rtw89_dev *rtwdev,
  4974. struct ieee80211_vif *vif,
  4975. struct ieee80211_sta *sta);
  4976. int rtw89_core_sta_disassoc(struct rtw89_dev *rtwdev,
  4977. struct ieee80211_vif *vif,
  4978. struct ieee80211_sta *sta);
  4979. int rtw89_core_sta_disconnect(struct rtw89_dev *rtwdev,
  4980. struct ieee80211_vif *vif,
  4981. struct ieee80211_sta *sta);
  4982. int rtw89_core_sta_remove(struct rtw89_dev *rtwdev,
  4983. struct ieee80211_vif *vif,
  4984. struct ieee80211_sta *sta);
  4985. void rtw89_core_set_tid_config(struct rtw89_dev *rtwdev,
  4986. struct ieee80211_sta *sta,
  4987. struct cfg80211_tid_config *tid_config);
  4988. int rtw89_core_init(struct rtw89_dev *rtwdev);
  4989. void rtw89_core_deinit(struct rtw89_dev *rtwdev);
  4990. int rtw89_core_register(struct rtw89_dev *rtwdev);
  4991. void rtw89_core_unregister(struct rtw89_dev *rtwdev);
  4992. struct rtw89_dev *rtw89_alloc_ieee80211_hw(struct device *device,
  4993. u32 bus_data_size,
  4994. const struct rtw89_chip_info *chip);
  4995. void rtw89_free_ieee80211_hw(struct rtw89_dev *rtwdev);
  4996. void rtw89_core_set_chip_txpwr(struct rtw89_dev *rtwdev);
  4997. void rtw89_get_default_chandef(struct cfg80211_chan_def *chandef);
  4998. void rtw89_get_channel_params(const struct cfg80211_chan_def *chandef,
  4999. struct rtw89_chan *chan);
  5000. void rtw89_set_channel(struct rtw89_dev *rtwdev);
  5001. void rtw89_get_channel(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif,
  5002. struct rtw89_chan *chan);
  5003. u8 rtw89_core_acquire_bit_map(unsigned long *addr, unsigned long size);
  5004. void rtw89_core_release_bit_map(unsigned long *addr, u8 bit);
  5005. void rtw89_core_release_all_bits_map(unsigned long *addr, unsigned int nbits);
  5006. int rtw89_core_acquire_sta_ba_entry(struct rtw89_dev *rtwdev,
  5007. struct rtw89_sta *rtwsta, u8 tid, u8 *cam_idx);
  5008. int rtw89_core_release_sta_ba_entry(struct rtw89_dev *rtwdev,
  5009. struct rtw89_sta *rtwsta, u8 tid, u8 *cam_idx);
  5010. void rtw89_vif_type_mapping(struct ieee80211_vif *vif, bool assoc);
  5011. int rtw89_chip_info_setup(struct rtw89_dev *rtwdev);
  5012. bool rtw89_ra_report_to_bitrate(struct rtw89_dev *rtwdev, u8 rpt_rate, u16 *bitrate);
  5013. int rtw89_regd_setup(struct rtw89_dev *rtwdev);
  5014. int rtw89_regd_init(struct rtw89_dev *rtwdev,
  5015. void (*reg_notifier)(struct wiphy *wiphy, struct regulatory_request *request));
  5016. void rtw89_regd_notifier(struct wiphy *wiphy, struct regulatory_request *request);
  5017. void rtw89_traffic_stats_init(struct rtw89_dev *rtwdev,
  5018. struct rtw89_traffic_stats *stats);
  5019. int rtw89_wait_for_cond(struct rtw89_wait_info *wait, unsigned int cond);
  5020. void rtw89_complete_cond(struct rtw89_wait_info *wait, unsigned int cond,
  5021. const struct rtw89_completion_data *data);
  5022. int rtw89_core_start(struct rtw89_dev *rtwdev);
  5023. void rtw89_core_stop(struct rtw89_dev *rtwdev);
  5024. #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0)
  5025. /**
  5026. * read_poll_timeout_atomic - Periodically poll an address until a condition is
  5027. * met or a timeout occurs
  5028. * @op: accessor function (takes @args as its arguments)
  5029. * @val: Variable to read the value into
  5030. * @cond: Break condition (usually involving @val)
  5031. * @delay_us: Time to udelay between reads in us (0 tight-loops). Should
  5032. * be less than ~10us since udelay is used (see
  5033. * Documentation/timers/timers-howto.rst).
  5034. * @timeout_us: Timeout in us, 0 means never timeout
  5035. * @delay_before_read: if it is true, delay @delay_us before read.
  5036. * @args: arguments for @op poll
  5037. *
  5038. * Returns 0 on success and -ETIMEDOUT upon a timeout. In either
  5039. * case, the last read value at @args is stored in @val.
  5040. *
  5041. * When available, you'll probably want to use one of the specialized
  5042. * macros defined below rather than this macro directly.
  5043. */
  5044. #define read_poll_timeout_atomic(op, val, cond, delay_us, timeout_us, \
  5045. delay_before_read, args...) \
  5046. ({ \
  5047. u64 __timeout_us = (timeout_us); \
  5048. unsigned long __delay_us = (delay_us); \
  5049. ktime_t __timeout = ktime_add_us(ktime_get(), __timeout_us); \
  5050. if (delay_before_read && __delay_us) \
  5051. udelay(__delay_us); \
  5052. for (;;) { \
  5053. (val) = op(args); \
  5054. if (cond) \
  5055. break; \
  5056. if (__timeout_us && \
  5057. ktime_compare(ktime_get(), __timeout) > 0) { \
  5058. (val) = op(args); \
  5059. break; \
  5060. } \
  5061. if (__delay_us) \
  5062. udelay(__delay_us); \
  5063. } \
  5064. (cond) ? 0 : -ETIMEDOUT; \
  5065. })
  5066. #if defined(CONFIG_SUSE_VERSION)
  5067. #if CONFIG_SUSE_PATCHLEVEL && CONFIG_SUSE_VERSION == 15 && CONFIG_SUSE_PATCHLEVEL == 3
  5068. #define SUSE 1
  5069. #else
  5070. #define SUSE 0
  5071. #endif
  5072. #else
  5073. #define SUSE 0
  5074. #endif
  5075. #endif
  5076. #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0)
  5077. /* see Documentation/timers/timers-howto.rst for the thresholds */
  5078. static inline void fsleep(unsigned long usecs)
  5079. {
  5080. if (usecs <= 10)
  5081. udelay(usecs);
  5082. else if (usecs <= 20000)
  5083. usleep_range(usecs, 2 * usecs);
  5084. else
  5085. msleep(DIV_ROUND_UP(usecs, 1000));
  5086. }
  5087. #endif
  5088. #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0) && (SUSE == 0)
  5089. static inline struct sk_buff *ieee80211_tx_dequeue_ni(struct ieee80211_hw *hw,
  5090. struct ieee80211_txq *txq)
  5091. {
  5092. struct sk_buff *skb;
  5093. local_bh_disable();
  5094. skb = ieee80211_tx_dequeue(hw, txq);
  5095. local_bh_enable();
  5096. return skb;
  5097. }
  5098. #endif
  5099. #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 7, 0)
  5100. /**
  5101. * read_poll_timeout_atomic - Periodically poll an address until a condition is
  5102. * met or a timeout occurs
  5103. * @op: accessor function (takes @args as its arguments)
  5104. * @val: Variable to read the value into
  5105. * @cond: Break condition (usually involving @val)
  5106. * @delay_us: Time to udelay between reads in us (0 tight-loops). Should
  5107. * be less than ~10us since udelay is used (see
  5108. * Documentation/timers/timers-howto.rst).
  5109. * @timeout_us: Timeout in us, 0 means never timeout
  5110. * @delay_before_read: if it is true, delay @delay_us before read.
  5111. * @args: arguments for @op poll
  5112. *
  5113. * Returns 0 on success and -ETIMEDOUT upon a timeout. In either
  5114. * case, the last read value at @args is stored in @val.
  5115. *
  5116. * When available, you'll probably want to use one of the specialized
  5117. * macros defined below rather than this macro directly.
  5118. */
  5119. #define read_poll_timeout_atomic(op, val, cond, delay_us, timeout_us, \
  5120. delay_before_read, args...) \
  5121. ({ \
  5122. u64 __timeout_us = (timeout_us); \
  5123. unsigned long __delay_us = (delay_us); \
  5124. ktime_t __timeout = ktime_add_us(ktime_get(), __timeout_us); \
  5125. if (delay_before_read && __delay_us) \
  5126. udelay(__delay_us); \
  5127. for (;;) { \
  5128. (val) = op(args); \
  5129. if (cond) \
  5130. break; \
  5131. if (__timeout_us && \
  5132. ktime_compare(ktime_get(), __timeout) > 0) { \
  5133. (val) = op(args); \
  5134. break; \
  5135. } \
  5136. if (__delay_us) \
  5137. udelay(__delay_us); \
  5138. } \
  5139. (cond) ? 0 : -ETIMEDOUT; \
  5140. })
  5141. /**
  5142. * read_poll_timeout - Periodically poll an address until a condition is
  5143. * met or a timeout occurs
  5144. * @op: accessor function (takes @args as its arguments)
  5145. * @val: Variable to read the value into
  5146. * @cond: Break condition (usually involving @val)
  5147. * @sleep_us: Maximum time to sleep between reads in us (0
  5148. * tight-loops). Should be less than ~20ms since usleep_range
  5149. * is used (see Documentation/timers/timers-howto.rst).
  5150. * @timeout_us: Timeout in us, 0 means never timeout
  5151. * @sleep_before_read: if it is true, sleep @sleep_us before read.
  5152. * @args: arguments for @op poll
  5153. *
  5154. * Returns 0 on success and -ETIMEDOUT upon a timeout. In either
  5155. * case, the last read value at @args is stored in @val. Must not
  5156. * be called from atomic context if sleep_us or timeout_us are used.
  5157. *
  5158. * When available, you'll probably want to use one of the specialized
  5159. * macros defined below rather than this macro directly.
  5160. */
  5161. #define read_poll_timeout(op, val, cond, sleep_us, timeout_us, \
  5162. sleep_before_read, args...) \
  5163. ({ \
  5164. u64 __timeout_us = (timeout_us); \
  5165. unsigned long __sleep_us = (sleep_us); \
  5166. ktime_t __timeout = ktime_add_us(ktime_get(), __timeout_us); \
  5167. might_sleep_if((__sleep_us) != 0); \
  5168. if (sleep_before_read && __sleep_us) \
  5169. usleep_range((__sleep_us >> 2) + 1, __sleep_us); \
  5170. for (;;) { \
  5171. (val) = op(args); \
  5172. if (cond) \
  5173. break; \
  5174. if (__timeout_us && \
  5175. ktime_compare(ktime_get(), __timeout) > 0) { \
  5176. (val) = op(args); \
  5177. break; \
  5178. } \
  5179. if (__sleep_us) \
  5180. usleep_range((__sleep_us >> 2) + 1, __sleep_us); \
  5181. } \
  5182. (cond) ? 0 : -ETIMEDOUT; \
  5183. })
  5184. #define BSS_CHANGED_HE_BSS_COLOR 1<<29
  5185. #endif
  5186. void rtw89_core_update_beacon_work(struct work_struct *work);
  5187. void rtw89_roc_work(struct work_struct *work);
  5188. void rtw89_roc_start(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif);
  5189. void rtw89_roc_end(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif);
  5190. void rtw89_core_scan_start(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif,
  5191. const u8 *mac_addr, bool hw_scan);
  5192. void rtw89_core_scan_complete(struct rtw89_dev *rtwdev,
  5193. struct ieee80211_vif *vif, bool hw_scan);
  5194. void rtw89_reg_6ghz_power_recalc(struct rtw89_dev *rtwdev,
  5195. struct rtw89_vif *rtwvif, bool active);
  5196. void rtw89_core_update_p2p_ps(struct rtw89_dev *rtwdev, struct ieee80211_vif *vif);
  5197. void rtw89_core_ntfy_btc_event(struct rtw89_dev *rtwdev, enum rtw89_btc_hmsg event);
  5198. #endif