wl_cfg80211.h 82 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590
  1. /*
  2. * Linux cfg80211 driver
  3. *
  4. * Portions of this code are copyright (c) 2020 Cypress Semiconductor Corporation
  5. *
  6. * Copyright (C) 1999-2020, Broadcom Corporation
  7. *
  8. * Unless you and Broadcom execute a separate written software license
  9. * agreement governing use of this software, this software is licensed to you
  10. * under the terms of the GNU General Public License version 2 (the "GPL"),
  11. * available at http://www.broadcom.com/licenses/GPLv2.php, with the
  12. * following added to such license:
  13. *
  14. * As a special exception, the copyright holders of this software give you
  15. * permission to link this software with independent modules, and to copy and
  16. * distribute the resulting executable under terms of your choice, provided that
  17. * you also meet, for each linked independent module, the terms and conditions of
  18. * the license of that module. An independent module is a module which is not
  19. * derived from this software. The special exception does not apply to any
  20. * modifications of the software.
  21. *
  22. * Notwithstanding the above, under no circumstances may you combine this
  23. * software in any way with any other Broadcom software provided under a license
  24. * other than the GPL, without Broadcom's express prior written consent.
  25. *
  26. *
  27. * <<Broadcom-WL-IPTag/Open:>>
  28. *
  29. * $Id: wl_cfg80211.h 815697 2019-04-19 03:53:33Z $
  30. */
  31. /**
  32. * Older Linux versions support the 'iw' interface, more recent ones the 'cfg80211' interface.
  33. */
  34. #ifndef _wl_cfg80211_h_
  35. #define _wl_cfg80211_h_
  36. #include <linux/wireless.h>
  37. #include <typedefs.h>
  38. #include <ethernet.h>
  39. #include <wlioctl.h>
  40. #include <linux/wireless.h>
  41. #include <net/cfg80211.h>
  42. #include <linux/rfkill.h>
  43. #include <osl.h>
  44. #include <dngl_stats.h>
  45. #include <dhd.h>
  46. #define WL_CFG_DRV_LOCK(lock, flags) (flags) = osl_spin_lock(lock)
  47. #define WL_CFG_DRV_UNLOCK(lock, flags) osl_spin_unlock((lock), (flags))
  48. #define WL_CFG_WPS_SYNC_LOCK(lock, flags) (flags) = osl_spin_lock(lock)
  49. #define WL_CFG_WPS_SYNC_UNLOCK(lock, flags) osl_spin_unlock((lock), (flags))
  50. #define WL_CFG_NET_LIST_SYNC_LOCK(lock, flags) (flags) = osl_spin_lock(lock)
  51. #define WL_CFG_NET_LIST_SYNC_UNLOCK(lock, flags) osl_spin_unlock((lock), (flags))
  52. #define WL_CFG_EQ_LOCK(lock, flags) (flags) = osl_spin_lock(lock)
  53. #define WL_CFG_EQ_UNLOCK(lock, flags) osl_spin_unlock((lock), (flags))
  54. #define WL_CFG_BAM_LOCK(lock, flags) (flags) = osl_spin_lock(lock)
  55. #define WL_CFG_BAM_UNLOCK(lock, flags) osl_spin_unlock((lock), (flags))
  56. #define WL_CFG_VNDR_OUI_SYNC_LOCK(lock, flags) (flags) = osl_spin_lock(lock)
  57. #define WL_CFG_VNDR_OUI_SYNC_UNLOCK(lock, flags) osl_spin_unlock((lock), (flags))
  58. #include <wl_cfgp2p.h>
  59. #ifdef WL_NAN
  60. #include <wl_cfgnan.h>
  61. #endif /* WL_NAN */
  62. #ifdef WL_BAM
  63. #include <wl_bam.h>
  64. #endif /* WL_BAM */
  65. #ifdef BIGDATA_SOFTAP
  66. #include <wl_bigdata.h>
  67. #endif /* BIGDATA_SOFTAP */
  68. struct wl_conf;
  69. struct wl_iface;
  70. struct bcm_cfg80211;
  71. struct wl_security;
  72. struct wl_ibss;
  73. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0) && !defined(WL_SAE))
  74. #define WL_SAE
  75. #endif // endif
  76. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0) && !defined(WL_FILS_ROAM_OFFLD))
  77. #define WL_FILS_ROAM_OFFLD
  78. #endif // endif
  79. #ifdef WL_SAE
  80. #define IS_AKM_SAE(akm) (akm == WLAN_AKM_SUITE_SAE)
  81. #else
  82. #define IS_AKM_SAE(akm) FALSE
  83. #endif // endif
  84. #ifdef WL_OWE
  85. #define IS_AKM_OWE(akm) (akm == WLAN_AKM_SUITE_OWE)
  86. #else
  87. #define IS_AKM_OWE(akm) FALSE
  88. #endif // endif
  89. #define htod32(i) (i)
  90. #define htod16(i) (i)
  91. #define dtoh64(i) (i)
  92. #define dtoh32(i) (i)
  93. #define dtoh16(i) (i)
  94. #define htodchanspec(i) (i)
  95. #define dtohchanspec(i) (i)
  96. #define WL_DBG_NONE 0
  97. #define WL_DBG_P2P_ACTION (1 << 5)
  98. #define WL_DBG_TRACE (1 << 4)
  99. #define WL_DBG_SCAN (1 << 3)
  100. #define WL_DBG_DBG (1 << 2)
  101. #define WL_DBG_INFO (1 << 1)
  102. #define WL_DBG_ERR (1 << 0)
  103. #ifndef WAIT_FOR_DISCONNECT_MAX
  104. #define WAIT_FOR_DISCONNECT_MAX 10
  105. #endif /* WAIT_FOR_DISCONNECT_MAX */
  106. #define WAIT_FOR_DISCONNECT_STATE_SYNC 10
  107. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0))
  108. /* Newer kernels use defines from nl80211.h */
  109. #define IEEE80211_BAND_2GHZ NL80211_BAND_2GHZ
  110. #define IEEE80211_BAND_5GHZ NL80211_BAND_5GHZ
  111. #define IEEE80211_BAND_60GHZ NL80211_BAND_60GHZ
  112. #define IEEE80211_NUM_BANDS NUM_NL80211_BANDS
  113. #endif /* LINUX_VER >= 4.7 */
  114. #ifdef DHD_LOG_DUMP
  115. extern void dhd_log_dump_write(int type, char *binary_data,
  116. int binary_len, const char *fmt, ...);
  117. extern char *dhd_log_dump_get_timestamp(void);
  118. #ifndef _DHD_LOG_DUMP_DEFINITIONS_
  119. #define DHD_LOG_DUMP_WRITE(fmt, ...) \
  120. dhd_log_dump_write(DLD_BUF_TYPE_GENERAL, NULL, 0, fmt, ##__VA_ARGS__)
  121. #define DHD_LOG_DUMP_WRITE_EX(fmt, ...) \
  122. dhd_log_dump_write(DLD_BUF_TYPE_SPECIAL, NULL, 0, fmt, ##__VA_ARGS__)
  123. #endif /* !_DHD_LOG_DUMP_DEFINITIONS_ */
  124. #endif /* DHD_LOG_DUMP */
  125. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)) || (defined(CONFIG_ARCH_MSM) && \
  126. defined(CFG80211_DISCONNECTED_V2))
  127. #define CFG80211_DISCONNECTED(dev, reason, ie, len, loc_gen, gfp) \
  128. cfg80211_disconnected(dev, reason, ie, len, loc_gen, gfp);
  129. #elif (LINUX_VERSION_CODE < KERNEL_VERSION(4, 2, 0))
  130. #define CFG80211_DISCONNECTED(dev, reason, ie, len, loc_gen, gfp) \
  131. BCM_REFERENCE(loc_gen); \
  132. cfg80211_disconnected(dev, reason, ie, len, gfp);
  133. #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)) */
  134. /* 0 invalidates all debug messages. default is 1 */
  135. #define WL_DBG_LEVEL 0xFF
  136. #define CFG80211_INFO_TEXT "CFG80211-INFO) "
  137. #ifdef CUSTOMER_HW4_DEBUG
  138. #define CFG80211_ERROR_TEXT "CFG80211-INFO2) "
  139. #else
  140. #define CFG80211_ERROR_TEXT "CFG80211-ERROR) "
  141. #endif /* CUSTOMER_HW4_DEBUG */
  142. #if defined(DHD_DEBUG)
  143. #ifdef DHD_LOG_DUMP
  144. #define WL_ERR(args) \
  145. do { \
  146. if (wl_dbg_level & WL_DBG_ERR) { \
  147. printk(KERN_INFO CFG80211_ERROR_TEXT "%s : ", __func__); \
  148. pr_cont args; \
  149. DHD_LOG_DUMP_WRITE("[%s] %s: ", dhd_log_dump_get_timestamp(), __func__); \
  150. DHD_LOG_DUMP_WRITE args; \
  151. } \
  152. } while (0)
  153. #define WL_ERR_KERN(args) \
  154. do { \
  155. if (wl_dbg_level & WL_DBG_ERR) { \
  156. printk(KERN_INFO CFG80211_ERROR_TEXT "%s : ", __func__); \
  157. pr_cont args; \
  158. } \
  159. } while (0)
  160. #define WL_ERR_MEM(args) \
  161. do { \
  162. if (wl_dbg_level & WL_DBG_ERR) { \
  163. DHD_LOG_DUMP_WRITE("[%s] %s: ", dhd_log_dump_get_timestamp(), __func__); \
  164. DHD_LOG_DUMP_WRITE args; \
  165. } \
  166. } while (0)
  167. #define WL_INFORM_MEM(args) \
  168. do { \
  169. if (wl_dbg_level & WL_DBG_INFO) { \
  170. printk(KERN_INFO CFG80211_INFO_TEXT "%s : ", __func__); \
  171. pr_cont args; \
  172. DHD_LOG_DUMP_WRITE("[%s] %s: ", dhd_log_dump_get_timestamp(), __func__); \
  173. DHD_LOG_DUMP_WRITE args; \
  174. } \
  175. } while (0)
  176. #define WL_ERR_EX(args) \
  177. do { \
  178. if (wl_dbg_level & WL_DBG_ERR) { \
  179. printk(KERN_INFO CFG80211_ERROR_TEXT "%s : ", __func__); \
  180. pr_cont args; \
  181. DHD_LOG_DUMP_WRITE_EX("[%s] %s: ", dhd_log_dump_get_timestamp(), __func__); \
  182. DHD_LOG_DUMP_WRITE_EX args; \
  183. } \
  184. } while (0)
  185. #define WL_MEM(args) \
  186. do { \
  187. DHD_LOG_DUMP_WRITE("[%s] %s: ", dhd_log_dump_get_timestamp(), __func__); \
  188. DHD_LOG_DUMP_WRITE args; \
  189. } while (0)
  190. #else
  191. #define WL_ERR(args) \
  192. do { \
  193. if (wl_dbg_level & WL_DBG_ERR) { \
  194. printk(KERN_INFO CFG80211_ERROR_TEXT "%s : ", __func__); \
  195. pr_cont args; \
  196. } \
  197. } while (0)
  198. #define WL_ERR_KERN(args) WL_ERR(args)
  199. #define WL_ERR_MEM(args) WL_ERR(args)
  200. #define WL_INFORM_MEM(args) WL_INFORM(args)
  201. #define WL_ERR_EX(args) WL_ERR(args)
  202. #define WL_MEM(args) WL_DBG(args)
  203. #endif /* DHD_LOG_DUMP */
  204. #else /* defined(DHD_DEBUG) */
  205. #define WL_ERR(args) \
  206. do { \
  207. if ((wl_dbg_level & WL_DBG_ERR) && net_ratelimit()) { \
  208. printk(KERN_INFO CFG80211_ERROR_TEXT "%s : ", __func__); \
  209. pr_cont args; \
  210. } \
  211. } while (0)
  212. #define WL_ERR_KERN(args) WL_ERR(args)
  213. #define WL_ERR_MEM(args) WL_ERR(args)
  214. #define WL_INFORM_MEM(args) WL_INFORM(args)
  215. #define WL_ERR_EX(args) WL_ERR(args)
  216. #define WL_MEM(args) WL_DBG(args)
  217. #endif /* defined(DHD_DEBUG) */
  218. #define WL_PRINT_RATE_LIMIT_PERIOD 4000000000u /* 4s in units of ns */
  219. #define WL_ERR_RLMT(args) \
  220. do { \
  221. if (wl_dbg_level & WL_DBG_ERR) { \
  222. static uint64 __err_ts = 0; \
  223. static uint32 __err_cnt = 0; \
  224. uint64 __cur_ts = 0; \
  225. __cur_ts = local_clock(); \
  226. if (__err_ts == 0 || (__cur_ts > __err_ts && \
  227. (__cur_ts - __err_ts > WL_PRINT_RATE_LIMIT_PERIOD))) { \
  228. __err_ts = __cur_ts; \
  229. WL_ERR(args); \
  230. WL_ERR(("[Repeats %u times]\n", __err_cnt)); \
  231. __err_cnt = 0; \
  232. } else { \
  233. ++__err_cnt; \
  234. } \
  235. } \
  236. } while (0)
  237. #ifdef WL_INFORM
  238. #undef WL_INFORM
  239. #endif // endif
  240. #define WL_INFORM(args) \
  241. do { \
  242. if (wl_dbg_level & WL_DBG_INFO) { \
  243. printk(KERN_INFO "CFG80211-INFO) %s : ", __func__); \
  244. pr_cont args; \
  245. } \
  246. } while (0)
  247. #ifdef WL_SCAN
  248. #undef WL_SCAN
  249. #endif // endif
  250. #define WL_SCAN(args) \
  251. do { \
  252. if (wl_dbg_level & WL_DBG_SCAN) { \
  253. printk(KERN_INFO "CFG80211-SCAN) %s :", __func__); \
  254. pr_cont args; \
  255. } \
  256. } while (0)
  257. #ifdef WL_TRACE
  258. #undef WL_TRACE
  259. #endif // endif
  260. #define WL_TRACE(args) \
  261. do { \
  262. if (wl_dbg_level & WL_DBG_TRACE) { \
  263. printk(KERN_INFO "CFG80211-TRACE) %s :", __func__); \
  264. pr_cont args; \
  265. } \
  266. } while (0)
  267. #ifdef WL_TRACE_HW4
  268. #undef WL_TRACE_HW4
  269. #endif // endif
  270. #ifdef CUSTOMER_HW4_DEBUG
  271. #define WL_TRACE_HW4(args) \
  272. do { \
  273. if (wl_dbg_level & WL_DBG_ERR) { \
  274. printk(KERN_INFO "CFG80211-TRACE) %s : ", __func__); \
  275. pr_cont args; \
  276. } \
  277. } while (0)
  278. #else
  279. #define WL_TRACE_HW4 WL_TRACE
  280. #endif /* CUSTOMER_HW4_DEBUG */
  281. #if (WL_DBG_LEVEL > 0)
  282. #define WL_DBG(args) \
  283. do { \
  284. if (wl_dbg_level & WL_DBG_DBG) { \
  285. printk(KERN_INFO "CFG80211-DEBUG) %s :", __func__); \
  286. pr_cont args; \
  287. } \
  288. } while (0)
  289. #else /* !(WL_DBG_LEVEL > 0) */
  290. #define WL_DBG(args)
  291. #endif /* (WL_DBG_LEVEL > 0) */
  292. #define WL_PNO(x)
  293. #define WL_SD(x)
  294. #define WL_SCAN_RETRY_MAX 3
  295. #define WL_NUM_PMKIDS_MAX MAXPMKID
  296. #define WL_SCAN_BUF_MAX (1024 * 8)
  297. #define WL_TLV_INFO_MAX 1500
  298. #define WL_SCAN_IE_LEN_MAX 2048
  299. #define WL_BSS_INFO_MAX 2048
  300. #define WL_ASSOC_INFO_MAX 512
  301. #define WL_IOCTL_LEN_MAX 2048
  302. #define WL_EXTRA_BUF_MAX 2048
  303. #define WL_SCAN_ERSULTS_LAST (WL_SCAN_RESULTS_NO_MEM+1)
  304. #define WL_AP_MAX 256
  305. #define WL_FILE_NAME_MAX 256
  306. #define WL_DWELL_TIME 200
  307. #define WL_MED_DWELL_TIME 400
  308. #define WL_MIN_DWELL_TIME 100
  309. #define WL_LONG_DWELL_TIME 1000
  310. #define IFACE_MAX_CNT 6
  311. #define WL_SCAN_CONNECT_DWELL_TIME_MS 200
  312. #define WL_SCAN_JOIN_PROBE_INTERVAL_MS 20
  313. #define WL_SCAN_JOIN_ACTIVE_DWELL_TIME_MS 320
  314. #define WL_SCAN_JOIN_PASSIVE_DWELL_TIME_MS 400
  315. #define WL_AF_TX_MAX_RETRY 5
  316. #define WL_AF_SEARCH_TIME_MAX 450
  317. #define WL_AF_TX_EXTRA_TIME_MAX 200
  318. #define WL_SCAN_TIMER_INTERVAL_MS 10000 /* Scan timeout */
  319. #ifdef WL_NAN
  320. #define WL_SCAN_TIMER_INTERVAL_MS_NAN 15000 /* Scan timeout */
  321. #endif /* WL_NAN */
  322. #define WL_CHANNEL_SYNC_RETRY 5
  323. #define WL_INVALID -1
  324. #ifdef DHD_LOSSLESS_ROAMING
  325. #define WL_ROAM_TIMEOUT_MS 1000 /* Roam timeout */
  326. #endif // endif
  327. /* Bring down SCB Timeout to 20secs from 60secs default */
  328. #ifndef WL_SCB_TIMEOUT
  329. #define WL_SCB_TIMEOUT 20
  330. #endif // endif
  331. #if defined(ROAM_ENABLE) || defined(ROAM_CHANNEL_CACHE)
  332. #define ESCAN_CHANNEL_CACHE
  333. #endif // endif
  334. #ifndef WL_SCB_ACTIVITY_TIME
  335. #define WL_SCB_ACTIVITY_TIME 5
  336. #endif // endif
  337. #ifndef WL_SCB_MAX_PROBE
  338. #define WL_SCB_MAX_PROBE 3
  339. #endif // endif
  340. #ifndef WL_PSPRETEND_RETRY_LIMIT
  341. #define WL_PSPRETEND_RETRY_LIMIT 1
  342. #endif // endif
  343. #ifndef WL_MIN_PSPRETEND_THRESHOLD
  344. #define WL_MIN_PSPRETEND_THRESHOLD 2
  345. #endif // endif
  346. /* Cipher suites */
  347. #ifndef WLAN_CIPHER_SUITE_PMK
  348. #define WLAN_CIPHER_SUITE_PMK 0x00904C00
  349. #endif /* WLAN_CIPHER_SUITE_PMK */
  350. #ifndef WLAN_AKM_SUITE_FT_8021X
  351. #define WLAN_AKM_SUITE_FT_8021X 0x000FAC03
  352. #endif /* WLAN_AKM_SUITE_FT_8021X */
  353. #ifndef WLAN_AKM_SUITE_FT_PSK
  354. #define WLAN_AKM_SUITE_FT_PSK 0x000FAC04
  355. #endif /* WLAN_AKM_SUITE_FT_PSK */
  356. #ifndef WLAN_AKM_SUITE_8021X_SUITE_B
  357. #define WLAN_AKM_SUITE_8021X_SUITE_B 0x000FAC0B
  358. #define WLAN_AKM_SUITE_8021X_SUITE_B_192 0x000FAC0C
  359. #endif /* WLAN_AKM_SUITE_8021X_SUITE_B */
  360. /* TODO: even in upstream linux(v5.0), FT-1X-SHA384 isn't defined and supported yet.
  361. * need to revisit here to sync correct name later.
  362. */
  363. #define WLAN_AKM_SUITE_FT_8021X_SHA384 0x000FAC0D
  364. #define WL_AKM_SUITE_SHA256_1X 0x000FAC05
  365. #define WL_AKM_SUITE_SHA256_PSK 0x000FAC06
  366. #define WLAN_AKM_SUITE_DPP 0x506F9A02
  367. #define WFA_AUTH_DPP 0x200000 /* WFA DPP AUTH */
  368. #ifndef WLAN_AKM_SUITE_FILS_SHA256
  369. #define WLAN_AKM_SUITE_FILS_SHA256 0x000FAC0E
  370. #define WLAN_AKM_SUITE_FILS_SHA384 0x000FAC0F
  371. #define WLAN_AKM_SUITE_FT_FILS_SHA256 0x000FAC10
  372. #define WLAN_AKM_SUITE_FT_FILS_SHA384 0x000FAC11
  373. #endif /* WLAN_AKM_SUITE_FILS_SHA256 */
  374. #define MIN_VENDOR_EXTN_IE_LEN 2
  375. #ifdef WL_OWE
  376. #ifndef WLAN_AKM_SUITE_OWE
  377. #define WLAN_AKM_SUITE_OWE 0X000FAC12
  378. #endif /* WPA_KEY_MGMT_OWE */
  379. #endif /* WL_OWE */
  380. /*
  381. * BRCM local.
  382. * Use a high number that's unlikely to clash with linux upstream for a while until we can
  383. * submit these changes to the community.
  384. */
  385. #define NL80211_FEATURE_FW_4WAY_HANDSHAKE (1<<31)
  386. /* SCAN_SUPPRESS timer values in ms */
  387. #define WL_SCAN_SUPPRESS_TIMEOUT 31000 /* default Framwork DHCP timeout is 30 sec */
  388. #define WL_SCAN_SUPPRESS_RETRY 3000
  389. #define WL_PM_ENABLE_TIMEOUT 10000
  390. /* cfg80211 wowlan definitions */
  391. #define WL_WOWLAN_MAX_PATTERNS 8
  392. #define WL_WOWLAN_MIN_PATTERN_LEN 1
  393. #define WL_WOWLAN_MAX_PATTERN_LEN 255
  394. #define WL_WOWLAN_PKT_FILTER_ID_FIRST 201
  395. #define WL_WOWLAN_PKT_FILTER_ID_LAST (WL_WOWLAN_PKT_FILTER_ID_FIRST + \
  396. WL_WOWLAN_MAX_PATTERNS - 1)
  397. #ifdef WLAIBSS
  398. #define IBSS_COALESCE_DEFAULT 0
  399. #define IBSS_INITIAL_SCAN_ALLOWED_DEFAULT 0
  400. #else /* WLAIBSS */
  401. #define IBSS_COALESCE_DEFAULT 1
  402. #define IBSS_INITIAL_SCAN_ALLOWED_DEFAULT 1
  403. #endif /* WLAIBSS */
  404. #ifdef WLTDLS
  405. #define TDLS_TUNNELED_PRB_REQ "\x7f\x50\x6f\x9a\04"
  406. #define TDLS_TUNNELED_PRB_RESP "\x7f\x50\x6f\x9a\05"
  407. #define TDLS_MAX_IFACE_FOR_ENABLE 1
  408. #endif /* WLTDLS */
  409. #ifdef WLAIBSS
  410. /* Custom AIBSS beacon parameters */
  411. #define AIBSS_INITIAL_MIN_BCN_DUR 500
  412. #define AIBSS_MIN_BCN_DUR 5000
  413. #define AIBSS_BCN_FLOOD_DUR 5000
  414. #define AIBSS_PEER_FREE 3
  415. #endif /* WLAIBSS */
  416. #ifndef FILS_INDICATION_IE_TAG_FIXED_LEN
  417. #define FILS_INDICATION_IE_TAG_FIXED_LEN 2
  418. #endif // endif
  419. /* driver status */
  420. enum wl_status {
  421. WL_STATUS_READY = 0,
  422. WL_STATUS_SCANNING,
  423. WL_STATUS_SCAN_ABORTING,
  424. WL_STATUS_CONNECTING,
  425. WL_STATUS_CONNECTED,
  426. WL_STATUS_DISCONNECTING,
  427. WL_STATUS_AP_CREATING,
  428. WL_STATUS_AP_CREATED,
  429. /* whole sending action frame procedure:
  430. * includes a) 'finding common channel' for public action request frame
  431. * and b) 'sending af via 'actframe' iovar'
  432. */
  433. WL_STATUS_SENDING_ACT_FRM,
  434. /* find a peer to go to a common channel before sending public action req frame */
  435. WL_STATUS_FINDING_COMMON_CHANNEL,
  436. /* waiting for next af to sync time of supplicant.
  437. * it includes SENDING_ACT_FRM and WAITING_NEXT_ACT_FRM_LISTEN
  438. */
  439. WL_STATUS_WAITING_NEXT_ACT_FRM,
  440. #ifdef WL_CFG80211_SYNC_GON
  441. /* go to listen state to wait for next af after SENDING_ACT_FRM */
  442. WL_STATUS_WAITING_NEXT_ACT_FRM_LISTEN,
  443. #endif /* WL_CFG80211_SYNC_GON */
  444. /* it will be set when upper layer requests listen and succeed in setting listen mode.
  445. * if set, other scan request can abort current listen state
  446. */
  447. WL_STATUS_REMAINING_ON_CHANNEL,
  448. #ifdef WL_CFG80211_VSDB_PRIORITIZE_SCAN_REQUEST
  449. /* it's fake listen state to keep current scan state.
  450. * it will be set when upper layer requests listen but scan is running. then just run
  451. * a expire timer without actual listen state.
  452. * if set, other scan request does not need to abort scan.
  453. */
  454. WL_STATUS_FAKE_REMAINING_ON_CHANNEL,
  455. #endif /* WL_CFG80211_VSDB_PRIORITIZE_SCAN_REQUEST */
  456. WL_STATUS_NESTED_CONNECT,
  457. WL_STATUS_CFG80211_CONNECT
  458. };
  459. typedef enum wl_iftype {
  460. WL_IF_TYPE_STA = 0,
  461. WL_IF_TYPE_AP = 1,
  462. WL_IF_TYPE_AWDL = 2,
  463. WL_IF_TYPE_NAN_NMI = 3,
  464. WL_IF_TYPE_NAN = 4,
  465. WL_IF_TYPE_P2P_GO = 5,
  466. WL_IF_TYPE_P2P_GC = 6,
  467. WL_IF_TYPE_P2P_DISC = 7,
  468. WL_IF_TYPE_IBSS = 8,
  469. WL_IF_TYPE_MONITOR = 9,
  470. WL_IF_TYPE_AIBSS = 10,
  471. WL_IF_TYPE_MAX
  472. } wl_iftype_t;
  473. typedef enum wl_interface_state {
  474. WL_IF_CREATE_REQ,
  475. WL_IF_CREATE_DONE,
  476. WL_IF_DELETE_REQ,
  477. WL_IF_DELETE_DONE,
  478. WL_IF_CHANGE_REQ,
  479. WL_IF_CHANGE_DONE,
  480. WL_IF_STATE_MAX, /* Retain as last one */
  481. } wl_interface_state_t;
  482. /* wi-fi mode */
  483. enum wl_mode {
  484. WL_MODE_BSS,
  485. WL_MODE_IBSS,
  486. WL_MODE_AP,
  487. WL_MODE_AWDL,
  488. WL_MODE_NAN
  489. };
  490. /* driver profile list */
  491. enum wl_prof_list {
  492. WL_PROF_MODE,
  493. WL_PROF_SSID,
  494. WL_PROF_SEC,
  495. WL_PROF_IBSS,
  496. WL_PROF_BAND,
  497. WL_PROF_CHAN,
  498. WL_PROF_BSSID,
  499. WL_PROF_ACT,
  500. WL_PROF_BEACONINT,
  501. WL_PROF_DTIMPERIOD,
  502. WL_PROF_LATEST_BSSID
  503. };
  504. /* donlge escan state */
  505. enum wl_escan_state {
  506. WL_ESCAN_STATE_IDLE,
  507. WL_ESCAN_STATE_SCANING
  508. };
  509. /* fw downloading status */
  510. enum wl_fw_status {
  511. WL_FW_LOADING_DONE,
  512. WL_NVRAM_LOADING_DONE
  513. };
  514. enum wl_management_type {
  515. WL_BEACON = 0x1,
  516. WL_PROBE_RESP = 0x2,
  517. WL_ASSOC_RESP = 0x4
  518. };
  519. enum wl_pm_workq_act_type {
  520. WL_PM_WORKQ_SHORT,
  521. WL_PM_WORKQ_LONG,
  522. WL_PM_WORKQ_DEL
  523. };
  524. enum wl_tdls_config {
  525. TDLS_STATE_AP_CREATE,
  526. TDLS_STATE_AP_DELETE,
  527. TDLS_STATE_CONNECT,
  528. TDLS_STATE_DISCONNECT,
  529. TDLS_STATE_SETUP,
  530. TDLS_STATE_TEARDOWN,
  531. TDLS_STATE_IF_CREATE,
  532. TDLS_STATE_IF_DELETE,
  533. TDLS_STATE_NMI_CREATE
  534. };
  535. /* beacon / probe_response */
  536. struct beacon_proberesp {
  537. __le64 timestamp;
  538. __le16 beacon_int;
  539. __le16 capab_info;
  540. u8 variable[0];
  541. } __attribute__ ((packed));
  542. /* driver configuration */
  543. struct wl_conf {
  544. u32 frag_threshold;
  545. u32 rts_threshold;
  546. u32 retry_short;
  547. u32 retry_long;
  548. s32 tx_power;
  549. struct ieee80211_channel channel;
  550. };
  551. typedef s32(*EVENT_HANDLER) (struct bcm_cfg80211 *cfg, bcm_struct_cfgdev *cfgdev,
  552. const wl_event_msg_t *e, void *data);
  553. /* bss inform structure for cfg80211 interface */
  554. struct wl_cfg80211_bss_info {
  555. u16 band;
  556. u16 channel;
  557. s16 rssi;
  558. u16 frame_len;
  559. u8 frame_buf[1];
  560. };
  561. /* basic structure of scan request */
  562. struct wl_scan_req {
  563. struct wlc_ssid ssid;
  564. };
  565. /* basic structure of information element */
  566. struct wl_ie {
  567. u16 offset;
  568. u8 buf[WL_TLV_INFO_MAX];
  569. };
  570. /* event queue for cfg80211 main event */
  571. struct wl_event_q {
  572. struct list_head eq_list;
  573. u32 etype;
  574. wl_event_msg_t emsg;
  575. u32 datalen;
  576. s8 edata[1];
  577. };
  578. /* security information with currently associated ap */
  579. struct wl_security {
  580. u32 wpa_versions;
  581. u32 auth_type;
  582. u32 cipher_pairwise;
  583. u32 cipher_group;
  584. u32 wpa_auth;
  585. u32 auth_assoc_res_status;
  586. };
  587. /* ibss information for currently joined ibss network */
  588. struct wl_ibss {
  589. u8 beacon_interval; /* in millisecond */
  590. u8 atim; /* in millisecond */
  591. s8 join_only;
  592. u8 band;
  593. u8 channel;
  594. };
  595. typedef struct wl_bss_vndr_ies {
  596. u8 probe_req_ie[VNDR_IES_BUF_LEN];
  597. u8 probe_res_ie[VNDR_IES_MAX_BUF_LEN];
  598. u8 assoc_req_ie[VNDR_IES_BUF_LEN];
  599. u8 assoc_res_ie[VNDR_IES_BUF_LEN];
  600. u8 beacon_ie[VNDR_IES_MAX_BUF_LEN];
  601. u8 disassoc_ie[VNDR_IES_BUF_LEN];
  602. u32 probe_req_ie_len;
  603. u32 probe_res_ie_len;
  604. u32 assoc_req_ie_len;
  605. u32 assoc_res_ie_len;
  606. u32 beacon_ie_len;
  607. u32 disassoc_ie_len;
  608. } wl_bss_vndr_ies_t;
  609. typedef struct wl_cfgbss {
  610. u8 *wpa_ie;
  611. u8 *rsn_ie;
  612. u8 *wps_ie;
  613. u8 *fils_ind_ie;
  614. bool security_mode;
  615. struct wl_bss_vndr_ies ies; /* Common for STA, P2P GC, GO, AP, P2P Disc Interface */
  616. } wl_cfgbss_t;
  617. #ifdef WL11U
  618. /* Max length of Interworking element */
  619. #define IW_IES_MAX_BUF_LEN 8
  620. #endif // endif
  621. /* cfg driver profile */
  622. struct wl_profile {
  623. u32 mode;
  624. s32 band;
  625. u32 channel;
  626. struct wlc_ssid ssid;
  627. struct wl_security sec;
  628. struct wl_ibss ibss;
  629. u8 bssid[ETHER_ADDR_LEN];
  630. u16 beacon_interval;
  631. u8 dtim_period;
  632. bool active;
  633. u8 latest_bssid[ETHER_ADDR_LEN];
  634. u32 channel_width;
  635. #ifdef WL11U
  636. u8 iw_ie[IW_IES_MAX_BUF_LEN];
  637. u32 iw_ie_len;
  638. #endif /* WL11U */
  639. };
  640. struct wl_wps_ie {
  641. uint8 id; /* IE ID: 0xDD */
  642. uint8 len; /* IE length */
  643. uint8 OUI[3]; /* WiFi WPS specific OUI */
  644. uint8 oui_type; /* Vendor specific OUI Type */
  645. uint8 attrib[1]; /* variable length attributes */
  646. } __attribute__ ((packed));
  647. typedef struct wl_wps_ie wl_wps_ie_t;
  648. struct wl_eap_msg {
  649. uint16 attrib;
  650. uint16 len;
  651. uint8 type;
  652. } __attribute__ ((packed));
  653. typedef struct wl_eap_msg wl_eap_msg_t;
  654. struct wl_eap_exp {
  655. uint8 OUI[3];
  656. uint32 oui_type;
  657. uint8 opcode;
  658. u8 flags;
  659. u8 data[1];
  660. } __attribute__ ((packed));
  661. typedef struct wl_eap_exp wl_eap_exp_t;
  662. struct net_info {
  663. struct net_device *ndev;
  664. struct wireless_dev *wdev;
  665. struct wl_profile profile;
  666. wl_iftype_t iftype;
  667. s32 roam_off;
  668. unsigned long sme_state;
  669. bool pm_restore;
  670. bool pm_block;
  671. s32 pm;
  672. s32 bssidx;
  673. wl_cfgbss_t bss;
  674. u8 ifidx;
  675. #ifdef WL_SAE
  676. unsigned long mgmt_txstatus;
  677. size_t mgmt_txid;
  678. struct completion mgmt_tx_cpl;
  679. #endif /* WL_SAE */
  680. struct list_head list; /* list of all net_info structure */
  681. };
  682. #ifdef WL_BCNRECV
  683. /* PERIODIC Beacon receive for detecting FakeAPs */
  684. typedef struct wl_bcnrecv_result {
  685. uint8 SSID[DOT11_MAX_SSID_LEN]; /**< SSID String */
  686. struct ether_addr BSSID; /**< Network BSSID */
  687. uint8 channel; /**< Channel */
  688. uint16 beacon_interval;
  689. uint32 timestamp[2]; /**< Beacon Timestamp */
  690. uint64 system_time;
  691. } wl_bcnrecv_result_t;
  692. typedef struct wl_bcnrecv_info {
  693. uint bcnrecv_state; /* TO know the fakeap state */
  694. } wl_bcnrecv_info_t;
  695. typedef enum wl_bcnrecv_state {
  696. BEACON_RECV_IDLE = 0,
  697. BEACON_RECV_STARTED,
  698. BEACON_RECV_STOPPED,
  699. BEACON_RECV_SUSPENDED
  700. } wl_bcnrecv_state_t;
  701. typedef enum wl_bcnrecv_reason {
  702. WL_BCNRECV_INVALID = 0,
  703. WL_BCNRECV_USER_TRIGGER,
  704. WL_BCNRECV_SUSPEND,
  705. WL_BCNRECV_SCANBUSY,
  706. WL_BCNRECV_CONCURRENCY,
  707. WL_BCNRECV_LISTENBUSY,
  708. WL_BCNRECV_ROAMABORT,
  709. WL_BCNRECV_HANG
  710. } wl_bcnrecv_reason_t;
  711. typedef enum wl_bcnrecv_status {
  712. WL_BCNRECV_STARTED = 0,
  713. WL_BCNRECV_STOPPED,
  714. WL_BCNRECV_ABORTED,
  715. WL_BCNRECV_SUSPENDED,
  716. WL_BCNRECV_MAX
  717. } wl_bcnrecv_status_t;
  718. typedef enum wl_bcnrecv_attr_type {
  719. BCNRECV_ATTR_STATUS = 1,
  720. BCNRECV_ATTR_REASON,
  721. BCNRECV_ATTR_BCNINFO
  722. } wl_bcnrecv_attr_type_t;
  723. #endif /* WL_BCNRECV */
  724. #ifdef WL_CHAN_UTIL
  725. #define CU_ATTR_PERCENTAGE 1
  726. #define CU_ATTR_HDR_LEN 30
  727. #endif /* WL_CHAN_UTIL */
  728. /* association inform */
  729. #define MAX_REQ_LINE 1024u
  730. struct wl_connect_info {
  731. u8 req_ie[MAX_REQ_LINE];
  732. u32 req_ie_len;
  733. u8 resp_ie[MAX_REQ_LINE];
  734. u32 resp_ie_len;
  735. };
  736. #define WL_MAX_FILS_KEY_LEN 64
  737. struct wl_fils_info {
  738. u8 fils_kek[WL_MAX_FILS_KEY_LEN];
  739. u32 fils_kek_len;
  740. u8 fils_pmk[WL_MAX_FILS_KEY_LEN];
  741. u32 fils_pmk_len;
  742. u8 fils_pmkid[WL_MAX_FILS_KEY_LEN];
  743. u16 fils_erp_next_seq_num;
  744. bool fils_roam_disabled;
  745. u32 fils_bcn_timeout_cache;
  746. };
  747. /* firmware /nvram downloading controller */
  748. struct wl_fw_ctrl {
  749. const struct firmware *fw_entry;
  750. unsigned long status;
  751. u32 ptr;
  752. s8 fw_name[WL_FILE_NAME_MAX];
  753. s8 nvram_name[WL_FILE_NAME_MAX];
  754. };
  755. /* assoc ie length */
  756. struct wl_assoc_ielen {
  757. u32 req_len;
  758. u32 resp_len;
  759. };
  760. #define MIN_PMKID_LIST_V3_FW_MAJOR 13
  761. #define MIN_PMKID_LIST_V3_FW_MINOR 0
  762. #define MIN_PMKID_LIST_V2_FW_MAJOR 12
  763. #define MIN_PMKID_LIST_V2_FW_MINOR 0
  764. #define MIN_ESCAN_PARAM_V2_FW_MAJOR 14
  765. #define MIN_ESCAN_PARAM_V2_FW_MINOR 0
  766. /* wpa2 pmk list */
  767. struct wl_pmk_list {
  768. pmkid_list_v3_t pmkids;
  769. pmkid_v3_t foo[MAXPMKID - 1];
  770. };
  771. #define KEY_PERM_PMK 0xFFFFFFFF
  772. #ifdef DHD_MAX_IFS
  773. #define WL_MAX_IFS DHD_MAX_IFS
  774. #else
  775. #define WL_MAX_IFS 16
  776. #endif // endif
  777. #define MAC_RAND_BYTES 3
  778. #define ESCAN_BUF_SIZE (64 * 1024)
  779. struct escan_info {
  780. u32 escan_state;
  781. #ifdef STATIC_WL_PRIV_STRUCT
  782. #ifndef CONFIG_DHD_USE_STATIC_BUF
  783. #error STATIC_WL_PRIV_STRUCT should be used with CONFIG_DHD_USE_STATIC_BUF
  784. #endif /* CONFIG_DHD_USE_STATIC_BUF */
  785. #ifdef DUAL_ESCAN_RESULT_BUFFER
  786. u8 *escan_buf[2];
  787. #else
  788. u8 *escan_buf;
  789. #endif /* DUAL_ESCAN_RESULT_BUFFER */
  790. #else
  791. #ifdef DUAL_ESCAN_RESULT_BUFFER
  792. u8 escan_buf[2][ESCAN_BUF_SIZE];
  793. #else
  794. u8 escan_buf[ESCAN_BUF_SIZE];
  795. #endif /* DUAL_ESCAN_RESULT_BUFFER */
  796. #endif /* STATIC_WL_PRIV_STRUCT */
  797. #ifdef DUAL_ESCAN_RESULT_BUFFER
  798. u8 cur_sync_id;
  799. u8 escan_type[2];
  800. #endif /* DUAL_ESCAN_RESULT_BUFFER */
  801. struct wiphy *wiphy;
  802. struct net_device *ndev;
  803. };
  804. #ifdef ESCAN_BUF_OVERFLOW_MGMT
  805. #define BUF_OVERFLOW_MGMT_COUNT 3
  806. typedef struct {
  807. int RSSI;
  808. int length;
  809. struct ether_addr BSSID;
  810. } removal_element_t;
  811. #endif /* ESCAN_BUF_OVERFLOW_MGMT */
  812. struct afx_hdl {
  813. wl_af_params_t *pending_tx_act_frm;
  814. struct ether_addr tx_dst_addr;
  815. struct net_device *dev;
  816. struct work_struct work;
  817. s32 bssidx;
  818. u32 retry;
  819. s32 peer_chan;
  820. s32 peer_listen_chan; /* search channel: configured by upper layer */
  821. s32 my_listen_chan; /* listen chanel: extract it from prb req or gon req */
  822. bool is_listen;
  823. bool ack_recv;
  824. bool is_active;
  825. };
  826. struct parsed_ies {
  827. const wpa_ie_fixed_t *wps_ie;
  828. u32 wps_ie_len;
  829. const wpa_ie_fixed_t *wpa_ie;
  830. u32 wpa_ie_len;
  831. const bcm_tlv_t *wpa2_ie;
  832. u32 wpa2_ie_len;
  833. const bcm_tlv_t *fils_ind_ie;
  834. u32 fils_ind_ie_len;
  835. };
  836. #ifdef P2P_LISTEN_OFFLOADING
  837. typedef struct {
  838. uint16 period; /* listen offload period */
  839. uint16 interval; /* listen offload interval */
  840. uint16 count; /* listen offload count */
  841. uint16 pad; /* pad for 32bit align */
  842. } wl_p2plo_listen_t;
  843. #endif /* P2P_LISTEN_OFFLOADING */
  844. #ifdef WLFBT
  845. #define FBT_KEYLEN 32
  846. #endif // endif
  847. #define MAX_EVENT_BUF_NUM 16
  848. typedef struct wl_eventmsg_buf {
  849. u16 num;
  850. struct {
  851. u16 type;
  852. bool set;
  853. } event [MAX_EVENT_BUF_NUM];
  854. } wl_eventmsg_buf_t;
  855. typedef struct wl_if_event_info {
  856. bool valid;
  857. int ifidx;
  858. int bssidx;
  859. uint8 mac[ETHER_ADDR_LEN];
  860. char name[IFNAMSIZ+1];
  861. uint8 role;
  862. } wl_if_event_info;
  863. #ifdef SUPPORT_AP_RADIO_PWRSAVE
  864. typedef struct ap_rps_info {
  865. bool enable;
  866. int sta_assoc_check;
  867. int pps;
  868. int quiet_time;
  869. int level;
  870. } ap_rps_info_t;
  871. #endif /* SUPPORT_AP_RADIO_PWRSAVE */
  872. #ifdef SUPPORT_RSSI_SUM_REPORT
  873. #define RSSILOG_FLAG_FEATURE_SW 0x1
  874. #define RSSILOG_FLAG_REPORT_READY 0x2
  875. typedef struct rssilog_set_param {
  876. uint8 enable;
  877. uint8 rssi_threshold;
  878. uint8 time_threshold;
  879. uint8 pad;
  880. } rssilog_set_param_t;
  881. typedef struct rssilog_get_param {
  882. uint8 report_count;
  883. uint8 enable;
  884. uint8 rssi_threshold;
  885. uint8 time_threshold;
  886. } rssilog_get_param_t;
  887. typedef struct rssi_ant_param {
  888. struct ether_addr ea;
  889. chanspec_t chanspec;
  890. } rssi_ant_param_t;
  891. typedef struct wl_rssi_ant_mimo {
  892. uint32 version;
  893. uint32 count;
  894. int8 rssi_ant[WL_RSSI_ANT_MAX];
  895. int8 rssi_sum;
  896. int8 PAD[3];
  897. } wl_rssi_ant_mimo_t;
  898. #endif /* SUPPORT_RSSI_SUM_REPORT */
  899. /* MBO-OCE prune event reason codes */
  900. #if defined(WL_MBO) || defined(WL_OCE)
  901. typedef enum wl_prune_evt_reason {
  902. WIFI_PRUNE_UNSPECIFIED = 0, /* Unspecified event reason code */
  903. WIFI_PRUNE_ASSOC_RETRY_DELAY = 1, /* MBO assoc retry delay */
  904. WIFI_PRUNE_RSSI_ASSOC_REJ = 2 /* OCE RSSI-based assoc rejection */
  905. } wl_prune_evt_reason_t;
  906. #endif /* WL_MBO || WL_OCE */
  907. #if defined(DHD_ENABLE_BIGDATA_LOGGING)
  908. #define GET_BSS_INFO_LEN 90
  909. #endif /* DHD_ENABLE_BIGDATA_LOGGING */
  910. #ifdef WL_MBO
  911. typedef struct wl_event_mbo wl_event_mbo_t;
  912. typedef struct wl_event_mbo_cell_nw_switch wl_event_mbo_cell_nw_switch_t;
  913. typedef struct wl_btm_event_type_data wl_btm_event_type_data_t;
  914. #endif /* WL_MBO */
  915. #if defined(WL_MBO) || defined(WL_OCE)
  916. typedef struct wl_bssid_prune_evt_info wl_bssid_pruned_evt_info_t;
  917. #endif /* WL_MBO || WL_OCE */
  918. #ifdef WL_NAN
  919. #define NAN_MAX_NDI 1u
  920. typedef struct wl_ndi_data
  921. {
  922. u8 ifname[IFNAMSIZ];
  923. u8 in_use;
  924. u8 created;
  925. struct net_device *nan_ndev;
  926. } wl_ndi_data_t;
  927. typedef struct wl_nancfg
  928. {
  929. wl_nan_ver_t version;
  930. wl_ndi_data_t ndi[NAN_MAX_NDI];
  931. struct mutex nan_sync;
  932. uint8 svc_inst_id_mask[NAN_SVC_INST_SIZE];
  933. uint8 inst_id_start;
  934. /* wait queue and condition variable for nan event */
  935. bool nan_event_recvd;
  936. wait_queue_head_t nan_event_wait;
  937. nan_stop_reason_code_t disable_reason;
  938. bool mac_rand;
  939. int range_type;
  940. uint8 max_ndp_count; /* Max no. of NDPs */
  941. nan_ndp_peer_t *nan_ndp_peer_info;
  942. } wl_nancfg_t;
  943. #ifdef WL_NANP2P
  944. #define WL_CFG_P2P_DISC_BIT 0x1u
  945. #define WL_CFG_NAN_DISC_BIT 0x2u
  946. #define WL_NANP2P_CONC_SUPPORT (WL_CFG_P2P_DISC_BIT | WL_CFG_NAN_DISC_BIT)
  947. #endif /* WL_NAN2P */
  948. #endif /* WL_NAN */
  949. #ifdef WL_IFACE_MGMT
  950. #define WL_IFACE_NOT_PRESENT -1
  951. typedef enum iface_conc_policy {
  952. WL_IF_POLICY_DEFAULT = 0,
  953. WL_IF_POLICY_FCFS = 1,
  954. WL_IF_POLICY_LP = 2,
  955. WL_IF_POLICY_ROLE_PRIORITY = 3,
  956. WL_IF_POLICY_CUSTOM = 4,
  957. WL_IF_POLICY_INVALID
  958. } iface_conc_policy_t;
  959. typedef struct iface_mgmt_data {
  960. uint8 policy;
  961. uint8 priority[WL_IF_TYPE_MAX];
  962. } iface_mgmt_data_t;
  963. #endif /* WL_IFACE_MGMT */
  964. #ifdef WL_WPS_SYNC
  965. #define EAP_PACKET 0
  966. #define EAP_EXPANDED_TYPE 254
  967. #define EAP_EXP_OPCODE_OFFSET 7
  968. #define EAP_EXP_FRAGMENT_LEN_OFFSET 2
  969. #define EAP_EXP_FLAGS_FRAGMENTED_DATA 2
  970. #define EAP_EXP_FLAGS_MORE_DATA 1
  971. #define EAPOL_EAP_HDR_LEN 5
  972. #define EAP_EXP_HDR_MIN_LENGTH (EAPOL_EAP_HDR_LEN + EAP_EXP_OPCODE_OFFSET)
  973. #define EAP_ATTRIB_MSGTYPE 0x1022
  974. #define EAP_WSC_UPNP 0
  975. #define EAP_WSC_START 1
  976. #define EAP_WSC_ACK 2
  977. #define EAP_WSC_NACK 3
  978. #define EAP_WSC_MSG 4
  979. #define EAP_WSC_DONE 5
  980. #define EAP_WSC_MSG_M8 12
  981. #define EAP_CODE_FAILURE 4
  982. #define WL_WPS_REAUTH_TIMEOUT 10000
  983. struct wl_eap_header {
  984. unsigned char code; /* EAP code */
  985. unsigned char id; /* Current request ID */
  986. unsigned short length; /* Length including header */
  987. unsigned char type; /* EAP type (optional) */
  988. unsigned char data[1]; /* Type data (optional) */
  989. } __attribute__ ((packed));
  990. typedef struct wl_eap_header wl_eap_header_t;
  991. typedef enum wl_wps_state {
  992. WPS_STATE_IDLE = 0,
  993. WPS_STATE_STARTED,
  994. WPS_STATE_M8_SENT,
  995. WPS_STATE_M8_RECVD,
  996. WPS_STATE_EAP_FAIL,
  997. WPS_STATE_REAUTH_WAIT,
  998. WPS_STATE_LINKUP,
  999. WPS_STATE_LINKDOWN,
  1000. WPS_STATE_DISCONNECT,
  1001. WPS_STATE_DISCONNECT_CLIENT,
  1002. WPS_STATE_CONNECT_FAIL,
  1003. WPS_STATE_AUTHORIZE,
  1004. WPS_STATE_DONE,
  1005. WPS_STATE_INVALID
  1006. } wl_wps_state_t;
  1007. #define WPS_MAX_SESSIONS 2
  1008. typedef struct wl_wps_session {
  1009. bool in_use;
  1010. timer_list_compat_t timer;
  1011. struct net_device *ndev;
  1012. wl_wps_state_t state;
  1013. u16 mode;
  1014. u8 peer_mac[ETHER_ADDR_LEN];
  1015. } wl_wps_session_t;
  1016. #endif /* WL_WPS_SYNC */
  1017. #ifndef WL_STATIC_IFNAME_PREFIX
  1018. #define WL_STATIC_IFNAME_PREFIX "wlan%d"
  1019. #endif /* WL_STATIC_IFNAME */
  1020. typedef struct buf_data {
  1021. u32 ver; /* version of struct */
  1022. u32 len; /* Total len */
  1023. /* size of each buffer in case of split buffers (0 - single buffer). */
  1024. u32 buf_threshold;
  1025. const void *data_buf[1]; /* array of user space buffer pointers. */
  1026. } buf_data_t;
  1027. /* private data of cfg80211 interface */
  1028. struct bcm_cfg80211 {
  1029. struct wireless_dev *wdev; /* representing cfg cfg80211 device */
  1030. struct wireless_dev *p2p_wdev; /* representing cfg cfg80211 device for P2P */
  1031. struct net_device *p2p_net; /* reference to p2p0 interface */
  1032. struct wl_conf *conf;
  1033. struct cfg80211_scan_request *scan_request; /* scan request object */
  1034. EVENT_HANDLER evt_handler[WLC_E_LAST];
  1035. struct list_head eq_list; /* used for event queue */
  1036. struct list_head net_list; /* used for struct net_info */
  1037. spinlock_t net_list_sync; /* to protect scan status (and others if needed) */
  1038. spinlock_t eq_lock; /* for event queue synchronization */
  1039. spinlock_t cfgdrv_lock; /* to protect scan status (and others if needed) */
  1040. struct completion act_frm_scan;
  1041. struct completion iface_disable;
  1042. struct completion wait_next_af;
  1043. struct mutex usr_sync; /* maily for up/down synchronization */
  1044. struct mutex if_sync; /* maily for iface op synchronization */
  1045. struct mutex scan_sync; /* scan sync from different scan contexts */
  1046. struct wl_scan_results *bss_list;
  1047. struct wl_scan_results *scan_results;
  1048. /* scan request object for internal purpose */
  1049. struct wl_scan_req *scan_req_int;
  1050. /* information element object for internal purpose */
  1051. #if defined(STATIC_WL_PRIV_STRUCT)
  1052. struct wl_ie *ie;
  1053. #else
  1054. struct wl_ie ie;
  1055. #endif // endif
  1056. /* association information container */
  1057. #if defined(STATIC_WL_PRIV_STRUCT)
  1058. struct wl_connect_info *conn_info;
  1059. #else
  1060. struct wl_connect_info conn_info;
  1061. #endif // endif
  1062. #ifdef DEBUGFS_CFG80211
  1063. struct dentry *debugfs;
  1064. #endif /* DEBUGFS_CFG80211 */
  1065. struct wl_pmk_list *pmk_list; /* wpa2 pmk list */
  1066. tsk_ctl_t event_tsk; /* task of main event handler thread */
  1067. void *pub;
  1068. u32 iface_cnt;
  1069. u32 channel; /* current channel */
  1070. u32 af_sent_channel; /* channel action frame is sent */
  1071. /* next af subtype to cancel the remained dwell time in rx process */
  1072. u8 next_af_subtype;
  1073. #ifdef WL_CFG80211_SYNC_GON
  1074. ulong af_tx_sent_jiffies;
  1075. #endif /* WL_CFG80211_SYNC_GON */
  1076. struct escan_info escan_info; /* escan information */
  1077. bool active_scan; /* current scan mode */
  1078. bool ibss_starter; /* indicates this sta is ibss starter */
  1079. bool link_up; /* link/connection up flag */
  1080. /* indicate whether chip to support power save mode */
  1081. bool pwr_save;
  1082. bool roam_on; /* on/off switch for self-roaming */
  1083. bool scan_tried; /* indicates if first scan attempted */
  1084. #if defined(BCMSDIO) || defined(BCMPCIE)
  1085. bool wlfc_on;
  1086. #endif // endif
  1087. bool vsdb_mode;
  1088. #define WL_ROAM_OFF_ON_CONCURRENT 0x0001
  1089. #define WL_ROAM_REVERT_STATUS 0x0002
  1090. u32 roam_flags;
  1091. u8 *ioctl_buf; /* ioctl buffer */
  1092. struct mutex ioctl_buf_sync;
  1093. u8 *escan_ioctl_buf;
  1094. u8 *extra_buf; /* maily to grab assoc information */
  1095. struct dentry *debugfsdir;
  1096. struct rfkill *rfkill;
  1097. bool rf_blocked;
  1098. struct ieee80211_channel remain_on_chan;
  1099. enum nl80211_channel_type remain_on_chan_type;
  1100. u64 send_action_id;
  1101. u64 last_roc_id;
  1102. wait_queue_head_t netif_change_event;
  1103. wl_if_event_info if_event_info;
  1104. struct completion send_af_done;
  1105. struct afx_hdl *afx_hdl;
  1106. struct p2p_info *p2p;
  1107. bool p2p_supported;
  1108. void *btcoex_info;
  1109. timer_list_compat_t scan_timeout; /* Timer for catch scan event timeout */
  1110. #ifdef WL_CFG80211_GON_COLLISION
  1111. u8 block_gon_req_tx_count;
  1112. u8 block_gon_req_rx_count;
  1113. #endif /* WL_CFG80211_GON_COLLISION */
  1114. #if defined(P2P_IE_MISSING_FIX)
  1115. bool p2p_prb_noti;
  1116. #endif // endif
  1117. s32(*state_notifier) (struct bcm_cfg80211 *cfg,
  1118. struct net_info *_net_info, enum wl_status state, bool set);
  1119. unsigned long interrested_state;
  1120. wlc_ssid_t hostapd_ssid;
  1121. #ifdef WL11U
  1122. bool wl11u;
  1123. #endif /* WL11U */
  1124. bool sched_scan_running; /* scheduled scan req status */
  1125. struct cfg80211_sched_scan_request *sched_scan_req; /* scheduled scan req */
  1126. #ifdef WL_HOST_BAND_MGMT
  1127. u8 curr_band;
  1128. #endif /* WL_HOST_BAND_MGMT */
  1129. bool scan_suppressed;
  1130. #ifdef OEM_ANDROID
  1131. timer_list_compat_t scan_supp_timer;
  1132. struct work_struct wlan_work;
  1133. #endif /* OEM_ANDROID */
  1134. struct mutex event_sync; /* maily for up/down synchronization */
  1135. bool disable_roam_event;
  1136. struct delayed_work pm_enable_work;
  1137. #ifdef OEM_ANDROID
  1138. struct workqueue_struct *event_workq; /* workqueue for event */
  1139. #else
  1140. bool event_workq_init;
  1141. #endif /* OEM_ANDROID */
  1142. struct work_struct event_work; /* work item for event */
  1143. struct mutex pm_sync; /* mainly for pm work synchronization */
  1144. vndr_ie_setbuf_t *ibss_vsie; /* keep the VSIE for IBSS */
  1145. int ibss_vsie_len;
  1146. #ifdef WLAIBSS
  1147. u32 aibss_txfail_pid;
  1148. u32 aibss_txfail_seq;
  1149. #endif /* WLAIBSS */
  1150. #ifdef WL_RELMCAST
  1151. u32 rmc_event_pid;
  1152. u32 rmc_event_seq;
  1153. #endif /* WL_RELMCAST */
  1154. #ifdef WLAIBSS_MCHAN
  1155. struct ether_addr ibss_if_addr;
  1156. bcm_struct_cfgdev *ibss_cfgdev; /* For AIBSS */
  1157. #endif /* WLAIBSS_MCHAN */
  1158. bool bss_pending_op; /* indicate where there is a pending IF operation */
  1159. #ifdef WLFBT
  1160. uint8 fbt_key[FBT_KEYLEN];
  1161. #endif // endif
  1162. int roam_offload;
  1163. #ifdef WL_NAN
  1164. bool nan_enable;
  1165. nan_svc_inst_t nan_inst_ctrl[NAN_ID_CTRL_SIZE];
  1166. struct ether_addr initiator_ndi;
  1167. uint8 nan_dp_state;
  1168. bool nan_init_state; /* nan initialization state */
  1169. wait_queue_head_t ndp_if_change_event;
  1170. uint8 support_5g;
  1171. u8 nan_nmi_mac[ETH_ALEN];
  1172. u8 nan_dp_mask;
  1173. wl_nancfg_t nancfg;
  1174. #ifdef WL_NAN_DISC_CACHE
  1175. int nan_disc_count;
  1176. nan_disc_result_cache *nan_disc_cache;
  1177. nan_svc_info_t svc_info[NAN_MAX_SVC_INST];
  1178. nan_ranging_inst_t nan_ranging_info[NAN_MAX_RANGING_INST];
  1179. #endif /* WL_NAN_DISC_CACHE */
  1180. #ifdef WL_NANP2P
  1181. uint8 conc_disc;
  1182. bool nan_p2p_supported;
  1183. #endif /* WL_NANP2P */
  1184. #endif /* WL_NAN */
  1185. #ifdef WL_IFACE_MGMT
  1186. iface_mgmt_data_t iface_data;
  1187. #endif /* WL_IFACE_MGMT */
  1188. #ifdef WL_CFG80211_P2P_DEV_IF
  1189. bool down_disc_if;
  1190. #endif /* WL_CFG80211_P2P_DEV_IF */
  1191. #ifdef P2PLISTEN_AP_SAMECHN
  1192. bool p2p_resp_apchn_status;
  1193. #endif /* P2PLISTEN_AP_SAMECHN */
  1194. struct wl_wsec_key wep_key;
  1195. #ifdef WLTDLS
  1196. u8 *tdls_mgmt_frame;
  1197. u32 tdls_mgmt_frame_len;
  1198. s32 tdls_mgmt_freq;
  1199. #endif /* WLTDLS */
  1200. bool need_wait_afrx;
  1201. #ifdef QOS_MAP_SET
  1202. uint8 *up_table; /* user priority table, size is UP_TABLE_MAX */
  1203. #endif /* QOS_MAP_SET */
  1204. struct ether_addr last_roamed_addr;
  1205. bool rcc_enabled; /* flag for Roam channel cache feature */
  1206. #if defined(DHD_ENABLE_BIGDATA_LOGGING)
  1207. char bss_info[GET_BSS_INFO_LEN];
  1208. wl_event_msg_t event_auth_assoc;
  1209. u32 assoc_reject_status;
  1210. u32 roam_count;
  1211. #endif /* DHD_ENABLE_BIGDATA_LOGGING */
  1212. u16 ap_oper_channel;
  1213. #if defined(SUPPORT_RANDOM_MAC_SCAN)
  1214. bool random_mac_enabled;
  1215. #endif /* SUPPORT_RANDOM_MAC_SCAN */
  1216. #ifdef DHD_LOSSLESS_ROAMING
  1217. timer_list_compat_t roam_timeout; /* Timer for catch roam timeout */
  1218. #endif // endif
  1219. #ifndef DUAL_ESCAN_RESULT_BUFFER
  1220. uint16 escan_sync_id_cntr;
  1221. #endif // endif
  1222. #ifdef WLTDLS
  1223. uint8 tdls_supported;
  1224. struct mutex tdls_sync; /* protect tdls config operations */
  1225. #endif /* WLTDLS */
  1226. #ifdef MFP
  1227. const uint8 *bip_pos;
  1228. int mfp_mode;
  1229. #endif /* MFP */
  1230. #ifdef WES_SUPPORT
  1231. #ifdef CUSTOMER_SCAN_TIMEOUT_SETTING
  1232. int custom_scan_channel_time;
  1233. int custom_scan_unassoc_time;
  1234. int custom_scan_passive_time;
  1235. int custom_scan_home_time;
  1236. int custom_scan_home_away_time;
  1237. #endif /* CUSTOMER_SCAN_TIMEOUT_SETTING */
  1238. #endif /* WES_SUPPORT */
  1239. uint8 vif_count; /* Virtual Interface count */
  1240. #ifdef WBTEXT
  1241. struct list_head wbtext_bssid_list;
  1242. #endif /* WBTEXT */
  1243. #ifdef SUPPORT_AP_RADIO_PWRSAVE
  1244. ap_rps_info_t ap_rps_info;
  1245. #endif /* SUPPORT_AP_RADIO_PWRSAVE */
  1246. u16 vif_macaddr_mask;
  1247. osl_t *osh;
  1248. struct list_head vndr_oui_list;
  1249. spinlock_t vndr_oui_sync; /* to protect vndr_oui_list */
  1250. bool rssi_sum_report;
  1251. int rssi; /* previous RSSI (backup) of get_station */
  1252. uint64 scan_enq_time;
  1253. uint64 scan_deq_time;
  1254. uint64 scan_hdlr_cmplt_time;
  1255. uint64 scan_cmplt_time;
  1256. uint64 wl_evt_deq_time;
  1257. uint64 wl_evt_hdlr_entry_time;
  1258. uint64 wl_evt_hdlr_exit_time;
  1259. #ifdef WL_WPS_SYNC
  1260. wl_wps_session_t wps_session[WPS_MAX_SESSIONS];
  1261. spinlock_t wps_sync; /* to protect wps states (and others if needed) */
  1262. #endif /* WL_WPS_SYNC */
  1263. struct wl_fils_info fils_info;
  1264. #ifdef WL_BAM
  1265. wl_bad_ap_mngr_t bad_ap_mngr;
  1266. #endif /* WL_BAM */
  1267. #ifdef BIGDATA_SOFTAP
  1268. struct wl_ap_sta_info *ap_sta_info;
  1269. #endif /* BIGDATA_SOFTAP */
  1270. uint8 scanmac_enabled;
  1271. #ifdef WL_BCNRECV
  1272. /* structure used for fake ap detection info */
  1273. struct mutex bcn_sync; /* mainly for bcn resume/suspend synchronization */
  1274. wl_bcnrecv_info_t bcnrecv_info;
  1275. #endif /* WL_BCNRECV */
  1276. struct net_device *static_ndev;
  1277. uint8 static_ndev_state;
  1278. bool hal_started;
  1279. wl_wlc_version_t wlc_ver;
  1280. bool scan_params_v2;
  1281. #ifdef DHD_BANDSTEER
  1282. void *dhd_bandsteer_cntx;
  1283. bool p2p_bs;
  1284. bool ap_bs;
  1285. #endif /* DHD_BANDSTEER */
  1286. };
  1287. #define WL_STATIC_IFIDX (DHD_MAX_IFS + DHD_MAX_STATIC_IFS - 1)
  1288. enum static_ndev_states {
  1289. NDEV_STATE_NONE,
  1290. NDEV_STATE_OS_IF_CREATED,
  1291. NDEV_STATE_FW_IF_CREATED,
  1292. NDEV_STATE_FW_IF_FAILED,
  1293. NDEV_STATE_FW_IF_DELETED
  1294. };
  1295. #define IS_CFG80211_STATIC_IF(cfg, ndev) \
  1296. ((cfg && (cfg->static_ndev == ndev)) ? true : false)
  1297. #define IS_CFG80211_STATIC_IF_ACTIVE(cfg) \
  1298. ((cfg && cfg->static_ndev && \
  1299. (cfg->static_ndev_state & NDEV_STATE_FW_IF_CREATED)) ? true : false)
  1300. #define IS_CFG80211_STATIC_IF_NAME(cfg, name) \
  1301. (cfg && cfg->static_ndev && \
  1302. !strncmp(cfg->static_ndev->name, name, strlen(name)))
  1303. #ifdef WL_SAE
  1304. typedef struct wl_sae_key_info {
  1305. uint8 peer_mac[ETHER_ADDR_LEN];
  1306. uint16 pmk_len;
  1307. uint16 pmkid_len;
  1308. const uint8 *pmk;
  1309. const uint8 *pmkid;
  1310. } wl_sae_key_info_t;
  1311. #endif /* WL_SAE */
  1312. typedef enum wl_concurrency_mode {
  1313. CONCURRENCY_MODE_NONE = 0,
  1314. CONCURRENCY_SCC_MODE,
  1315. CONCURRENCY_VSDB_MODE,
  1316. CONCURRENCY_RSDB_MODE
  1317. } wl_concurrency_mode_t;
  1318. s32 wl_iftype_to_mode(wl_iftype_t iftype);
  1319. #define BCM_LIST_FOR_EACH_ENTRY_SAFE(pos, next, head, member) \
  1320. list_for_each_entry_safe((pos), (next), (head), member)
  1321. extern int ioctl_version;
  1322. static inline wl_bss_info_t *next_bss(struct wl_scan_results *list, wl_bss_info_t *bss)
  1323. {
  1324. return bss = bss ?
  1325. (wl_bss_info_t *)((uintptr) bss + dtoh32(bss->length)) : list->bss_info;
  1326. }
  1327. static inline void
  1328. wl_probe_wdev_all(struct bcm_cfg80211 *cfg)
  1329. {
  1330. struct net_info *_net_info, *next;
  1331. unsigned long int flags;
  1332. int idx = 0;
  1333. WL_CFG_NET_LIST_SYNC_LOCK(&cfg->net_list_sync, flags);
  1334. GCC_DIAGNOSTIC_PUSH_SUPPRESS_CAST();
  1335. BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next,
  1336. &cfg->net_list, list) {
  1337. GCC_DIAGNOSTIC_POP();
  1338. WL_INFORM_MEM(("wl_probe_wdev_all: net_list[%d] bssidx: %d\n",
  1339. idx++, _net_info->bssidx));
  1340. }
  1341. WL_CFG_NET_LIST_SYNC_UNLOCK(&cfg->net_list_sync, flags);
  1342. return;
  1343. }
  1344. static inline struct net_info *
  1345. wl_get_netinfo_by_fw_idx(struct bcm_cfg80211 *cfg, s32 bssidx, u8 ifidx)
  1346. {
  1347. struct net_info *_net_info, *next, *info = NULL;
  1348. unsigned long int flags;
  1349. WL_CFG_NET_LIST_SYNC_LOCK(&cfg->net_list_sync, flags);
  1350. GCC_DIAGNOSTIC_PUSH_SUPPRESS_CAST();
  1351. BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
  1352. GCC_DIAGNOSTIC_POP();
  1353. if ((bssidx >= 0) && (_net_info->bssidx == bssidx) &&
  1354. (_net_info->ifidx == ifidx)) {
  1355. info = _net_info;
  1356. break;
  1357. }
  1358. }
  1359. WL_CFG_NET_LIST_SYNC_UNLOCK(&cfg->net_list_sync, flags);
  1360. return info;
  1361. }
  1362. static inline void
  1363. wl_dealloc_netinfo_by_wdev(struct bcm_cfg80211 *cfg, struct wireless_dev *wdev)
  1364. {
  1365. struct net_info *_net_info, *next;
  1366. unsigned long int flags;
  1367. #ifdef DHD_IFDEBUG
  1368. WL_INFORM_MEM(("dealloc_netinfo enter wdev=%p \n", OSL_OBFUSCATE_BUF(wdev)));
  1369. #endif // endif
  1370. WL_CFG_NET_LIST_SYNC_LOCK(&cfg->net_list_sync, flags);
  1371. GCC_DIAGNOSTIC_PUSH_SUPPRESS_CAST();
  1372. BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
  1373. GCC_DIAGNOSTIC_POP();
  1374. if (wdev && (_net_info->wdev == wdev)) {
  1375. wl_cfgbss_t *bss = &_net_info->bss;
  1376. if (bss->wpa_ie) {
  1377. MFREE(cfg->osh, bss->wpa_ie, bss->wpa_ie[1]
  1378. + WPA_RSN_IE_TAG_FIXED_LEN);
  1379. bss->wpa_ie = NULL;
  1380. }
  1381. if (bss->rsn_ie) {
  1382. MFREE(cfg->osh, bss->rsn_ie,
  1383. bss->rsn_ie[1] + WPA_RSN_IE_TAG_FIXED_LEN);
  1384. bss->rsn_ie = NULL;
  1385. }
  1386. if (bss->wps_ie) {
  1387. MFREE(cfg->osh, bss->wps_ie, bss->wps_ie[1] + 2);
  1388. bss->wps_ie = NULL;
  1389. }
  1390. list_del(&_net_info->list);
  1391. cfg->iface_cnt--;
  1392. MFREE(cfg->osh, _net_info, sizeof(struct net_info));
  1393. }
  1394. }
  1395. WL_CFG_NET_LIST_SYNC_UNLOCK(&cfg->net_list_sync, flags);
  1396. #ifdef DHD_IFDEBUG
  1397. WL_INFORM_MEM(("dealloc_netinfo exit iface_cnt=%d \n", cfg->iface_cnt));
  1398. #endif // endif
  1399. }
  1400. static inline s32
  1401. wl_alloc_netinfo(struct bcm_cfg80211 *cfg, struct net_device *ndev,
  1402. struct wireless_dev * wdev, wl_iftype_t iftype, bool pm_block, u8 bssidx, u8 ifidx)
  1403. {
  1404. struct net_info *_net_info;
  1405. s32 err = 0;
  1406. unsigned long int flags;
  1407. #ifdef DHD_IFDEBUG
  1408. WL_INFORM_MEM(("alloc_netinfo enter bssidx=%d wdev=%p\n",
  1409. bssidx, OSL_OBFUSCATE_BUF(wdev)));
  1410. #endif // endif
  1411. /* Check whether there is any duplicate entry for the
  1412. * same bssidx && ifidx.
  1413. */
  1414. if ((_net_info = wl_get_netinfo_by_fw_idx(cfg, bssidx, ifidx))) {
  1415. /* We have a duplicate entry for the same bssidx
  1416. * already present which shouldn't have been the case.
  1417. * Attempt recovery.
  1418. */
  1419. WL_ERR(("Duplicate entry for bssidx=%d ifidx=%d present."
  1420. " Can't add new entry\n", bssidx, ifidx));
  1421. wl_probe_wdev_all(cfg);
  1422. #ifdef DHD_DEBUG
  1423. ASSERT(0);
  1424. #endif /* DHD_DEBUG */
  1425. return -EINVAL;
  1426. }
  1427. if (cfg->iface_cnt == IFACE_MAX_CNT)
  1428. return -ENOMEM;
  1429. _net_info = (struct net_info *)MALLOCZ(cfg->osh, sizeof(struct net_info));
  1430. if (!_net_info)
  1431. err = -ENOMEM;
  1432. else {
  1433. _net_info->iftype = iftype;
  1434. _net_info->ndev = ndev;
  1435. _net_info->wdev = wdev;
  1436. _net_info->pm_restore = 0;
  1437. _net_info->pm = 0;
  1438. _net_info->pm_block = pm_block;
  1439. _net_info->roam_off = WL_INVALID;
  1440. _net_info->bssidx = bssidx;
  1441. _net_info->ifidx = ifidx;
  1442. WL_CFG_NET_LIST_SYNC_LOCK(&cfg->net_list_sync, flags);
  1443. cfg->iface_cnt++;
  1444. list_add(&_net_info->list, &cfg->net_list);
  1445. WL_CFG_NET_LIST_SYNC_UNLOCK(&cfg->net_list_sync, flags);
  1446. #ifdef WL_SAE
  1447. init_completion(&_net_info->mgmt_tx_cpl);
  1448. #endif /* WL_SAE */
  1449. }
  1450. #ifdef DHD_IFDEBUG
  1451. WL_DBG(("alloc_netinfo exit iface_cnt=%d \n", cfg->iface_cnt));
  1452. #endif // endif
  1453. return err;
  1454. }
  1455. static inline void
  1456. wl_delete_all_netinfo(struct bcm_cfg80211 *cfg)
  1457. {
  1458. struct net_info *_net_info, *next;
  1459. unsigned long int flags;
  1460. WL_CFG_NET_LIST_SYNC_LOCK(&cfg->net_list_sync, flags);
  1461. GCC_DIAGNOSTIC_PUSH_SUPPRESS_CAST();
  1462. BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
  1463. wl_cfgbss_t *bss = &_net_info->bss;
  1464. GCC_DIAGNOSTIC_POP();
  1465. if (bss->wpa_ie) {
  1466. MFREE(cfg->osh, bss->wpa_ie, bss->wpa_ie[1]
  1467. + WPA_RSN_IE_TAG_FIXED_LEN);
  1468. bss->wpa_ie = NULL;
  1469. }
  1470. if (bss->rsn_ie) {
  1471. MFREE(cfg->osh, bss->rsn_ie, bss->rsn_ie[1]
  1472. + WPA_RSN_IE_TAG_FIXED_LEN);
  1473. bss->rsn_ie = NULL;
  1474. }
  1475. if (bss->wps_ie) {
  1476. MFREE(cfg->osh, bss->wps_ie, bss->wps_ie[1] + 2);
  1477. bss->wps_ie = NULL;
  1478. }
  1479. if (bss->fils_ind_ie) {
  1480. MFREE(cfg->osh, bss->fils_ind_ie, bss->fils_ind_ie[1]
  1481. + FILS_INDICATION_IE_TAG_FIXED_LEN);
  1482. bss->fils_ind_ie = NULL;
  1483. }
  1484. list_del(&_net_info->list);
  1485. if (_net_info->wdev) {
  1486. MFREE(cfg->osh, _net_info->wdev, sizeof(struct wireless_dev));
  1487. }
  1488. MFREE(cfg->osh, _net_info, sizeof(struct net_info));
  1489. }
  1490. cfg->iface_cnt = 0;
  1491. WL_CFG_NET_LIST_SYNC_UNLOCK(&cfg->net_list_sync, flags);
  1492. }
  1493. static inline u32
  1494. wl_get_status_all(struct bcm_cfg80211 *cfg, s32 status)
  1495. {
  1496. struct net_info *_net_info, *next;
  1497. u32 cnt = 0;
  1498. unsigned long int flags;
  1499. WL_CFG_NET_LIST_SYNC_LOCK(&cfg->net_list_sync, flags);
  1500. GCC_DIAGNOSTIC_PUSH_SUPPRESS_CAST();
  1501. BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
  1502. GCC_DIAGNOSTIC_POP();
  1503. if (_net_info->ndev &&
  1504. test_bit(status, &_net_info->sme_state))
  1505. cnt++;
  1506. }
  1507. WL_CFG_NET_LIST_SYNC_UNLOCK(&cfg->net_list_sync, flags);
  1508. return cnt;
  1509. }
  1510. static inline void
  1511. wl_set_status_all(struct bcm_cfg80211 *cfg, s32 status, u32 op)
  1512. {
  1513. struct net_info *_net_info, *next;
  1514. unsigned long int flags;
  1515. WL_CFG_NET_LIST_SYNC_LOCK(&cfg->net_list_sync, flags);
  1516. GCC_DIAGNOSTIC_PUSH_SUPPRESS_CAST();
  1517. BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
  1518. GCC_DIAGNOSTIC_POP();
  1519. switch (op) {
  1520. case 1:
  1521. break; /* set all status is not allowed */
  1522. case 2:
  1523. /*
  1524. * Release the spinlock before calling notifier. Else there
  1525. * will be nested calls
  1526. */
  1527. WL_CFG_NET_LIST_SYNC_UNLOCK(&cfg->net_list_sync, flags);
  1528. clear_bit(status, &_net_info->sme_state);
  1529. if (cfg->state_notifier &&
  1530. test_bit(status, &(cfg->interrested_state)))
  1531. cfg->state_notifier(cfg, _net_info, status, false);
  1532. return;
  1533. case 4:
  1534. break; /* change all status is not allowed */
  1535. default:
  1536. break; /* unknown operation */
  1537. }
  1538. }
  1539. WL_CFG_NET_LIST_SYNC_UNLOCK(&cfg->net_list_sync, flags);
  1540. }
  1541. static inline void
  1542. wl_set_status_by_netdev(struct bcm_cfg80211 *cfg, s32 status,
  1543. struct net_device *ndev, u32 op)
  1544. {
  1545. struct net_info *_net_info, *next;
  1546. unsigned long int flags;
  1547. if (status >= BITS_PER_LONG) {
  1548. /* max value for shift operation is
  1549. * (BITS_PER_LONG -1) for unsigned long.
  1550. * if status crosses BIT_PER_LONG, the variable
  1551. * sme_state should be correspondingly updated.
  1552. */
  1553. ASSERT(0);
  1554. return;
  1555. }
  1556. WL_CFG_NET_LIST_SYNC_LOCK(&cfg->net_list_sync, flags);
  1557. GCC_DIAGNOSTIC_PUSH_SUPPRESS_CAST();
  1558. BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
  1559. if (ndev && (_net_info->ndev == ndev)) {
  1560. GCC_DIAGNOSTIC_POP();
  1561. switch (op) {
  1562. case 1:
  1563. /*
  1564. * Release the spinlock before calling notifier. Else there
  1565. * will be nested calls
  1566. */
  1567. WL_CFG_NET_LIST_SYNC_UNLOCK(&cfg->net_list_sync, flags);
  1568. set_bit(status, &_net_info->sme_state);
  1569. if (cfg->state_notifier &&
  1570. test_bit(status, &(cfg->interrested_state)))
  1571. cfg->state_notifier(cfg, _net_info, status, true);
  1572. return;
  1573. case 2:
  1574. /*
  1575. * Release the spinlock before calling notifier. Else there
  1576. * will be nested calls
  1577. */
  1578. WL_CFG_NET_LIST_SYNC_UNLOCK(&cfg->net_list_sync, flags);
  1579. clear_bit(status, &_net_info->sme_state);
  1580. if (cfg->state_notifier &&
  1581. test_bit(status, &(cfg->interrested_state)))
  1582. cfg->state_notifier(cfg, _net_info, status, false);
  1583. return;
  1584. case 4:
  1585. change_bit(status, &_net_info->sme_state);
  1586. break;
  1587. }
  1588. }
  1589. }
  1590. WL_CFG_NET_LIST_SYNC_UNLOCK(&cfg->net_list_sync, flags);
  1591. }
  1592. static inline wl_cfgbss_t *
  1593. wl_get_cfgbss_by_wdev(struct bcm_cfg80211 *cfg,
  1594. struct wireless_dev *wdev)
  1595. {
  1596. struct net_info *_net_info, *next;
  1597. wl_cfgbss_t *bss = NULL;
  1598. unsigned long int flags;
  1599. WL_CFG_NET_LIST_SYNC_LOCK(&cfg->net_list_sync, flags);
  1600. GCC_DIAGNOSTIC_PUSH_SUPPRESS_CAST();
  1601. BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
  1602. GCC_DIAGNOSTIC_POP();
  1603. if (wdev && (_net_info->wdev == wdev)) {
  1604. bss = &_net_info->bss;
  1605. break;
  1606. }
  1607. }
  1608. WL_CFG_NET_LIST_SYNC_UNLOCK(&cfg->net_list_sync, flags);
  1609. return bss;
  1610. }
  1611. static inline u32
  1612. wl_get_status_by_netdev(struct bcm_cfg80211 *cfg, s32 status,
  1613. struct net_device *ndev)
  1614. {
  1615. struct net_info *_net_info, *next;
  1616. u32 stat = 0;
  1617. unsigned long int flags;
  1618. WL_CFG_NET_LIST_SYNC_LOCK(&cfg->net_list_sync, flags);
  1619. GCC_DIAGNOSTIC_PUSH_SUPPRESS_CAST();
  1620. BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
  1621. GCC_DIAGNOSTIC_POP();
  1622. if (ndev && (_net_info->ndev == ndev)) {
  1623. stat = test_bit(status, &_net_info->sme_state);
  1624. break;
  1625. }
  1626. }
  1627. WL_CFG_NET_LIST_SYNC_UNLOCK(&cfg->net_list_sync, flags);
  1628. return stat;
  1629. }
  1630. static inline s32
  1631. wl_get_mode_by_netdev(struct bcm_cfg80211 *cfg, struct net_device *ndev)
  1632. {
  1633. struct net_info *_net_info, *next;
  1634. s32 mode = -1;
  1635. unsigned long int flags;
  1636. WL_CFG_NET_LIST_SYNC_LOCK(&cfg->net_list_sync, flags);
  1637. GCC_DIAGNOSTIC_PUSH_SUPPRESS_CAST();
  1638. BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
  1639. GCC_DIAGNOSTIC_POP();
  1640. if (_net_info->ndev && (_net_info->ndev == ndev)) {
  1641. mode = wl_iftype_to_mode(_net_info->iftype);
  1642. break;
  1643. }
  1644. }
  1645. WL_CFG_NET_LIST_SYNC_UNLOCK(&cfg->net_list_sync, flags);
  1646. return mode;
  1647. }
  1648. static inline s32
  1649. wl_get_bssidx_by_wdev(struct bcm_cfg80211 *cfg, struct wireless_dev *wdev)
  1650. {
  1651. struct net_info *_net_info, *next;
  1652. s32 bssidx = -1;
  1653. unsigned long int flags;
  1654. WL_CFG_NET_LIST_SYNC_LOCK(&cfg->net_list_sync, flags);
  1655. GCC_DIAGNOSTIC_PUSH_SUPPRESS_CAST();
  1656. BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
  1657. GCC_DIAGNOSTIC_POP();
  1658. if (_net_info->wdev && (_net_info->wdev == wdev)) {
  1659. bssidx = _net_info->bssidx;
  1660. break;
  1661. }
  1662. }
  1663. WL_CFG_NET_LIST_SYNC_UNLOCK(&cfg->net_list_sync, flags);
  1664. return bssidx;
  1665. }
  1666. static inline struct wireless_dev *
  1667. wl_get_wdev_by_fw_idx(struct bcm_cfg80211 *cfg, s32 bssidx, s32 ifidx)
  1668. {
  1669. struct net_info *_net_info, *next;
  1670. struct wireless_dev *wdev = NULL;
  1671. unsigned long int flags;
  1672. if (bssidx < 0)
  1673. return NULL;
  1674. WL_CFG_NET_LIST_SYNC_LOCK(&cfg->net_list_sync, flags);
  1675. GCC_DIAGNOSTIC_PUSH_SUPPRESS_CAST();
  1676. BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
  1677. GCC_DIAGNOSTIC_POP();
  1678. if ((_net_info->bssidx == bssidx) && (_net_info->ifidx == ifidx)) {
  1679. wdev = _net_info->wdev;
  1680. break;
  1681. }
  1682. }
  1683. WL_CFG_NET_LIST_SYNC_UNLOCK(&cfg->net_list_sync, flags);
  1684. return wdev;
  1685. }
  1686. static inline struct wl_profile *
  1687. wl_get_profile_by_netdev(struct bcm_cfg80211 *cfg, struct net_device *ndev)
  1688. {
  1689. struct net_info *_net_info, *next;
  1690. struct wl_profile *prof = NULL;
  1691. unsigned long int flags;
  1692. WL_CFG_NET_LIST_SYNC_LOCK(&cfg->net_list_sync, flags);
  1693. GCC_DIAGNOSTIC_PUSH_SUPPRESS_CAST();
  1694. BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
  1695. GCC_DIAGNOSTIC_POP();
  1696. if (ndev && (_net_info->ndev == ndev)) {
  1697. prof = &_net_info->profile;
  1698. break;
  1699. }
  1700. }
  1701. WL_CFG_NET_LIST_SYNC_UNLOCK(&cfg->net_list_sync, flags);
  1702. return prof;
  1703. }
  1704. static inline struct net_info *
  1705. wl_get_netinfo_by_netdev(struct bcm_cfg80211 *cfg, struct net_device *ndev)
  1706. {
  1707. struct net_info *_net_info, *next, *info = NULL;
  1708. unsigned long int flags;
  1709. WL_CFG_NET_LIST_SYNC_LOCK(&cfg->net_list_sync, flags);
  1710. GCC_DIAGNOSTIC_PUSH_SUPPRESS_CAST();
  1711. BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
  1712. GCC_DIAGNOSTIC_POP();
  1713. if (ndev && (_net_info->ndev == ndev)) {
  1714. info = _net_info;
  1715. break;
  1716. }
  1717. }
  1718. WL_CFG_NET_LIST_SYNC_UNLOCK(&cfg->net_list_sync, flags);
  1719. return info;
  1720. }
  1721. static inline struct net_info *
  1722. wl_get_netinfo_by_wdev(struct bcm_cfg80211 *cfg, struct wireless_dev *wdev)
  1723. {
  1724. struct net_info *_net_info, *next, *info = NULL;
  1725. unsigned long int flags;
  1726. WL_CFG_NET_LIST_SYNC_LOCK(&cfg->net_list_sync, flags);
  1727. GCC_DIAGNOSTIC_PUSH_SUPPRESS_CAST();
  1728. BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
  1729. GCC_DIAGNOSTIC_POP();
  1730. if (wdev && (_net_info->wdev == wdev)) {
  1731. info = _net_info;
  1732. break;
  1733. }
  1734. }
  1735. WL_CFG_NET_LIST_SYNC_UNLOCK(&cfg->net_list_sync, flags);
  1736. return info;
  1737. }
  1738. static inline u32
  1739. wl_get_chanwidth_by_netdev(struct bcm_cfg80211 *cfg, struct net_device *ndev)
  1740. {
  1741. struct net_info *_net_info, *next;
  1742. unsigned long int flags;
  1743. u32 info = 0;
  1744. spin_lock_irqsave(&cfg->net_list_sync, flags);
  1745. GCC_DIAGNOSTIC_PUSH_SUPPRESS_CAST();
  1746. BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
  1747. GCC_DIAGNOSTIC_POP();
  1748. if (ndev && (_net_info->ndev == ndev)) {
  1749. info = _net_info->profile.channel_width;
  1750. break;
  1751. }
  1752. }
  1753. spin_unlock_irqrestore(&cfg->net_list_sync, flags);
  1754. return info;
  1755. }
  1756. static inline void
  1757. wl_set_chanwidth_by_netdev(struct bcm_cfg80211 *cfg, struct net_device *ndev, u32 chanwidth)
  1758. {
  1759. struct net_info *_net_info, *next;
  1760. unsigned long int flags;
  1761. spin_lock_irqsave(&cfg->net_list_sync, flags);
  1762. GCC_DIAGNOSTIC_PUSH_SUPPRESS_CAST();
  1763. BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
  1764. GCC_DIAGNOSTIC_POP();
  1765. if (ndev && (_net_info->ndev == ndev))
  1766. _net_info->profile.channel_width = chanwidth;
  1767. }
  1768. spin_unlock_irqrestore(&cfg->net_list_sync, flags);
  1769. }
  1770. static inline char *
  1771. wl_iftype_to_str(int wl_iftype)
  1772. {
  1773. switch (wl_iftype) {
  1774. case (WL_IF_TYPE_STA):
  1775. return "WL_IF_TYPE_STA";
  1776. case (WL_IF_TYPE_AP):
  1777. return "WL_IF_TYPE_AP";
  1778. case (WL_IF_TYPE_AWDL):
  1779. return "WL_IF_TYPE_AWDL";
  1780. case (WL_IF_TYPE_NAN_NMI):
  1781. return "WL_IF_TYPE_NAN_NMI";
  1782. case (WL_IF_TYPE_NAN):
  1783. return "WL_IF_TYPE_NAN";
  1784. case (WL_IF_TYPE_P2P_GO):
  1785. return "WL_IF_TYPE_P2P_GO";
  1786. case (WL_IF_TYPE_P2P_GC):
  1787. return "WL_IF_TYPE_P2P_GC";
  1788. case (WL_IF_TYPE_P2P_DISC):
  1789. return "WL_IF_TYPE_P2P_DISC";
  1790. case (WL_IF_TYPE_IBSS):
  1791. return "WL_IF_TYPE_IBSS";
  1792. case (WL_IF_TYPE_MONITOR):
  1793. return "WL_IF_TYPE_MONITOR";
  1794. case (WL_IF_TYPE_AIBSS):
  1795. return "WL_IF_TYPE_AIBSS";
  1796. default:
  1797. return "WL_IF_TYPE_UNKNOWN";
  1798. }
  1799. }
  1800. #define is_discovery_iface(iface) (((iface == WL_IF_TYPE_P2P_DISC) || \
  1801. (iface == WL_IF_TYPE_NAN_NMI)) ? 1 : 0)
  1802. #define is_p2p_group_iface(wdev) (((wdev->iftype == NL80211_IFTYPE_P2P_GO) || \
  1803. (wdev->iftype == NL80211_IFTYPE_P2P_CLIENT)) ? 1 : 0)
  1804. #define bcmcfg_to_wiphy(cfg) (cfg->wdev->wiphy)
  1805. #define bcmcfg_to_prmry_ndev(cfg) (cfg->wdev->netdev)
  1806. #define bcmcfg_to_prmry_wdev(cfg) (cfg->wdev)
  1807. #define bcmcfg_to_p2p_wdev(cfg) (cfg->p2p_wdev)
  1808. #define ndev_to_wl(n) (wdev_to_wl(n->ieee80211_ptr))
  1809. #define ndev_to_wdev(ndev) (ndev->ieee80211_ptr)
  1810. #define wdev_to_ndev(wdev) (wdev->netdev)
  1811. #ifdef WL_BLOCK_P2P_SCAN_ON_STA
  1812. #define IS_P2P_IFACE(wdev) (wdev && \
  1813. ((wdev->iftype == NL80211_IFTYPE_P2P_DEVICE) || \
  1814. (wdev->iftype == NL80211_IFTYPE_P2P_GO) || \
  1815. (wdev->iftype == NL80211_IFTYPE_P2P_CLIENT)))
  1816. #endif /* WL_BLOCK_P2P_SCAN_ON_STA */
  1817. #define IS_STA_IFACE(wdev) (wdev && \
  1818. (wdev->iftype == NL80211_IFTYPE_STATION))
  1819. #define IS_AP_IFACE(wdev) (wdev && \
  1820. (wdev->iftype == NL80211_IFTYPE_AP))
  1821. #if defined(WL_ENABLE_P2P_IF)
  1822. #define ndev_to_wlc_ndev(ndev, cfg) ((ndev == cfg->p2p_net) ? \
  1823. bcmcfg_to_prmry_ndev(cfg) : ndev)
  1824. #else
  1825. #define ndev_to_wlc_ndev(ndev, cfg) (ndev)
  1826. #endif /* WL_ENABLE_P2P_IF */
  1827. #define wdev_to_wlc_ndev(wdev, cfg) \
  1828. (wdev_to_ndev(wdev) ? \
  1829. wdev_to_ndev(wdev) : bcmcfg_to_prmry_ndev(cfg))
  1830. #if defined(WL_CFG80211_P2P_DEV_IF)
  1831. #define cfgdev_to_wlc_ndev(cfgdev, cfg) wdev_to_wlc_ndev(cfgdev, cfg)
  1832. #define bcmcfg_to_prmry_cfgdev(cfgdev, cfg) bcmcfg_to_prmry_wdev(cfg)
  1833. #elif defined(WL_ENABLE_P2P_IF)
  1834. #define cfgdev_to_wlc_ndev(cfgdev, cfg) ndev_to_wlc_ndev(cfgdev, cfg)
  1835. #define bcmcfg_to_prmry_cfgdev(cfgdev, cfg) bcmcfg_to_prmry_ndev(cfg)
  1836. #else
  1837. #define cfgdev_to_wlc_ndev(cfgdev, cfg) (cfgdev)
  1838. #define bcmcfg_to_prmry_cfgdev(cfgdev, cfg) (cfgdev)
  1839. #endif /* WL_CFG80211_P2P_DEV_IF */
  1840. #if defined(WL_CFG80211_P2P_DEV_IF)
  1841. #define cfgdev_to_wdev(cfgdev) (cfgdev)
  1842. #define ndev_to_cfgdev(ndev) ndev_to_wdev(ndev)
  1843. #define cfgdev_to_ndev(cfgdev) (cfgdev ? (cfgdev->netdev) : NULL)
  1844. #define wdev_to_cfgdev(cfgdev) (cfgdev)
  1845. #define discover_cfgdev(cfgdev, cfg) (cfgdev->iftype == NL80211_IFTYPE_P2P_DEVICE)
  1846. #else
  1847. #define cfgdev_to_wdev(cfgdev) (cfgdev->ieee80211_ptr)
  1848. #define wdev_to_cfgdev(cfgdev) cfgdev ? (cfgdev->netdev) : NULL
  1849. #define ndev_to_cfgdev(ndev) (ndev)
  1850. #define cfgdev_to_ndev(cfgdev) (cfgdev)
  1851. #define discover_cfgdev(cfgdev, cfg) (cfgdev == cfg->p2p_net)
  1852. #endif /* WL_CFG80211_P2P_DEV_IF */
  1853. #if defined(WL_CFG80211_P2P_DEV_IF)
  1854. #define scan_req_match(cfg) (((cfg) && (cfg->scan_request) && \
  1855. (cfg->scan_request->wdev == cfg->p2p_wdev)) ? true : false)
  1856. #elif defined(WL_ENABLE_P2P_IF)
  1857. #define scan_req_match(cfg) (((cfg) && (cfg->scan_request) && \
  1858. (cfg->scan_request->dev == cfg->p2p_net)) ? true : false)
  1859. #else
  1860. #define scan_req_match(cfg) (((cfg) && p2p_is_on(cfg) && p2p_scan(cfg)) ? \
  1861. true : false)
  1862. #endif /* WL_CFG80211_P2P_DEV_IF */
  1863. #define PRINT_WDEV_INFO(cfgdev) \
  1864. { \
  1865. struct wireless_dev *wdev = cfgdev_to_wdev(cfgdev); \
  1866. struct net_device *netdev = wdev ? wdev->netdev : NULL; \
  1867. WL_DBG(("wdev_ptr:%p ndev_ptr:%p ifname:%s iftype:%d\n", OSL_OBFUSCATE_BUF(wdev), \
  1868. OSL_OBFUSCATE_BUF(netdev), \
  1869. netdev ? netdev->name : "NULL (non-ndev device)", \
  1870. wdev ? wdev->iftype : 0xff)); \
  1871. }
  1872. #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 0))
  1873. #define scan_req_iftype(req) (req->dev->ieee80211_ptr->iftype)
  1874. #else
  1875. #define scan_req_iftype(req) (req->wdev->iftype)
  1876. #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 0) */
  1877. #define wl_to_sr(w) (w->scan_req_int)
  1878. #if defined(STATIC_WL_PRIV_STRUCT)
  1879. #define wl_to_ie(w) (w->ie)
  1880. #define wl_to_conn(w) (w->conn_info)
  1881. #else
  1882. #define wl_to_ie(w) (&w->ie)
  1883. #define wl_to_conn(w) (&w->conn_info)
  1884. #endif // endif
  1885. #define wl_to_fils_info(w) (&w->fils_info)
  1886. #define wiphy_from_scan(w) (w->escan_info.wiphy)
  1887. #define wl_get_drv_status_all(cfg, stat) \
  1888. (wl_get_status_all(cfg, WL_STATUS_ ## stat))
  1889. #define wl_get_drv_status(cfg, stat, ndev) \
  1890. (wl_get_status_by_netdev(cfg, WL_STATUS_ ## stat, ndev))
  1891. #define wl_set_drv_status(cfg, stat, ndev) \
  1892. (wl_set_status_by_netdev(cfg, WL_STATUS_ ## stat, ndev, 1))
  1893. #define wl_clr_drv_status(cfg, stat, ndev) \
  1894. (wl_set_status_by_netdev(cfg, WL_STATUS_ ## stat, ndev, 2))
  1895. #define wl_clr_drv_status_all(cfg, stat) \
  1896. (wl_set_status_all(cfg, WL_STATUS_ ## stat, 2))
  1897. #define wl_chg_drv_status(cfg, stat, ndev) \
  1898. (wl_set_status_by_netdev(cfg, WL_STATUS_ ## stat, ndev, 4))
  1899. #define for_each_bss(list, bss, __i) \
  1900. for (__i = 0; __i < list->count && __i < WL_AP_MAX; __i++, bss = next_bss(list, bss))
  1901. #define for_each_ndev(cfg, iter, next) \
  1902. list_for_each_entry_safe(iter, next, &cfg->net_list, list)
  1903. /* In case of WPS from wpa_supplicant, pairwise siute and group suite is 0.
  1904. * In addtion to that, wpa_version is WPA_VERSION_1
  1905. */
  1906. #define is_wps_conn(_sme) \
  1907. ((wl_cfgp2p_find_wpsie(_sme->ie, _sme->ie_len) != NULL) && \
  1908. (!_sme->crypto.n_ciphers_pairwise) && \
  1909. (!_sme->crypto.cipher_group))
  1910. #ifdef WLFBT
  1911. #if defined(WLAN_AKM_SUITE_FT_8021X) && defined(WLAN_AKM_SUITE_FT_PSK)
  1912. #define IS_AKM_SUITE_FT(sec) (sec->wpa_auth == WLAN_AKM_SUITE_FT_8021X || \
  1913. sec->wpa_auth == WLAN_AKM_SUITE_FT_PSK)
  1914. #elif defined(WLAN_AKM_SUITE_FT_8021X)
  1915. #define IS_AKM_SUITE_FT(sec) (sec->wpa_auth == WLAN_AKM_SUITE_FT_8021X)
  1916. #elif defined(WLAN_AKM_SUITE_FT_PSK)
  1917. #define IS_AKM_SUITE_FT(sec) (sec->wpa_auth == WLAN_AKM_SUITE_FT_PSK)
  1918. #else
  1919. #define IS_AKM_SUITE_FT(sec) ({BCM_REFERENCE(sec); FALSE;})
  1920. #endif /* WLAN_AKM_SUITE_FT_8021X && WLAN_AKM_SUITE_FT_PSK */
  1921. #else
  1922. #define IS_AKM_SUITE_FT(sec) ({BCM_REFERENCE(sec); FALSE;})
  1923. #endif /* WLFBT */
  1924. #define IS_AKM_SUITE_CCKM(sec) ({BCM_REFERENCE(sec); FALSE;})
  1925. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0))
  1926. #define STA_INFO_BIT(info) (1ul << NL80211_STA_ ## info)
  1927. #ifdef strnicmp
  1928. #undef strnicmp
  1929. #endif /* strnicmp */
  1930. #define strnicmp(str1, str2, len) strncasecmp((str1), (str2), (len))
  1931. #else
  1932. #define STA_INFO_BIT(info) (STATION_ ## info)
  1933. #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0)) */
  1934. extern s32 wl_cfg80211_attach(struct net_device *ndev, void *context);
  1935. extern void wl_cfg80211_detach(struct bcm_cfg80211 *cfg);
  1936. extern void wl_cfg80211_event(struct net_device *ndev, const wl_event_msg_t *e,
  1937. void *data);
  1938. extern s32 wl_cfg80211_handle_critical_events(struct bcm_cfg80211 *cfg,
  1939. const wl_event_msg_t * e);
  1940. void wl_cfg80211_set_parent_dev(void *dev);
  1941. struct device *wl_cfg80211_get_parent_dev(void);
  1942. struct bcm_cfg80211 *wl_cfg80211_get_bcmcfg(void);
  1943. void wl_cfg80211_set_bcmcfg(struct bcm_cfg80211 *cfg);
  1944. /* clear IEs */
  1945. extern s32 wl_cfg80211_clear_mgmt_vndr_ies(struct bcm_cfg80211 *cfg);
  1946. extern s32 wl_cfg80211_clear_per_bss_ies(struct bcm_cfg80211 *cfg, struct wireless_dev *wdev);
  1947. extern void wl_cfg80211_clear_p2p_disc_ies(struct bcm_cfg80211 *cfg);
  1948. #ifdef WL_STATIC_IF
  1949. extern int32 wl_cfg80211_update_iflist_info(struct bcm_cfg80211 *cfg, struct net_device *ndev,
  1950. int ifidx, uint8 *addr, int bssidx, char *name, int if_state);
  1951. #endif /* WL_STATIC_IF */
  1952. extern s32 wl_cfg80211_up(struct net_device *net);
  1953. extern s32 wl_cfg80211_down(struct net_device *net);
  1954. extern void wl_cfg80211_sta_ifdown(struct net_device *net);
  1955. extern s32 wl_cfg80211_notify_ifadd(struct net_device * dev, int ifidx, char *name, uint8 *mac,
  1956. uint8 bssidx, uint8 role);
  1957. extern s32 wl_cfg80211_notify_ifdel(struct net_device * dev, int ifidx, char *name, uint8 *mac,
  1958. uint8 bssidx);
  1959. extern s32 wl_cfg80211_notify_ifchange(struct net_device * dev, int ifidx, char *name, uint8 *mac,
  1960. uint8 bssidx);
  1961. extern struct net_device* wl_cfg80211_allocate_if(struct bcm_cfg80211 *cfg, int ifidx,
  1962. const char *name, uint8 *mac, uint8 bssidx, const char *dngl_name);
  1963. extern int wl_cfg80211_register_if(struct bcm_cfg80211 *cfg,
  1964. int ifidx, struct net_device* ndev, bool rtnl_lock_reqd);
  1965. extern int wl_cfg80211_remove_if(struct bcm_cfg80211 *cfg,
  1966. int ifidx, struct net_device* ndev, bool rtnl_lock_reqd);
  1967. extern void wl_cfg80211_cleanup_if(struct net_device *dev);
  1968. extern bool wl_cfg80211_is_concurrent_mode(struct net_device * dev);
  1969. extern void wl_cfg80211_disassoc(struct net_device *ndev, uint32 reason);
  1970. extern void wl_cfg80211_del_all_sta(struct net_device *ndev, uint32 reason);
  1971. extern void* wl_cfg80211_get_dhdp(struct net_device * dev);
  1972. extern bool wl_cfg80211_is_p2p_active(struct net_device * dev);
  1973. extern bool wl_cfg80211_is_roam_offload(struct net_device * dev);
  1974. extern bool wl_cfg80211_is_event_from_connected_bssid(struct net_device * dev,
  1975. const wl_event_msg_t *e, int ifidx);
  1976. extern void wl_cfg80211_dbg_level(u32 level);
  1977. extern s32 wl_cfg80211_get_p2p_dev_addr(struct net_device *net, struct ether_addr *p2pdev_addr);
  1978. extern s32 wl_cfg80211_set_p2p_noa(struct net_device *net, char* buf, int len);
  1979. extern s32 wl_cfg80211_get_p2p_noa(struct net_device *net, char* buf, int len);
  1980. extern s32 wl_cfg80211_set_wps_p2p_ie(struct net_device *net, char *buf, int len,
  1981. enum wl_management_type type);
  1982. extern s32 wl_cfg80211_set_p2p_ps(struct net_device *net, char* buf, int len);
  1983. extern s32 wl_cfg80211_set_p2p_ecsa(struct net_device *net, char* buf, int len);
  1984. extern s32 wl_cfg80211_increase_p2p_bw(struct net_device *net, char* buf, int len);
  1985. extern bool wl_cfg80211_check_vif_in_use(struct net_device *ndev);
  1986. #ifdef P2PLISTEN_AP_SAMECHN
  1987. extern s32 wl_cfg80211_set_p2p_resp_ap_chn(struct net_device *net, s32 enable);
  1988. #endif /* P2PLISTEN_AP_SAMECHN */
  1989. /* btcoex functions */
  1990. void* wl_cfg80211_btcoex_init(struct net_device *ndev);
  1991. void wl_cfg80211_btcoex_deinit(void);
  1992. extern chanspec_t wl_chspec_from_legacy(chanspec_t legacy_chspec);
  1993. extern chanspec_t wl_chspec_driver_to_host(chanspec_t chanspec);
  1994. #ifdef WL_SUPPORT_AUTO_CHANNEL
  1995. #define CHANSPEC_BUF_SIZE 1024
  1996. #define CHAN_SEL_IOCTL_DELAY 300
  1997. #define CHAN_SEL_RETRY_COUNT 15
  1998. #define CHANNEL_IS_RADAR(channel) (((channel & WL_CHAN_RADAR) || \
  1999. (channel & WL_CHAN_PASSIVE)) ? true : false)
  2000. #define CHANNEL_IS_2G(channel) (((channel >= 1) && (channel <= 14)) ? \
  2001. true : false)
  2002. #define CHANNEL_IS_5G(channel) (((channel >= 36) && (channel <= 165)) ? \
  2003. true : false)
  2004. extern s32 wl_cfg80211_get_best_channels(struct net_device *dev, char* command,
  2005. int total_len);
  2006. #endif /* WL_SUPPORT_AUTO_CHANNEL */
  2007. extern int wl_cfg80211_ether_atoe(const char *a, struct ether_addr *n);
  2008. extern int wl_cfg80211_hang(struct net_device *dev, u16 reason);
  2009. extern s32 wl_mode_to_nl80211_iftype(s32 mode);
  2010. int wl_cfg80211_do_driver_init(struct net_device *net);
  2011. void wl_cfg80211_enable_trace(bool set, u32 level);
  2012. extern s32 wl_update_wiphybands(struct bcm_cfg80211 *cfg, bool notify);
  2013. extern s32 wl_cfg80211_if_is_group_owner(void);
  2014. extern chanspec_t wl_chspec_host_to_driver(chanspec_t chanspec);
  2015. extern chanspec_t wl_ch_host_to_driver(u16 channel);
  2016. extern s32 wl_set_tx_power(struct net_device *dev,
  2017. enum nl80211_tx_power_setting type, s32 dbm);
  2018. extern s32 wl_get_tx_power(struct net_device *dev, s32 *dbm);
  2019. extern s32 wl_add_remove_eventmsg(struct net_device *ndev, u16 event, bool add);
  2020. extern void wl_stop_wait_next_action_frame(struct bcm_cfg80211 *cfg, struct net_device *ndev,
  2021. u8 bsscfgidx);
  2022. #ifdef WL_HOST_BAND_MGMT
  2023. extern s32 wl_cfg80211_set_band(struct net_device *ndev, int band);
  2024. #endif /* WL_HOST_BAND_MGMT */
  2025. extern void wl_cfg80211_add_to_eventbuffer(wl_eventmsg_buf_t *ev, u16 event, bool set);
  2026. extern s32 wl_cfg80211_apply_eventbuffer(struct net_device *ndev,
  2027. struct bcm_cfg80211 *cfg, wl_eventmsg_buf_t *ev);
  2028. extern void get_primary_mac(struct bcm_cfg80211 *cfg, struct ether_addr *mac);
  2029. extern void wl_cfg80211_update_power_mode(struct net_device *dev);
  2030. extern void wl_terminate_event_handler(struct net_device *dev);
  2031. #if defined(DHD_ENABLE_BIGDATA_LOGGING)
  2032. extern s32 wl_cfg80211_get_bss_info(struct net_device *dev, char* cmd, int total_len);
  2033. extern s32 wl_cfg80211_get_connect_failed_status(struct net_device *dev, char* cmd, int total_len);
  2034. #endif /* DHD_ENABLE_BIGDATA_LOGGING */
  2035. extern struct bcm_cfg80211 *wl_get_cfg(struct net_device *ndev);
  2036. extern s32 wl_cfg80211_set_if_band(struct net_device *ndev, int band);
  2037. extern s32 wl_cfg80211_set_country_code(struct net_device *dev, char *country_code,
  2038. bool notify, bool user_enforced, int revinfo);
  2039. extern bool wl_cfg80211_is_hal_started(struct bcm_cfg80211 *cfg);
  2040. #ifdef WL_WIPSEVT
  2041. extern int wl_cfg80211_wips_event(uint16 misdeauth, char* bssid);
  2042. #endif /* WL_WIPSEVT */
  2043. #define SCAN_BUF_CNT 2
  2044. #define SCAN_BUF_NEXT 1
  2045. #define WL_SCANTYPE_LEGACY 0x1
  2046. #define WL_SCANTYPE_P2P 0x2
  2047. #ifdef DUAL_ESCAN_RESULT_BUFFER
  2048. #define wl_escan_set_sync_id(a, b) ((a) = (b)->escan_info.cur_sync_id)
  2049. #define wl_escan_set_type(a, b) ((a)->escan_info.escan_type\
  2050. [((a)->escan_info.cur_sync_id)%SCAN_BUF_CNT] = (b))
  2051. static inline wl_scan_results_t *wl_escan_get_buf(struct bcm_cfg80211 *cfg, bool aborted)
  2052. {
  2053. u8 index;
  2054. if (aborted) {
  2055. if (cfg->escan_info.escan_type[0] == cfg->escan_info.escan_type[1])
  2056. index = (cfg->escan_info.cur_sync_id + 1)%SCAN_BUF_CNT;
  2057. else
  2058. index = (cfg->escan_info.cur_sync_id)%SCAN_BUF_CNT;
  2059. }
  2060. else
  2061. index = (cfg->escan_info.cur_sync_id)%SCAN_BUF_CNT;
  2062. return (wl_scan_results_t *)cfg->escan_info.escan_buf[index];
  2063. }
  2064. static inline int wl_escan_check_sync_id(s32 status, u16 result_id, u16 wl_id)
  2065. {
  2066. if (result_id != wl_id) {
  2067. WL_ERR(("ESCAN sync id mismatch :status :%d "
  2068. "cur_sync_id:%d coming sync_id:%d\n",
  2069. status, wl_id, result_id));
  2070. return -1;
  2071. }
  2072. else
  2073. return 0;
  2074. }
  2075. static inline void wl_escan_print_sync_id(s32 status, u16 result_id, u16 wl_id)
  2076. {
  2077. if (result_id != wl_id) {
  2078. WL_ERR(("ESCAN sync id mismatch :status :%d "
  2079. "cur_sync_id:%d coming sync_id:%d\n",
  2080. status, wl_id, result_id));
  2081. }
  2082. }
  2083. #define wl_escan_increment_sync_id(a, b) ((a)->escan_info.cur_sync_id += b)
  2084. #define wl_escan_init_sync_id(a) ((a)->escan_info.cur_sync_id = 0)
  2085. #else
  2086. #define wl_escan_set_sync_id(a, b) ((a) = htod16((b)->escan_sync_id_cntr++))
  2087. #define wl_escan_set_type(a, b)
  2088. #define wl_escan_get_buf(a, b) ((wl_scan_results_t *) (a)->escan_info.escan_buf)
  2089. #define wl_escan_check_sync_id(a, b, c) 0
  2090. #define wl_escan_print_sync_id(a, b, c)
  2091. #define wl_escan_increment_sync_id(a, b)
  2092. #define wl_escan_init_sync_id(a)
  2093. #endif /* DUAL_ESCAN_RESULT_BUFFER */
  2094. extern void wl_cfg80211_ibss_vsie_set_buffer(struct net_device *dev, vndr_ie_setbuf_t *ibss_vsie,
  2095. int ibss_vsie_len);
  2096. extern s32 wl_cfg80211_ibss_vsie_delete(struct net_device *dev);
  2097. #ifdef WLAIBSS
  2098. extern void wl_cfg80211_set_txfail_pid(struct net_device *dev, int pid);
  2099. #endif /* WLAIBSS */
  2100. #ifdef WL_RELMCAST
  2101. extern void wl_cfg80211_set_rmc_pid(struct net_device *dev, int pid);
  2102. #endif /* WL_RELMCAST */
  2103. extern int wl_cfg80211_set_mgmt_vndr_ies(struct bcm_cfg80211 *cfg,
  2104. bcm_struct_cfgdev *cfgdev, s32 bssidx, s32 pktflag,
  2105. const u8 *vndr_ie, u32 vndr_ie_len);
  2106. #ifdef WLFBT
  2107. extern int wl_cfg80211_get_fbt_key(struct net_device *dev, uint8 *key, int total_len);
  2108. #endif // endif
  2109. /* Action frame specific functions */
  2110. extern u8 wl_get_action_category(void *frame, u32 frame_len);
  2111. extern int wl_get_public_action(void *frame, u32 frame_len, u8 *ret_action);
  2112. #ifdef WL_CFG80211_VSDB_PRIORITIZE_SCAN_REQUEST
  2113. struct net_device *wl_cfg80211_get_remain_on_channel_ndev(struct bcm_cfg80211 *cfg);
  2114. #endif /* WL_CFG80211_VSDB_PRIORITIZE_SCAN_REQUEST */
  2115. #ifdef WL_SUPPORT_ACS
  2116. #define ACS_MSRMNT_DELAY 1000 /* dump_obss delay in ms */
  2117. #define IOCTL_RETRY_COUNT 5
  2118. #define CHAN_NOISE_DUMMY -80
  2119. #define OBSS_TOKEN_IDX 15
  2120. #define IBSS_TOKEN_IDX 15
  2121. #define TX_TOKEN_IDX 14
  2122. #define CTG_TOKEN_IDX 13
  2123. #define PKT_TOKEN_IDX 15
  2124. #define IDLE_TOKEN_IDX 12
  2125. #endif /* WL_SUPPORT_ACS */
  2126. #ifdef BCMWAPI_WPI
  2127. #define is_wapi(cipher) (cipher == WLAN_CIPHER_SUITE_SMS4) ? 1 : 0
  2128. #endif /* BCMWAPI_WPI */
  2129. extern int wl_cfg80211_get_ioctl_version(void);
  2130. extern int wl_cfg80211_enable_roam_offload(struct net_device *dev, int enable);
  2131. extern s32 wl_cfg80211_dfs_ap_move(struct net_device *ndev, char *data,
  2132. char *command, int total_len);
  2133. #ifdef WBTEXT
  2134. extern s32 wl_cfg80211_wbtext_set_default(struct net_device *ndev);
  2135. extern s32 wl_cfg80211_wbtext_config(struct net_device *ndev, char *data,
  2136. char *command, int total_len);
  2137. extern int wl_cfg80211_wbtext_weight_config(struct net_device *ndev, char *data,
  2138. char *command, int total_len);
  2139. extern int wl_cfg80211_wbtext_table_config(struct net_device *ndev, char *data,
  2140. char *command, int total_len);
  2141. extern s32 wl_cfg80211_wbtext_delta_config(struct net_device *ndev, char *data,
  2142. char *command, int total_len);
  2143. #endif /* WBTEXT */
  2144. extern s32 wl_cfg80211_get_chanspecs_2g(struct net_device *ndev,
  2145. void *buf, s32 buflen);
  2146. extern s32 wl_cfg80211_get_chanspecs_5g(struct net_device *ndev,
  2147. void *buf, s32 buflen);
  2148. extern s32 wl_cfg80211_bss_up(struct bcm_cfg80211 *cfg,
  2149. struct net_device *ndev, s32 bsscfg_idx, s32 up);
  2150. extern bool wl_cfg80211_bss_isup(struct net_device *ndev, int bsscfg_idx);
  2151. struct net_device *wl_cfg80211_post_ifcreate(struct net_device *ndev,
  2152. wl_if_event_info *event, u8 *addr, const char *name, bool rtnl_lock_reqd);
  2153. extern s32 wl_cfg80211_post_ifdel(struct net_device *ndev, bool rtnl_lock_reqd, s32 ifidx);
  2154. #if defined(PKT_FILTER_SUPPORT) && defined(APSTA_BLOCK_ARP_DURING_DHCP)
  2155. extern void wl_cfg80211_block_arp(struct net_device *dev, int enable);
  2156. #endif /* PKT_FILTER_SUPPORT && APSTA_BLOCK_ARP_DURING_DHCP */
  2157. #ifdef WLTDLS
  2158. extern s32 wl_cfg80211_tdls_config(struct bcm_cfg80211 *cfg,
  2159. enum wl_tdls_config state, bool tdls_mode);
  2160. extern s32 wl_tdls_event_handler(struct bcm_cfg80211 *cfg, bcm_struct_cfgdev *cfgdev,
  2161. const wl_event_msg_t *e, void *data);
  2162. #endif /* WLTDLS */
  2163. #ifdef WL_NAN
  2164. extern int wl_cfgvendor_send_nan_event(struct wiphy * wiphy,
  2165. struct net_device *dev, int event_id,
  2166. nan_event_data_t *nan_event_data);
  2167. extern int wl_cfgnan_init(struct bcm_cfg80211 *cfg);
  2168. extern int wl_cfgnan_deinit(struct bcm_cfg80211 *cfg, uint8 busstate);
  2169. extern bool wl_cfgnan_check_state(struct bcm_cfg80211 *cfg);
  2170. #ifdef RTT_SUPPORT
  2171. extern s32 wl_cfgvendor_send_as_rtt_legacy_event(struct wiphy *wiphy,
  2172. struct net_device *dev, wl_nan_ev_rng_rpt_ind_t *range_res,
  2173. uint32 status);
  2174. #endif /* RTT_SUPPORT */
  2175. #ifdef WL_NANP2P
  2176. extern int wl_cfg80211_set_iface_conc_disc(struct net_device *ndev,
  2177. uint8 arg_val);
  2178. extern uint8 wl_cfg80211_get_iface_conc_disc(struct net_device *ndev);
  2179. #endif /* WL_NANP2P */
  2180. #endif /* WL_NAN */
  2181. #ifdef WL_CFG80211_P2P_DEV_IF
  2182. extern void wl_cfg80211_del_p2p_wdev(struct net_device *dev);
  2183. #endif /* WL_CFG80211_P2P_DEV_IF */
  2184. #if defined(WL_SUPPORT_AUTO_CHANNEL)
  2185. extern int wl_cfg80211_set_spect(struct net_device *dev, int spect);
  2186. extern int wl_cfg80211_get_sta_channel(struct bcm_cfg80211 *cfg);
  2187. #endif /* WL_SUPPORT_AUTO_CHANNEL */
  2188. #ifdef WL_CFG80211_SYNC_GON
  2189. #define WL_DRV_STATUS_SENDING_AF_FRM_EXT(cfg) \
  2190. (wl_get_drv_status_all(cfg, SENDING_ACT_FRM) || \
  2191. wl_get_drv_status_all(cfg, WAITING_NEXT_ACT_FRM_LISTEN))
  2192. #else
  2193. #define WL_DRV_STATUS_SENDING_AF_FRM_EXT(cfg) wl_get_drv_status_all(cfg, SENDING_ACT_FRM)
  2194. #endif /* WL_CFG80211_SYNC_GON */
  2195. #ifdef P2P_LISTEN_OFFLOADING
  2196. extern s32 wl_cfg80211_p2plo_deinit(struct bcm_cfg80211 *cfg);
  2197. #endif /* P2P_LISTEN_OFFLOADING */
  2198. /* Function to flush the FW log buffer content */
  2199. extern void wl_flush_fw_log_buffer(struct net_device *dev, uint32 logset_mask);
  2200. #define RETURN_EIO_IF_NOT_UP(wlpriv) \
  2201. do { \
  2202. struct net_device *checkSysUpNDev = bcmcfg_to_prmry_ndev(wlpriv); \
  2203. if (unlikely(!wl_get_drv_status(wlpriv, READY, checkSysUpNDev))) { \
  2204. WL_INFORM(("device is not ready\n")); \
  2205. return -EIO; \
  2206. } \
  2207. } while (0)
  2208. #ifdef QOS_MAP_SET
  2209. extern uint8 *wl_get_up_table(void);
  2210. #endif /* QOS_MAP_SET */
  2211. #define P2PO_COOKIE 65535
  2212. u64 wl_cfg80211_get_new_roc_id(struct bcm_cfg80211 *cfg);
  2213. #ifdef SUPPORT_AP_HIGHER_BEACONRATE
  2214. int wl_set_ap_beacon_rate(struct net_device *dev, int val, char *ifname);
  2215. int wl_get_ap_basic_rate(struct net_device *dev, char* command, char *ifname, int total_len);
  2216. #endif /* SUPPORT_AP_HIGHER_BEACONRATE */
  2217. #ifdef SUPPORT_AP_RADIO_PWRSAVE
  2218. int wl_get_ap_rps(struct net_device *dev, char* command, char *ifname, int total_len);
  2219. int wl_set_ap_rps(struct net_device *dev, bool enable, char *ifname);
  2220. int wl_update_ap_rps_params(struct net_device *dev, ap_rps_info_t* rps, char *ifname);
  2221. void wl_cfg80211_init_ap_rps(struct bcm_cfg80211 *cfg);
  2222. #endif /* SUPPORT_AP_RADIO_PWRSAVE */
  2223. #ifdef SUPPORT_RSSI_SUM_REPORT
  2224. int wl_get_rssi_logging(struct net_device *dev, void *param);
  2225. int wl_set_rssi_logging(struct net_device *dev, void *param);
  2226. int wl_get_rssi_per_ant(struct net_device *dev, char *ifname, char *peer_mac, void *param);
  2227. #endif /* SUPPORT_RSSI_SUM_REPORT */
  2228. int wl_cfg80211_iface_count(struct net_device *dev);
  2229. struct net_device* wl_get_ap_netdev(struct bcm_cfg80211 *cfg, char *ifname);
  2230. void wl_cfg80211_cleanup_virtual_ifaces(struct bcm_cfg80211 *cfg, bool rtnl_lock_reqd);
  2231. #ifdef WL_IFACE_MGMT
  2232. extern int wl_cfg80211_set_iface_policy(struct net_device *ndev, char *arg, int len);
  2233. extern uint8 wl_cfg80211_get_iface_policy(struct net_device *ndev);
  2234. extern s32 wl_cfg80211_handle_if_role_conflict(struct bcm_cfg80211 *cfg, wl_iftype_t new_wl_iftype);
  2235. s32 wl_cfg80211_data_if_mgmt(struct bcm_cfg80211 *cfg, wl_iftype_t new_wl_iftype);
  2236. s32 wl_cfg80211_disc_if_mgmt(struct bcm_cfg80211 *cfg, wl_iftype_t new_wl_iftype,
  2237. bool *disable_nan, bool *disable_p2p);
  2238. s32 wl_cfg80211_handle_discovery_config(struct bcm_cfg80211 *cfg, wl_iftype_t new_wl_iftype);
  2239. wl_iftype_t wl_cfg80211_get_sec_iface(struct bcm_cfg80211 *cfg);
  2240. bool wl_cfg80211_is_associated_discovery(struct bcm_cfg80211 *cfg, wl_iftype_t new_wl_iftype);
  2241. #endif /* WL_IFACE_MGMT */
  2242. struct wireless_dev * wl_cfg80211_add_if(struct bcm_cfg80211 *cfg, struct net_device *primary_ndev,
  2243. wl_iftype_t wl_iftype, const char *name, u8 *mac);
  2244. extern s32 wl_cfg80211_del_if(struct bcm_cfg80211 *cfg, struct net_device *primary_ndev,
  2245. struct wireless_dev *wdev, char *name);
  2246. s32 _wl_cfg80211_del_if(struct bcm_cfg80211 *cfg, struct net_device *primary_ndev,
  2247. struct wireless_dev *wdev, char *ifname);
  2248. s32 wl_cfg80211_delete_iface(struct bcm_cfg80211 *cfg, wl_iftype_t sec_data_if_type);
  2249. #ifdef WL_STATIC_IF
  2250. extern struct net_device *wl_cfg80211_register_static_if(struct bcm_cfg80211 *cfg,
  2251. u16 iftype, char *ifname);
  2252. extern void wl_cfg80211_unregister_static_if(struct bcm_cfg80211 * cfg);
  2253. extern s32 wl_cfg80211_static_if_open(struct net_device *net);
  2254. extern s32 wl_cfg80211_static_if_close(struct net_device *net);
  2255. extern struct net_device * wl_cfg80211_post_static_ifcreate(struct bcm_cfg80211 *cfg,
  2256. wl_if_event_info *event, u8 *addr, s32 iface_type);
  2257. extern s32 wl_cfg80211_post_static_ifdel(struct bcm_cfg80211 *cfg, struct net_device *ndev);
  2258. #endif /* WL_STATIC_IF */
  2259. extern struct wireless_dev *wl_cfg80211_get_wdev_from_ifname(struct bcm_cfg80211 *cfg,
  2260. const char *name);
  2261. struct net_device* wl_get_netdev_by_name(struct bcm_cfg80211 *cfg, char *ifname);
  2262. extern s32 wl_get_vif_macaddr(struct bcm_cfg80211 *cfg, u16 wl_iftype, u8 *mac_addr);
  2263. extern s32 wl_release_vif_macaddr(struct bcm_cfg80211 *cfg, u8 *mac_addr, u16 wl_iftype);
  2264. extern int wl_cfg80211_ifstats_counters(struct net_device *dev, wl_if_stats_t *if_stats);
  2265. extern s32 wl_cfg80211_set_dbg_verbose(struct net_device *ndev, u32 level);
  2266. extern int wl_cfg80211_deinit_p2p_discovery(struct bcm_cfg80211 * cfg);
  2267. extern int wl_cfg80211_set_frameburst(struct bcm_cfg80211 *cfg, bool enable);
  2268. extern int wl_cfg80211_determine_p2p_rsdb_mode(struct bcm_cfg80211 *cfg);
  2269. extern uint8 wl_cfg80211_get_bus_state(struct bcm_cfg80211 *cfg);
  2270. #ifdef WL_WPS_SYNC
  2271. void wl_handle_wps_states(struct net_device *ndev, u8 *dump_data, u16 len, bool direction);
  2272. #endif /* WL_WPS_SYNC */
  2273. extern int wl_features_set(u8 *array, uint8 len, u32 ftidx);
  2274. extern void *wl_read_prof(struct bcm_cfg80211 *cfg, struct net_device *ndev, s32 item);
  2275. extern s32 wl_cfg80211_sup_event_handler(struct bcm_cfg80211 *cfg, bcm_struct_cfgdev *cfgdev,
  2276. const wl_event_msg_t *event, void *data);
  2277. extern s32 wl_inform_bss(struct bcm_cfg80211 *cfg);
  2278. extern void wl_cfg80211_cancel_scan(struct bcm_cfg80211 *cfg);
  2279. extern s32 wl_notify_escan_complete(struct bcm_cfg80211 *cfg,
  2280. struct net_device *ndev, bool aborted, bool fw_abort);
  2281. #ifdef CUSTOMER_HW4_DEBUG
  2282. extern void wl_scan_timeout_dbg_clear(void);
  2283. #endif /* CUSTOMER_HW4_DEBUG */
  2284. extern s32 cfg80211_to_wl_iftype(uint16 type, uint16 *role, uint16 *mode);
  2285. extern s32 wl_cfg80211_net_attach(struct net_device *primary_ndev);
  2286. extern void wl_print_verinfo(struct bcm_cfg80211 *cfg);
  2287. extern const u8 *wl_find_attribute(const u8 *buf, u16 len, u16 element_id);
  2288. extern int wl_cfg80211_get_concurrency_mode(struct bcm_cfg80211 *cfg);
  2289. #if defined(WL_DISABLE_HE_SOFTAP) || defined(WL_DISABLE_HE_P2P)
  2290. int wl_cfg80211_set_he_mode(struct net_device *dev, struct bcm_cfg80211 *cfg,
  2291. s32 bssidx, u32 interface_type, bool set);
  2292. #define WL_HE_FEATURES_HE_AP 0x8
  2293. #define WL_HE_FEATURES_HE_P2P 0x20
  2294. #endif /* WL_DISABLE_HE_SOFTAP || WL_DISABLE_HE_P2P */
  2295. extern s32 wl_cfg80211_config_suspend_events(struct net_device *ndev, bool enable);
  2296. #ifdef WL11U
  2297. extern bcm_tlv_t *
  2298. wl_cfg80211_find_interworking_ie(const u8 *parse, u32 len);
  2299. extern s32
  2300. wl_cfg80211_add_iw_ie(struct bcm_cfg80211 *cfg, struct net_device *ndev, s32 bssidx, s32 pktflag,
  2301. uint8 ie_id, uint8 *data, uint8 data_len);
  2302. extern s32
  2303. wl_cfg80211_clear_iw_ie(struct bcm_cfg80211 *cfg, struct net_device *ndev, s32 bssidx);
  2304. static inline void
  2305. wl_get_iwdata_by_netdev(struct bcm_cfg80211 *cfg, struct net_device *ndev, u8 *iw_ie,
  2306. u32 *iw_ie_len)
  2307. {
  2308. struct net_info *_net_info, *next;
  2309. unsigned long int flags;
  2310. spin_lock_irqsave(&cfg->net_list_sync, flags);
  2311. BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
  2312. if (ndev && (_net_info->ndev == ndev)) {
  2313. *iw_ie_len = _net_info->profile.iw_ie_len;
  2314. memcpy(iw_ie, _net_info->profile.iw_ie, _net_info->profile.iw_ie_len);
  2315. break;
  2316. }
  2317. }
  2318. spin_unlock_irqrestore(&cfg->net_list_sync, flags);
  2319. }
  2320. static inline void
  2321. wl_set_iwdata_by_netdev(struct bcm_cfg80211 *cfg, struct net_device *ndev, u8 *iw_ie, u32 iw_ie_len)
  2322. {
  2323. struct net_info *_net_info, *next;
  2324. unsigned long int flags;
  2325. spin_lock_irqsave(&cfg->net_list_sync, flags);
  2326. BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
  2327. if (ndev && (_net_info->ndev == ndev)) {
  2328. _net_info->profile.iw_ie_len = iw_ie_len;
  2329. memcpy(_net_info->profile.iw_ie, iw_ie, _net_info->profile.iw_ie_len);
  2330. }
  2331. }
  2332. spin_unlock_irqrestore(&cfg->net_list_sync, flags);
  2333. }
  2334. static inline void
  2335. wl_clear_iwdata_by_netdev(struct bcm_cfg80211 *cfg, struct net_device *ndev)
  2336. {
  2337. struct net_info *_net_info, *next;
  2338. unsigned long int flags;
  2339. spin_lock_irqsave(&cfg->net_list_sync, flags);
  2340. BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
  2341. if (ndev && (_net_info->ndev == ndev)) {
  2342. _net_info->profile.iw_ie_len = 0;
  2343. memset(_net_info->profile.iw_ie, 0, IW_IES_MAX_BUF_LEN);
  2344. }
  2345. }
  2346. spin_unlock_irqrestore(&cfg->net_list_sync, flags);
  2347. }
  2348. static inline void
  2349. wl_clear_iwdata(struct bcm_cfg80211 *cfg)
  2350. {
  2351. struct net_info *_net_info, *next;
  2352. unsigned long int flags;
  2353. spin_lock_irqsave(&cfg->net_list_sync, flags);
  2354. BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next,
  2355. &cfg->net_list, list) {
  2356. if (_net_info->profile.iw_ie_len) {
  2357. _net_info->profile.iw_ie_len = 0;
  2358. memset(_net_info->profile.iw_ie, 0, IW_IES_MAX_BUF_LEN);
  2359. }
  2360. }
  2361. spin_unlock_irqrestore(&cfg->net_list_sync, flags);
  2362. return;
  2363. }
  2364. #endif /* WL11U */
  2365. #endif /* _wl_cfg80211_h_ */