dhd.h 127 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461
  1. /*
  2. * Header file describing the internal (inter-module) DHD interfaces.
  3. *
  4. * Provides type definitions and function prototypes used to link the
  5. * DHD OS, bus, and protocol modules.
  6. *
  7. * Portions of this code are copyright (c) 2020 Cypress Semiconductor Corporation
  8. *
  9. * Copyright (C) 1999-2020, Broadcom Corporation
  10. *
  11. * Unless you and Broadcom execute a separate written software license
  12. * agreement governing use of this software, this software is licensed to you
  13. * under the terms of the GNU General Public License version 2 (the "GPL"),
  14. * available at http://www.broadcom.com/licenses/GPLv2.php, with the
  15. * following added to such license:
  16. *
  17. * As a special exception, the copyright holders of this software give you
  18. * permission to link this software with independent modules, and to copy and
  19. * distribute the resulting executable under terms of your choice, provided that
  20. * you also meet, for each linked independent module, the terms and conditions of
  21. * the license of that module. An independent module is a module which is not
  22. * derived from this software. The special exception does not apply to any
  23. * modifications of the software.
  24. *
  25. * Notwithstanding the above, under no circumstances may you combine this
  26. * software in any way with any other Broadcom software provided under a license
  27. * other than the GPL, without Broadcom's express prior written consent.
  28. *
  29. *
  30. * <<Broadcom-WL-IPTag/Open:>>
  31. *
  32. * $Id: dhd.h 701844 2017-05-26 18:56:40Z $
  33. */
  34. /****************
  35. * Common types *
  36. */
  37. #ifndef _dhd_h_
  38. #define _dhd_h_
  39. #include <linux/init.h>
  40. #include <linux/kernel.h>
  41. #include <linux/slab.h>
  42. #include <linux/skbuff.h>
  43. #include <linux/netdevice.h>
  44. #include <linux/etherdevice.h>
  45. #include <linux/random.h>
  46. #include <linux/spinlock.h>
  47. #include <linux/ethtool.h>
  48. #include <linux/fs.h>
  49. #include <linux/proc_fs.h>
  50. #include <asm/uaccess.h>
  51. #include <asm/unaligned.h>
  52. #if defined(CONFIG_PM_WAKELOCKS) || defined(CONFIG_HAS_WAKELOCK)
  53. #include <linux/wakelock.h>
  54. #endif /* CONFIG_PM_WAKELOCKS || CONFIG_HAS_WAKELOCK */
  55. #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
  56. #include <linux/sched/types.h>
  57. #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) */
  58. /* The kernel threading is sdio-specific */
  59. struct task_struct;
  60. struct sched_param;
  61. #if defined(BT_OVER_SDIO)
  62. #include <dhd_bt_interface.h>
  63. #endif /* defined (BT_OVER_SDIO) */
  64. int setScheduler(struct task_struct *p, int policy, struct sched_param *param);
  65. int get_scheduler_policy(struct task_struct *p);
  66. #define MAX_EVENT 16
  67. #define ALL_INTERFACES 0xff
  68. /* H2D and D2H ring dump is enabled by default */
  69. #ifdef PCIE_FULL_DONGLE
  70. #define DHD_DUMP_PCIE_RINGS
  71. #endif /* PCIE_FULL_DONGLE */
  72. #include <wlioctl.h>
  73. #include <bcmstdlib_s.h>
  74. #include <dhdioctl.h>
  75. #include <wlfc_proto.h>
  76. #include <hnd_armtrap.h>
  77. #if defined(DUMP_IOCTL_IOV_LIST) || defined(DHD_DEBUG)
  78. #include <bcmutils.h>
  79. #endif /* DUMP_IOCTL_IOV_LIST || DHD_DEBUG */
  80. #if defined(BCMWDF)
  81. #include <wdf.h>
  82. #include <WdfMiniport.h>
  83. #endif /* (BCMWDF) */
  84. #ifdef WL_CFGVENDOR_SEND_HANG_EVENT
  85. #include <rte_ioctl.h>
  86. #endif /* WL_CFGVENDOR_SEND_HANG_EVENT */
  87. #ifdef DHD_ERPOM
  88. #include <pom.h>
  89. #endif /* DHD_ERPOM */
  90. #include <dngl_stats.h>
  91. #ifdef DEBUG_DPC_THREAD_WATCHDOG
  92. #define MAX_RESCHED_CNT 600
  93. #endif /* DEBUG_DPC_THREAD_WATCHDOG */
  94. #if defined(KEEP_ALIVE)
  95. /* Default KEEP_ALIVE Period is 55 sec to prevent AP from sending Keep Alive probe frame */
  96. #define KEEP_ALIVE_PERIOD 55000
  97. #define NULL_PKT_STR "null_pkt"
  98. #endif /* KEEP_ALIVE */
  99. /* By default enabled from here, later the WQ code will be removed */
  100. #define DHD_USE_KTHREAD_FOR_LOGTRACE
  101. /*
  102. * Earlier DHD used to have it own time stamp for printk and
  103. * Dongle used to have its own time stamp for console messages
  104. * With this flag, DHD and Dongle console messges will have same time zone
  105. */
  106. #define DHD_H2D_LOG_TIME_SYNC
  107. /* Forward decls */
  108. struct dhd_bus;
  109. struct dhd_prot;
  110. struct dhd_info;
  111. struct dhd_ioctl;
  112. struct dhd_dbg;
  113. struct dhd_ts;
  114. #ifdef DNGL_AXI_ERROR_LOGGING
  115. struct dhd_axi_error_dump;
  116. #endif /* DNGL_AXI_ERROR_LOGGING */
  117. /* The level of bus communication with the dongle */
  118. enum dhd_bus_state {
  119. DHD_BUS_DOWN, /* Not ready for frame transfers */
  120. DHD_BUS_LOAD, /* Download access only (CPU reset) */
  121. DHD_BUS_DATA, /* Ready for frame transfers */
  122. DHD_BUS_SUSPEND, /* Bus has been suspended */
  123. DHD_BUS_DOWN_IN_PROGRESS, /* Bus going Down */
  124. };
  125. /* The level of bus communication with the dongle */
  126. enum dhd_bus_devreset_type {
  127. DHD_BUS_DEVRESET_ON = 0, /* ON */
  128. DHD_BUS_DEVRESET_OFF = 1, /* OFF */
  129. DHD_BUS_DEVRESET_FLR = 2, /* FLR */
  130. DHD_BUS_DEVRESET_FLR_FORCE_FAIL = 3, /* FLR FORCE FAIL */
  131. DHD_BUS_DEVRESET_QUIESCE = 4, /* FLR */
  132. };
  133. /*
  134. * Bit fields to Indicate clean up process that wait till they are finished.
  135. * Future synchronizable processes can add their bit filed below and update
  136. * their functionalities accordingly
  137. */
  138. #define DHD_BUS_BUSY_IN_TX 0x01
  139. #define DHD_BUS_BUSY_IN_SEND_PKT 0x02
  140. #define DHD_BUS_BUSY_IN_DPC 0x04
  141. #define DHD_BUS_BUSY_IN_WD 0x08
  142. #define DHD_BUS_BUSY_IN_IOVAR 0x10
  143. #define DHD_BUS_BUSY_IN_DHD_IOVAR 0x20
  144. #define DHD_BUS_BUSY_SUSPEND_IN_PROGRESS 0x40
  145. #define DHD_BUS_BUSY_RESUME_IN_PROGRESS 0x80
  146. #define DHD_BUS_BUSY_RPM_SUSPEND_IN_PROGRESS 0x100
  147. #define DHD_BUS_BUSY_RPM_SUSPEND_DONE 0x200
  148. #define DHD_BUS_BUSY_RPM_RESUME_IN_PROGRESS 0x400
  149. #define DHD_BUS_BUSY_RPM_ALL (DHD_BUS_BUSY_RPM_SUSPEND_DONE | \
  150. DHD_BUS_BUSY_RPM_SUSPEND_IN_PROGRESS | \
  151. DHD_BUS_BUSY_RPM_RESUME_IN_PROGRESS)
  152. #define DHD_BUS_BUSY_IN_CHECKDIED 0x800
  153. #define DHD_BUS_BUSY_IN_MEMDUMP 0x1000
  154. #define DHD_BUS_BUSY_IN_SSSRDUMP 0x2000
  155. #define DHD_BUS_BUSY_IN_LOGDUMP 0x4000
  156. #define DHD_BUS_BUSY_IN_HALDUMP 0x8000
  157. #define DHD_BUS_BUSY_SET_IN_TX(dhdp) \
  158. (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_IN_TX
  159. #define DHD_BUS_BUSY_SET_IN_SEND_PKT(dhdp) \
  160. (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_IN_SEND_PKT
  161. #define DHD_BUS_BUSY_SET_IN_DPC(dhdp) \
  162. (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_IN_DPC
  163. #define DHD_BUS_BUSY_SET_IN_WD(dhdp) \
  164. (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_IN_WD
  165. #define DHD_BUS_BUSY_SET_IN_IOVAR(dhdp) \
  166. (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_IN_IOVAR
  167. #define DHD_BUS_BUSY_SET_IN_DHD_IOVAR(dhdp) \
  168. (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_IN_DHD_IOVAR
  169. #define DHD_BUS_BUSY_SET_SUSPEND_IN_PROGRESS(dhdp) \
  170. (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_SUSPEND_IN_PROGRESS
  171. #define DHD_BUS_BUSY_SET_RESUME_IN_PROGRESS(dhdp) \
  172. (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_RESUME_IN_PROGRESS
  173. #define DHD_BUS_BUSY_SET_RPM_SUSPEND_IN_PROGRESS(dhdp) \
  174. (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_RPM_SUSPEND_IN_PROGRESS
  175. #define DHD_BUS_BUSY_SET_RPM_SUSPEND_DONE(dhdp) \
  176. (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_RPM_SUSPEND_DONE
  177. #define DHD_BUS_BUSY_SET_RPM_RESUME_IN_PROGRESS(dhdp) \
  178. (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_RPM_RESUME_IN_PROGRESS
  179. #define DHD_BUS_BUSY_SET_IN_CHECKDIED(dhdp) \
  180. (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_IN_CHECKDIED
  181. #define DHD_BUS_BUSY_SET_IN_MEMDUMP(dhdp) \
  182. (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_IN_MEMDUMP
  183. #define DHD_BUS_BUSY_SET_IN_SSSRDUMP(dhdp) \
  184. (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_IN_SSSRDUMP
  185. #define DHD_BUS_BUSY_SET_IN_LOGDUMP(dhdp) \
  186. (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_IN_LOGDUMP
  187. #define DHD_BUS_BUSY_SET_IN_HALDUMP(dhdp) \
  188. (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_IN_HALDUMP
  189. #define DHD_BUS_BUSY_CLEAR_IN_TX(dhdp) \
  190. (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_IN_TX
  191. #define DHD_BUS_BUSY_CLEAR_IN_SEND_PKT(dhdp) \
  192. (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_IN_SEND_PKT
  193. #define DHD_BUS_BUSY_CLEAR_IN_DPC(dhdp) \
  194. (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_IN_DPC
  195. #define DHD_BUS_BUSY_CLEAR_IN_WD(dhdp) \
  196. (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_IN_WD
  197. #define DHD_BUS_BUSY_CLEAR_IN_IOVAR(dhdp) \
  198. (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_IN_IOVAR
  199. #define DHD_BUS_BUSY_CLEAR_IN_DHD_IOVAR(dhdp) \
  200. (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_IN_DHD_IOVAR
  201. #define DHD_BUS_BUSY_CLEAR_SUSPEND_IN_PROGRESS(dhdp) \
  202. (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_SUSPEND_IN_PROGRESS
  203. #define DHD_BUS_BUSY_CLEAR_RESUME_IN_PROGRESS(dhdp) \
  204. (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_RESUME_IN_PROGRESS
  205. #define DHD_BUS_BUSY_CLEAR_RPM_SUSPEND_IN_PROGRESS(dhdp) \
  206. (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_RPM_SUSPEND_IN_PROGRESS
  207. #define DHD_BUS_BUSY_CLEAR_RPM_SUSPEND_DONE(dhdp) \
  208. (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_RPM_SUSPEND_DONE
  209. #define DHD_BUS_BUSY_CLEAR_RPM_RESUME_IN_PROGRESS(dhdp) \
  210. (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_RPM_RESUME_IN_PROGRESS
  211. #define DHD_BUS_BUSY_CLEAR_IN_CHECKDIED(dhdp) \
  212. (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_IN_CHECKDIED
  213. #define DHD_BUS_BUSY_CLEAR_IN_MEMDUMP(dhdp) \
  214. (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_IN_MEMDUMP
  215. #define DHD_BUS_BUSY_CLEAR_IN_SSSRDUMP(dhdp) \
  216. (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_IN_SSSRDUMP
  217. #define DHD_BUS_BUSY_CLEAR_IN_LOGDUMP(dhdp) \
  218. (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_IN_LOGDUMP
  219. #define DHD_BUS_BUSY_CLEAR_IN_HALDUMP(dhdp) \
  220. (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_IN_HALDUMP
  221. #define DHD_BUS_BUSY_CHECK_IN_TX(dhdp) \
  222. ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_IN_TX)
  223. #define DHD_BUS_BUSY_CHECK_IN_SEND_PKT(dhdp) \
  224. ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_IN_SEND_PKT)
  225. #define DHD_BUS_BUSY_CHECK_IN_DPC(dhdp) \
  226. ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_IN_DPC)
  227. #define DHD_BUS_BUSY_CHECK_IN_WD(dhdp) \
  228. ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_IN_WD)
  229. #define DHD_BUS_BUSY_CHECK_IN_IOVAR(dhdp) \
  230. ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_IN_IOVAR)
  231. #define DHD_BUS_BUSY_CHECK_IN_DHD_IOVAR(dhdp) \
  232. ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_IN_DHD_IOVAR)
  233. #define DHD_BUS_BUSY_CHECK_SUSPEND_IN_PROGRESS(dhdp) \
  234. ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_SUSPEND_IN_PROGRESS)
  235. #define DHD_BUS_BUSY_CHECK_RESUME_IN_PROGRESS(dhdp) \
  236. ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_RESUME_IN_PROGRESS)
  237. #define DHD_BUS_BUSY_CHECK_RPM_SUSPEND_IN_PROGRESS(dhdp) \
  238. ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_RPM_SUSPEND_IN_PROGRESS)
  239. #define DHD_BUS_BUSY_CHECK_RPM_SUSPEND_DONE(dhdp) \
  240. ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_RPM_SUSPEND_DONE)
  241. #define DHD_BUS_BUSY_CHECK_RPM_RESUME_IN_PROGRESS(dhdp) \
  242. ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_RPM_RESUME_IN_PROGRESS)
  243. #define DHD_BUS_BUSY_CHECK_RPM_ALL(dhdp) \
  244. ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_RPM_ALL)
  245. #define DHD_BUS_BUSY_CHECK_IN_CHECKDIED(dhdp) \
  246. ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_IN_CHECKDIED)
  247. #define DHD_BUS_BUSY_CHECK_IN_MEMDUMP(dhdp) \
  248. ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_IN_MEMDUMP)
  249. #define DHD_BUS_BUSY_CHECK_IN_SSSRDUMP(dhdp) \
  250. ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_IN_SSSRDUMP)
  251. #define DHD_BUS_BUSY_CHECK_IN_LOGDUMP(dhdp) \
  252. ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_IN_LOGDUMP)
  253. #define DHD_BUS_BUSY_CHECK_IN_HALDUMP(dhdp) \
  254. ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_IN_HALDUMP)
  255. #define DHD_BUS_BUSY_CHECK_IDLE(dhdp) \
  256. ((dhdp)->dhd_bus_busy_state == 0)
  257. #define DHD_BUS_CHECK_SUSPEND_OR_SUSPEND_IN_PROGRESS(dhdp) \
  258. ((dhdp)->busstate == DHD_BUS_SUSPEND || DHD_BUS_BUSY_CHECK_SUSPEND_IN_PROGRESS(dhdp))
  259. #define DHD_BUS_CHECK_ANY_SUSPEND_IN_PROGRESS(dhdp) \
  260. (DHD_BUS_BUSY_CHECK_SUSPEND_IN_PROGRESS(dhdp) || \
  261. DHD_BUS_BUSY_CHECK_RPM_SUSPEND_IN_PROGRESS(dhdp))
  262. #define DHD_BUS_CHECK_SUSPEND_OR_ANY_SUSPEND_IN_PROGRESS(dhdp) \
  263. ((dhdp)->busstate == DHD_BUS_SUSPEND || DHD_BUS_CHECK_ANY_SUSPEND_IN_PROGRESS(dhdp))
  264. #define DHD_BUS_CHECK_DOWN_OR_DOWN_IN_PROGRESS(dhdp) \
  265. ((dhdp)->busstate == DHD_BUS_DOWN || (dhdp)->busstate == DHD_BUS_DOWN_IN_PROGRESS)
  266. /* IOVar flags for common error checks */
  267. #define DHD_IOVF_PWRREQ_BYPASS (1<<0) /* flags to prevent bp access during host sleep state */
  268. #define MAX_MTU_SZ (1600u)
  269. /* (u64)result = (u64)dividend / (u64)divisor */
  270. #define DIV_U64_BY_U64(dividend, divisor) div64_u64(dividend, divisor)
  271. /* (u64)result = (u64)dividend / (u32)divisor */
  272. #define DIV_U64_BY_U32(dividend, divisor) div_u64(dividend, divisor)
  273. /* Be careful while using this, as it divides dividend also
  274. * (u32)remainder = (u64)dividend % (u32)divisor
  275. * (u64)dividend = (u64)dividend / (u32)divisor
  276. */
  277. #define DIV_AND_MOD_U64_BY_U32(dividend, divisor) do_div(dividend, divisor)
  278. /* (u32)remainder = (u64)dividend % (u32)divisor */
  279. #define MOD_U64_BY_U32(dividend, divisor) ({ \
  280. uint64 temp_dividend = (dividend); \
  281. uint32 rem = DIV_AND_MOD_U64_BY_U32(temp_dividend, (divisor)); \
  282. rem; \
  283. })
  284. #define SEC_USEC_FMT \
  285. "%5llu.%06u"
  286. /* t: time in nano second */
  287. #define GET_SEC_USEC(t) \
  288. DIV_U64_BY_U32(t, NSEC_PER_SEC), \
  289. ((uint32)(MOD_U64_BY_U32(t, NSEC_PER_SEC) / (uint32)NSEC_PER_USEC))
  290. /* Download Types */
  291. typedef enum download_type {
  292. FW,
  293. NVRAM,
  294. CLM_BLOB,
  295. TXCAP_BLOB
  296. } download_type_t;
  297. /* For supporting multiple interfaces */
  298. #define DHD_MAX_IFS 16
  299. #define DHD_MAX_STATIC_IFS 1
  300. #define DHD_DEL_IF -0xE
  301. #define DHD_BAD_IF -0xF
  302. #define DHD_DUMMY_INFO_IF 0xDEAF /* Hack i/f to handle events from INFO Ring */
  303. #define DHD_EVENT_IF DHD_DUMMY_INFO_IF
  304. enum dhd_op_flags {
  305. /* Firmware requested operation mode */
  306. DHD_FLAG_STA_MODE = (1 << (0)), /* STA only */
  307. DHD_FLAG_HOSTAP_MODE = (1 << (1)), /* SOFTAP only */
  308. DHD_FLAG_P2P_MODE = (1 << (2)), /* P2P Only */
  309. /* STA + P2P */
  310. DHD_FLAG_CONCURR_SINGLE_CHAN_MODE = (DHD_FLAG_STA_MODE | DHD_FLAG_P2P_MODE),
  311. /* STA + SoftAP */
  312. DHD_FLAG_CONCURR_STA_HOSTAP_MODE = (DHD_FLAG_STA_MODE | DHD_FLAG_HOSTAP_MODE),
  313. DHD_FLAG_CONCURR_MULTI_CHAN_MODE = (1 << (4)), /* STA + P2P */
  314. /* Current P2P mode for P2P connection */
  315. DHD_FLAG_P2P_GC_MODE = (1 << (5)),
  316. DHD_FLAG_P2P_GO_MODE = (1 << (6)),
  317. DHD_FLAG_MBSS_MODE = (1 << (7)), /* MBSS in future */
  318. DHD_FLAG_IBSS_MODE = (1 << (8)),
  319. DHD_FLAG_MFG_MODE = (1 << (9)),
  320. DHD_FLAG_RSDB_MODE = (1 << (10)),
  321. DHD_FLAG_MP2P_MODE = (1 << (11))
  322. };
  323. #define DHD_OPMODE_SUPPORTED(dhd, opmode_flag) \
  324. (dhd ? ((((dhd_pub_t *)dhd)->op_mode) & opmode_flag) : -1)
  325. #define DHD_OPMODE_STA_SOFTAP_CONCURR(dhd) \
  326. (dhd ? (((dhd->op_mode) & DHD_FLAG_CONCURR_STA_HOSTAP_MODE) == \
  327. DHD_FLAG_CONCURR_STA_HOSTAP_MODE) : 0)
  328. /* Max sequential TX/RX Control timeouts to set HANG event */
  329. #ifndef MAX_CNTL_TX_TIMEOUT
  330. #define MAX_CNTL_TX_TIMEOUT 2
  331. #endif /* MAX_CNTL_TX_TIMEOUT */
  332. #ifndef MAX_CNTL_RX_TIMEOUT
  333. #define MAX_CNTL_RX_TIMEOUT 1
  334. #endif /* MAX_CNTL_RX_TIMEOUT */
  335. #define DHD_SCAN_ASSOC_ACTIVE_TIME 40 /* ms: Embedded default Active setting from DHD */
  336. #define DHD_SCAN_UNASSOC_ACTIVE_TIME 80 /* ms: Embedded def. Unassoc Active setting from DHD */
  337. #define DHD_SCAN_HOME_TIME 45 /* ms: Embedded default Home time setting from DHD */
  338. #define DHD_SCAN_HOME_AWAY_TIME 100 /* ms: Embedded default Home Away time setting from DHD */
  339. #ifndef CUSTOM_SCAN_PASSIVE_TIME
  340. #define DHD_SCAN_PASSIVE_TIME 130 /* ms: Embedded default Passive setting from DHD */
  341. #else
  342. #define DHD_SCAN_PASSIVE_TIME CUSTOM_SCAN_PASSIVE_TIME /* ms: Custom Passive setting from DHD */
  343. #endif /* CUSTOM_SCAN_PASSIVE_TIME */
  344. #ifndef POWERUP_MAX_RETRY
  345. #define POWERUP_MAX_RETRY 3 /* how many times we retry to power up the chip */
  346. #endif // endif
  347. #ifndef POWERUP_WAIT_MS
  348. #define POWERUP_WAIT_MS 2000 /* ms: time out in waiting wifi to come up */
  349. #endif // endif
  350. /*
  351. * MAX_NVRAMBUF_SIZE determines the size of the Buffer in the DHD that holds
  352. * the NVRAM data. That is the size of the buffer pointed by bus->vars
  353. * This also needs to be increased to 16K to support NVRAM size higher than 8K
  354. */
  355. #define MAX_NVRAMBUF_SIZE (16 * 1024) /* max nvram buf size */
  356. #define MAX_CLM_BUF_SIZE (48 * 1024) /* max clm blob size */
  357. #define MAX_TXCAP_BUF_SIZE (16 * 1024) /* max txcap blob size */
  358. #ifdef DHD_DEBUG
  359. #define DHD_JOIN_MAX_TIME_DEFAULT 10000 /* ms: Max time out for joining AP */
  360. #define DHD_SCAN_DEF_TIMEOUT 10000 /* ms: Max time out for scan in progress */
  361. #endif /* DHD_DEBUG */
  362. #ifndef CONFIG_BCMDHD_CLM_PATH
  363. #ifdef OEM_ANDROID
  364. #define CONFIG_BCMDHD_CLM_PATH "/etc/wifi/bcmdhd_clm.blob"
  365. #else
  366. #define CONFIG_BCMDHD_CLM_PATH "/var/run/bcmdhd_clm.blob"
  367. #endif /* OEM_ANDROID */
  368. #endif /* CONFIG_BCMDHD_CLM_PATH */
  369. #define WL_CCODE_NULL_COUNTRY "#n"
  370. #define FW_VER_STR_LEN 128
  371. #define FWID_STR_LEN 256
  372. #define CLM_VER_STR_LEN 128
  373. #define BUS_API_REV_STR_LEN 128
  374. #define FW_VER_STR "Version"
  375. #define FWID_STR_1 "FWID: 01-"
  376. #define FWID_STR_2 "FWID=01-"
  377. extern char bus_api_revision[];
  378. enum dhd_bus_wake_state {
  379. WAKE_LOCK_OFF = 0,
  380. WAKE_LOCK_PRIV = 1,
  381. WAKE_LOCK_DPC = 2,
  382. WAKE_LOCK_IOCTL = 3,
  383. WAKE_LOCK_DOWNLOAD = 4,
  384. WAKE_LOCK_TMOUT = 5,
  385. WAKE_LOCK_WATCHDOG = 6,
  386. WAKE_LOCK_LINK_DOWN_TMOUT = 7,
  387. WAKE_LOCK_PNO_FIND_TMOUT = 8,
  388. WAKE_LOCK_SOFTAP_SET = 9,
  389. WAKE_LOCK_SOFTAP_STOP = 10,
  390. WAKE_LOCK_SOFTAP_START = 11,
  391. WAKE_LOCK_SOFTAP_THREAD = 12
  392. };
  393. enum dhd_prealloc_index {
  394. DHD_PREALLOC_PROT = 0,
  395. DHD_PREALLOC_RXBUF = 1,
  396. DHD_PREALLOC_DATABUF = 2,
  397. DHD_PREALLOC_OSL_BUF = 3,
  398. /* 4 */
  399. DHD_PREALLOC_WIPHY_ESCAN0 = 5,
  400. DHD_PREALLOC_WIPHY_ESCAN1 = 6,
  401. DHD_PREALLOC_DHD_INFO = 7,
  402. DHD_PREALLOC_DHD_WLFC_INFO = 8,
  403. DHD_PREALLOC_IF_FLOW_LKUP = 9,
  404. /* 10 */
  405. DHD_PREALLOC_MEMDUMP_RAM = 11,
  406. DHD_PREALLOC_DHD_WLFC_HANGER = 12,
  407. DHD_PREALLOC_PKTID_MAP = 13,
  408. DHD_PREALLOC_PKTID_MAP_IOCTL = 14,
  409. DHD_PREALLOC_DHD_LOG_DUMP_BUF = 15,
  410. DHD_PREALLOC_DHD_LOG_DUMP_BUF_EX = 16,
  411. DHD_PREALLOC_DHD_PKTLOG_DUMP_BUF = 17
  412. };
  413. enum dhd_dongledump_mode {
  414. DUMP_DISABLED = 0,
  415. DUMP_MEMONLY = 1,
  416. DUMP_MEMFILE = 2,
  417. DUMP_MEMFILE_BUGON = 3,
  418. DUMP_MEMFILE_MAX = 4
  419. };
  420. enum dhd_dongledump_type {
  421. DUMP_TYPE_RESUMED_ON_TIMEOUT = 1,
  422. DUMP_TYPE_D3_ACK_TIMEOUT = 2,
  423. DUMP_TYPE_DONGLE_TRAP = 3,
  424. DUMP_TYPE_MEMORY_CORRUPTION = 4,
  425. DUMP_TYPE_PKTID_AUDIT_FAILURE = 5,
  426. DUMP_TYPE_PKTID_INVALID = 6,
  427. DUMP_TYPE_SCAN_TIMEOUT = 7,
  428. DUMP_TYPE_SCAN_BUSY = 8,
  429. DUMP_TYPE_BY_SYSDUMP = 9,
  430. DUMP_TYPE_BY_LIVELOCK = 10,
  431. DUMP_TYPE_AP_LINKUP_FAILURE = 11,
  432. DUMP_TYPE_AP_ABNORMAL_ACCESS = 12,
  433. DUMP_TYPE_CFG_VENDOR_TRIGGERED = 13,
  434. DUMP_TYPE_RESUMED_ON_TIMEOUT_TX = 14,
  435. DUMP_TYPE_RESUMED_ON_TIMEOUT_RX = 15,
  436. DUMP_TYPE_RESUMED_ON_INVALID_RING_RDWR = 16,
  437. DUMP_TYPE_TRANS_ID_MISMATCH = 17,
  438. DUMP_TYPE_IFACE_OP_FAILURE = 18,
  439. DUMP_TYPE_DONGLE_INIT_FAILURE = 19,
  440. DUMP_TYPE_READ_SHM_FAIL = 20,
  441. DUMP_TYPE_DONGLE_HOST_EVENT = 21,
  442. DUMP_TYPE_SMMU_FAULT = 22,
  443. DUMP_TYPE_RESUMED_UNKNOWN = 23,
  444. DUMP_TYPE_DUE_TO_BT = 24,
  445. DUMP_TYPE_LOGSET_BEYOND_RANGE = 25,
  446. DUMP_TYPE_BY_USER = 26,
  447. DUMP_TYPE_CTO_RECOVERY = 27,
  448. DUMP_TYPE_SEQUENTIAL_PRIVCMD_ERROR = 28,
  449. DUMP_TYPE_PROXD_TIMEOUT = 29,
  450. DUMP_TYPE_PKTID_POOL_DEPLETED = 30
  451. };
  452. enum dhd_hang_reason {
  453. HANG_REASON_MASK = 0x8000,
  454. HANG_REASON_IOCTL_RESP_TIMEOUT = 0x8001,
  455. HANG_REASON_DONGLE_TRAP = 0x8002,
  456. HANG_REASON_D3_ACK_TIMEOUT = 0x8003,
  457. HANG_REASON_BUS_DOWN = 0x8004,
  458. HANG_REASON_MSGBUF_LIVELOCK = 0x8006,
  459. HANG_REASON_IFACE_DEL_FAILURE = 0x8007,
  460. HANG_REASON_HT_AVAIL_ERROR = 0x8008,
  461. HANG_REASON_PCIE_RC_LINK_UP_FAIL = 0x8009,
  462. HANG_REASON_PCIE_PKTID_ERROR = 0x800A,
  463. HANG_REASON_IFACE_ADD_FAILURE = 0x800B,
  464. HANG_REASON_IOCTL_RESP_TIMEOUT_SCHED_ERROR = 0x800C,
  465. HANG_REASON_D3_ACK_TIMEOUT_SCHED_ERROR = 0x800D,
  466. HANG_REASON_SEQUENTIAL_PRIVCMD_ERROR = 0x800E,
  467. HANG_REASON_PCIE_LINK_DOWN_RC_DETECT = 0x8805,
  468. HANG_REASON_INVALID_EVENT_OR_DATA = 0x8806,
  469. HANG_REASON_UNKNOWN = 0x8807,
  470. HANG_REASON_PCIE_LINK_DOWN_EP_DETECT = 0x8808,
  471. HANG_REASON_PCIE_CTO_DETECT = 0x8809,
  472. HANG_REASON_MAX = 0x880A
  473. };
  474. #define WLC_E_DEAUTH_MAX_REASON 0x0FFF
  475. enum dhd_rsdb_scan_features {
  476. /* Downgraded scan feature for AP active */
  477. RSDB_SCAN_DOWNGRADED_AP_SCAN = 0x01,
  478. /* Downgraded scan feature for P2P Discovery */
  479. RSDB_SCAN_DOWNGRADED_P2P_DISC_SCAN = 0x02,
  480. /* Enable channel pruning for ROAM SCAN */
  481. RSDB_SCAN_DOWNGRADED_CH_PRUNE_ROAM = 0x10,
  482. /* Enable channel pruning for any SCAN */
  483. RSDB_SCAN_DOWNGRADED_CH_PRUNE_ALL = 0x20
  484. };
  485. #define VENDOR_SEND_HANG_EXT_INFO_LEN (800 + 1)
  486. #ifdef DHD_EWPR_VER2
  487. #define VENDOR_SEND_HANG_EXT_INFO_VER 20181111
  488. #else
  489. #define VENDOR_SEND_HANG_EXT_INFO_VER 20170905
  490. #endif // endif
  491. #define HANG_INFO_TRAP_T_NAME_MAX 6
  492. #define HANG_INFO_TRAP_T_REASON_IDX 0
  493. #define HANG_INFO_TRAP_T_SUBTYPE_IDX 2
  494. #define HANG_INFO_TRAP_T_OFFSET_IDX 3
  495. #define HANG_INFO_TRAP_T_EPC_IDX 4
  496. #define HANG_FIELD_STR_MAX_LEN 9
  497. #define HANG_FIELD_CNT_MAX 69
  498. #define HANG_FIELD_IF_FAILURE_CNT 10
  499. #define HANG_FIELD_IOCTL_RESP_TIMEOUT_CNT 8
  500. #define HANG_FIELD_TRAP_T_STACK_CNT_MAX 16
  501. #define HANG_FIELD_MISMATCH_CNT 10
  502. #define HANG_INFO_BIGDATA_KEY_STACK_CNT 4
  503. #define DEBUG_DUMP_TIME_BUF_LEN (16 + 1)
  504. /* delimiter between values */
  505. #define HANG_KEY_DEL ' '
  506. #define HANG_RAW_DEL '_'
  507. #ifdef DHD_EWPR_VER2
  508. #define HANG_INFO_BIGDATA_EXTRA_KEY 4
  509. #define HANG_INFO_TRAP_T_EXTRA_KEY_IDX 5
  510. #endif // endif
  511. /* Packet alignment for most efficient SDIO (can change based on platform) */
  512. #ifndef DHD_SDALIGN
  513. #define DHD_SDALIGN 32
  514. #endif // endif
  515. #define DHD_TX_CONTEXT_MASK 0xff
  516. #define DHD_TX_START_XMIT 0x01
  517. #define DHD_TX_SEND_PKT 0x02
  518. #define DHD_IF_SET_TX_ACTIVE(ifp, context) \
  519. ifp->tx_paths_active |= context;
  520. #define DHD_IF_CLR_TX_ACTIVE(ifp, context) \
  521. ifp->tx_paths_active &= ~context;
  522. #define DHD_IF_IS_TX_ACTIVE(ifp) \
  523. (ifp->tx_paths_active)
  524. /**
  525. * DMA-able buffer parameters
  526. * - dmaaddr_t is 32bits on a 32bit host.
  527. * dhd_dma_buf::pa may not be used as a sh_addr_t, bcm_addr64_t or uintptr
  528. * - dhd_dma_buf::_alloced is ONLY for freeing a DMA-able buffer.
  529. */
  530. typedef struct dhd_dma_buf {
  531. void *va; /* virtual address of buffer */
  532. uint32 len; /* user requested buffer length */
  533. dmaaddr_t pa; /* physical address of buffer */
  534. void *dmah; /* dma mapper handle */
  535. void *secdma; /* secure dma sec_cma_info handle */
  536. uint32 _alloced; /* actual size of buffer allocated with align and pad */
  537. } dhd_dma_buf_t;
  538. /* host reordering packts logic */
  539. /* followed the structure to hold the reorder buffers (void **p) */
  540. typedef struct reorder_info {
  541. void **p;
  542. uint8 flow_id;
  543. uint8 cur_idx;
  544. uint8 exp_idx;
  545. uint8 max_idx;
  546. uint8 pend_pkts;
  547. } reorder_info_t;
  548. /* throughput test packet format */
  549. typedef struct tput_pkt {
  550. /* header */
  551. uint8 mac_sta[ETHER_ADDR_LEN];
  552. uint8 mac_ap[ETHER_ADDR_LEN];
  553. uint16 pkt_type;
  554. uint8 PAD[2];
  555. /* data */
  556. uint32 crc32;
  557. uint32 pkt_id;
  558. uint32 num_pkts;
  559. } tput_pkt_t;
  560. typedef enum {
  561. TPUT_PKT_TYPE_NORMAL,
  562. TPUT_PKT_TYPE_STOP
  563. } tput_pkt_type_t;
  564. #define TPUT_TEST_MAX_PAYLOAD 1500
  565. #define TPUT_TEST_WAIT_TIMEOUT_DEFAULT 5000
  566. #ifdef DHDTCPACK_SUPPRESS
  567. enum {
  568. /* TCPACK suppress off */
  569. TCPACK_SUP_OFF,
  570. /* Replace TCPACK in txq when new coming one has higher ACK number. */
  571. TCPACK_SUP_REPLACE,
  572. /* TCPACK_SUP_REPLACE + delayed TCPACK TX unless ACK to PSH DATA.
  573. * This will give benefits to Half-Duplex bus interface(e.g. SDIO) that
  574. * 1. we are able to read TCP DATA packets first from the bus
  575. * 2. TCPACKs that don't need to hurry delivered remains longer in TXQ so can be suppressed.
  576. */
  577. TCPACK_SUP_DELAYTX,
  578. TCPACK_SUP_HOLD,
  579. TCPACK_SUP_LAST_MODE
  580. };
  581. #endif /* DHDTCPACK_SUPPRESS */
  582. #define DHD_NULL_CHK_AND_RET(cond) \
  583. if (!cond) { \
  584. DHD_ERROR(("%s " #cond " is NULL\n", __FUNCTION__)); \
  585. return; \
  586. }
  587. #define DHD_NULL_CHK_AND_RET_VAL(cond, value) \
  588. if (!cond) { \
  589. DHD_ERROR(("%s " #cond " is NULL\n", __FUNCTION__)); \
  590. return value; \
  591. }
  592. #define DHD_NULL_CHK_AND_GOTO(cond, label) \
  593. if (!cond) { \
  594. DHD_ERROR(("%s " #cond " is NULL\n", __FUNCTION__)); \
  595. goto label; \
  596. }
  597. /*
  598. * Accumulating the queue lengths of all flowring queues in a parent object,
  599. * to assert flow control, when the cummulative queue length crosses an upper
  600. * threshold defined on a parent object. Upper threshold may be maintained
  601. * at a station level, at an interface level, or at a dhd instance.
  602. *
  603. * cumm_ctr_t abstraction:
  604. * cumm_ctr_t abstraction may be enhanced to use an object with a hysterisis
  605. * pause on/off threshold callback.
  606. * All macros use the address of the cummulative length in the parent objects.
  607. *
  608. * BCM_GMAC3 builds use a single perimeter lock, as opposed to a per queue lock.
  609. * Cummulative counters in parent objects may be updated without spinlocks.
  610. *
  611. * In non BCM_GMAC3, if a cummulative queue length is desired across all flows
  612. * belonging to either of (a station, or an interface or a dhd instance), then
  613. * an atomic operation is required using an atomic_t cummulative counters or
  614. * using a spinlock. BCM_ROUTER_DHD uses the Linux atomic_t construct.
  615. */
  616. /* Cummulative length not supported. */
  617. typedef uint32 cumm_ctr_t;
  618. #define DHD_CUMM_CTR_PTR(clen) ((cumm_ctr_t*)(clen))
  619. #define DHD_CUMM_CTR(clen) *(DHD_CUMM_CTR_PTR(clen)) /* accessor */
  620. #define DHD_CUMM_CTR_READ(clen) DHD_CUMM_CTR(clen) /* read access */
  621. #define DHD_CUMM_CTR_INIT(clen) \
  622. ASSERT(DHD_CUMM_CTR_PTR(clen) != DHD_CUMM_CTR_PTR(NULL));
  623. #define DHD_CUMM_CTR_INCR(clen) \
  624. ASSERT(DHD_CUMM_CTR_PTR(clen) != DHD_CUMM_CTR_PTR(NULL));
  625. #define DHD_CUMM_CTR_DECR(clen) \
  626. ASSERT(DHD_CUMM_CTR_PTR(clen) != DHD_CUMM_CTR_PTR(NULL));
  627. #if defined(WLTDLS) && defined(PCIE_FULL_DONGLE)
  628. struct tdls_peer_node {
  629. uint8 addr[ETHER_ADDR_LEN];
  630. struct tdls_peer_node *next;
  631. };
  632. typedef struct tdls_peer_node tdls_peer_node_t;
  633. typedef struct {
  634. tdls_peer_node_t *node;
  635. uint8 tdls_peer_count;
  636. } tdls_peer_tbl_t;
  637. #endif /* defined(WLTDLS) && defined(PCIE_FULL_DONGLE) */
  638. #ifdef DHD_LOG_DUMP
  639. #define DUMP_SSSR_ATTR_START 2
  640. #define DUMP_SSSR_ATTR_COUNT 6
  641. typedef enum {
  642. SSSR_C0_D11_BEFORE = 0,
  643. SSSR_C0_D11_AFTER = 1,
  644. SSSR_C1_D11_BEFORE = 2,
  645. SSSR_C1_D11_AFTER = 3,
  646. SSSR_DIG_BEFORE = 4,
  647. SSSR_DIG_AFTER = 5
  648. } EWP_SSSR_DUMP;
  649. typedef enum {
  650. DLD_BUF_TYPE_GENERAL = 0,
  651. DLD_BUF_TYPE_PRESERVE = 1,
  652. DLD_BUF_TYPE_SPECIAL = 2,
  653. DLD_BUF_TYPE_ECNTRS = 3,
  654. DLD_BUF_TYPE_FILTER = 4,
  655. DLD_BUF_TYPE_ALL = 5
  656. } log_dump_type_t;
  657. #define LOG_DUMP_MAGIC 0xDEB3DEB3
  658. #define HEALTH_CHK_BUF_SIZE 256
  659. #ifdef EWP_ECNTRS_LOGGING
  660. #define ECNTR_RING_ID 0xECDB
  661. #define ECNTR_RING_NAME "ewp_ecntr_ring"
  662. #endif /* EWP_ECNTRS_LOGGING */
  663. #ifdef EWP_RTT_LOGGING
  664. #define RTT_RING_ID 0xADCD
  665. #define RTT_RING_NAME "ewp_rtt_ring"
  666. #endif /* EWP_ECNTRS_LOGGING */
  667. #if defined(DEBUGABILITY) && defined(EWP_ECNTRS_LOGGING)
  668. #error "Duplicate rings will be created since both the features are enabled"
  669. #endif /* DEBUGABILITY && EWP_ECNTRS_LOGGING */
  670. typedef enum {
  671. LOG_DUMP_SECTION_GENERAL = 0,
  672. LOG_DUMP_SECTION_ECNTRS,
  673. LOG_DUMP_SECTION_SPECIAL,
  674. LOG_DUMP_SECTION_DHD_DUMP,
  675. LOG_DUMP_SECTION_EXT_TRAP,
  676. LOG_DUMP_SECTION_HEALTH_CHK,
  677. LOG_DUMP_SECTION_PRESERVE,
  678. LOG_DUMP_SECTION_COOKIE,
  679. LOG_DUMP_SECTION_FLOWRING,
  680. LOG_DUMP_SECTION_STATUS,
  681. LOG_DUMP_SECTION_RTT
  682. } log_dump_section_type_t;
  683. /* Each section in the debug_dump log file shall begin with a header */
  684. typedef struct {
  685. uint32 magic; /* 0xDEB3DEB3 */
  686. uint32 type; /* of type log_dump_section_type_t */
  687. uint64 timestamp;
  688. uint32 length; /* length of the section that follows */
  689. uint32 pad;
  690. } log_dump_section_hdr_t;
  691. /* below structure describe ring buffer. */
  692. struct dhd_log_dump_buf
  693. {
  694. spinlock_t lock;
  695. void *dhd_pub;
  696. unsigned int enable;
  697. unsigned int wraparound;
  698. unsigned long max;
  699. unsigned int remain;
  700. char* present;
  701. char* front;
  702. char* buffer;
  703. };
  704. #define DHD_LOG_DUMP_MAX_TEMP_BUFFER_SIZE 256
  705. #define DHD_LOG_DUMP_MAX_TAIL_FLUSH_SIZE (80 * 1024)
  706. extern void dhd_log_dump_write(int type, char *binary_data,
  707. int binary_len, const char *fmt, ...);
  708. #endif /* DHD_LOG_DUMP */
  709. /* DEBUG_DUMP SUB COMMAND */
  710. enum {
  711. CMD_DEFAULT,
  712. CMD_UNWANTED,
  713. CMD_DISCONNECTED,
  714. CMD_MAX
  715. };
  716. #define DHD_LOG_DUMP_TS_MULTIPLIER_VALUE 60
  717. #define DHD_LOG_DUMP_TS_FMT_YYMMDDHHMMSSMSMS "%02d%02d%02d%02d%02d%02d%04d"
  718. #define DHD_DEBUG_DUMP_TYPE "debug_dump_FORUSER"
  719. #define DHD_DUMP_SUBSTR_UNWANTED "_unwanted"
  720. #define DHD_DUMP_SUBSTR_DISCONNECTED "_disconnected"
  721. #ifdef DNGL_AXI_ERROR_LOGGING
  722. #define DHD_DUMP_AXI_ERROR_FILENAME "axi_error"
  723. #define DHD_DUMP_HAL_FILENAME_SUFFIX "_hal"
  724. #endif /* DNGL_AXI_ERROR_LOGGING */
  725. extern void get_debug_dump_time(char *str);
  726. extern void clear_debug_dump_time(char *str);
  727. #if defined(WL_CFGVENDOR_SEND_HANG_EVENT) || defined(DHD_PKT_LOGGING)
  728. extern void copy_debug_dump_time(char *dest, char *src);
  729. #endif /* WL_CFGVENDOR_SEND_HANG_EVENT || DHD_PKT_LOGGING */
  730. #define FW_LOGSET_MASK_ALL 0xFF
  731. #ifdef WL_MONITOR
  732. #define MONPKT_EXTRA_LEN 48u
  733. #endif /* WL_MONITOR */
  734. #define DHDIF_FWDER(dhdif) FALSE
  735. #if defined(CUSTOMER_HW2) || defined(BOARD_HIKEY)
  736. #define DHD_COMMON_DUMP_PATH "/data/misc/wifi/"
  737. #elif defined(OEM_ANDROID) && (defined(BOARD_PANDA) || defined(__ARM_ARCH_7A__))
  738. #define DHD_COMMON_DUMP_PATH "/data/vendor/wifi/"
  739. #elif defined(OEM_ANDROID) /* For Brix Live Image */
  740. #define DHD_COMMON_DUMP_PATH "/installmedia/"
  741. #else /* Default */
  742. #define DHD_COMMON_DUMP_PATH "/root/"
  743. #endif // endif
  744. struct cntry_locales_custom {
  745. char iso_abbrev[WLC_CNTRY_BUF_SZ]; /* ISO 3166-1 country abbreviation */
  746. char custom_locale[WLC_CNTRY_BUF_SZ]; /* Custom firmware locale */
  747. int32 custom_locale_rev; /* Custom local revisin default -1 */
  748. };
  749. int dhd_send_msg_to_daemon(struct sk_buff *skb, void *data, int size);
  750. #ifdef DMAMAP_STATS
  751. typedef struct dmamap_stats {
  752. uint64 txdata;
  753. uint64 txdata_sz;
  754. uint64 rxdata;
  755. uint64 rxdata_sz;
  756. uint64 ioctl_rx;
  757. uint64 ioctl_rx_sz;
  758. uint64 event_rx;
  759. uint64 event_rx_sz;
  760. uint64 info_rx;
  761. uint64 info_rx_sz;
  762. uint64 tsbuf_rx;
  763. uint64 tsbuf_rx_sz;
  764. } dma_stats_t;
  765. #endif /* DMAMAP_STATS */
  766. /* see wlfc_proto.h for tx status details */
  767. #define DHD_MAX_TX_STATUS_MSGS 9u
  768. #ifdef TX_STATUS_LATENCY_STATS
  769. typedef struct dhd_if_tx_status_latency {
  770. /* total number of tx_status received on this interface */
  771. uint64 num_tx_status;
  772. /* cumulative tx_status latency for this interface */
  773. uint64 cum_tx_status_latency;
  774. } dhd_if_tx_status_latency_t;
  775. #endif /* TX_STATUS_LATENCY_STATS */
  776. #if defined(SHOW_LOGTRACE) && defined(DHD_USE_KTHREAD_FOR_LOGTRACE)
  777. /* Timestamps to trace dhd_logtrace_thread() */
  778. struct dhd_logtrace_thr_ts {
  779. uint64 entry_time;
  780. uint64 sem_down_time;
  781. uint64 flush_time;
  782. uint64 unexpected_break_time;
  783. uint64 complete_time;
  784. };
  785. #endif /* SHOW_LOGTRACE && DHD_USE_KTHREAD_FOR_LOGTRACE */
  786. /* Enable Reserve STA flowrings only for Android */
  787. #if defined(OEM_ANDROID)
  788. #define DHD_LIMIT_MULTI_CLIENT_FLOWRINGS
  789. #endif /* OEM_ANDROID */
  790. typedef enum dhd_induce_error_states
  791. {
  792. DHD_INDUCE_ERROR_CLEAR = 0x0,
  793. DHD_INDUCE_IOCTL_TIMEOUT = 0x1,
  794. DHD_INDUCE_D3_ACK_TIMEOUT = 0x2,
  795. DHD_INDUCE_LIVELOCK = 0x3,
  796. DHD_INDUCE_DROP_OOB_IRQ = 0x4,
  797. DHD_INDUCE_DROP_AXI_SIG = 0x5,
  798. DHD_INDUCE_ERROR_MAX = 0x6
  799. } dhd_induce_error_states_t;
  800. #ifdef DHD_HP2P
  801. #define MAX_TX_HIST_BIN 16
  802. #define MAX_RX_HIST_BIN 10
  803. #define MAX_HP2P_FLOWS 16
  804. #define HP2P_PRIO 7
  805. #define HP2P_PKT_THRESH 48
  806. #define HP2P_TIME_THRESH 200
  807. #define HP2P_PKT_EXPIRY 40
  808. #define HP2P_TIME_SCALE 32
  809. typedef struct hp2p_info {
  810. void *dhd_pub;
  811. uint16 flowid;
  812. bool hrtimer_init;
  813. void *ring;
  814. #if (LINUX_VERSION_CODE <= KERNEL_VERSION(5, 1, 21))
  815. struct tasklet_hrtimer timer;
  816. #else
  817. struct hrtimer timer;
  818. #endif /* (LINUX_VERSION_CODE <= KERNEL_VERSION(5, 1, 21) */
  819. uint64 num_pkt_limit;
  820. uint64 num_timer_limit;
  821. uint64 num_timer_start;
  822. uint64 tx_t0[MAX_TX_HIST_BIN];
  823. uint64 tx_t1[MAX_TX_HIST_BIN];
  824. uint64 rx_t0[MAX_RX_HIST_BIN];
  825. } hp2p_info_t;
  826. #endif /* DHD_HP2P */
  827. typedef enum {
  828. FW_UNLOADED = 0,
  829. FW_DOWNLOAD_IN_PROGRESS = 1,
  830. FW_DOWNLOAD_DONE = 2
  831. } fw_download_status_t;
  832. /**
  833. * Common structure for module and instance linkage.
  834. * Instantiated once per hardware (dongle) instance that this DHD manages.
  835. */
  836. typedef struct dhd_pub {
  837. /* Linkage ponters */
  838. osl_t *osh; /* OSL handle */
  839. struct dhd_bus *bus; /* Bus module handle */
  840. struct dhd_prot *prot; /* Protocol module handle */
  841. struct dhd_info *info; /* Info module handle */
  842. struct dhd_dbg *dbg; /* Debugability module handle */
  843. #if defined(SHOW_LOGTRACE) && defined(DHD_USE_KTHREAD_FOR_LOGTRACE)
  844. struct dhd_logtrace_thr_ts logtrace_thr_ts;
  845. #endif /* SHOW_LOGTRACE && DHD_USE_KTHREAD_FOR_LOGTRACE */
  846. /* to NDIS developer, the structure dhd_common is redundant,
  847. * please do NOT merge it back from other branches !!!
  848. */
  849. /* Internal dhd items */
  850. bool up; /* Driver up/down (to OS) */
  851. #ifdef WL_CFG80211
  852. spinlock_t up_lock; /* Synchronization with CFG80211 down */
  853. #endif /* WL_CFG80211 */
  854. bool txoff; /* Transmit flow-controlled */
  855. bool dongle_reset; /* TRUE = DEVRESET put dongle into reset */
  856. enum dhd_bus_state busstate;
  857. uint dhd_bus_busy_state; /* Bus busy state */
  858. uint hdrlen; /* Total DHD header length (proto + bus) */
  859. uint maxctl; /* Max size rxctl request from proto to bus */
  860. uint rxsz; /* Rx buffer size bus module should use */
  861. uint8 wme_dp; /* wme discard priority */
  862. #ifdef DNGL_AXI_ERROR_LOGGING
  863. uint32 axierror_logbuf_addr;
  864. bool axi_error;
  865. struct dhd_axi_error_dump *axi_err_dump;
  866. #endif /* DNGL_AXI_ERROR_LOGGING */
  867. /* Dongle media info */
  868. bool iswl; /* Dongle-resident driver is wl */
  869. ulong drv_version; /* Version of dongle-resident driver */
  870. struct ether_addr mac; /* MAC address obtained from dongle */
  871. dngl_stats_t dstats; /* Stats for dongle-based data */
  872. /* Additional stats for the bus level */
  873. ulong tx_packets; /* Data packets sent to dongle */
  874. ulong tx_dropped; /* Data packets dropped in dhd */
  875. ulong tx_multicast; /* Multicast data packets sent to dongle */
  876. ulong tx_errors; /* Errors in sending data to dongle */
  877. ulong tx_ctlpkts; /* Control packets sent to dongle */
  878. ulong tx_ctlerrs; /* Errors sending control frames to dongle */
  879. ulong rx_packets; /* Packets sent up the network interface */
  880. ulong rx_multicast; /* Multicast packets sent up the network interface */
  881. ulong rx_errors; /* Errors processing rx data packets */
  882. ulong rx_ctlpkts; /* Control frames processed from dongle */
  883. ulong rx_ctlerrs; /* Errors in processing rx control frames */
  884. ulong rx_dropped; /* Packets dropped locally (no memory) */
  885. ulong rx_flushed; /* Packets flushed due to unscheduled sendup thread */
  886. ulong wd_dpc_sched; /* Number of times dhd dpc scheduled by watchdog timer */
  887. ulong rx_pktgetfail; /* Number of PKTGET failures in DHD on RX */
  888. ulong tx_pktgetfail; /* Number of PKTGET failures in DHD on TX */
  889. ulong rx_readahead_cnt; /* Number of packets where header read-ahead was used. */
  890. ulong tx_realloc; /* Number of tx packets we had to realloc for headroom */
  891. ulong fc_packets; /* Number of flow control pkts recvd */
  892. ulong tx_big_packets; /* Dropped data packets that are larger than MAX_MTU_SZ */
  893. #ifdef DMAMAP_STATS
  894. /* DMA Mapping statistics */
  895. dma_stats_t dma_stats;
  896. #endif /* DMAMAP_STATS */
  897. /* Last error return */
  898. int bcmerror;
  899. uint tickcnt;
  900. /* Last error from dongle */
  901. int dongle_error;
  902. uint8 country_code[WLC_CNTRY_BUF_SZ];
  903. /* Suspend disable flag and "in suspend" flag */
  904. int suspend_disable_flag; /* "1" to disable all extra powersaving during suspend */
  905. int in_suspend; /* flag set to 1 when early suspend called */
  906. #ifdef PNO_SUPPORT
  907. int pno_enable; /* pno status : "1" is pno enable */
  908. int pno_suspend; /* pno suspend status : "1" is pno suspended */
  909. #endif /* PNO_SUPPORT */
  910. /* DTIM skip value, default 0(or 1) means wake each DTIM
  911. * 3 means skip 2 DTIMs and wake up 3rd DTIM(9th beacon when AP DTIM is 3)
  912. */
  913. int suspend_bcn_li_dtim; /* bcn_li_dtim value in suspend mode */
  914. #ifdef PKT_FILTER_SUPPORT
  915. int early_suspended; /* Early suspend status */
  916. int dhcp_in_progress; /* DHCP period */
  917. #endif // endif
  918. /* Pkt filter defination */
  919. char * pktfilter[100];
  920. int pktfilter_count;
  921. wl_country_t dhd_cspec; /* Current Locale info */
  922. #ifdef CUSTOM_COUNTRY_CODE
  923. uint dhd_cflags;
  924. #endif /* CUSTOM_COUNTRY_CODE */
  925. #if defined(DHD_BLOB_EXISTENCE_CHECK)
  926. bool is_blob; /* Checking for existance of Blob file */
  927. #endif /* DHD_BLOB_EXISTENCE_CHECK */
  928. bool force_country_change;
  929. char eventmask[WL_EVENTING_MASK_LEN];
  930. int op_mode; /* STA, HostAPD, WFD, SoftAP */
  931. /* Set this to 1 to use a seperate interface (p2p0) for p2p operations.
  932. * For ICS MR1 releases it should be disable to be compatable with ICS MR1 Framework
  933. * see target dhd-cdc-sdmmc-panda-cfg80211-icsmr1-gpl-debug in Makefile
  934. */
  935. /* #define WL_ENABLE_P2P_IF 1 */
  936. #if defined(OEM_ANDROID)
  937. struct mutex wl_start_stop_lock; /* lock/unlock for Android start/stop */
  938. struct mutex wl_softap_lock; /* lock/unlock for any SoftAP/STA settings */
  939. #endif /* defined(OEM_ANDROID) */
  940. #ifdef PROP_TXSTATUS
  941. bool wlfc_enabled;
  942. int wlfc_mode;
  943. void* wlfc_state;
  944. /*
  945. Mode in which the dhd flow control shall operate. Must be set before
  946. traffic starts to the device.
  947. 0 - Do not do any proptxtstatus flow control
  948. 1 - Use implied credit from a packet status
  949. 2 - Use explicit credit
  950. 3 - Only AMPDU hostreorder used. no wlfc.
  951. */
  952. uint8 proptxstatus_mode;
  953. bool proptxstatus_txoff;
  954. bool proptxstatus_module_ignore;
  955. bool proptxstatus_credit_ignore;
  956. bool proptxstatus_txstatus_ignore;
  957. bool wlfc_rxpkt_chk;
  958. #ifdef LIMIT_BORROW
  959. bool wlfc_borrow_allowed;
  960. #endif /* LIMIT_BORROW */
  961. /*
  962. * implement below functions in each platform if needed.
  963. */
  964. /* platform specific function whether to skip flow control */
  965. bool (*skip_fc)(void * dhdp, uint8 ifx);
  966. /* platform specific function for wlfc_enable and wlfc_deinit */
  967. void (*plat_init)(void *dhd);
  968. void (*plat_deinit)(void *dhd);
  969. #ifdef DHD_WLFC_THREAD
  970. bool wlfc_thread_go;
  971. struct task_struct* wlfc_thread;
  972. wait_queue_head_t wlfc_wqhead;
  973. #endif /* DHD_WLFC_THREAD */
  974. #endif /* PROP_TXSTATUS */
  975. #ifdef PNO_SUPPORT
  976. void *pno_state;
  977. #endif // endif
  978. #ifdef RTT_SUPPORT
  979. void *rtt_state;
  980. #endif // endif
  981. #ifdef ROAM_AP_ENV_DETECTION
  982. bool roam_env_detection;
  983. #endif // endif
  984. bool dongle_isolation;
  985. bool is_pcie_watchdog_reset;
  986. /* Begin - Variables to track Bus Errors */
  987. bool dongle_trap_occured; /* flag for sending HANG event to upper layer */
  988. bool iovar_timeout_occured; /* flag to indicate iovar resumed on timeout */
  989. bool is_sched_error; /* flag to indicate timeout due to scheduling issue */
  990. #ifdef PCIE_FULL_DONGLE
  991. bool d3ack_timeout_occured; /* flag to indicate d3ack resumed on timeout */
  992. bool livelock_occured; /* flag to indicate livelock occured */
  993. bool pktid_audit_failed; /* flag to indicate pktid audit failure */
  994. #endif /* PCIE_FULL_DONGLE */
  995. bool iface_op_failed; /* flag to indicate interface operation failed */
  996. bool scan_timeout_occurred; /* flag to indicate scan has timedout */
  997. bool scan_busy_occurred; /* flag to indicate scan busy occurred */
  998. #ifdef BT_OVER_SDIO
  999. bool is_bt_recovery_required;
  1000. #endif // endif
  1001. bool smmu_fault_occurred; /* flag to indicate SMMU Fault */
  1002. /*
  1003. * Add any new variables to track Bus errors above
  1004. * this line. Also ensure that the variable is
  1005. * cleared from dhd_clear_bus_errors
  1006. */
  1007. /* End - Variables to track Bus Errors */
  1008. int hang_was_sent;
  1009. int hang_was_pending;
  1010. int rxcnt_timeout; /* counter rxcnt timeout to send HANG */
  1011. int txcnt_timeout; /* counter txcnt timeout to send HANG */
  1012. #ifdef BCMPCIE
  1013. int d3ackcnt_timeout; /* counter d3ack timeout to send HANG */
  1014. #endif /* BCMPCIE */
  1015. bool hang_report; /* enable hang report by default */
  1016. uint16 hang_reason; /* reason codes for HANG event */
  1017. #if defined(DHD_HANG_SEND_UP_TEST)
  1018. uint req_hang_type;
  1019. #endif /* DHD_HANG_SEND_UP_TEST */
  1020. #if defined(CONFIG_BCM_DETECT_CONSECUTIVE_HANG)
  1021. uint hang_counts;
  1022. #endif /* CONFIG_BCM_DETECT_CONSECUTIVE_HANG */
  1023. #ifdef WLTDLS
  1024. bool tdls_enable;
  1025. #endif // endif
  1026. struct reorder_info *reorder_bufs[WLHOST_REORDERDATA_MAXFLOWS];
  1027. #define WLC_IOCTL_MAXBUF_FWCAP 1024
  1028. char fw_capabilities[WLC_IOCTL_MAXBUF_FWCAP];
  1029. #define MAXSKBPEND 1024
  1030. void *skbbuf[MAXSKBPEND];
  1031. uint32 store_idx;
  1032. uint32 sent_idx;
  1033. #ifdef DHDTCPACK_SUPPRESS
  1034. uint8 tcpack_sup_mode; /* TCPACK suppress mode */
  1035. void *tcpack_sup_module; /* TCPACK suppress module */
  1036. uint32 tcpack_sup_ratio;
  1037. uint32 tcpack_sup_delay;
  1038. #endif /* DHDTCPACK_SUPPRESS */
  1039. #if defined(ARP_OFFLOAD_SUPPORT)
  1040. uint32 arp_version;
  1041. #endif // endif
  1042. #if defined(BCMSUP_4WAY_HANDSHAKE)
  1043. bool fw_4way_handshake; /* Whether firmware will to do the 4way handshake. */
  1044. #endif // endif
  1045. #ifdef DEBUG_DPC_THREAD_WATCHDOG
  1046. bool dhd_bug_on;
  1047. #endif /* DEBUG_DPC_THREAD_WATCHDOG */
  1048. #ifdef CUSTOM_SET_CPUCORE
  1049. struct task_struct * current_dpc;
  1050. struct task_struct * current_rxf;
  1051. int chan_isvht80;
  1052. #endif /* CUSTOM_SET_CPUCORE */
  1053. void *sta_pool; /* pre-allocated pool of sta objects */
  1054. void *staid_allocator; /* allocator of sta indexes */
  1055. #ifdef PCIE_FULL_DONGLE
  1056. bool flow_rings_inited; /* set this flag after initializing flow rings */
  1057. #endif /* PCIE_FULL_DONGLE */
  1058. void *flowid_allocator; /* unique flowid allocator */
  1059. void *flow_ring_table; /* flow ring table, include prot and bus info */
  1060. void *if_flow_lkup; /* per interface flowid lkup hash table */
  1061. void *flowid_lock; /* per os lock for flowid info protection */
  1062. void *flowring_list_lock; /* per os lock for flowring list protection */
  1063. uint8 max_multi_client_flow_rings;
  1064. uint8 multi_client_flow_rings;
  1065. uint32 num_flow_rings;
  1066. cumm_ctr_t cumm_ctr; /* cumm queue length placeholder */
  1067. cumm_ctr_t l2cumm_ctr; /* level 2 cumm queue length placeholder */
  1068. uint32 d2h_sync_mode; /* D2H DMA completion sync mode */
  1069. uint8 flow_prio_map[NUMPRIO];
  1070. uint8 flow_prio_map_type;
  1071. char enable_log[MAX_EVENT];
  1072. bool dma_d2h_ring_upd_support;
  1073. bool dma_h2d_ring_upd_support;
  1074. bool dma_ring_upd_overwrite; /* host overwrites support setting */
  1075. bool hwa_enable;
  1076. uint hwa_inited;
  1077. bool idma_enable;
  1078. uint idma_inited;
  1079. bool ifrm_enable; /* implicit frm enable */
  1080. uint ifrm_inited; /* implicit frm init */
  1081. bool dar_enable; /* use DAR registers */
  1082. uint dar_inited;
  1083. bool fast_delete_ring_support; /* fast delete ring supported */
  1084. #ifdef DHD_L2_FILTER
  1085. unsigned long l2_filter_cnt; /* for L2_FILTER ARP table timeout */
  1086. #endif /* DHD_L2_FILTER */
  1087. #ifdef DHD_SSSR_DUMP
  1088. bool sssr_inited;
  1089. bool sssr_dump_collected; /* Flag to indicate sssr dump is collected */
  1090. sssr_reg_info_v1_t sssr_reg_info;
  1091. uint8 *sssr_mempool;
  1092. uint *sssr_d11_before[MAX_NUM_D11CORES];
  1093. uint *sssr_d11_after[MAX_NUM_D11CORES];
  1094. bool sssr_d11_outofreset[MAX_NUM_D11CORES];
  1095. uint *sssr_dig_buf_before;
  1096. uint *sssr_dig_buf_after;
  1097. uint32 sssr_dump_mode;
  1098. bool collect_sssr; /* Flag to indicate SSSR dump is required */
  1099. #endif /* DHD_SSSR_DUMP */
  1100. uint8 *soc_ram;
  1101. uint32 soc_ram_length;
  1102. uint32 memdump_type;
  1103. #ifdef DHD_RND_DEBUG
  1104. uint8 *rnd_buf;
  1105. uint32 rnd_len;
  1106. #endif /* DHD_RND_DEBUG */
  1107. #ifdef DHD_FW_COREDUMP
  1108. uint32 memdump_enabled;
  1109. #ifdef DHD_DEBUG_UART
  1110. bool memdump_success;
  1111. #endif /* DHD_DEBUG_UART */
  1112. #endif /* DHD_FW_COREDUMP */
  1113. #ifdef PCIE_FULL_DONGLE
  1114. #ifdef WLTDLS
  1115. tdls_peer_tbl_t peer_tbl;
  1116. #endif /* WLTDLS */
  1117. uint8 tx_in_progress;
  1118. #endif /* PCIE_FULL_DONGLE */
  1119. #ifdef DHD_ULP
  1120. void *dhd_ulp;
  1121. #endif // endif
  1122. #ifdef WLTDLS
  1123. uint32 tdls_mode;
  1124. #endif // endif
  1125. #ifdef GSCAN_SUPPORT
  1126. bool lazy_roam_enable;
  1127. #endif // endif
  1128. #if defined(PKT_FILTER_SUPPORT) && defined(APF)
  1129. bool apf_set;
  1130. #endif /* PKT_FILTER_SUPPORT && APF */
  1131. void *macdbg_info;
  1132. #ifdef DHD_WET
  1133. void *wet_info;
  1134. #endif // endif
  1135. bool h2d_phase_supported;
  1136. bool force_dongletrap_on_bad_h2d_phase;
  1137. uint32 dongle_trap_data;
  1138. fw_download_status_t fw_download_status;
  1139. trap_t last_trap_info; /* trap info from the last trap */
  1140. uint8 rand_mac_oui[DOT11_OUI_LEN];
  1141. #ifdef DHD_LOSSLESS_ROAMING
  1142. uint8 dequeue_prec_map;
  1143. uint8 prio_8021x;
  1144. #endif // endif
  1145. #ifdef WL_NATOE
  1146. struct dhd_nfct_info *nfct;
  1147. spinlock_t nfct_lock;
  1148. #endif /* WL_NATOE */
  1149. /* timesync link */
  1150. struct dhd_ts *ts;
  1151. bool d2h_hostrdy_supported;
  1152. #ifdef DHD_PCIE_NATIVE_RUNTIMEPM
  1153. atomic_t block_bus;
  1154. #endif /* DHD_PCIE_NATIVE_RUNTIMEPM */
  1155. #if defined(DBG_PKT_MON) || defined(DHD_PKT_LOGGING)
  1156. bool d11_tx_status;
  1157. #endif /* DBG_PKT_MON || DHD_PKT_LOGGING */
  1158. uint16 ndo_version; /* ND offload version supported */
  1159. #ifdef NDO_CONFIG_SUPPORT
  1160. bool ndo_enable; /* ND offload feature enable */
  1161. bool ndo_host_ip_overflow; /* # of host ip addr exceed FW capacity */
  1162. uint32 ndo_max_host_ip; /* # of host ip addr supported by FW */
  1163. #endif /* NDO_CONFIG_SUPPORT */
  1164. #if defined(DHD_LOG_DUMP)
  1165. /* buffer to hold 'dhd dump' data before dumping to file */
  1166. uint8 *concise_dbg_buf;
  1167. uint64 last_file_posn;
  1168. int logdump_periodic_flush;
  1169. /* ecounter debug ring */
  1170. #ifdef EWP_ECNTRS_LOGGING
  1171. void *ecntr_dbg_ring;
  1172. #endif // endif
  1173. #ifdef EWP_RTT_LOGGING
  1174. void *rtt_dbg_ring;
  1175. #endif // endif
  1176. #ifdef DNGL_EVENT_SUPPORT
  1177. uint8 health_chk_event_data[HEALTH_CHK_BUF_SIZE];
  1178. #endif // endif
  1179. void *logdump_cookie;
  1180. #endif /* DHD_LOG_DUMP */
  1181. uint32 dhd_console_ms; /** interval for polling the dongle for console (log) messages */
  1182. bool ext_trap_data_supported;
  1183. uint32 *extended_trap_data;
  1184. #ifdef DUMP_IOCTL_IOV_LIST
  1185. /* dump iovar list */
  1186. dll_t dump_iovlist_head;
  1187. uint8 dump_iovlist_len;
  1188. #endif /* DUMP_IOCTL_IOV_LIST */
  1189. #ifdef CUSTOM_SET_ANTNPM
  1190. uint32 mimo_ant_set;
  1191. #endif /* CUSTOM_SET_ANTNPM */
  1192. #ifdef CUSTOM_SET_OCLOFF
  1193. bool ocl_off;
  1194. #endif /* CUSTOM_SET_OCLOFF */
  1195. #ifdef DHD_DEBUG
  1196. /* memwaste feature */
  1197. dll_t mw_list_head; /* memwaste list head */
  1198. uint32 mw_id; /* memwaste list unique id */
  1199. #endif /* DHD_DEBUG */
  1200. #ifdef WLTDLS
  1201. spinlock_t tdls_lock;
  1202. #endif /* WLTDLS */
  1203. uint pcie_txs_metadata_enable;
  1204. uint wbtext_policy; /* wbtext policy of dongle */
  1205. bool wbtext_support; /* for product policy only */
  1206. bool max_dtim_enable; /* use MAX bcn_li_dtim value in suspend mode */
  1207. tput_test_t tput_data;
  1208. uint64 tput_start_ts;
  1209. uint64 tput_stop_ts;
  1210. #ifdef WL_MONITOR
  1211. bool monitor_enable;
  1212. #endif // endif
  1213. #ifdef DHD_PKT_LOGGING
  1214. struct dhd_pktlog *pktlog;
  1215. char debug_dump_time_pktlog_str[DEBUG_DUMP_TIME_BUF_LEN];
  1216. #endif /* DHD_PKT_LOGGING */
  1217. uint dhd_watchdog_ms_backup;
  1218. void *event_log_filter;
  1219. #ifdef WL_CFGVENDOR_SEND_HANG_EVENT
  1220. char *hang_info;
  1221. int hang_info_cnt;
  1222. char debug_dump_time_hang_str[DEBUG_DUMP_TIME_BUF_LEN];
  1223. #endif /* WL_CFGVENDOR_SEND_HANG_EVENT */
  1224. char debug_dump_time_str[DEBUG_DUMP_TIME_BUF_LEN];
  1225. uint32 logset_prsrv_mask;
  1226. bool wl_event_enabled;
  1227. bool logtrace_pkt_sendup;
  1228. #ifdef DHD_DUMP_MNGR
  1229. struct _dhd_dump_file_manage *dump_file_manage;
  1230. #endif /* DHD_DUMP_MNGR */
  1231. int debug_dump_subcmd;
  1232. uint64 debug_dump_time_sec;
  1233. bool hscb_enable;
  1234. wait_queue_head_t tx_completion_wait;
  1235. uint32 batch_tx_pkts_cmpl;
  1236. uint32 batch_tx_num_pkts;
  1237. #ifdef DHD_ERPOM
  1238. bool enable_erpom;
  1239. pom_func_handler_t pom_wlan_handler;
  1240. int (*pom_func_register)(pom_func_handler_t *func);
  1241. int (*pom_func_deregister)(pom_func_handler_t *func);
  1242. int (*pom_toggle_reg_on)(uchar func_id, uchar reason);
  1243. #endif /* DHD_ERPOM */
  1244. #ifdef EWP_EDL
  1245. bool dongle_edl_support;
  1246. dhd_dma_buf_t edl_ring_mem;
  1247. #endif /* EWP_EDL */
  1248. struct mutex ndev_op_sync;
  1249. bool debug_buf_dest_support;
  1250. uint32 debug_buf_dest_stat[DEBUG_BUF_DEST_MAX];
  1251. #if defined(DHD_H2D_LOG_TIME_SYNC)
  1252. #define DHD_H2D_LOG_TIME_STAMP_MATCH (10000) /* 10 Seconds */
  1253. /*
  1254. * Interval for updating the dongle console message time stamp with the Host (DHD)
  1255. * time stamp
  1256. */
  1257. uint32 dhd_rte_time_sync_ms;
  1258. #endif /* DHD_H2D_LOG_TIME_SYNC */
  1259. int wlc_ver_major;
  1260. int wlc_ver_minor;
  1261. #ifdef DHD_STATUS_LOGGING
  1262. void *statlog;
  1263. #endif /* DHD_STATUS_LOGGING */
  1264. #ifdef DHD_HP2P
  1265. bool hp2p_enable;
  1266. bool hp2p_infra_enable;
  1267. bool hp2p_capable;
  1268. bool hp2p_ts_capable;
  1269. uint16 pkt_thresh;
  1270. uint16 time_thresh;
  1271. uint16 pkt_expiry;
  1272. hp2p_info_t hp2p_info[MAX_HP2P_FLOWS];
  1273. bool hp2p_ring_active;
  1274. #endif /* D2H_HP2P */
  1275. #ifdef DHD_DB0TS
  1276. bool db0ts_capable;
  1277. #endif /* DHD_DB0TS */
  1278. bool event_log_max_sets_queried;
  1279. uint32 event_log_max_sets;
  1280. uint16 dhd_induce_error;
  1281. #ifdef CONFIG_SILENT_ROAM
  1282. bool sroam_turn_on; /* Silent roam monitor enable flags */
  1283. bool sroamed; /* Silent roam monitor check flags */
  1284. #endif /* CONFIG_SILENT_ROAM */
  1285. bool extdtxs_in_txcpl;
  1286. bool hostrdy_after_init;
  1287. #ifdef SUPPORT_SET_TID
  1288. uint8 tid_mode;
  1289. uint32 target_uid;
  1290. uint8 target_tid;
  1291. #endif /* SUPPORT_SET_TID */
  1292. #ifdef DHD_PKTDUMP_ROAM
  1293. void *pktcnts;
  1294. #endif /* DHD_PKTDUMP_ROAM */
  1295. bool disable_dtim_in_suspend; /* Disable set bcn_li_dtim in suspend */
  1296. #ifdef REVERSE_AIFSN
  1297. bool aifsn_reverse;
  1298. #endif /* REVERSE_AIFSN */
  1299. } dhd_pub_t;
  1300. typedef struct {
  1301. uint rxwake;
  1302. uint rcwake;
  1303. #ifdef DHD_WAKE_RX_STATUS
  1304. uint rx_bcast;
  1305. uint rx_arp;
  1306. uint rx_mcast;
  1307. uint rx_multi_ipv6;
  1308. uint rx_icmpv6;
  1309. uint rx_icmpv6_ra;
  1310. uint rx_icmpv6_na;
  1311. uint rx_icmpv6_ns;
  1312. uint rx_multi_ipv4;
  1313. uint rx_multi_other;
  1314. uint rx_ucast;
  1315. #endif /* DHD_WAKE_RX_STATUS */
  1316. #ifdef DHD_WAKE_EVENT_STATUS
  1317. uint rc_event[WLC_E_LAST];
  1318. #endif /* DHD_WAKE_EVENT_STATUS */
  1319. } wake_counts_t;
  1320. #if defined(PCIE_FULL_DONGLE)
  1321. /* Packet Tag for PCIE Full Dongle DHD */
  1322. typedef struct dhd_pkttag_fd {
  1323. uint16 flowid; /* Flowring Id */
  1324. uint16 ifid;
  1325. #ifndef DHD_PCIE_PKTID
  1326. uint16 dma_len; /* pkt len for DMA_MAP/UNMAP */
  1327. dmaaddr_t pa; /* physical address */
  1328. void *dmah; /* dma mapper handle */
  1329. void *secdma; /* secure dma sec_cma_info handle */
  1330. #endif /* !DHD_PCIE_PKTID */
  1331. #if defined(TX_STATUS_LATENCY_STATS)
  1332. uint64 q_time_us; /* time when tx pkt queued to flowring */
  1333. #endif // endif
  1334. } dhd_pkttag_fd_t;
  1335. /* Packet Tag for DHD PCIE Full Dongle */
  1336. #define DHD_PKTTAG_FD(pkt) ((dhd_pkttag_fd_t *)(PKTTAG(pkt)))
  1337. #define DHD_PKT_GET_FLOWID(pkt) ((DHD_PKTTAG_FD(pkt))->flowid)
  1338. #define DHD_PKT_SET_FLOWID(pkt, pkt_flowid) \
  1339. DHD_PKTTAG_FD(pkt)->flowid = (uint16)(pkt_flowid)
  1340. #define DHD_PKT_GET_DATAOFF(pkt) ((DHD_PKTTAG_FD(pkt))->dataoff)
  1341. #define DHD_PKT_SET_DATAOFF(pkt, pkt_dataoff) \
  1342. DHD_PKTTAG_FD(pkt)->dataoff = (uint16)(pkt_dataoff)
  1343. #define DHD_PKT_GET_DMA_LEN(pkt) ((DHD_PKTTAG_FD(pkt))->dma_len)
  1344. #define DHD_PKT_SET_DMA_LEN(pkt, pkt_dma_len) \
  1345. DHD_PKTTAG_FD(pkt)->dma_len = (uint16)(pkt_dma_len)
  1346. #define DHD_PKT_GET_PA(pkt) ((DHD_PKTTAG_FD(pkt))->pa)
  1347. #define DHD_PKT_SET_PA(pkt, pkt_pa) \
  1348. DHD_PKTTAG_FD(pkt)->pa = (dmaaddr_t)(pkt_pa)
  1349. #define DHD_PKT_GET_DMAH(pkt) ((DHD_PKTTAG_FD(pkt))->dmah)
  1350. #define DHD_PKT_SET_DMAH(pkt, pkt_dmah) \
  1351. DHD_PKTTAG_FD(pkt)->dmah = (void *)(pkt_dmah)
  1352. #define DHD_PKT_GET_SECDMA(pkt) ((DHD_PKTTAG_FD(pkt))->secdma)
  1353. #define DHD_PKT_SET_SECDMA(pkt, pkt_secdma) \
  1354. DHD_PKTTAG_FD(pkt)->secdma = (void *)(pkt_secdma)
  1355. #if defined(TX_STATUS_LATENCY_STATS)
  1356. #define DHD_PKT_GET_QTIME(pkt) ((DHD_PKTTAG_FD(pkt))->q_time_us)
  1357. #define DHD_PKT_SET_QTIME(pkt, pkt_q_time_us) \
  1358. DHD_PKTTAG_FD(pkt)->q_time_us = (uint64)(pkt_q_time_us)
  1359. #endif // endif
  1360. #endif /* PCIE_FULL_DONGLE */
  1361. #if defined(BCMWDF)
  1362. typedef struct {
  1363. dhd_pub_t *dhd_pub;
  1364. } dhd_workitem_context_t;
  1365. WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(dhd_workitem_context_t, dhd_get_dhd_workitem_context)
  1366. #endif /* (BCMWDF) */
  1367. #if defined(CONFIG_PM_SLEEP)
  1368. #define DHD_PM_RESUME_WAIT_INIT(a) DECLARE_WAIT_QUEUE_HEAD(a);
  1369. #define _DHD_PM_RESUME_WAIT(a, b) do {\
  1370. int retry = 0; \
  1371. SMP_RD_BARRIER_DEPENDS(); \
  1372. while (dhd_mmc_suspend && retry++ != b) { \
  1373. SMP_RD_BARRIER_DEPENDS(); \
  1374. wait_event_interruptible_timeout(a, !dhd_mmc_suspend, 1); \
  1375. } \
  1376. } while (0)
  1377. #define DHD_PM_RESUME_WAIT(a) _DHD_PM_RESUME_WAIT(a, 200)
  1378. #define DHD_PM_RESUME_WAIT_FOREVER(a) _DHD_PM_RESUME_WAIT(a, ~0)
  1379. #define DHD_PM_RESUME_RETURN_ERROR(a) do { \
  1380. if (dhd_mmc_suspend) { \
  1381. printf("%s[%d]: mmc is still in suspend state!!!\n", \
  1382. __FUNCTION__, __LINE__); \
  1383. return a; \
  1384. } \
  1385. } while (0)
  1386. #define DHD_PM_RESUME_RETURN do { if (dhd_mmc_suspend) return; } while (0)
  1387. #define DHD_SPINWAIT_SLEEP_INIT(a) DECLARE_WAIT_QUEUE_HEAD(a);
  1388. #define SPINWAIT_SLEEP(a, exp, us) do { \
  1389. uint countdown = (us) + 9999; \
  1390. while ((exp) && (countdown >= 10000)) { \
  1391. wait_event_interruptible_timeout(a, FALSE, 1); \
  1392. countdown -= 10000; \
  1393. } \
  1394. } while (0)
  1395. #else
  1396. #define DHD_PM_RESUME_WAIT_INIT(a)
  1397. #define DHD_PM_RESUME_WAIT(a)
  1398. #define DHD_PM_RESUME_WAIT_FOREVER(a)
  1399. #define DHD_PM_RESUME_RETURN_ERROR(a)
  1400. #define DHD_PM_RESUME_RETURN
  1401. #define DHD_SPINWAIT_SLEEP_INIT(a)
  1402. #define SPINWAIT_SLEEP(a, exp, us) do { \
  1403. uint countdown = (us) + 9; \
  1404. while ((exp) && (countdown >= 10)) { \
  1405. OSL_DELAY(10); \
  1406. countdown -= 10; \
  1407. } \
  1408. } while (0)
  1409. #endif /* CONFIG_PM_SLEEP */
  1410. #ifndef OSL_SLEEP
  1411. #define OSL_SLEEP(ms) OSL_DELAY(ms*1000)
  1412. #endif /* OSL_SLEEP */
  1413. #define DHD_IF_VIF 0x01 /* Virtual IF (Hidden from user) */
  1414. #ifdef PNO_SUPPORT
  1415. int dhd_pno_clean(dhd_pub_t *dhd);
  1416. #endif /* PNO_SUPPORT */
  1417. /*
  1418. * Wake locks are an Android power management concept. They are used by applications and services
  1419. * to request CPU resources.
  1420. */
  1421. #if defined(OEM_ANDROID)
  1422. extern int dhd_os_wake_lock(dhd_pub_t *pub);
  1423. extern int dhd_os_wake_unlock(dhd_pub_t *pub);
  1424. extern int dhd_os_wake_lock_waive(dhd_pub_t *pub);
  1425. extern int dhd_os_wake_lock_restore(dhd_pub_t *pub);
  1426. extern void dhd_event_wake_lock(dhd_pub_t *pub);
  1427. extern void dhd_event_wake_unlock(dhd_pub_t *pub);
  1428. extern void dhd_pm_wake_lock_timeout(dhd_pub_t *pub, int val);
  1429. extern void dhd_pm_wake_unlock(dhd_pub_t *pub);
  1430. extern void dhd_txfl_wake_lock_timeout(dhd_pub_t *pub, int val);
  1431. extern void dhd_txfl_wake_unlock(dhd_pub_t *pub);
  1432. extern int dhd_os_wake_lock_timeout(dhd_pub_t *pub);
  1433. extern int dhd_os_wake_lock_rx_timeout_enable(dhd_pub_t *pub, int val);
  1434. extern int dhd_os_wake_lock_ctrl_timeout_enable(dhd_pub_t *pub, int val);
  1435. extern int dhd_os_wake_lock_ctrl_timeout_cancel(dhd_pub_t *pub);
  1436. extern int dhd_os_wd_wake_lock(dhd_pub_t *pub);
  1437. extern int dhd_os_wd_wake_unlock(dhd_pub_t *pub);
  1438. extern void dhd_os_wake_lock_init(struct dhd_info *dhd);
  1439. extern void dhd_os_wake_lock_destroy(struct dhd_info *dhd);
  1440. #ifdef DHD_USE_SCAN_WAKELOCK
  1441. extern void dhd_os_scan_wake_lock_timeout(dhd_pub_t *pub, int val);
  1442. extern void dhd_os_scan_wake_unlock(dhd_pub_t *pub);
  1443. #endif /* BCMPCIE_SCAN_WAKELOCK */
  1444. inline static void MUTEX_LOCK_SOFTAP_SET_INIT(dhd_pub_t * dhdp)
  1445. {
  1446. #if defined(OEM_ANDROID)
  1447. mutex_init(&dhdp->wl_softap_lock);
  1448. #endif /* OEM_ANDROID */
  1449. }
  1450. inline static void MUTEX_LOCK_SOFTAP_SET(dhd_pub_t * dhdp)
  1451. {
  1452. #if defined(OEM_ANDROID)
  1453. mutex_lock(&dhdp->wl_softap_lock);
  1454. #endif /* OEM_ANDROID */
  1455. }
  1456. inline static void MUTEX_UNLOCK_SOFTAP_SET(dhd_pub_t * dhdp)
  1457. {
  1458. #if defined(OEM_ANDROID)
  1459. mutex_unlock(&dhdp->wl_softap_lock);
  1460. #endif /* OEM_ANDROID */
  1461. }
  1462. #ifdef DHD_DEBUG_WAKE_LOCK
  1463. #define DHD_OS_WAKE_LOCK(pub) \
  1464. do { \
  1465. printf("call wake_lock: %s %d\n", \
  1466. __FUNCTION__, __LINE__); \
  1467. dhd_os_wake_lock(pub); \
  1468. } while (0)
  1469. #define DHD_OS_WAKE_UNLOCK(pub) \
  1470. do { \
  1471. printf("call wake_unlock: %s %d\n", \
  1472. __FUNCTION__, __LINE__); \
  1473. dhd_os_wake_unlock(pub); \
  1474. } while (0)
  1475. #define DHD_EVENT_WAKE_LOCK(pub) \
  1476. do { \
  1477. printf("call event wake_lock: %s %d\n", \
  1478. __FUNCTION__, __LINE__); \
  1479. dhd_event_wake_lock(pub); \
  1480. } while (0)
  1481. #define DHD_EVENT_WAKE_UNLOCK(pub) \
  1482. do { \
  1483. printf("call event wake_unlock: %s %d\n", \
  1484. __FUNCTION__, __LINE__); \
  1485. dhd_event_wake_unlock(pub); \
  1486. } while (0)
  1487. #define DHD_PM_WAKE_LOCK_TIMEOUT(pub, val) \
  1488. do { \
  1489. printf("call pm_wake_timeout enable\n"); \
  1490. dhd_pm_wake_lock_timeout(pub, val); \
  1491. } while (0)
  1492. #define DHD_PM_WAKE_UNLOCK(pub) \
  1493. do { \
  1494. printf("call pm_wake unlock\n"); \
  1495. dhd_pm_wake_unlock(pub); \
  1496. } while (0)
  1497. #define DHD_TXFL_WAKE_LOCK_TIMEOUT(pub, val) \
  1498. do { \
  1499. printf("call pm_wake_timeout enable\n"); \
  1500. dhd_txfl_wake_lock_timeout(pub, val); \
  1501. } while (0)
  1502. #define DHD_TXFL_WAKE_UNLOCK(pub) \
  1503. do { \
  1504. printf("call pm_wake unlock\n"); \
  1505. dhd_txfl_wake_unlock(pub); \
  1506. } while (0)
  1507. #define DHD_OS_WAKE_LOCK_TIMEOUT(pub) \
  1508. do { \
  1509. printf("call wake_lock_timeout: %s %d\n", \
  1510. __FUNCTION__, __LINE__); \
  1511. dhd_os_wake_lock_timeout(pub); \
  1512. } while (0)
  1513. #define DHD_OS_WAKE_LOCK_RX_TIMEOUT_ENABLE(pub, val) \
  1514. do { \
  1515. printf("call wake_lock_rx_timeout_enable[%d]: %s %d\n", \
  1516. val, __FUNCTION__, __LINE__); \
  1517. dhd_os_wake_lock_rx_timeout_enable(pub, val); \
  1518. } while (0)
  1519. #define DHD_OS_WAKE_LOCK_CTRL_TIMEOUT_ENABLE(pub, val) \
  1520. do { \
  1521. printf("call wake_lock_ctrl_timeout_enable[%d]: %s %d\n", \
  1522. val, __FUNCTION__, __LINE__); \
  1523. dhd_os_wake_lock_ctrl_timeout_enable(pub, val); \
  1524. } while (0)
  1525. #define DHD_OS_WAKE_LOCK_CTRL_TIMEOUT_CANCEL(pub) \
  1526. do { \
  1527. printf("call wake_lock_ctrl_timeout_cancel: %s %d\n", \
  1528. __FUNCTION__, __LINE__); \
  1529. dhd_os_wake_lock_ctrl_timeout_cancel(pub); \
  1530. } while (0)
  1531. #define DHD_OS_WAKE_LOCK_WAIVE(pub) \
  1532. do { \
  1533. printf("call wake_lock_waive: %s %d\n", \
  1534. __FUNCTION__, __LINE__); \
  1535. dhd_os_wake_lock_waive(pub); \
  1536. } while (0)
  1537. #define DHD_OS_WAKE_LOCK_RESTORE(pub) \
  1538. do { \
  1539. printf("call wake_lock_restore: %s %d\n", \
  1540. __FUNCTION__, __LINE__); \
  1541. dhd_os_wake_lock_restore(pub); \
  1542. } while (0)
  1543. #define DHD_OS_WAKE_LOCK_INIT(dhd) \
  1544. do { \
  1545. printf("call wake_lock_init: %s %d\n", \
  1546. __FUNCTION__, __LINE__); \
  1547. dhd_os_wake_lock_init(dhd); \
  1548. } while (0)
  1549. #define DHD_OS_WAKE_LOCK_DESTROY(dhd) \
  1550. do { \
  1551. printf("call wake_lock_destroy: %s %d\n", \
  1552. __FUNCTION__, __LINE__); \
  1553. dhd_os_wake_lock_destroy(dhd); \
  1554. } while (0)
  1555. #else
  1556. #define DHD_OS_WAKE_LOCK(pub) dhd_os_wake_lock(pub)
  1557. #define DHD_OS_WAKE_UNLOCK(pub) dhd_os_wake_unlock(pub)
  1558. #define DHD_EVENT_WAKE_LOCK(pub) dhd_event_wake_lock(pub)
  1559. #define DHD_EVENT_WAKE_UNLOCK(pub) dhd_event_wake_unlock(pub)
  1560. #define DHD_PM_WAKE_LOCK_TIMEOUT(pub, val) dhd_pm_wake_lock_timeout(pub, val)
  1561. #define DHD_PM_WAKE_UNLOCK(pub) dhd_pm_wake_unlock(pub)
  1562. #define DHD_TXFL_WAKE_LOCK_TIMEOUT(pub, val) dhd_txfl_wake_lock_timeout(pub, val)
  1563. #define DHD_TXFL_WAKE_UNLOCK(pub) dhd_txfl_wake_unlock(pub)
  1564. #define DHD_OS_WAKE_LOCK_TIMEOUT(pub) dhd_os_wake_lock_timeout(pub)
  1565. #define DHD_OS_WAKE_LOCK_RX_TIMEOUT_ENABLE(pub, val) \
  1566. dhd_os_wake_lock_rx_timeout_enable(pub, val)
  1567. #define DHD_OS_WAKE_LOCK_CTRL_TIMEOUT_ENABLE(pub, val) \
  1568. dhd_os_wake_lock_ctrl_timeout_enable(pub, val)
  1569. #define DHD_OS_WAKE_LOCK_CTRL_TIMEOUT_CANCEL(pub) \
  1570. dhd_os_wake_lock_ctrl_timeout_cancel(pub)
  1571. #define DHD_OS_WAKE_LOCK_WAIVE(pub) dhd_os_wake_lock_waive(pub)
  1572. #define DHD_OS_WAKE_LOCK_RESTORE(pub) dhd_os_wake_lock_restore(pub)
  1573. #define DHD_OS_WAKE_LOCK_INIT(dhd) dhd_os_wake_lock_init(dhd);
  1574. #define DHD_OS_WAKE_LOCK_DESTROY(dhd) dhd_os_wake_lock_destroy(dhd);
  1575. #endif /* DHD_DEBUG_WAKE_LOCK */
  1576. #define DHD_OS_WD_WAKE_LOCK(pub) dhd_os_wd_wake_lock(pub)
  1577. #define DHD_OS_WD_WAKE_UNLOCK(pub) dhd_os_wd_wake_unlock(pub)
  1578. #ifdef DHD_USE_SCAN_WAKELOCK
  1579. #ifdef DHD_DEBUG_SCAN_WAKELOCK
  1580. #define DHD_OS_SCAN_WAKE_LOCK_TIMEOUT(pub, val) \
  1581. do { \
  1582. printf("call wake_lock_scan: %s %d\n", \
  1583. __FUNCTION__, __LINE__); \
  1584. dhd_os_scan_wake_lock_timeout(pub, val); \
  1585. } while (0)
  1586. #define DHD_OS_SCAN_WAKE_UNLOCK(pub) \
  1587. do { \
  1588. printf("call wake_unlock_scan: %s %d\n", \
  1589. __FUNCTION__, __LINE__); \
  1590. dhd_os_scan_wake_unlock(pub); \
  1591. } while (0)
  1592. #else
  1593. #define DHD_OS_SCAN_WAKE_LOCK_TIMEOUT(pub, val) dhd_os_scan_wake_lock_timeout(pub, val)
  1594. #define DHD_OS_SCAN_WAKE_UNLOCK(pub) dhd_os_scan_wake_unlock(pub)
  1595. #endif /* DHD_DEBUG_SCAN_WAKELOCK */
  1596. #else
  1597. #define DHD_OS_SCAN_WAKE_LOCK_TIMEOUT(pub, val)
  1598. #define DHD_OS_SCAN_WAKE_UNLOCK(pub)
  1599. #endif /* DHD_USE_SCAN_WAKELOCK */
  1600. #else
  1601. /* Wake lock are used in Android only (until the Linux community accepts it) */
  1602. #define DHD_OS_WAKE_LOCK(pub)
  1603. #define DHD_OS_WAKE_UNLOCK(pub)
  1604. #define DHD_EVENT_WAKE_LOCK(pub)
  1605. #define DHD_EVENT_WAKE_UNLOCK(pub)
  1606. #define DHD_PM_WAKE_LOCK_TIMEOUT(pub, val)
  1607. #define DHD_PM_WAKE_UNLOCK(pub)
  1608. #define DHD_TXFL_WAKE_LOCK_TIMEOUT(pub, val)
  1609. #define DHD_TXFL_WAKE_UNLOCK(pub)
  1610. #define DHD_OS_WD_WAKE_LOCK(pub)
  1611. #define DHD_OS_WD_WAKE_UNLOCK(pub)
  1612. #define DHD_OS_WAKE_LOCK_TIMEOUT(pub)
  1613. #define DHD_OS_WAKE_LOCK_RX_TIMEOUT_ENABLE(pub, val) UNUSED_PARAMETER(val)
  1614. #define DHD_OS_WAKE_LOCK_CTRL_TIMEOUT_ENABLE(pub, val) UNUSED_PARAMETER(val)
  1615. #define DHD_OS_WAKE_LOCK_CTRL_TIMEOUT_CANCEL(pub, val)
  1616. #define DHD_OS_WAKE_LOCK_WAIVE(pub)
  1617. #define DHD_OS_WAKE_LOCK_RESTORE(pub)
  1618. #define DHD_OS_SCAN_WAKE_LOCK_TIMEOUT(pub, val)
  1619. #define DHD_OS_SCAN_WAKE_UNLOCK(pub)
  1620. #define DHD_OS_WAKE_LOCK_INIT(dhd)
  1621. #define DHD_OS_WAKE_LOCK_DESTROY(dhd)
  1622. #endif // endif
  1623. #ifdef BCMPCIE_OOB_HOST_WAKE
  1624. #define OOB_WAKE_LOCK_TIMEOUT 500
  1625. extern void dhd_os_oob_irq_wake_lock_timeout(dhd_pub_t *pub, int val);
  1626. extern void dhd_os_oob_irq_wake_unlock(dhd_pub_t *pub);
  1627. #define DHD_OS_OOB_IRQ_WAKE_LOCK_TIMEOUT(pub, val) dhd_os_oob_irq_wake_lock_timeout(pub, val)
  1628. #define DHD_OS_OOB_IRQ_WAKE_UNLOCK(pub) dhd_os_oob_irq_wake_unlock(pub)
  1629. #endif /* BCMPCIE_OOB_HOST_WAKE */
  1630. #define DHD_PACKET_TIMEOUT_MS 500
  1631. #define DHD_EVENT_TIMEOUT_MS 1500
  1632. #define SCAN_WAKE_LOCK_TIMEOUT 10000
  1633. #define MAX_TX_TIMEOUT 500
  1634. /* Enum for IOCTL recieved status */
  1635. typedef enum dhd_ioctl_recieved_status
  1636. {
  1637. IOCTL_WAIT = 0,
  1638. IOCTL_RETURN_ON_SUCCESS,
  1639. IOCTL_RETURN_ON_TRAP,
  1640. IOCTL_RETURN_ON_BUS_STOP,
  1641. IOCTL_RETURN_ON_ERROR
  1642. } dhd_ioctl_recieved_status_t;
  1643. /* interface operations (register, remove) should be atomic, use this lock to prevent race
  1644. * condition among wifi on/off and interface operation functions
  1645. */
  1646. void dhd_net_if_lock(struct net_device *dev);
  1647. void dhd_net_if_unlock(struct net_device *dev);
  1648. #if defined(MULTIPLE_SUPPLICANT)
  1649. #if defined(OEM_ANDROID) && defined(BCMSDIO)
  1650. extern struct mutex _dhd_sdio_mutex_lock_;
  1651. #endif // endif
  1652. #endif /* MULTIPLE_SUPPLICANT */
  1653. typedef enum dhd_attach_states
  1654. {
  1655. DHD_ATTACH_STATE_INIT = 0x0,
  1656. DHD_ATTACH_STATE_NET_ALLOC = 0x1,
  1657. DHD_ATTACH_STATE_DHD_ALLOC = 0x2,
  1658. DHD_ATTACH_STATE_ADD_IF = 0x4,
  1659. DHD_ATTACH_STATE_PROT_ATTACH = 0x8,
  1660. DHD_ATTACH_STATE_WL_ATTACH = 0x10,
  1661. DHD_ATTACH_STATE_THREADS_CREATED = 0x20,
  1662. DHD_ATTACH_STATE_WAKELOCKS_INIT = 0x40,
  1663. DHD_ATTACH_STATE_CFG80211 = 0x80,
  1664. DHD_ATTACH_STATE_EARLYSUSPEND_DONE = 0x100,
  1665. DHD_ATTACH_TIMESYNC_ATTACH_DONE = 0x200,
  1666. DHD_ATTACH_LOGTRACE_INIT = 0x400,
  1667. DHD_ATTACH_STATE_LB_ATTACH_DONE = 0x800,
  1668. DHD_ATTACH_STATE_DONE = 0x1000
  1669. } dhd_attach_states_t;
  1670. /* Value -1 means we are unsuccessful in creating the kthread. */
  1671. #define DHD_PID_KT_INVALID -1
  1672. /* Value -2 means we are unsuccessful in both creating the kthread and tasklet */
  1673. #define DHD_PID_KT_TL_INVALID -2
  1674. /* default reporting period */
  1675. #define ECOUNTERS_DEFAULT_PERIOD 0
  1676. /* default number of reports. '0' indicates forever */
  1677. #define ECOUNTERS_NUM_REPORTS 0
  1678. typedef struct ecounters_cfg {
  1679. uint16 type;
  1680. uint16 if_slice_idx;
  1681. uint16 stats_rep;
  1682. } ecounters_cfg_t;
  1683. typedef struct event_ecounters_cfg {
  1684. uint16 event_id;
  1685. uint16 type;
  1686. uint16 if_slice_idx;
  1687. uint16 stats_rep;
  1688. } event_ecounters_cfg_t;
  1689. typedef struct ecountersv2_xtlv_list_elt {
  1690. /* Not quite the exact bcm_xtlv_t type as data could be pointing to other pieces in
  1691. * memory at the time of parsing arguments.
  1692. */
  1693. uint16 id;
  1694. uint16 len;
  1695. uint8 *data;
  1696. struct ecountersv2_xtlv_list_elt *next;
  1697. } ecountersv2_xtlv_list_elt_t;
  1698. typedef struct ecountersv2_processed_xtlv_list_elt {
  1699. uint8 *data;
  1700. struct ecountersv2_processed_xtlv_list_elt *next;
  1701. } ecountersv2_processed_xtlv_list_elt;
  1702. /*
  1703. * Exported from dhd OS modules (dhd_linux/dhd_ndis)
  1704. */
  1705. /* Indication from bus module regarding presence/insertion of dongle.
  1706. * Return dhd_pub_t pointer, used as handle to OS module in later calls.
  1707. * Returned structure should have bus and prot pointers filled in.
  1708. * bus_hdrlen specifies required headroom for bus module header.
  1709. */
  1710. extern dhd_pub_t *dhd_attach(osl_t *osh, struct dhd_bus *bus, uint bus_hdrlen);
  1711. extern int dhd_attach_net(dhd_pub_t *dhdp, bool need_rtnl_lock);
  1712. #if defined(WLP2P) && defined(WL_CFG80211)
  1713. /* To allow attach/detach calls corresponding to p2p0 interface */
  1714. extern int dhd_attach_p2p(dhd_pub_t *);
  1715. extern int dhd_detach_p2p(dhd_pub_t *);
  1716. #endif /* WLP2P && WL_CFG80211 */
  1717. extern int dhd_register_if(dhd_pub_t *dhdp, int idx, bool need_rtnl_lock);
  1718. #ifdef WL_VIF_SUPPORT
  1719. extern int dhd_register_vif(dhd_pub_t *dhdp);
  1720. #endif /* WL_VIF_SUPPORT */
  1721. /* Indication from bus module regarding removal/absence of dongle */
  1722. extern void dhd_detach(dhd_pub_t *dhdp);
  1723. extern void dhd_free(dhd_pub_t *dhdp);
  1724. extern void dhd_clear(dhd_pub_t *dhdp);
  1725. /* Indication from bus module to change flow-control state */
  1726. extern void dhd_txflowcontrol(dhd_pub_t *dhdp, int ifidx, bool on);
  1727. /* Store the status of a connection attempt for later retrieval by an iovar */
  1728. extern void dhd_store_conn_status(uint32 event, uint32 status, uint32 reason);
  1729. extern bool dhd_prec_enq(dhd_pub_t *dhdp, struct pktq *q, void *pkt, int prec);
  1730. extern void dhd_rx_frame(dhd_pub_t *dhdp, int ifidx, void *rxp, int numpkt, uint8 chan);
  1731. /* Return pointer to interface name */
  1732. extern char *dhd_ifname(dhd_pub_t *dhdp, int idx);
  1733. #ifdef DHD_UCODE_DOWNLOAD
  1734. /* Returns the ucode path */
  1735. extern char *dhd_get_ucode_path(dhd_pub_t *dhdp);
  1736. #endif /* DHD_UCODE_DOWNLOAD */
  1737. /* Request scheduling of the bus dpc */
  1738. extern void dhd_sched_dpc(dhd_pub_t *dhdp);
  1739. /* Notify tx completion */
  1740. extern void dhd_txcomplete(dhd_pub_t *dhdp, void *txp, bool success);
  1741. #ifdef DHD_4WAYM4_FAIL_DISCONNECT
  1742. extern void dhd_eap_txcomplete(dhd_pub_t *dhdp, void *txp, bool success, int ifidx);
  1743. extern void dhd_cleanup_m4_state_work(dhd_pub_t *dhdp, int ifidx);
  1744. #endif /* DHD_4WAYM4_FAIL_DISCONNECT */
  1745. #ifdef DHD_PCIE_NATIVE_RUNTIMEPM
  1746. extern void dhd_bus_wakeup_work(dhd_pub_t *dhdp);
  1747. #endif /* DHD_PCIE_NATIVE_RUNTIMEPM */
  1748. #define WIFI_FEATURE_INFRA 0x0001 /* Basic infrastructure mode */
  1749. #define WIFI_FEATURE_INFRA_5G 0x0002 /* Support for 5 GHz Band */
  1750. #define WIFI_FEATURE_HOTSPOT 0x0004 /* Support for GAS/ANQP */
  1751. #define WIFI_FEATURE_P2P 0x0008 /* Wifi-Direct */
  1752. #define WIFI_FEATURE_SOFT_AP 0x0010 /* Soft AP */
  1753. #define WIFI_FEATURE_GSCAN 0x0020 /* Google-Scan APIs */
  1754. #define WIFI_FEATURE_NAN 0x0040 /* Neighbor Awareness Networking */
  1755. #define WIFI_FEATURE_D2D_RTT 0x0080 /* Device-to-device RTT */
  1756. #define WIFI_FEATURE_D2AP_RTT 0x0100 /* Device-to-AP RTT */
  1757. #define WIFI_FEATURE_BATCH_SCAN 0x0200 /* Batched Scan (legacy) */
  1758. #define WIFI_FEATURE_PNO 0x0400 /* Preferred network offload */
  1759. #define WIFI_FEATURE_ADDITIONAL_STA 0x0800 /* Support for two STAs */
  1760. #define WIFI_FEATURE_TDLS 0x1000 /* Tunnel directed link setup */
  1761. #define WIFI_FEATURE_TDLS_OFFCHANNEL 0x2000 /* Support for TDLS off channel */
  1762. #define WIFI_FEATURE_EPR 0x4000 /* Enhanced power reporting */
  1763. #define WIFI_FEATURE_AP_STA 0x8000 /* Support for AP STA Concurrency */
  1764. #define WIFI_FEATURE_LINKSTAT 0x10000 /* Support for Linkstats */
  1765. #define WIFI_FEATURE_LOGGER 0x20000 /* WiFi Logger */
  1766. #define WIFI_FEATURE_HAL_EPNO 0x40000 /* WiFi PNO enhanced */
  1767. #define WIFI_FEATURE_RSSI_MONITOR 0x80000 /* RSSI Monitor */
  1768. #define WIFI_FEATURE_MKEEP_ALIVE 0x100000 /* WiFi mkeep_alive */
  1769. #define WIFI_FEATURE_CONFIG_NDO 0x200000 /* ND offload configure */
  1770. #define WIFI_FEATURE_TX_TRANSMIT_POWER 0x400000 /* Capture Tx transmit power levels */
  1771. #define WIFI_FEATURE_CONTROL_ROAMING 0x800000 /* Enable/Disable firmware roaming */
  1772. #define WIFI_FEATURE_FILTER_IE 0x1000000 /* Probe req ie filter */
  1773. #define WIFI_FEATURE_SCAN_RAND 0x2000000 /* Support MAC & Prb SN randomization */
  1774. #define WIFI_FEATURE_INVALID 0xFFFFFFFF /* Invalid Feature */
  1775. #define MAX_FEATURE_SET_CONCURRRENT_GROUPS 3
  1776. extern int dhd_dev_get_feature_set(struct net_device *dev);
  1777. extern int dhd_dev_get_feature_set_matrix(struct net_device *dev, int num);
  1778. extern int dhd_dev_cfg_rand_mac_oui(struct net_device *dev, uint8 *oui);
  1779. #ifdef CUSTOM_FORCE_NODFS_FLAG
  1780. extern int dhd_dev_set_nodfs(struct net_device *dev, uint nodfs);
  1781. #endif /* CUSTOM_FORCE_NODFS_FLAG */
  1782. #ifdef NDO_CONFIG_SUPPORT
  1783. #ifndef NDO_MAX_HOST_IP_ENTRIES
  1784. #define NDO_MAX_HOST_IP_ENTRIES 10
  1785. #endif /* NDO_MAX_HOST_IP_ENTRIES */
  1786. extern int dhd_dev_ndo_cfg(struct net_device *dev, u8 enable);
  1787. extern int dhd_dev_ndo_update_inet6addr(struct net_device * dev);
  1788. #endif /* NDO_CONFIG_SUPPORT */
  1789. extern int dhd_set_rand_mac_oui(dhd_pub_t *dhd);
  1790. #ifdef GSCAN_SUPPORT
  1791. extern int dhd_dev_set_lazy_roam_cfg(struct net_device *dev,
  1792. wlc_roam_exp_params_t *roam_param);
  1793. extern int dhd_dev_lazy_roam_enable(struct net_device *dev, uint32 enable);
  1794. extern int dhd_dev_set_lazy_roam_bssid_pref(struct net_device *dev,
  1795. wl_bssid_pref_cfg_t *bssid_pref, uint32 flush);
  1796. #endif /* GSCAN_SUPPORT */
  1797. #if defined(GSCAN_SUPPORT) || defined(ROAMEXP_SUPPORT)
  1798. extern int dhd_dev_set_blacklist_bssid(struct net_device *dev, maclist_t *blacklist,
  1799. uint32 len, uint32 flush);
  1800. extern int dhd_dev_set_whitelist_ssid(struct net_device *dev, wl_ssid_whitelist_t *whitelist,
  1801. uint32 len, uint32 flush);
  1802. #endif /* GSCAN_SUPPORT || ROAMEXP_SUPPORT */
  1803. /* OS independent layer functions */
  1804. extern void dhd_os_dhdiovar_lock(dhd_pub_t *pub);
  1805. extern void dhd_os_dhdiovar_unlock(dhd_pub_t *pub);
  1806. void dhd_os_logdump_lock(dhd_pub_t *pub);
  1807. void dhd_os_logdump_unlock(dhd_pub_t *pub);
  1808. extern int dhd_os_proto_block(dhd_pub_t * pub);
  1809. extern int dhd_os_proto_unblock(dhd_pub_t * pub);
  1810. extern int dhd_os_ioctl_resp_wait(dhd_pub_t * pub, uint * condition);
  1811. extern int dhd_os_ioctl_resp_wake(dhd_pub_t * pub);
  1812. extern unsigned int dhd_os_get_ioctl_resp_timeout(void);
  1813. extern void dhd_os_set_ioctl_resp_timeout(unsigned int timeout_msec);
  1814. extern void dhd_os_ioctl_resp_lock(dhd_pub_t * pub);
  1815. extern void dhd_os_ioctl_resp_unlock(dhd_pub_t * pub);
  1816. #ifdef PCIE_FULL_DONGLE
  1817. extern void dhd_wakeup_ioctl_event(dhd_pub_t *pub, dhd_ioctl_recieved_status_t reason);
  1818. #else
  1819. static INLINE void dhd_wakeup_ioctl_event(dhd_pub_t *pub, dhd_ioctl_recieved_status_t reason)
  1820. { printf("%s is NOT implemented for SDIO", __FUNCTION__); return; }
  1821. #endif // endif
  1822. #ifdef SHOW_LOGTRACE
  1823. /* Bound and delay are fine tuned after several experiments and these
  1824. * are the best case values to handle bombarding of console logs.
  1825. */
  1826. #define DHD_EVENT_LOGTRACE_BOUND 10
  1827. /* since FW has event log rate health check (EVENT_LOG_RATE_HC) we can reduce
  1828. * the reschedule delay to 10ms
  1829. */
  1830. #define DHD_EVENT_LOGTRACE_RESCHEDULE_DELAY_MS 10u
  1831. extern int dhd_os_read_file(void *file, char *buf, uint32 size);
  1832. extern int dhd_os_seek_file(void *file, int64 offset);
  1833. void dhd_sendup_info_buf(dhd_pub_t *dhdp, uint8 *msg);
  1834. #endif /* SHOW_LOGTRACE */
  1835. int dhd_os_write_file_posn(void *fp, unsigned long *posn,
  1836. void *buf, unsigned long buflen);
  1837. int dhd_msix_message_set(dhd_pub_t *dhdp, uint table_entry,
  1838. uint message_number, bool unmask);
  1839. extern void
  1840. dhd_pcie_dump_core_regs(dhd_pub_t * pub, uint32 index, uint32 first_addr, uint32 last_addr);
  1841. extern void wl_dhdpcie_dump_regs(void * context);
  1842. extern int dhd_os_get_image_block(char * buf, int len, void * image);
  1843. extern int dhd_os_get_image_size(void * image);
  1844. #if defined(BT_OVER_SDIO)
  1845. extern int dhd_os_gets_image(dhd_pub_t *pub, char *str, int len, void *image);
  1846. extern void dhdsdio_bus_usr_cnt_inc(dhd_pub_t *pub);
  1847. extern void dhdsdio_bus_usr_cnt_dec(dhd_pub_t *pub);
  1848. #endif /* (BT_OVER_SDIO) */
  1849. extern void *dhd_os_open_image1(dhd_pub_t *pub, char *filename); /* rev1 function signature */
  1850. extern void dhd_os_close_image1(dhd_pub_t *pub, void *image);
  1851. extern void dhd_os_wd_timer(void *bus, uint wdtick);
  1852. #ifdef DHD_PCIE_RUNTIMEPM
  1853. extern void dhd_os_runtimepm_timer(void *bus, uint tick);
  1854. #endif /* DHD_PCIE_RUNTIMEPM */
  1855. extern void dhd_os_sdlock(dhd_pub_t * pub);
  1856. extern void dhd_os_sdunlock(dhd_pub_t * pub);
  1857. extern void dhd_os_sdlock_txq(dhd_pub_t * pub);
  1858. extern void dhd_os_sdunlock_txq(dhd_pub_t * pub);
  1859. extern void dhd_os_sdlock_rxq(dhd_pub_t * pub);
  1860. extern void dhd_os_sdunlock_rxq(dhd_pub_t * pub);
  1861. extern void dhd_os_sdlock_sndup_rxq(dhd_pub_t * pub);
  1862. extern void dhd_os_tracelog(const char *format, ...);
  1863. #ifdef DHDTCPACK_SUPPRESS
  1864. extern unsigned long dhd_os_tcpacklock(dhd_pub_t *pub);
  1865. extern void dhd_os_tcpackunlock(dhd_pub_t *pub, unsigned long flags);
  1866. #endif /* DHDTCPACK_SUPPRESS */
  1867. extern int dhd_customer_oob_irq_map(void *adapter, unsigned long *irq_flags_ptr);
  1868. extern int dhd_customer_gpio_wlan_ctrl(void *adapter, int onoff);
  1869. extern int dhd_custom_get_mac_address(void *adapter, unsigned char *buf);
  1870. #if defined(CUSTOM_COUNTRY_CODE)
  1871. extern void get_customized_country_code(void *adapter, char *country_iso_code,
  1872. wl_country_t *cspec, u32 flags);
  1873. #else
  1874. extern void get_customized_country_code(void *adapter, char *country_iso_code, wl_country_t *cspec);
  1875. #endif /* CUSTOM_COUNTRY_CODE */
  1876. extern void dhd_os_sdunlock_sndup_rxq(dhd_pub_t * pub);
  1877. extern void dhd_os_sdlock_eventq(dhd_pub_t * pub);
  1878. extern void dhd_os_sdunlock_eventq(dhd_pub_t * pub);
  1879. extern bool dhd_os_check_hang(dhd_pub_t *dhdp, int ifidx, int ret);
  1880. extern int dhd_os_send_hang_message(dhd_pub_t *dhdp);
  1881. extern void dhd_set_version_info(dhd_pub_t *pub, char *fw);
  1882. extern bool dhd_os_check_if_up(dhd_pub_t *pub);
  1883. extern int dhd_os_check_wakelock(dhd_pub_t *pub);
  1884. extern int dhd_os_check_wakelock_all(dhd_pub_t *pub);
  1885. extern int dhd_get_instance(dhd_pub_t *pub);
  1886. #ifdef CUSTOM_SET_CPUCORE
  1887. extern void dhd_set_cpucore(dhd_pub_t *dhd, int set);
  1888. #endif /* CUSTOM_SET_CPUCORE */
  1889. #if defined(KEEP_ALIVE)
  1890. extern int dhd_keep_alive_onoff(dhd_pub_t *dhd);
  1891. #endif /* KEEP_ALIVE */
  1892. #if defined(DHD_FW_COREDUMP)
  1893. void dhd_schedule_memdump(dhd_pub_t *dhdp, uint8 *buf, uint32 size);
  1894. #endif /* DHD_FW_COREDUMP */
  1895. void dhd_write_sssr_dump(dhd_pub_t *dhdp, uint32 dump_mode);
  1896. #ifdef DNGL_AXI_ERROR_LOGGING
  1897. void dhd_schedule_axi_error_dump(dhd_pub_t *dhdp, void *type);
  1898. #endif /* DNGL_AXI_ERROR_LOGGING */
  1899. #ifdef BCMPCIE
  1900. void dhd_schedule_cto_recovery(dhd_pub_t *dhdp);
  1901. #endif /* BCMPCIE */
  1902. #ifdef PKT_FILTER_SUPPORT
  1903. #define DHD_UNICAST_FILTER_NUM 0
  1904. #define DHD_BROADCAST_FILTER_NUM 1
  1905. #define DHD_MULTICAST4_FILTER_NUM 2
  1906. #define DHD_MULTICAST6_FILTER_NUM 3
  1907. #define DHD_MDNS_FILTER_NUM 4
  1908. #define DHD_ARP_FILTER_NUM 5
  1909. #define DHD_BROADCAST_ARP_FILTER_NUM 6
  1910. #define DHD_IP4BCAST_DROP_FILTER_NUM 7
  1911. #define DHD_LLC_STP_DROP_FILTER_NUM 8
  1912. #define DHD_LLC_XID_DROP_FILTER_NUM 9
  1913. #define DISCARD_IPV4_MCAST "102 1 6 IP4_H:16 0xf0 0xe0"
  1914. #define DISCARD_IPV6_MCAST "103 1 6 IP6_H:24 0xff 0xff"
  1915. #define DISCARD_IPV4_BCAST "107 1 6 IP4_H:16 0xffffffff 0xffffffff"
  1916. #define DISCARD_LLC_STP "108 1 6 ETH_H:14 0xFFFFFFFFFFFF 0xAAAA0300000C"
  1917. #define DISCARD_LLC_XID "109 1 6 ETH_H:14 0xFFFFFF 0x0001AF"
  1918. extern int dhd_os_enable_packet_filter(dhd_pub_t *dhdp, int val);
  1919. extern void dhd_enable_packet_filter(int value, dhd_pub_t *dhd);
  1920. extern int dhd_packet_filter_add_remove(dhd_pub_t *dhdp, int add_remove, int num);
  1921. extern int net_os_enable_packet_filter(struct net_device *dev, int val);
  1922. extern int net_os_rxfilter_add_remove(struct net_device *dev, int val, int num);
  1923. #define MAX_PKTFLT_BUF_SIZE 2048
  1924. #define MAX_PKTFLT_FIXED_PATTERN_SIZE 32
  1925. #define MAX_PKTFLT_FIXED_BUF_SIZE \
  1926. (WL_PKT_FILTER_FIXED_LEN + MAX_PKTFLT_FIXED_PATTERN_SIZE * 2)
  1927. #define MAXPKT_ARG 16
  1928. #endif /* PKT_FILTER_SUPPORT */
  1929. #if defined(OEM_ANDROID) && defined(BCMPCIE)
  1930. extern int dhd_get_suspend_bcn_li_dtim(dhd_pub_t *dhd, int *dtim_period, int *bcn_interval);
  1931. #else
  1932. extern int dhd_get_suspend_bcn_li_dtim(dhd_pub_t *dhd);
  1933. #endif /* OEM_ANDROID && BCMPCIE */
  1934. extern bool dhd_support_sta_mode(dhd_pub_t *dhd);
  1935. extern int write_to_file(dhd_pub_t *dhd, uint8 *buf, int size);
  1936. #ifdef RSSI_MONITOR_SUPPORT
  1937. extern int dhd_dev_set_rssi_monitor_cfg(struct net_device *dev, int start,
  1938. int8 max_rssi, int8 min_rssi);
  1939. #endif /* RSSI_MONITOR_SUPPORT */
  1940. #ifdef DHDTCPACK_SUPPRESS
  1941. int dhd_dev_set_tcpack_sup_mode_cfg(struct net_device *dev, uint8 enable);
  1942. #endif /* DHDTCPACK_SUPPRESS */
  1943. #define DHD_RSSI_MONITOR_EVT_VERSION 1
  1944. typedef struct {
  1945. uint8 version;
  1946. int8 cur_rssi;
  1947. struct ether_addr BSSID;
  1948. } dhd_rssi_monitor_evt_t;
  1949. typedef struct {
  1950. uint32 limit; /* Expiration time (usec) */
  1951. uint32 increment; /* Current expiration increment (usec) */
  1952. uint32 elapsed; /* Current elapsed time (usec) */
  1953. uint32 tick; /* O/S tick time (usec) */
  1954. } dhd_timeout_t;
  1955. #ifdef SHOW_LOGTRACE
  1956. typedef struct {
  1957. uint num_fmts;
  1958. char **fmts;
  1959. char *raw_fmts;
  1960. char *raw_sstr;
  1961. uint32 fmts_size;
  1962. uint32 raw_fmts_size;
  1963. uint32 raw_sstr_size;
  1964. uint32 ramstart;
  1965. uint32 rodata_start;
  1966. uint32 rodata_end;
  1967. char *rom_raw_sstr;
  1968. uint32 rom_raw_sstr_size;
  1969. uint32 rom_ramstart;
  1970. uint32 rom_rodata_start;
  1971. uint32 rom_rodata_end;
  1972. } dhd_event_log_t;
  1973. #endif /* SHOW_LOGTRACE */
  1974. #ifdef KEEP_ALIVE
  1975. extern int dhd_dev_start_mkeep_alive(dhd_pub_t *dhd_pub, uint8 mkeep_alive_id, uint8 *ip_pkt,
  1976. uint16 ip_pkt_len, uint8* src_mac_addr, uint8* dst_mac_addr, uint32 period_msec);
  1977. extern int dhd_dev_stop_mkeep_alive(dhd_pub_t *dhd_pub, uint8 mkeep_alive_id);
  1978. #endif /* KEEP_ALIVE */
  1979. #if defined(PKT_FILTER_SUPPORT) && defined(APF)
  1980. /*
  1981. * As per Google's current implementation, there will be only one APF filter.
  1982. * Therefore, userspace doesn't bother about filter id and because of that
  1983. * DHD has to manage the filter id.
  1984. */
  1985. #define PKT_FILTER_APF_ID 200
  1986. #define DHD_APF_LOCK(ndev) dhd_apf_lock(ndev)
  1987. #define DHD_APF_UNLOCK(ndev) dhd_apf_unlock(ndev)
  1988. extern void dhd_apf_lock(struct net_device *dev);
  1989. extern void dhd_apf_unlock(struct net_device *dev);
  1990. extern int dhd_dev_apf_get_version(struct net_device *ndev, uint32 *version);
  1991. extern int dhd_dev_apf_get_max_len(struct net_device *ndev, uint32 *max_len);
  1992. extern int dhd_dev_apf_add_filter(struct net_device *ndev, u8* program,
  1993. uint32 program_len);
  1994. extern int dhd_dev_apf_enable_filter(struct net_device *ndev);
  1995. extern int dhd_dev_apf_disable_filter(struct net_device *ndev);
  1996. extern int dhd_dev_apf_delete_filter(struct net_device *ndev);
  1997. #endif /* PKT_FILTER_SUPPORT && APF */
  1998. extern void dhd_timeout_start(dhd_timeout_t *tmo, uint usec);
  1999. extern int dhd_timeout_expired(dhd_timeout_t *tmo);
  2000. extern int dhd_ifname2idx(struct dhd_info *dhd, char *name);
  2001. extern int dhd_net2idx(struct dhd_info *dhd, struct net_device *net);
  2002. extern struct net_device * dhd_idx2net(void *pub, int ifidx);
  2003. extern int net_os_send_hang_message(struct net_device *dev);
  2004. extern int net_os_send_hang_message_reason(struct net_device *dev, const char *string_num);
  2005. extern bool dhd_wowl_cap(void *bus);
  2006. extern int wl_host_event(dhd_pub_t *dhd_pub, int *idx, void *pktdata, uint pktlen,
  2007. wl_event_msg_t *, void **data_ptr, void *);
  2008. extern int wl_process_host_event(dhd_pub_t *dhd_pub, int *idx, void *pktdata, uint pktlen,
  2009. wl_event_msg_t *, void **data_ptr, void *);
  2010. extern void wl_event_to_host_order(wl_event_msg_t * evt);
  2011. extern int wl_host_event_get_data(void *pktdata, uint pktlen, bcm_event_msg_u_t *evu);
  2012. extern int dhd_wl_ioctl(dhd_pub_t *dhd_pub, int ifindex, wl_ioctl_t *ioc, void *buf, int len);
  2013. extern int dhd_wl_ioctl_cmd(dhd_pub_t *dhd_pub, int cmd, void *arg, int len, uint8 set,
  2014. int ifindex);
  2015. extern int dhd_wl_ioctl_get_intiovar(dhd_pub_t *dhd_pub, char *name, uint *pval,
  2016. int cmd, uint8 set, int ifidx);
  2017. extern int dhd_wl_ioctl_set_intiovar(dhd_pub_t *dhd_pub, char *name, uint val,
  2018. int cmd, uint8 set, int ifidx);
  2019. extern void dhd_common_init(osl_t *osh);
  2020. extern int dhd_do_driver_init(struct net_device *net);
  2021. extern int dhd_event_ifadd(struct dhd_info *dhd, struct wl_event_data_if *ifevent,
  2022. char *name, uint8 *mac);
  2023. extern int dhd_event_ifdel(struct dhd_info *dhd, struct wl_event_data_if *ifevent,
  2024. char *name, uint8 *mac);
  2025. extern int dhd_event_ifchange(struct dhd_info *dhd, struct wl_event_data_if *ifevent,
  2026. char *name, uint8 *mac);
  2027. extern struct net_device* dhd_allocate_if(dhd_pub_t *dhdpub, int ifidx, const char *name,
  2028. uint8 *mac, uint8 bssidx, bool need_rtnl_lock, const char *dngl_name);
  2029. extern int dhd_remove_if(dhd_pub_t *dhdpub, int ifidx, bool need_rtnl_lock);
  2030. #ifdef WL_STATIC_IF
  2031. extern s32 dhd_update_iflist_info(dhd_pub_t *dhdp, struct net_device *ndev, int ifidx,
  2032. uint8 *mac, uint8 bssidx, const char *dngl_name, int if_state);
  2033. #endif /* WL_STATIC_IF */
  2034. extern void dhd_vif_add(struct dhd_info *dhd, int ifidx, char * name);
  2035. extern void dhd_vif_del(struct dhd_info *dhd, int ifidx);
  2036. extern void dhd_event(struct dhd_info *dhd, char *evpkt, int evlen, int ifidx);
  2037. extern void dhd_vif_sendup(struct dhd_info *dhd, int ifidx, uchar *cp, int len);
  2038. #ifdef WL_NATOE
  2039. extern int dhd_natoe_ct_event(dhd_pub_t *dhd, char *data);
  2040. #endif /* WL_NATOE */
  2041. /* Send packet to dongle via data channel */
  2042. extern int dhd_sendpkt(dhd_pub_t *dhdp, int ifidx, void *pkt);
  2043. /* send up locally generated event */
  2044. extern void dhd_sendup_event_common(dhd_pub_t *dhdp, wl_event_msg_t *event, void *data);
  2045. /* Send event to host */
  2046. extern void dhd_sendup_event(dhd_pub_t *dhdp, wl_event_msg_t *event, void *data);
  2047. #ifdef LOG_INTO_TCPDUMP
  2048. extern void dhd_sendup_log(dhd_pub_t *dhdp, void *data, int len);
  2049. #endif /* LOG_INTO_TCPDUMP */
  2050. #ifdef SHOW_LOGTRACE
  2051. void dhd_sendup_info_buf(dhd_pub_t *dhdp, uint8 *msg);
  2052. #endif // endif
  2053. extern int dhd_bus_devreset(dhd_pub_t *dhdp, uint8 flag);
  2054. extern uint dhd_bus_status(dhd_pub_t *dhdp);
  2055. extern int dhd_bus_start(dhd_pub_t *dhdp);
  2056. extern int dhd_bus_suspend(dhd_pub_t *dhdpub);
  2057. extern int dhd_bus_resume(dhd_pub_t *dhdpub, int stage);
  2058. extern int dhd_bus_membytes(dhd_pub_t *dhdp, bool set, uint32 address, uint8 *data, uint size);
  2059. extern void dhd_print_buf(void *pbuf, int len, int bytes_per_line);
  2060. extern bool dhd_is_associated(dhd_pub_t *dhd, uint8 ifidx, int *retval);
  2061. #if defined(BCMSDIO) || defined(BCMPCIE)
  2062. extern uint dhd_bus_chip_id(dhd_pub_t *dhdp);
  2063. extern uint dhd_bus_chiprev_id(dhd_pub_t *dhdp);
  2064. extern uint dhd_bus_chippkg_id(dhd_pub_t *dhdp);
  2065. #endif /* defined(BCMSDIO) || defined(BCMPCIE) */
  2066. int dhd_bus_get_fw_mode(dhd_pub_t *dhdp);
  2067. #if defined(KEEP_ALIVE)
  2068. extern int dhd_keep_alive_onoff(dhd_pub_t *dhd);
  2069. #endif /* KEEP_ALIVE */
  2070. /* OS spin lock API */
  2071. extern void *dhd_os_spin_lock_init(osl_t *osh);
  2072. extern void dhd_os_spin_lock_deinit(osl_t *osh, void *lock);
  2073. extern unsigned long dhd_os_spin_lock(void *lock);
  2074. void dhd_os_spin_unlock(void *lock, unsigned long flags);
  2075. /* linux is defined for DHD EFI builds also,
  2076. * since its cross-compiled for EFI from linux.
  2077. * dbgring_lock apis are meant only for linux
  2078. * to use mutexes, other OSes will continue to
  2079. * use dhd_os_spin_lock
  2080. */
  2081. void *dhd_os_dbgring_lock_init(osl_t *osh);
  2082. void dhd_os_dbgring_lock_deinit(osl_t *osh, void *mtx);
  2083. unsigned long dhd_os_dbgring_lock(void *lock);
  2084. void dhd_os_dbgring_unlock(void *lock, unsigned long flags);
  2085. static INLINE int dhd_os_tput_test_wait(dhd_pub_t *pub, uint *condition,
  2086. uint timeout_ms)
  2087. { return 0; }
  2088. static INLINE int dhd_os_tput_test_wake(dhd_pub_t * pub)
  2089. { return 0; }
  2090. extern int dhd_os_busbusy_wait_negation(dhd_pub_t * pub, uint * condition);
  2091. extern int dhd_os_busbusy_wake(dhd_pub_t * pub);
  2092. extern void dhd_os_tx_completion_wake(dhd_pub_t *dhd);
  2093. extern int dhd_os_busbusy_wait_condition(dhd_pub_t *pub, uint *var, uint condition);
  2094. int dhd_os_busbusy_wait_bitmask(dhd_pub_t *pub, uint *var,
  2095. uint bitmask, uint condition);
  2096. extern int dhd_os_d3ack_wait(dhd_pub_t * pub, uint * condition);
  2097. extern int dhd_os_d3ack_wake(dhd_pub_t * pub);
  2098. extern int dhd_os_dmaxfer_wait(dhd_pub_t *pub, uint *condition);
  2099. extern int dhd_os_dmaxfer_wake(dhd_pub_t *pub);
  2100. /*
  2101. * Manage sta objects in an interface. Interface is identified by an ifindex and
  2102. * sta(s) within an interfaces are managed using a MacAddress of the sta.
  2103. */
  2104. struct dhd_sta;
  2105. extern bool dhd_sta_associated(dhd_pub_t *dhdp, uint32 bssidx, uint8 *mac);
  2106. extern struct dhd_sta *dhd_find_sta(void *pub, int ifidx, void *ea);
  2107. extern struct dhd_sta *dhd_findadd_sta(void *pub, int ifidx, void *ea);
  2108. extern void dhd_del_all_sta(void *pub, int ifidx);
  2109. extern void dhd_del_sta(void *pub, int ifidx, void *ea);
  2110. extern int dhd_get_ap_isolate(dhd_pub_t *dhdp, uint32 idx);
  2111. extern int dhd_set_ap_isolate(dhd_pub_t *dhdp, uint32 idx, int val);
  2112. extern int dhd_bssidx2idx(dhd_pub_t *dhdp, uint32 bssidx);
  2113. extern struct net_device *dhd_linux_get_primary_netdev(dhd_pub_t *dhdp);
  2114. extern bool dhd_is_concurrent_mode(dhd_pub_t *dhd);
  2115. int dhd_iovar(dhd_pub_t *pub, int ifidx, char *name, char *param_buf, uint param_len,
  2116. char *res_buf, uint res_len, int set);
  2117. extern int dhd_getiovar(dhd_pub_t *pub, int ifidx, char *name, char *cmd_buf,
  2118. uint cmd_len, char **resptr, uint resp_len);
  2119. #ifdef DHD_MCAST_REGEN
  2120. extern int dhd_get_mcast_regen_bss_enable(dhd_pub_t *dhdp, uint32 idx);
  2121. extern int dhd_set_mcast_regen_bss_enable(dhd_pub_t *dhdp, uint32 idx, int val);
  2122. #endif // endif
  2123. typedef enum cust_gpio_modes {
  2124. WLAN_RESET_ON,
  2125. WLAN_RESET_OFF,
  2126. WLAN_POWER_ON,
  2127. WLAN_POWER_OFF
  2128. } cust_gpio_modes_t;
  2129. typedef struct dmaxref_mem_map {
  2130. dhd_dma_buf_t *srcmem;
  2131. dhd_dma_buf_t *dstmem;
  2132. } dmaxref_mem_map_t;
  2133. #if defined(OEM_ANDROID)
  2134. extern int wl_iw_iscan_set_scan_broadcast_prep(struct net_device *dev, uint flag);
  2135. extern int wl_iw_send_priv_event(struct net_device *dev, char *flag);
  2136. #endif /* defined(OEM_ANDROID) */
  2137. #ifdef DHD_PCIE_NATIVE_RUNTIMEPM
  2138. extern void dhd_flush_rx_tx_wq(dhd_pub_t *dhdp);
  2139. #endif /* DHD_PCIE_NATIVE_RUNTIMEPM */
  2140. /*
  2141. * Insmod parameters for debug/test
  2142. */
  2143. /* Watchdog timer interval */
  2144. extern uint dhd_watchdog_ms;
  2145. #ifdef DHD_PCIE_RUNTIMEPM
  2146. extern uint dhd_runtimepm_ms;
  2147. #endif /* DHD_PCIE_RUNTIMEPM */
  2148. /** Default console output poll interval */
  2149. extern uint dhd_console_ms;
  2150. #if defined(DHD_DEBUG)
  2151. extern uint wl_msg_level;
  2152. #endif /* defined(DHD_DEBUG) */
  2153. extern uint dhd_slpauto;
  2154. /* Use interrupts */
  2155. extern uint dhd_intr;
  2156. /* Use polling */
  2157. extern uint dhd_poll;
  2158. /* ARP offload agent mode */
  2159. extern uint dhd_arp_mode;
  2160. /* ARP offload enable */
  2161. extern uint dhd_arp_enable;
  2162. /* Pkt filte enable control */
  2163. extern uint dhd_pkt_filter_enable;
  2164. /* Pkt filter init setup */
  2165. extern uint dhd_pkt_filter_init;
  2166. /* Pkt filter mode control */
  2167. extern uint dhd_master_mode;
  2168. /* Roaming mode control */
  2169. extern uint dhd_roam_disable;
  2170. /* Roaming mode control */
  2171. extern uint dhd_radio_up;
  2172. /* TCM verification control */
  2173. extern uint dhd_tcm_test_enable;
  2174. /* Initial idletime ticks (may be -1 for immediate idle, 0 for no idle) */
  2175. extern int dhd_idletime;
  2176. #ifdef DHD_USE_IDLECOUNT
  2177. #define DHD_IDLETIME_TICKS 5
  2178. #else
  2179. #define DHD_IDLETIME_TICKS 1
  2180. #endif /* DHD_USE_IDLECOUNT */
  2181. /* SDIO Drive Strength */
  2182. extern uint dhd_sdiod_drive_strength;
  2183. /* triggers bcm_bprintf to print to kernel log */
  2184. extern bool bcm_bprintf_bypass;
  2185. /* Override to force tx queueing all the time */
  2186. extern uint dhd_force_tx_queueing;
  2187. /* Default bcn_timeout value is 4 */
  2188. #define DEFAULT_BCN_TIMEOUT_VALUE 4
  2189. #ifndef CUSTOM_BCN_TIMEOUT_SETTING
  2190. #define CUSTOM_BCN_TIMEOUT_SETTING DEFAULT_BCN_TIMEOUT_VALUE
  2191. #endif // endif
  2192. /* Default KEEP_ALIVE Period is 55 sec to prevent AP from sending Keep Alive probe frame */
  2193. #define DEFAULT_KEEP_ALIVE_VALUE 55000 /* msec */
  2194. #ifndef CUSTOM_KEEP_ALIVE_SETTING
  2195. #define CUSTOM_KEEP_ALIVE_SETTING DEFAULT_KEEP_ALIVE_VALUE
  2196. #endif /* DEFAULT_KEEP_ALIVE_VALUE */
  2197. #define NULL_PKT_STR "null_pkt"
  2198. /* hooks for custom glom setting option via Makefile */
  2199. #define DEFAULT_GLOM_VALUE -1
  2200. #ifndef CUSTOM_GLOM_SETTING
  2201. #define CUSTOM_GLOM_SETTING DEFAULT_GLOM_VALUE
  2202. #endif // endif
  2203. #define WL_AUTO_ROAM_TRIGGER -75
  2204. /* hooks for custom Roaming Trigger setting via Makefile */
  2205. #define DEFAULT_ROAM_TRIGGER_VALUE -75 /* dBm default roam trigger all band */
  2206. #define DEFAULT_ROAM_TRIGGER_SETTING -1
  2207. #ifndef CUSTOM_ROAM_TRIGGER_SETTING
  2208. #define CUSTOM_ROAM_TRIGGER_SETTING DEFAULT_ROAM_TRIGGER_VALUE
  2209. #endif // endif
  2210. /* hooks for custom Roaming Romaing setting via Makefile */
  2211. #define DEFAULT_ROAM_DELTA_VALUE 10 /* dBm default roam delta all band */
  2212. #define DEFAULT_ROAM_DELTA_SETTING -1
  2213. #ifndef CUSTOM_ROAM_DELTA_SETTING
  2214. #define CUSTOM_ROAM_DELTA_SETTING DEFAULT_ROAM_DELTA_VALUE
  2215. #endif // endif
  2216. /* hooks for custom PNO Event wake lock to guarantee enough time
  2217. for the Platform to detect Event before system suspended
  2218. */
  2219. #define DEFAULT_PNO_EVENT_LOCK_xTIME 2 /* multiplay of DHD_PACKET_TIMEOUT_MS */
  2220. #ifndef CUSTOM_PNO_EVENT_LOCK_xTIME
  2221. #define CUSTOM_PNO_EVENT_LOCK_xTIME DEFAULT_PNO_EVENT_LOCK_xTIME
  2222. #endif // endif
  2223. /* hooks for custom dhd_dpc_prio setting option via Makefile */
  2224. #define DEFAULT_DHP_DPC_PRIO 1
  2225. #ifndef CUSTOM_DPC_PRIO_SETTING
  2226. #define CUSTOM_DPC_PRIO_SETTING DEFAULT_DHP_DPC_PRIO
  2227. #endif // endif
  2228. #ifndef CUSTOM_LISTEN_INTERVAL
  2229. #define CUSTOM_LISTEN_INTERVAL LISTEN_INTERVAL
  2230. #endif /* CUSTOM_LISTEN_INTERVAL */
  2231. #define DEFAULT_SUSPEND_BCN_LI_DTIM 3
  2232. #ifndef CUSTOM_SUSPEND_BCN_LI_DTIM
  2233. #define CUSTOM_SUSPEND_BCN_LI_DTIM DEFAULT_SUSPEND_BCN_LI_DTIM
  2234. #endif // endif
  2235. #ifdef OEM_ANDROID
  2236. #ifndef BCN_TIMEOUT_IN_SUSPEND
  2237. #define BCN_TIMEOUT_IN_SUSPEND 6 /* bcn timeout value in suspend mode */
  2238. #endif // endif
  2239. #endif /* OEM_ANDROID */
  2240. #ifndef CUSTOM_RXF_PRIO_SETTING
  2241. #define CUSTOM_RXF_PRIO_SETTING MAX((CUSTOM_DPC_PRIO_SETTING - 1), 1)
  2242. #endif // endif
  2243. #define DEFAULT_WIFI_TURNOFF_DELAY 0
  2244. #ifndef WIFI_TURNOFF_DELAY
  2245. #define WIFI_TURNOFF_DELAY DEFAULT_WIFI_TURNOFF_DELAY
  2246. #endif /* WIFI_TURNOFF_DELAY */
  2247. #define DEFAULT_WIFI_TURNON_DELAY 200
  2248. #ifndef WIFI_TURNON_DELAY
  2249. #define WIFI_TURNON_DELAY DEFAULT_WIFI_TURNON_DELAY
  2250. #endif /* WIFI_TURNON_DELAY */
  2251. #define DEFAULT_DHD_WATCHDOG_INTERVAL_MS 10 /* msec */
  2252. #ifndef CUSTOM_DHD_WATCHDOG_MS
  2253. #define CUSTOM_DHD_WATCHDOG_MS DEFAULT_DHD_WATCHDOG_INTERVAL_MS
  2254. #endif /* DEFAULT_DHD_WATCHDOG_INTERVAL_MS */
  2255. #define DEFAULT_ASSOC_RETRY_MAX 3
  2256. #ifndef CUSTOM_ASSOC_RETRY_MAX
  2257. #define CUSTOM_ASSOC_RETRY_MAX DEFAULT_ASSOC_RETRY_MAX
  2258. #endif /* DEFAULT_ASSOC_RETRY_MAX */
  2259. #if defined(BCMSDIO) || defined(DISABLE_FRAMEBURST)
  2260. #define DEFAULT_FRAMEBURST_SET 0
  2261. #else
  2262. #define DEFAULT_FRAMEBURST_SET 1
  2263. #endif /* BCMSDIO */
  2264. #ifndef CUSTOM_FRAMEBURST_SET
  2265. #define CUSTOM_FRAMEBURST_SET DEFAULT_FRAMEBURST_SET
  2266. #endif /* CUSTOM_FRAMEBURST_SET */
  2267. #ifdef WLTDLS
  2268. #ifndef CUSTOM_TDLS_IDLE_MODE_SETTING
  2269. #define CUSTOM_TDLS_IDLE_MODE_SETTING 60000 /* 60sec to tear down TDLS of not active */
  2270. #endif // endif
  2271. #ifndef CUSTOM_TDLS_RSSI_THRESHOLD_HIGH
  2272. #define CUSTOM_TDLS_RSSI_THRESHOLD_HIGH -70 /* rssi threshold for establishing TDLS link */
  2273. #endif // endif
  2274. #ifndef CUSTOM_TDLS_RSSI_THRESHOLD_LOW
  2275. #define CUSTOM_TDLS_RSSI_THRESHOLD_LOW -80 /* rssi threshold for tearing down TDLS link */
  2276. #endif // endif
  2277. #ifndef CUSTOM_TDLS_PCKTCNT_THRESHOLD_HIGH
  2278. #define CUSTOM_TDLS_PCKTCNT_THRESHOLD_HIGH 100 /* pkt/sec threshold for establishing TDLS link */
  2279. #endif // endif
  2280. #ifndef CUSTOM_TDLS_PCKTCNT_THRESHOLD_LOW
  2281. #define CUSTOM_TDLS_PCKTCNT_THRESHOLD_LOW 10 /* pkt/sec threshold for tearing down TDLS link */
  2282. #endif // endif
  2283. #endif /* WLTDLS */
  2284. #if defined(VSDB) || defined(ROAM_ENABLE)
  2285. #define DEFAULT_BCN_TIMEOUT 8
  2286. #else
  2287. #define DEFAULT_BCN_TIMEOUT 4
  2288. #endif // endif
  2289. #ifndef CUSTOM_BCN_TIMEOUT
  2290. #define CUSTOM_BCN_TIMEOUT DEFAULT_BCN_TIMEOUT
  2291. #endif // endif
  2292. #define MAX_DTIM_SKIP_BEACON_INTERVAL 100 /* max allowed associated AP beacon for DTIM skip */
  2293. #ifndef MAX_DTIM_ALLOWED_INTERVAL
  2294. #define MAX_DTIM_ALLOWED_INTERVAL 600 /* max allowed total beacon interval for DTIM skip */
  2295. #endif // endif
  2296. #ifdef OEM_ANDROID
  2297. #ifndef MIN_DTIM_FOR_ROAM_THRES_EXTEND
  2298. #define MIN_DTIM_FOR_ROAM_THRES_EXTEND 600 /* minimum dtim interval to extend roam threshold */
  2299. #endif // endif
  2300. #endif /* OEM_ANDROID */
  2301. #define NO_DTIM_SKIP 1
  2302. #ifdef SDTEST
  2303. /* Echo packet generator (SDIO), pkts/s */
  2304. extern uint dhd_pktgen;
  2305. /* Echo packet len (0 => sawtooth, max 1800) */
  2306. extern uint dhd_pktgen_len;
  2307. #define MAX_PKTGEN_LEN 1800
  2308. #endif // endif
  2309. /* optionally set by a module_param_string() */
  2310. #define MOD_PARAM_PATHLEN 2048
  2311. #define MOD_PARAM_INFOLEN 512
  2312. #define MOD_PARAM_SRLEN 64
  2313. #ifdef SOFTAP
  2314. extern char fw_path2[MOD_PARAM_PATHLEN];
  2315. #endif // endif
  2316. #if defined(ANDROID_PLATFORM_VERSION)
  2317. #if (ANDROID_PLATFORM_VERSION < 7)
  2318. #define DHD_LEGACY_FILE_PATH
  2319. #define VENDOR_PATH "/system"
  2320. #elif (ANDROID_PLATFORM_VERSION == 7)
  2321. #define VENDOR_PATH "/system"
  2322. #elif (ANDROID_PLATFORM_VERSION >= 8)
  2323. #define VENDOR_PATH "/vendor"
  2324. #endif /* ANDROID_PLATFORM_VERSION < 7 */
  2325. #else
  2326. #define VENDOR_PATH ""
  2327. #endif /* ANDROID_PLATFORM_VERSION */
  2328. #if defined(ANDROID_PLATFORM_VERSION)
  2329. #if (ANDROID_PLATFORM_VERSION < 9)
  2330. #ifdef WL_STATIC_IF
  2331. #undef WL_STATIC_IF
  2332. #endif /* WL_STATIC_IF */
  2333. #ifdef WL_STATIC_IFNAME_PREFIX
  2334. #undef WL_STATIC_IFNAME_PREFIX
  2335. #endif /* WL_STATIC_IFNAME_PREFIX */
  2336. #endif /* ANDROID_PLATFORM_VERSION < 9 */
  2337. #endif /* ANDROID_PLATFORM_VERSION */
  2338. #if defined(DHD_LEGACY_FILE_PATH)
  2339. #define PLATFORM_PATH "/data/"
  2340. #elif defined(PLATFORM_SLP)
  2341. #define PLATFORM_PATH "/opt/etc/"
  2342. #else
  2343. #if defined(ANDROID_PLATFORM_VERSION)
  2344. #if (ANDROID_PLATFORM_VERSION >= 9)
  2345. #define PLATFORM_PATH "/data/vendor/conn/"
  2346. #define DHD_MAC_ADDR_EXPORT
  2347. #define DHD_ADPS_BAM_EXPORT
  2348. #define DHD_EXPORT_CNTL_FILE
  2349. #define DHD_SOFTAP_DUAL_IF_INFO
  2350. #define DHD_SEND_HANG_PRIVCMD_ERRORS
  2351. #else
  2352. #define PLATFORM_PATH "/data/misc/conn/"
  2353. #endif /* ANDROID_PLATFORM_VERSION >= 9 */
  2354. #else
  2355. #define PLATFORM_PATH "/data/misc/conn/"
  2356. #endif /* ANDROID_PLATFORM_VERSION */
  2357. #endif /* DHD_LEGACY_FILE_PATH */
  2358. #ifdef DHD_MAC_ADDR_EXPORT
  2359. extern struct ether_addr sysfs_mac_addr;
  2360. #endif /* DHD_MAC_ADDR_EXPORT */
  2361. /* Flag to indicate if we should download firmware on driver load */
  2362. extern uint dhd_download_fw_on_driverload;
  2363. extern int allow_delay_fwdl;
  2364. extern int dhd_process_cid_mac(dhd_pub_t *dhdp, bool prepost);
  2365. extern int dhd_write_file(const char *filepath, char *buf, int buf_len);
  2366. extern int dhd_read_file(const char *filepath, char *buf, int buf_len);
  2367. extern int dhd_write_file_and_check(const char *filepath, char *buf, int buf_len);
  2368. extern int dhd_file_delete(char *path);
  2369. #ifdef READ_MACADDR
  2370. extern int dhd_set_macaddr_from_file(dhd_pub_t *dhdp);
  2371. #else
  2372. static INLINE int dhd_set_macaddr_from_file(dhd_pub_t *dhdp) { return 0; }
  2373. #endif /* READ_MACADDR */
  2374. #ifdef WRITE_MACADDR
  2375. extern int dhd_write_macaddr(struct ether_addr *mac);
  2376. #else
  2377. static INLINE int dhd_write_macaddr(struct ether_addr *mac) { return 0; }
  2378. #endif /* WRITE_MACADDR */
  2379. #ifdef USE_CID_CHECK
  2380. #define MAX_VNAME_LEN 64
  2381. #ifdef DHD_EXPORT_CNTL_FILE
  2382. extern char cidinfostr[MAX_VNAME_LEN];
  2383. #endif /* DHD_EXPORT_CNTL_FILE */
  2384. extern int dhd_check_module_cid(dhd_pub_t *dhdp);
  2385. extern char *dhd_get_cid_info(unsigned char *vid, int vid_length);
  2386. #else
  2387. static INLINE int dhd_check_module_cid(dhd_pub_t *dhdp) { return 0; }
  2388. #endif /* USE_CID_CHECK */
  2389. #ifdef GET_MAC_FROM_OTP
  2390. extern int dhd_check_module_mac(dhd_pub_t *dhdp);
  2391. #else
  2392. static INLINE int dhd_check_module_mac(dhd_pub_t *dhdp) { return 0; }
  2393. #endif /* GET_MAC_FROM_OTP */
  2394. #if defined(READ_MACADDR) || defined(WRITE_MACADDR) || defined(USE_CID_CHECK) || \
  2395. defined(GET_MAC_FROM_OTP)
  2396. #define DHD_USE_CISINFO
  2397. #endif /* READ_MACADDR || WRITE_MACADDR || USE_CID_CHECK || GET_MAC_FROM_OTP */
  2398. #ifdef DHD_USE_CISINFO
  2399. int dhd_read_cis(dhd_pub_t *dhdp);
  2400. void dhd_clear_cis(dhd_pub_t *dhdp);
  2401. #if defined(SUPPORT_MULTIPLE_MODULE_CIS) && defined(USE_CID_CHECK)
  2402. extern int dhd_check_module_b85a(void);
  2403. extern int dhd_check_module_b90(void);
  2404. #define BCM4359_MODULE_TYPE_B90B 1
  2405. #define BCM4359_MODULE_TYPE_B90S 2
  2406. #endif /* defined(SUPPORT_MULTIPLE_MODULE_CIS) && defined(USE_CID_CHECK) */
  2407. #if defined(USE_CID_CHECK)
  2408. extern int dhd_check_module_bcm(char *module_type, int index, bool *is_murata_fem);
  2409. #endif /* defined(USE_CID_CHECK) */
  2410. #else
  2411. static INLINE int dhd_read_cis(dhd_pub_t *dhdp) { return 0; }
  2412. static INLINE void dhd_clear_cis(dhd_pub_t *dhdp) { }
  2413. #endif /* DHD_USE_CISINFO */
  2414. #if defined(WL_CFG80211) && defined(SUPPORT_DEEP_SLEEP)
  2415. /* Flags to indicate if we distingish power off policy when
  2416. * user set the memu "Keep Wi-Fi on during sleep" to "Never"
  2417. */
  2418. extern int trigger_deep_sleep;
  2419. int dhd_deepsleep(struct net_device *dev, int flag);
  2420. #endif /* WL_CFG80211 && SUPPORT_DEEP_SLEEP */
  2421. extern void dhd_wait_for_event(dhd_pub_t *dhd, bool *lockvar);
  2422. extern void dhd_wait_event_wakeup(dhd_pub_t*dhd);
  2423. #define IFLOCK_INIT(lock) *lock = 0
  2424. #define IFLOCK(lock) while (InterlockedCompareExchange((lock), 1, 0)) \
  2425. NdisStallExecution(1);
  2426. #define IFUNLOCK(lock) InterlockedExchange((lock), 0)
  2427. #define IFLOCK_FREE(lock)
  2428. #define FW_SUPPORTED(dhd, capa) ((strstr(dhd->fw_capabilities, " " #capa " ") != NULL))
  2429. #ifdef ARP_OFFLOAD_SUPPORT
  2430. #define MAX_IPV4_ENTRIES 8
  2431. void dhd_arp_offload_set(dhd_pub_t * dhd, int arp_mode);
  2432. void dhd_arp_offload_enable(dhd_pub_t * dhd, int arp_enable);
  2433. /* dhd_commn arp offload wrapers */
  2434. void dhd_aoe_hostip_clr(dhd_pub_t *dhd, int idx);
  2435. void dhd_aoe_arp_clr(dhd_pub_t *dhd, int idx);
  2436. int dhd_arp_get_arp_hostip_table(dhd_pub_t *dhd, void *buf, int buflen, int idx);
  2437. void dhd_arp_offload_add_ip(dhd_pub_t *dhd, uint32 ipaddr, int idx);
  2438. #endif /* ARP_OFFLOAD_SUPPORT */
  2439. #ifdef WLTDLS
  2440. int dhd_tdls_enable(struct net_device *dev, bool tdls_on, bool auto_on, struct ether_addr *mac);
  2441. int dhd_tdls_set_mode(dhd_pub_t *dhd, bool wfd_mode);
  2442. #ifdef PCIE_FULL_DONGLE
  2443. int dhd_tdls_update_peer_info(dhd_pub_t *dhdp, wl_event_msg_t *event);
  2444. int dhd_tdls_event_handler(dhd_pub_t *dhd_pub, wl_event_msg_t *event);
  2445. int dhd_free_tdls_peer_list(dhd_pub_t *dhd_pub);
  2446. #endif /* PCIE_FULL_DONGLE */
  2447. #endif /* WLTDLS */
  2448. /* Neighbor Discovery Offload Support */
  2449. extern int dhd_ndo_enable(dhd_pub_t * dhd, int ndo_enable);
  2450. int dhd_ndo_add_ip(dhd_pub_t *dhd, char* ipaddr, int idx);
  2451. int dhd_ndo_remove_ip(dhd_pub_t *dhd, int idx);
  2452. /* Enhanced ND offload support */
  2453. uint16 dhd_ndo_get_version(dhd_pub_t *dhdp);
  2454. int dhd_ndo_add_ip_with_type(dhd_pub_t *dhdp, char *ipv6addr, uint8 type, int idx);
  2455. int dhd_ndo_remove_ip_by_addr(dhd_pub_t *dhdp, char *ipv6addr, int idx);
  2456. int dhd_ndo_remove_ip_by_type(dhd_pub_t *dhdp, uint8 type, int idx);
  2457. int dhd_ndo_unsolicited_na_filter_enable(dhd_pub_t *dhdp, int enable);
  2458. /* ioctl processing for nl80211 */
  2459. int dhd_ioctl_process(dhd_pub_t *pub, int ifidx, struct dhd_ioctl *ioc, void *data_buf);
  2460. #if defined(SUPPORT_MULTIPLE_REVISION)
  2461. extern int
  2462. concate_revision(struct dhd_bus *bus, char *fwpath, char *nvpath);
  2463. #endif /* SUPPORT_MULTIPLE_REVISION */
  2464. void dhd_bus_update_fw_nv_path(struct dhd_bus *bus, char *pfw_path, char *pnv_path);
  2465. void dhd_set_bus_state(void *bus, uint32 state);
  2466. /* Remove proper pkts(either one no-frag pkt or whole fragmented pkts) */
  2467. typedef int (*f_droppkt_t)(dhd_pub_t *dhdp, int prec, void* p, bool bPktInQ);
  2468. extern bool dhd_prec_drop_pkts(dhd_pub_t *dhdp, struct pktq *pq, int prec, f_droppkt_t fn);
  2469. #ifdef PROP_TXSTATUS
  2470. int dhd_os_wlfc_block(dhd_pub_t *pub);
  2471. int dhd_os_wlfc_unblock(dhd_pub_t *pub);
  2472. extern const uint8 prio2fifo[];
  2473. #endif /* PROP_TXSTATUS */
  2474. int dhd_os_socram_dump(struct net_device *dev, uint32 *dump_size);
  2475. int dhd_os_get_socram_dump(struct net_device *dev, char **buf, uint32 *size);
  2476. int dhd_common_socram_dump(dhd_pub_t *dhdp);
  2477. int dhd_dump(dhd_pub_t *dhdp, char *buf, int buflen);
  2478. int dhd_os_get_version(struct net_device *dev, bool dhd_ver, char **buf, uint32 size);
  2479. void dhd_get_memdump_filename(struct net_device *ndev, char *memdump_path, int len, char *fname);
  2480. uint8* dhd_os_prealloc(dhd_pub_t *dhdpub, int section, uint size, bool kmalloc_if_fail);
  2481. void dhd_os_prefree(dhd_pub_t *dhdpub, void *addr, uint size);
  2482. #if defined(CONFIG_DHD_USE_STATIC_BUF)
  2483. #define DHD_OS_PREALLOC(dhdpub, section, size) dhd_os_prealloc(dhdpub, section, size, FALSE)
  2484. #define DHD_OS_PREFREE(dhdpub, addr, size) dhd_os_prefree(dhdpub, addr, size)
  2485. #else
  2486. #define DHD_OS_PREALLOC(dhdpub, section, size) MALLOC(dhdpub->osh, size)
  2487. #define DHD_OS_PREFREE(dhdpub, addr, size) MFREE(dhdpub->osh, addr, size)
  2488. #endif /* defined(CONFIG_DHD_USE_STATIC_BUF) */
  2489. #ifdef USE_WFA_CERT_CONF
  2490. enum {
  2491. SET_PARAM_BUS_TXGLOM_MODE,
  2492. SET_PARAM_ROAMOFF,
  2493. #ifdef USE_WL_FRAMEBURST
  2494. SET_PARAM_FRAMEBURST,
  2495. #endif /* USE_WL_FRAMEBURST */
  2496. #ifdef USE_WL_TXBF
  2497. SET_PARAM_TXBF,
  2498. #endif /* USE_WL_TXBF */
  2499. #ifdef PROP_TXSTATUS
  2500. SET_PARAM_PROPTX,
  2501. SET_PARAM_PROPTXMODE,
  2502. #endif /* PROP_TXSTATUS */
  2503. PARAM_LAST_VALUE
  2504. };
  2505. extern int sec_get_param_wfa_cert(dhd_pub_t *dhd, int mode, uint* read_val);
  2506. #ifdef DHD_EXPORT_CNTL_FILE
  2507. #define VALUENOTSET 0xFFFFFFFFu
  2508. extern uint32 bus_txglom;
  2509. extern uint32 roam_off;
  2510. #ifdef USE_WL_FRAMEBURST
  2511. extern uint32 frameburst;
  2512. #endif /* USE_WL_FRAMEBURST */
  2513. #ifdef USE_WL_TXBF
  2514. extern uint32 txbf;
  2515. #endif /* USE_WL_TXBF */
  2516. #ifdef PROP_TXSTATUS
  2517. extern uint32 proptx;
  2518. #endif /* PROP_TXSTATUS */
  2519. #endif /* DHD_EXPORT_CNTL_FILE */
  2520. #endif /* USE_WFA_CERT_CONF */
  2521. #define dhd_add_flowid(pub, ifidx, ac_prio, ea, flowid) do {} while (0)
  2522. #define dhd_del_flowid(pub, ifidx, flowid) do {} while (0)
  2523. bool dhd_wet_chainable(dhd_pub_t *dhdp);
  2524. extern unsigned long dhd_os_general_spin_lock(dhd_pub_t *pub);
  2525. extern void dhd_os_general_spin_unlock(dhd_pub_t *pub, unsigned long flags);
  2526. /** Miscellaenous DHD Spin Locks */
  2527. /* Disable router 3GMAC bypass path perimeter lock */
  2528. #define DHD_PERIM_LOCK(dhdp) do {} while (0)
  2529. #define DHD_PERIM_UNLOCK(dhdp) do {} while (0)
  2530. #define DHD_PERIM_LOCK_ALL(processor_id) do {} while (0)
  2531. #define DHD_PERIM_UNLOCK_ALL(processor_id) do {} while (0)
  2532. /* Enable DHD general spin lock/unlock */
  2533. #define DHD_GENERAL_LOCK(dhdp, flags) \
  2534. (flags) = dhd_os_general_spin_lock(dhdp)
  2535. #define DHD_GENERAL_UNLOCK(dhdp, flags) \
  2536. dhd_os_general_spin_unlock((dhdp), (flags))
  2537. /* Enable DHD timer spin lock/unlock */
  2538. #define DHD_TIMER_LOCK(lock, flags) (flags) = dhd_os_spin_lock(lock)
  2539. #define DHD_TIMER_UNLOCK(lock, flags) dhd_os_spin_unlock(lock, (flags))
  2540. /* Enable DHD flowring spin lock/unlock */
  2541. #define DHD_FLOWRING_LOCK(lock, flags) (flags) = dhd_os_spin_lock(lock)
  2542. #define DHD_FLOWRING_UNLOCK(lock, flags) dhd_os_spin_unlock((lock), (flags))
  2543. /* Enable DHD common flowring info spin lock/unlock */
  2544. #define DHD_FLOWID_LOCK(lock, flags) (flags) = dhd_os_spin_lock(lock)
  2545. #define DHD_FLOWID_UNLOCK(lock, flags) dhd_os_spin_unlock((lock), (flags))
  2546. /* Enable DHD common flowring list spin lock/unlock */
  2547. #define DHD_FLOWRING_LIST_LOCK(lock, flags) (flags) = dhd_os_spin_lock(lock)
  2548. #define DHD_FLOWRING_LIST_UNLOCK(lock, flags) dhd_os_spin_unlock((lock), (flags))
  2549. #define DHD_SPIN_LOCK(lock, flags) (flags) = dhd_os_spin_lock(lock)
  2550. #define DHD_SPIN_UNLOCK(lock, flags) dhd_os_spin_unlock((lock), (flags))
  2551. #define DHD_RING_LOCK(lock, flags) (flags) = dhd_os_spin_lock(lock)
  2552. #define DHD_RING_UNLOCK(lock, flags) dhd_os_spin_unlock((lock), (flags))
  2553. #define DHD_BUS_LOCK(lock, flags) (flags) = dhd_os_spin_lock(lock)
  2554. #define DHD_BUS_UNLOCK(lock, flags) dhd_os_spin_unlock((lock), (flags))
  2555. /* Enable DHD backplane spin lock/unlock */
  2556. #define DHD_BACKPLANE_ACCESS_LOCK(lock, flags) (flags) = dhd_os_spin_lock(lock)
  2557. #define DHD_BACKPLANE_ACCESS_UNLOCK(lock, flags) dhd_os_spin_unlock((lock), (flags))
  2558. #define DHD_BUS_INB_DW_LOCK(lock, flags) (flags) = dhd_os_spin_lock(lock)
  2559. #define DHD_BUS_INB_DW_UNLOCK(lock, flags) dhd_os_spin_unlock((lock), (flags))
  2560. /* Enable DHD TDLS peer list spin lock/unlock */
  2561. #ifdef WLTDLS
  2562. #define DHD_TDLS_LOCK(lock, flags) (flags) = dhd_os_spin_lock(lock)
  2563. #define DHD_TDLS_UNLOCK(lock, flags) dhd_os_spin_unlock((lock), (flags))
  2564. #endif /* WLTDLS */
  2565. #define DHD_BUS_INB_DW_LOCK(lock, flags) (flags) = dhd_os_spin_lock(lock)
  2566. #define DHD_BUS_INB_DW_UNLOCK(lock, flags) dhd_os_spin_unlock((lock), (flags))
  2567. #ifdef DBG_PKT_MON
  2568. /* Enable DHD PKT MON spin lock/unlock */
  2569. #define DHD_PKT_MON_LOCK(lock, flags) (flags) = dhd_os_spin_lock(lock)
  2570. #define DHD_PKT_MON_UNLOCK(lock, flags) dhd_os_spin_unlock(lock, (flags))
  2571. #endif /* DBG_PKT_MON */
  2572. #define DHD_LINUX_GENERAL_LOCK(dhdp, flags) DHD_GENERAL_LOCK(dhdp, flags)
  2573. #define DHD_LINUX_GENERAL_UNLOCK(dhdp, flags) DHD_GENERAL_UNLOCK(dhdp, flags)
  2574. /* linux is defined for DHD EFI builds also,
  2575. * since its cross-compiled for EFI from linux
  2576. */
  2577. #define DHD_DBG_RING_LOCK_INIT(osh) dhd_os_dbgring_lock_init(osh)
  2578. #define DHD_DBG_RING_LOCK_DEINIT(osh, lock) dhd_os_dbgring_lock_deinit(osh, (lock))
  2579. #define DHD_DBG_RING_LOCK(lock, flags) (flags) = dhd_os_dbgring_lock(lock)
  2580. #define DHD_DBG_RING_UNLOCK(lock, flags) dhd_os_dbgring_unlock((lock), flags)
  2581. extern void dhd_dump_to_kernelog(dhd_pub_t *dhdp);
  2582. extern void dhd_print_tasklet_status(dhd_pub_t *dhd);
  2583. #ifdef DHD_L2_FILTER
  2584. extern int dhd_get_parp_status(dhd_pub_t *dhdp, uint32 idx);
  2585. extern int dhd_set_parp_status(dhd_pub_t *dhdp, uint32 idx, int val);
  2586. extern int dhd_get_dhcp_unicast_status(dhd_pub_t *dhdp, uint32 idx);
  2587. extern int dhd_set_dhcp_unicast_status(dhd_pub_t *dhdp, uint32 idx, int val);
  2588. extern int dhd_get_block_ping_status(dhd_pub_t *dhdp, uint32 idx);
  2589. extern int dhd_set_block_ping_status(dhd_pub_t *dhdp, uint32 idx, int val);
  2590. extern int dhd_get_grat_arp_status(dhd_pub_t *dhdp, uint32 idx);
  2591. extern int dhd_set_grat_arp_status(dhd_pub_t *dhdp, uint32 idx, int val);
  2592. extern int dhd_get_block_tdls_status(dhd_pub_t *dhdp, uint32 idx);
  2593. extern int dhd_set_block_tdls_status(dhd_pub_t *dhdp, uint32 idx, int val);
  2594. #endif /* DHD_L2_FILTER */
  2595. typedef struct wl_io_pport {
  2596. dhd_pub_t *dhd_pub;
  2597. uint ifidx;
  2598. } wl_io_pport_t;
  2599. typedef struct wl_evt_pport {
  2600. dhd_pub_t *dhd_pub;
  2601. int *ifidx;
  2602. void *pktdata;
  2603. uint data_len;
  2604. void **data_ptr;
  2605. void *raw_event;
  2606. } wl_evt_pport_t;
  2607. extern void *dhd_pub_shim(dhd_pub_t *dhd_pub);
  2608. #ifdef DHD_FW_COREDUMP
  2609. void* dhd_get_fwdump_buf(dhd_pub_t *dhd_pub, uint32 length);
  2610. #endif /* DHD_FW_COREDUMP */
  2611. #if defined(SET_RPS_CPUS)
  2612. int dhd_rps_cpus_enable(struct net_device *net, int enable);
  2613. int custom_rps_map_set(struct netdev_rx_queue *queue, char *buf, size_t len);
  2614. void custom_rps_map_clear(struct netdev_rx_queue *queue);
  2615. #define PRIMARY_INF 0
  2616. #define VIRTUAL_INF 1
  2617. #if defined(CONFIG_MACH_UNIVERSAL5433) || defined(CONFIG_MACH_UNIVERSAL7420) || \
  2618. defined(CONFIG_SOC_EXYNOS8890)
  2619. #define RPS_CPUS_MASK "10"
  2620. #define RPS_CPUS_MASK_P2P "10"
  2621. #define RPS_CPUS_MASK_IBSS "10"
  2622. #define RPS_CPUS_WLAN_CORE_ID 4
  2623. #else
  2624. #define RPS_CPUS_MASK "6"
  2625. #define RPS_CPUS_MASK_P2P "6"
  2626. #define RPS_CPUS_MASK_IBSS "6"
  2627. #endif /* CONFIG_MACH_UNIVERSAL5433 || CONFIG_MACH_UNIVERSAL7420 || CONFIG_SOC_EXYNOS8890 */
  2628. #endif // endif
  2629. int dhd_get_download_buffer(dhd_pub_t *dhd, char *file_path, download_type_t component,
  2630. char ** buffer, int *length);
  2631. void dhd_free_download_buffer(dhd_pub_t *dhd, void *buffer, int length);
  2632. int dhd_download_blob(dhd_pub_t *dhd, unsigned char *buf,
  2633. uint32 len, char *iovar);
  2634. int dhd_download_blob_cached(dhd_pub_t *dhd, char *file_path,
  2635. uint32 len, char *iovar);
  2636. int dhd_apply_default_txcap(dhd_pub_t *dhd, char *txcap_path);
  2637. int dhd_apply_default_clm(dhd_pub_t *dhd, char *clm_path);
  2638. #ifdef SHOW_LOGTRACE
  2639. int dhd_parse_logstrs_file(osl_t *osh, char *raw_fmts, int logstrs_size,
  2640. dhd_event_log_t *event_log);
  2641. int dhd_parse_map_file(osl_t *osh, void *file, uint32 *ramstart,
  2642. uint32 *rodata_start, uint32 *rodata_end);
  2643. #ifdef PCIE_FULL_DONGLE
  2644. int dhd_event_logtrace_infobuf_pkt_process(dhd_pub_t *dhdp, void *pktbuf,
  2645. dhd_event_log_t *event_data);
  2646. #endif /* PCIE_FULL_DONGLE */
  2647. #endif /* SHOW_LOGTRACE */
  2648. #define dhd_is_device_removed(x) FALSE
  2649. #define dhd_os_ind_firmware_stall(x)
  2650. #if defined(DHD_FW_COREDUMP)
  2651. extern void dhd_get_memdump_info(dhd_pub_t *dhd);
  2652. #endif /* defined(DHD_FW_COREDUMP) */
  2653. #ifdef BCMASSERT_LOG
  2654. extern void dhd_get_assert_info(dhd_pub_t *dhd);
  2655. #else
  2656. static INLINE void dhd_get_assert_info(dhd_pub_t *dhd) { }
  2657. #endif /* BCMASSERT_LOG */
  2658. #define DMAXFER_FREE(dhdp, dmap) dhd_schedule_dmaxfer_free(dhdp, dmap);
  2659. #if defined(PCIE_FULL_DONGLE)
  2660. extern void dmaxfer_free_prev_dmaaddr(dhd_pub_t *dhdp, dmaxref_mem_map_t *dmmap);
  2661. void dhd_schedule_dmaxfer_free(dhd_pub_t *dhdp, dmaxref_mem_map_t *dmmap);
  2662. #endif /* PCIE_FULL_DONGLE */
  2663. #define DHD_LB_STATS_NOOP do { /* noop */ } while (0)
  2664. #if defined(DHD_LB_STATS)
  2665. #include <bcmutils.h>
  2666. extern void dhd_lb_stats_init(dhd_pub_t *dhd);
  2667. extern void dhd_lb_stats_deinit(dhd_pub_t *dhd);
  2668. extern void dhd_lb_stats_dump(dhd_pub_t *dhdp, struct bcmstrbuf *strbuf);
  2669. extern void dhd_lb_stats_update_napi_histo(dhd_pub_t *dhdp, uint32 count);
  2670. extern void dhd_lb_stats_update_txc_histo(dhd_pub_t *dhdp, uint32 count);
  2671. extern void dhd_lb_stats_update_rxc_histo(dhd_pub_t *dhdp, uint32 count);
  2672. extern void dhd_lb_stats_txc_percpu_cnt_incr(dhd_pub_t *dhdp);
  2673. extern void dhd_lb_stats_rxc_percpu_cnt_incr(dhd_pub_t *dhdp);
  2674. #define DHD_LB_STATS_INIT(dhdp) dhd_lb_stats_init(dhdp)
  2675. #define DHD_LB_STATS_DEINIT(dhdp) dhd_lb_stats_deinit(dhdp)
  2676. /* Reset is called from common layer so it takes dhd_pub_t as argument */
  2677. #define DHD_LB_STATS_RESET(dhdp) dhd_lb_stats_init(dhdp)
  2678. #define DHD_LB_STATS_CLR(x) (x) = 0U
  2679. #define DHD_LB_STATS_INCR(x) (x) = (x) + 1
  2680. #define DHD_LB_STATS_ADD(x, c) (x) = (x) + (c)
  2681. #define DHD_LB_STATS_PERCPU_ARR_INCR(x) \
  2682. { \
  2683. int cpu = get_cpu(); put_cpu(); \
  2684. DHD_LB_STATS_INCR(x[cpu]); \
  2685. }
  2686. #define DHD_LB_STATS_UPDATE_NAPI_HISTO(dhdp, x) dhd_lb_stats_update_napi_histo(dhdp, x)
  2687. #define DHD_LB_STATS_UPDATE_TXC_HISTO(dhdp, x) dhd_lb_stats_update_txc_histo(dhdp, x)
  2688. #define DHD_LB_STATS_UPDATE_RXC_HISTO(dhdp, x) dhd_lb_stats_update_rxc_histo(dhdp, x)
  2689. #define DHD_LB_STATS_TXC_PERCPU_CNT_INCR(dhdp) dhd_lb_stats_txc_percpu_cnt_incr(dhdp)
  2690. #define DHD_LB_STATS_RXC_PERCPU_CNT_INCR(dhdp) dhd_lb_stats_rxc_percpu_cnt_incr(dhdp)
  2691. #else /* !DHD_LB_STATS */
  2692. #define DHD_LB_STATS_INIT(dhdp) DHD_LB_STATS_NOOP
  2693. #define DHD_LB_STATS_DEINIT(dhdp) DHD_LB_STATS_NOOP
  2694. #define DHD_LB_STATS_RESET(dhdp) DHD_LB_STATS_NOOP
  2695. #define DHD_LB_STATS_CLR(x) DHD_LB_STATS_NOOP
  2696. #define DHD_LB_STATS_INCR(x) DHD_LB_STATS_NOOP
  2697. #define DHD_LB_STATS_ADD(x, c) DHD_LB_STATS_NOOP
  2698. #define DHD_LB_STATS_PERCPU_ARR_INCR(x) DHD_LB_STATS_NOOP
  2699. #define DHD_LB_STATS_UPDATE_NAPI_HISTO(dhd, x) DHD_LB_STATS_NOOP
  2700. #define DHD_LB_STATS_UPDATE_TXC_HISTO(dhd, x) DHD_LB_STATS_NOOP
  2701. #define DHD_LB_STATS_UPDATE_RXC_HISTO(dhd, x) DHD_LB_STATS_NOOP
  2702. #define DHD_LB_STATS_TXC_PERCPU_CNT_INCR(dhdp) DHD_LB_STATS_NOOP
  2703. #define DHD_LB_STATS_RXC_PERCPU_CNT_INCR(dhdp) DHD_LB_STATS_NOOP
  2704. #endif /* !DHD_LB_STATS */
  2705. #ifdef DHD_SSSR_DUMP
  2706. #define DHD_SSSR_MEMPOOL_SIZE (2 * 1024 * 1024) /* 2MB size */
  2707. /* used in sssr_dump_mode */
  2708. #define SSSR_DUMP_MODE_SSSR 0 /* dump both *before* and *after* files */
  2709. #define SSSR_DUMP_MODE_FIS 1 /* dump *after* files only */
  2710. extern int dhd_sssr_mempool_init(dhd_pub_t *dhd);
  2711. extern void dhd_sssr_mempool_deinit(dhd_pub_t *dhd);
  2712. extern int dhd_sssr_dump_init(dhd_pub_t *dhd);
  2713. extern void dhd_sssr_dump_deinit(dhd_pub_t *dhd);
  2714. extern int dhdpcie_sssr_dump(dhd_pub_t *dhd);
  2715. extern void dhd_sssr_print_filepath(dhd_pub_t *dhd, char *path);
  2716. #define DHD_SSSR_MEMPOOL_INIT(dhdp) dhd_sssr_mempool_init(dhdp)
  2717. #define DHD_SSSR_MEMPOOL_DEINIT(dhdp) dhd_sssr_mempool_deinit(dhdp)
  2718. #define DHD_SSSR_DUMP_INIT(dhdp) dhd_sssr_dump_init(dhdp)
  2719. #define DHD_SSSR_DUMP_DEINIT(dhdp) dhd_sssr_dump_deinit(dhdp)
  2720. #define DHD_SSSR_PRINT_FILEPATH(dhdp, path) dhd_sssr_print_filepath(dhdp, path)
  2721. #else
  2722. #define DHD_SSSR_MEMPOOL_INIT(dhdp) do { /* noop */ } while (0)
  2723. #define DHD_SSSR_MEMPOOL_DEINIT(dhdp) do { /* noop */ } while (0)
  2724. #define DHD_SSSR_DUMP_INIT(dhdp) do { /* noop */ } while (0)
  2725. #define DHD_SSSR_DUMP_DEINIT(dhdp) do { /* noop */ } while (0)
  2726. #define DHD_SSSR_PRINT_FILEPATH(dhdp, path) do { /* noop */ } while (0)
  2727. #endif /* DHD_SSSR_DUMP */
  2728. #ifdef BCMPCIE
  2729. extern int dhd_prot_debug_info_print(dhd_pub_t *dhd);
  2730. extern bool dhd_bus_skip_clm(dhd_pub_t *dhdp);
  2731. extern void dhd_pcie_dump_rc_conf_space_cap(dhd_pub_t *dhd);
  2732. extern bool dhd_pcie_dump_int_regs(dhd_pub_t *dhd);
  2733. #else
  2734. #define dhd_prot_debug_info_print(x)
  2735. static INLINE bool dhd_bus_skip_clm(dhd_pub_t *dhd_pub)
  2736. { return 0; }
  2737. #endif /* BCMPCIE */
  2738. fw_download_status_t dhd_fw_download_status(dhd_pub_t * dhd_pub);
  2739. void dhd_show_kirqstats(dhd_pub_t *dhd);
  2740. /* Bitmask used for Join Timeout */
  2741. #define WLC_SSID_MASK 0x01
  2742. #define WLC_WPA_MASK 0x02
  2743. extern int dhd_start_join_timer(dhd_pub_t *pub);
  2744. extern int dhd_stop_join_timer(dhd_pub_t *pub);
  2745. extern int dhd_start_scan_timer(dhd_pub_t *pub, bool is_escan);
  2746. extern int dhd_stop_scan_timer(dhd_pub_t *pub, bool is_escan, uint16 sync_id);
  2747. extern int dhd_start_cmd_timer(dhd_pub_t *pub);
  2748. extern int dhd_stop_cmd_timer(dhd_pub_t *pub);
  2749. extern int dhd_start_bus_timer(dhd_pub_t *pub);
  2750. extern int dhd_stop_bus_timer(dhd_pub_t *pub);
  2751. extern uint16 dhd_get_request_id(dhd_pub_t *pub);
  2752. extern int dhd_set_request_id(dhd_pub_t *pub, uint16 id, uint32 cmd);
  2753. extern void dhd_set_join_error(dhd_pub_t *pub, uint32 mask);
  2754. extern void dhd_clear_join_error(dhd_pub_t *pub, uint32 mask);
  2755. extern void dhd_get_scan_to_val(dhd_pub_t *pub, uint32 *to_val);
  2756. extern void dhd_set_scan_to_val(dhd_pub_t *pub, uint32 to_val);
  2757. extern void dhd_get_join_to_val(dhd_pub_t *pub, uint32 *to_val);
  2758. extern void dhd_set_join_to_val(dhd_pub_t *pub, uint32 to_val);
  2759. extern void dhd_get_cmd_to_val(dhd_pub_t *pub, uint32 *to_val);
  2760. extern void dhd_set_cmd_to_val(dhd_pub_t *pub, uint32 to_val);
  2761. extern void dhd_get_bus_to_val(dhd_pub_t *pub, uint32 *to_val);
  2762. extern void dhd_set_bus_to_val(dhd_pub_t *pub, uint32 to_val);
  2763. extern int dhd_start_timesync_timer(dhd_pub_t *pub);
  2764. extern int dhd_stop_timesync_timer(dhd_pub_t *pub);
  2765. #ifdef DHD_PKTID_AUDIT_ENABLED
  2766. void dhd_pktid_error_handler(dhd_pub_t *dhdp);
  2767. #endif /* DHD_PKTID_AUDIT_ENABLED */
  2768. #ifdef DHD_MAP_PKTID_LOGGING
  2769. extern void dhd_pktid_logging_dump(dhd_pub_t *dhdp);
  2770. #endif /* DHD_MAP_PKTID_LOGGING */
  2771. #ifdef DHD_PCIE_RUNTIMEPM
  2772. extern bool dhd_runtimepm_state(dhd_pub_t *dhd);
  2773. extern bool dhd_runtime_bus_wake(struct dhd_bus *bus, bool wait, void *func_addr);
  2774. extern bool dhdpcie_runtime_bus_wake(dhd_pub_t *dhdp, bool wait, void *func_addr);
  2775. extern void dhdpcie_block_runtime_pm(dhd_pub_t *dhdp);
  2776. extern bool dhdpcie_is_resume_done(dhd_pub_t *dhdp);
  2777. extern void dhd_runtime_pm_disable(dhd_pub_t *dhdp);
  2778. extern void dhd_runtime_pm_enable(dhd_pub_t *dhdp);
  2779. /* Disable the Runtime PM and wake up if the bus is already in suspend */
  2780. #define DHD_DISABLE_RUNTIME_PM(dhdp) \
  2781. do { \
  2782. dhd_runtime_pm_disable(dhdp); \
  2783. } while (0);
  2784. /* Enable the Runtime PM */
  2785. #define DHD_ENABLE_RUNTIME_PM(dhdp) \
  2786. do { \
  2787. dhd_runtime_pm_enable(dhdp); \
  2788. } while (0);
  2789. #else
  2790. #define DHD_DISABLE_RUNTIME_PM(dhdp)
  2791. #define DHD_ENABLE_RUNTIME_PM(dhdp)
  2792. #endif /* DHD_PCIE_RUNTIMEPM */
  2793. #ifdef REVERSE_AIFSN
  2794. extern int check_reverse_aifsn_condition(dhd_pub_t *dhdp, struct net_device *ndev);
  2795. #define DHD_REVERSE_AIFSN(dhdp, ndev) \
  2796. do { \
  2797. check_reverse_aifsn_condition(dhdp, ndev); \
  2798. } while (0);
  2799. #else
  2800. #define DHD_REVERSE_AIFSN(dhdp, ndev)
  2801. #endif /* AIFSN_REVERSE */
  2802. extern bool dhd_prot_is_cmpl_ring_empty(dhd_pub_t *dhd, void *prot_info);
  2803. extern void dhd_prot_dump_ring_ptrs(void *prot_info);
  2804. #if defined(DHD_TRACE_WAKE_LOCK)
  2805. void dhd_wk_lock_stats_dump(dhd_pub_t *dhdp);
  2806. #endif // endif
  2807. extern bool dhd_query_bus_erros(dhd_pub_t *dhdp);
  2808. void dhd_clear_bus_errors(dhd_pub_t *dhdp);
  2809. #if defined(CONFIG_64BIT)
  2810. #define DHD_SUPPORT_64BIT
  2811. #endif /* (linux || LINUX) && CONFIG_64BIT */
  2812. #if defined(DHD_ERPOM)
  2813. extern void dhd_schedule_reset(dhd_pub_t *dhdp);
  2814. #else
  2815. static INLINE void dhd_schedule_reset(dhd_pub_t *dhdp) {;}
  2816. #endif // endif
  2817. extern void init_dhd_timeouts(dhd_pub_t *pub);
  2818. extern void deinit_dhd_timeouts(dhd_pub_t *pub);
  2819. typedef enum timeout_resons {
  2820. DHD_REASON_COMMAND_TO,
  2821. DHD_REASON_JOIN_TO,
  2822. DHD_REASON_SCAN_TO,
  2823. DHD_REASON_OQS_TO
  2824. } timeout_reasons_t;
  2825. extern void dhd_prhex(const char *msg, volatile uchar *buf, uint nbytes, uint8 dbg_level);
  2826. int dhd_tput_test(dhd_pub_t *dhd, tput_test_t *tput_data);
  2827. void dhd_tput_test_rx(dhd_pub_t *dhd, void *pkt);
  2828. static INLINE int dhd_get_max_txbufs(dhd_pub_t *dhdp)
  2829. { return -1; }
  2830. #ifdef FILTER_IE
  2831. int dhd_read_from_file(dhd_pub_t *dhd);
  2832. int dhd_parse_filter_ie(dhd_pub_t *dhd, uint8 *buf);
  2833. int dhd_get_filter_ie_count(dhd_pub_t *dhd, uint8 *buf);
  2834. int dhd_parse_oui(dhd_pub_t *dhd, uint8 *inbuf, uint8 *oui, int len);
  2835. int dhd_check_valid_ie(dhd_pub_t *dhdp, uint8 *buf, int len);
  2836. #endif /* FILTER_IE */
  2837. uint16 dhd_prot_get_ioctl_trans_id(dhd_pub_t *dhdp);
  2838. #ifdef SET_PCIE_IRQ_CPU_CORE
  2839. enum {
  2840. PCIE_IRQ_AFFINITY_OFF = 0,
  2841. PCIE_IRQ_AFFINITY_BIG_CORE_ANY,
  2842. PCIE_IRQ_AFFINITY_BIG_CORE_EXYNOS,
  2843. PCIE_IRQ_AFFINITY_LAST
  2844. };
  2845. extern void dhd_set_irq_cpucore(dhd_pub_t *dhdp, int affinity_cmd);
  2846. #endif /* SET_PCIE_IRQ_CPU_CORE */
  2847. #if defined(DHD_HANG_SEND_UP_TEST)
  2848. extern void dhd_make_hang_with_reason(struct net_device *dev, const char *string_num);
  2849. #endif /* DHD_HANG_SEND_UP_TEST */
  2850. #ifdef DHD_RND_DEBUG
  2851. int dhd_dump_rnd_info(dhd_pub_t *dhd, uint8 *rnd_buf, uint32 rnd_len);
  2852. int dhd_get_rnd_info(dhd_pub_t *dhd);
  2853. #endif /* DHD_RND_DEBUG */
  2854. #ifdef DHD_WAKE_STATUS
  2855. wake_counts_t* dhd_get_wakecount(dhd_pub_t *dhdp);
  2856. #endif /* DHD_WAKE_STATUS */
  2857. extern int dhd_get_random_bytes(uint8 *buf, uint len);
  2858. #if defined(DHD_BLOB_EXISTENCE_CHECK)
  2859. extern void dhd_set_blob_support(dhd_pub_t *dhdp, char *fw_path);
  2860. #endif /* DHD_BLOB_EXISTENCE_CHECK */
  2861. /* configuration of ecounters. API's tp start/stop. currently supported only for linux */
  2862. extern int dhd_ecounter_configure(dhd_pub_t *dhd, bool enable);
  2863. extern int dhd_start_ecounters(dhd_pub_t *dhd);
  2864. extern int dhd_stop_ecounters(dhd_pub_t *dhd);
  2865. extern int dhd_start_event_ecounters(dhd_pub_t *dhd);
  2866. extern int dhd_stop_event_ecounters(dhd_pub_t *dhd);
  2867. int dhd_get_preserve_log_numbers(dhd_pub_t *dhd, uint32 *logset_mask);
  2868. #ifdef DHD_LOG_DUMP
  2869. void dhd_schedule_log_dump(dhd_pub_t *dhdp, void *type);
  2870. void dhd_log_dump_trigger(dhd_pub_t *dhdp, int subcmd);
  2871. int dhd_log_dump_ring_to_file(dhd_pub_t *dhdp, void *ring_ptr, void *file,
  2872. unsigned long *file_posn, log_dump_section_hdr_t *sec_hdr, char *text_hdr,
  2873. uint32 sec_type);
  2874. int dhd_dump_debug_ring(dhd_pub_t *dhdp, void *ring_ptr, const void *user_buf,
  2875. log_dump_section_hdr_t *sec_hdr, char *text_hdr, int buflen, uint32 sec_type);
  2876. int dhd_log_dump_cookie_to_file(dhd_pub_t *dhdp, void *fp,
  2877. const void *user_buf, unsigned long *f_pos);
  2878. int dhd_log_dump_cookie(dhd_pub_t *dhdp, const void *user_buf);
  2879. uint32 dhd_log_dump_cookie_len(dhd_pub_t *dhdp);
  2880. int dhd_logdump_cookie_init(dhd_pub_t *dhdp, uint8 *buf, uint32 buf_size);
  2881. void dhd_logdump_cookie_deinit(dhd_pub_t *dhdp);
  2882. void dhd_logdump_cookie_save(dhd_pub_t *dhdp, char *cookie, char *type);
  2883. int dhd_logdump_cookie_get(dhd_pub_t *dhdp, char *ret_cookie, uint32 buf_size);
  2884. int dhd_logdump_cookie_count(dhd_pub_t *dhdp);
  2885. int dhd_get_dld_log_dump(void *dev, dhd_pub_t *dhdp, const void *user_buf, void *fp,
  2886. uint32 len, int type, void *pos);
  2887. int dhd_print_ext_trap_data(void *dev, dhd_pub_t *dhdp, const void *user_buf,
  2888. void *fp, uint32 len, void *pos);
  2889. int dhd_print_dump_data(void *dev, dhd_pub_t *dhdp, const void *user_buf,
  2890. void *fp, uint32 len, void *pos);
  2891. int dhd_print_cookie_data(void *dev, dhd_pub_t *dhdp, const void *user_buf,
  2892. void *fp, uint32 len, void *pos);
  2893. int dhd_print_health_chk_data(void *dev, dhd_pub_t *dhdp, const void *user_buf,
  2894. void *fp, uint32 len, void *pos);
  2895. int dhd_print_time_str(const void *user_buf, void *fp, uint32 len, void *pos);
  2896. #ifdef DHD_DUMP_PCIE_RINGS
  2897. int dhd_print_flowring_data(void *dev, dhd_pub_t *dhdp, const void *user_buf,
  2898. void *fp, uint32 len, void *pos);
  2899. uint32 dhd_get_flowring_len(void *ndev, dhd_pub_t *dhdp);
  2900. #endif /* DHD_DUMP_PCIE_RINGS */
  2901. #ifdef DHD_STATUS_LOGGING
  2902. extern int dhd_print_status_log_data(void *dev, dhd_pub_t *dhdp,
  2903. const void *user_buf, void *fp, uint32 len, void *pos);
  2904. extern uint32 dhd_get_status_log_len(void *ndev, dhd_pub_t *dhdp);
  2905. #endif /* DHD_STATUS_LOGGING */
  2906. int dhd_print_ecntrs_data(void *dev, dhd_pub_t *dhdp, const void *user_buf,
  2907. void *fp, uint32 len, void *pos);
  2908. int dhd_print_rtt_data(void *dev, dhd_pub_t *dhdp, const void *user_buf,
  2909. void *fp, uint32 len, void *pos);
  2910. int dhd_get_debug_dump_file_name(void *dev, dhd_pub_t *dhdp,
  2911. char *dump_path, int size);
  2912. uint32 dhd_get_ext_trap_len(void *ndev, dhd_pub_t *dhdp);
  2913. uint32 dhd_get_time_str_len(void);
  2914. uint32 dhd_get_health_chk_len(void *ndev, dhd_pub_t *dhdp);
  2915. uint32 dhd_get_dhd_dump_len(void *ndev, dhd_pub_t *dhdp);
  2916. uint32 dhd_get_cookie_log_len(void *ndev, dhd_pub_t *dhdp);
  2917. uint32 dhd_get_ecntrs_len(void *ndev, dhd_pub_t *dhdp);
  2918. uint32 dhd_get_rtt_len(void *ndev, dhd_pub_t *dhdp);
  2919. uint32 dhd_get_dld_len(int log_type);
  2920. void dhd_init_sec_hdr(log_dump_section_hdr_t *sec_hdr);
  2921. extern char *dhd_log_dump_get_timestamp(void);
  2922. bool dhd_log_dump_ecntr_enabled(void);
  2923. bool dhd_log_dump_rtt_enabled(void);
  2924. void dhd_nla_put_sssr_dump_len(void *ndev, uint32 *arr_len);
  2925. int dhd_get_debug_dump(void *dev, const void *user_buf, uint32 len, int type);
  2926. int
  2927. dhd_sssr_dump_d11_buf_before(void *dev, const void *user_buf, uint32 len, int core);
  2928. int
  2929. dhd_sssr_dump_d11_buf_after(void *dev, const void *user_buf, uint32 len, int core);
  2930. int
  2931. dhd_sssr_dump_dig_buf_before(void *dev, const void *user_buf, uint32 len);
  2932. int
  2933. dhd_sssr_dump_dig_buf_after(void *dev, const void *user_buf, uint32 len);
  2934. #ifdef DHD_PKT_LOGGING
  2935. extern int dhd_os_get_pktlog_dump(void *dev, const void *user_buf, uint32 len);
  2936. extern uint32 dhd_os_get_pktlog_dump_size(struct net_device *dev);
  2937. extern void dhd_os_get_pktlogdump_filename(struct net_device *dev, char *dump_path, int len);
  2938. #endif /* DHD_PKT_LOGGING */
  2939. #ifdef DNGL_AXI_ERROR_LOGGING
  2940. extern int dhd_os_get_axi_error_dump(void *dev, const void *user_buf, uint32 len);
  2941. extern int dhd_os_get_axi_error_dump_size(struct net_device *dev);
  2942. extern void dhd_os_get_axi_error_filename(struct net_device *dev, char *dump_path, int len);
  2943. #endif /* DNGL_AXI_ERROR_LOGGING */
  2944. #endif /* DHD_LOG_DUMP */
  2945. int dhd_export_debug_data(void *mem_buf, void *fp, const void *user_buf, int buf_len, void *pos);
  2946. #define DHD_PCIE_CONFIG_SAVE(bus) pci_save_state(bus->dev)
  2947. #define DHD_PCIE_CONFIG_RESTORE(bus) pci_restore_state(bus->dev)
  2948. #ifdef BIGDATA_SOFTAP
  2949. void dhd_schedule_gather_ap_stadata(void *bcm_cfg, void *ndev, const wl_event_msg_t *e);
  2950. #endif /* BIGDATA_SOFTAP */
  2951. typedef struct dhd_pkt_parse {
  2952. uint32 proto; /* Network layer protocol */
  2953. uint32 t1; /* n-tuple */
  2954. uint32 t2;
  2955. } dhd_pkt_parse_t;
  2956. /* ========= RING API functions : exposed to others ============= */
  2957. #define DHD_RING_TYPE_FIXED 1
  2958. #define DHD_RING_TYPE_SINGLE_IDX 2
  2959. uint32 dhd_ring_get_hdr_size(void);
  2960. void *dhd_ring_init(dhd_pub_t *dhdp, uint8 *buf, uint32 buf_size, uint32 elem_size,
  2961. uint32 elem_cnt, uint32 type);
  2962. void dhd_ring_deinit(dhd_pub_t *dhdp, void *_ring);
  2963. void *dhd_ring_get_first(void *_ring);
  2964. void dhd_ring_free_first(void *_ring);
  2965. void dhd_ring_set_read_idx(void *_ring, uint32 read_idx);
  2966. void dhd_ring_set_write_idx(void *_ring, uint32 write_idx);
  2967. uint32 dhd_ring_get_read_idx(void *_ring);
  2968. uint32 dhd_ring_get_write_idx(void *_ring);
  2969. void *dhd_ring_get_last(void *_ring);
  2970. void *dhd_ring_get_next(void *_ring, void *cur);
  2971. void *dhd_ring_get_prev(void *_ring, void *cur);
  2972. void *dhd_ring_get_empty(void *_ring);
  2973. int dhd_ring_get_cur_size(void *_ring);
  2974. void dhd_ring_lock(void *ring, void *fist_ptr, void *last_ptr);
  2975. void dhd_ring_lock_free(void *ring);
  2976. void *dhd_ring_lock_get_first(void *_ring);
  2977. void *dhd_ring_lock_get_last(void *_ring);
  2978. int dhd_ring_lock_get_count(void *_ring);
  2979. void dhd_ring_lock_free_first(void *ring);
  2980. void dhd_ring_whole_lock(void *ring);
  2981. void dhd_ring_whole_unlock(void *ring);
  2982. #define DHD_DUMP_TYPE_NAME_SIZE 32
  2983. #define DHD_DUMP_FILE_PATH_SIZE 256
  2984. #define DHD_DUMP_FILE_COUNT_MAX 5
  2985. #define DHD_DUMP_TYPE_COUNT_MAX 10
  2986. #ifdef DHD_DUMP_MNGR
  2987. typedef struct _DFM_elem {
  2988. char type_name[DHD_DUMP_TYPE_NAME_SIZE];
  2989. char file_path[DHD_DUMP_FILE_COUNT_MAX][DHD_DUMP_FILE_PATH_SIZE];
  2990. int file_idx;
  2991. } DFM_elem_t;
  2992. typedef struct _dhd_dump_file_manage {
  2993. DFM_elem_t elems[DHD_DUMP_TYPE_COUNT_MAX];
  2994. } dhd_dump_file_manage_t;
  2995. extern void dhd_dump_file_manage_enqueue(dhd_pub_t *dhd, char *dump_path, char *fname);
  2996. #endif /* DHD_DUMP_MNGR */
  2997. #ifdef PKT_FILTER_SUPPORT
  2998. extern void dhd_pktfilter_offload_set(dhd_pub_t * dhd, char *arg);
  2999. extern void dhd_pktfilter_offload_enable(dhd_pub_t * dhd, char *arg, int enable, int master_mode);
  3000. extern void dhd_pktfilter_offload_delete(dhd_pub_t *dhd, int id);
  3001. #endif // endif
  3002. #ifdef DHD_DUMP_PCIE_RINGS
  3003. extern int dhd_d2h_h2d_ring_dump(dhd_pub_t *dhd, void *file, const void *user_buf,
  3004. unsigned long *file_posn, bool file_write);
  3005. #endif /* DHD_DUMP_PCIE_RINGS */
  3006. #ifdef EWP_EDL
  3007. #define DHD_EDL_RING_SIZE (D2HRING_EDL_MAX_ITEM * D2HRING_EDL_ITEMSIZE)
  3008. int dhd_event_logtrace_process_edl(dhd_pub_t *dhdp, uint8 *data,
  3009. void *evt_decode_data);
  3010. int dhd_edl_mem_init(dhd_pub_t *dhd);
  3011. void dhd_edl_mem_deinit(dhd_pub_t *dhd);
  3012. void dhd_prot_edl_ring_tcm_rd_update(dhd_pub_t *dhd);
  3013. #define DHD_EDL_MEM_INIT(dhdp) dhd_edl_mem_init(dhdp)
  3014. #define DHD_EDL_MEM_DEINIT(dhdp) dhd_edl_mem_deinit(dhdp)
  3015. #define DHD_EDL_RING_TCM_RD_UPDATE(dhdp) \
  3016. dhd_prot_edl_ring_tcm_rd_update(dhdp)
  3017. #else
  3018. #define DHD_EDL_MEM_INIT(dhdp) do { /* noop */ } while (0)
  3019. #define DHD_EDL_MEM_DEINIT(dhdp) do { /* noop */ } while (0)
  3020. #define DHD_EDL_RING_TCM_RD_UPDATE(dhdp) do { /* noop */ } while (0)
  3021. #endif /* EWP_EDL */
  3022. void dhd_schedule_logtrace(void *dhd_info);
  3023. int dhd_print_fw_ver_from_file(dhd_pub_t *dhdp, char *fwpath);
  3024. #define HD_PREFIX_SIZE 2 /* hexadecimal prefix size */
  3025. #define HD_BYTE_SIZE 2 /* hexadecimal byte size */
  3026. #if defined(DHD_H2D_LOG_TIME_SYNC)
  3027. void dhd_h2d_log_time_sync_deferred_wq_schedule(dhd_pub_t *dhdp);
  3028. void dhd_h2d_log_time_sync(dhd_pub_t *dhdp);
  3029. #endif /* DHD_H2D_LOG_TIME_SYNC */
  3030. extern void dhd_cleanup_if(struct net_device *net);
  3031. #ifdef DNGL_AXI_ERROR_LOGGING
  3032. extern void dhd_axi_error(dhd_pub_t *dhd);
  3033. #ifdef DHD_USE_WQ_FOR_DNGL_AXI_ERROR
  3034. extern void dhd_axi_error_dispatch(dhd_pub_t *dhdp);
  3035. #endif /* DHD_USE_WQ_FOR_DNGL_AXI_ERROR */
  3036. #endif /* DNGL_AXI_ERROR_LOGGING */
  3037. #ifdef DHD_HP2P
  3038. extern unsigned long dhd_os_hp2plock(dhd_pub_t *pub);
  3039. extern void dhd_os_hp2punlock(dhd_pub_t *pub, unsigned long flags);
  3040. #endif /* DHD_HP2P */
  3041. extern struct dhd_if * dhd_get_ifp(dhd_pub_t *dhdp, uint32 ifidx);
  3042. #ifdef DHD_STATUS_LOGGING
  3043. #include <dhd_statlog.h>
  3044. #else
  3045. #define ST(x) 0
  3046. #define STDIR(x) 0
  3047. #define DHD_STATLOG_CTRL(dhdp, stat, ifidx, reason) \
  3048. do { /* noop */ } while (0)
  3049. #define DHD_STATLOG_DATA(dhdp, stat, ifidx, dir, cond) \
  3050. do { BCM_REFERENCE(cond); } while (0)
  3051. #define DHD_STATLOG_DATA_RSN(dhdp, stat, ifidx, dir, reason) \
  3052. do { /* noop */ } while (0)
  3053. #endif /* DHD_STATUS_LOGGING */
  3054. #ifdef CONFIG_SILENT_ROAM
  3055. extern int dhd_sroam_set_mon(dhd_pub_t *dhd, bool set);
  3056. typedef wlc_sroam_info_v1_t wlc_sroam_info_t;
  3057. #endif /* CONFIG_SILENT_ROAM */
  3058. #ifdef SUPPORT_SET_TID
  3059. enum dhd_set_tid_mode {
  3060. /* Disalbe changing TID */
  3061. SET_TID_OFF = 0,
  3062. /* Change TID for all UDP frames */
  3063. SET_TID_ALL_UDP,
  3064. /* Change TID for UDP frames based on UID */
  3065. SET_TID_BASED_ON_UID
  3066. };
  3067. extern void dhd_set_tid_based_on_uid(dhd_pub_t *dhdp, void *pkt);
  3068. #endif /* SUPPORT_SET_TID */
  3069. #ifdef DHD_DUMP_FILE_WRITE_FROM_KERNEL
  3070. #define FILE_NAME_HAL_TAG ""
  3071. #else
  3072. #define FILE_NAME_HAL_TAG "_hal" /* The tag name concatenated by HAL */
  3073. #endif /* DHD_DUMP_FILE_WRITE_FROM_KERNEL */
  3074. #if defined(DISABLE_HE_ENAB) || defined(CUSTOM_CONTROL_HE_ENAB)
  3075. extern int dhd_control_he_enab(dhd_pub_t * dhd, uint8 he_enab);
  3076. extern uint8 control_he_enab;
  3077. #endif /* DISABLE_HE_ENAB || CUSTOM_CONTROL_HE_ENAB */
  3078. #if defined(BCMSDIO)
  3079. void dhd_set_role(dhd_pub_t *dhdp, int role, int bssidx);
  3080. #endif /* BCMSDIO */
  3081. #endif /* _dhd_h_ */