dhd.h 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065
  1. /*
  2. * Header file describing the internal (inter-module) DHD interfaces.
  3. *
  4. * Provides type definitions and function prototypes used to link the
  5. * DHD OS, bus, and protocol modules.
  6. *
  7. * Copyright (C) 1999-2015, Broadcom Corporation
  8. *
  9. * Unless you and Broadcom execute a separate written software license
  10. * agreement governing use of this software, this software is licensed to you
  11. * under the terms of the GNU General Public License version 2 (the "GPL"),
  12. * available at http://www.broadcom.com/licenses/GPLv2.php, with the
  13. * following added to such license:
  14. *
  15. * As a special exception, the copyright holders of this software give you
  16. * permission to link this software with independent modules, and to copy and
  17. * distribute the resulting executable under terms of your choice, provided that
  18. * you also meet, for each linked independent module, the terms and conditions of
  19. * the license of that module. An independent module is a module which is not
  20. * derived from this software. The special exception does not apply to any
  21. * modifications of the software.
  22. *
  23. * Notwithstanding the above, under no circumstances may you combine this
  24. * software in any way with any other Broadcom software provided under a license
  25. * other than the GPL, without Broadcom's express prior written consent.
  26. *
  27. * $Id: dhd.h 605803 2015-12-11 14:44:32Z $
  28. */
  29. /****************
  30. * Common types *
  31. */
  32. #ifndef _dhd_h_
  33. #define _dhd_h_
  34. #include <linux/init.h>
  35. #include <linux/kernel.h>
  36. #include <linux/slab.h>
  37. #include <linux/skbuff.h>
  38. #include <linux/netdevice.h>
  39. #include <linux/etherdevice.h>
  40. #include <linux/random.h>
  41. #include <linux/spinlock.h>
  42. #include <linux/ethtool.h>
  43. #include <asm/uaccess.h>
  44. #include <asm/unaligned.h>
  45. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_HAS_WAKELOCK)
  46. #include <linux/wakelock.h>
  47. #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined (CONFIG_HAS_WAKELOCK) */
  48. /* The kernel threading is sdio-specific */
  49. struct task_struct;
  50. struct sched_param;
  51. int setScheduler(struct task_struct *p, int policy, struct sched_param *param);
  52. int get_scheduler_policy(struct task_struct *p);
  53. #define ALL_INTERFACES 0xff
  54. #include <wlioctl.h>
  55. #include <wlfc_proto.h>
  56. #if defined(KEEP_ALIVE)
  57. /* Default KEEP_ALIVE Period is 55 sec to prevent AP from sending Keep Alive probe frame */
  58. #define KEEP_ALIVE_PERIOD 55000
  59. #define NULL_PKT_STR "null_pkt"
  60. #endif /* KEEP_ALIVE */
  61. /* Forward decls */
  62. struct dhd_bus;
  63. struct dhd_prot;
  64. struct dhd_info;
  65. struct dhd_ioctl;
  66. /* The level of bus communication with the dongle */
  67. enum dhd_bus_state {
  68. DHD_BUS_DOWN, /* Not ready for frame transfers */
  69. DHD_BUS_LOAD, /* Download access only (CPU reset) */
  70. DHD_BUS_DATA /* Ready for frame transfers */
  71. };
  72. enum dhd_op_flags {
  73. /* Firmware requested operation mode */
  74. DHD_FLAG_STA_MODE = (1 << (0)), /* STA only */
  75. DHD_FLAG_HOSTAP_MODE = (1 << (1)), /* SOFTAP only */
  76. DHD_FLAG_P2P_MODE = (1 << (2)), /* P2P Only */
  77. /* STA + P2P */
  78. DHD_FLAG_CONCURR_SINGLE_CHAN_MODE = (DHD_FLAG_STA_MODE | DHD_FLAG_P2P_MODE),
  79. DHD_FLAG_CONCURR_MULTI_CHAN_MODE = (1 << (4)), /* STA + P2P */
  80. /* Current P2P mode for P2P connection */
  81. DHD_FLAG_P2P_GC_MODE = (1 << (5)),
  82. DHD_FLAG_P2P_GO_MODE = (1 << (6)),
  83. DHD_FLAG_MBSS_MODE = (1 << (7)), /* MBSS in future */
  84. DHD_FLAG_IBSS_MODE = (1 << (8)),
  85. DHD_FLAG_MFG_MODE = (1 << (9))
  86. };
  87. /* Max sequential TX/RX Control timeouts to set HANG event */
  88. #ifndef MAX_CNTL_TX_TIMEOUT
  89. #define MAX_CNTL_TX_TIMEOUT 2
  90. #endif /* MAX_CNTL_TX_TIMEOUT */
  91. #ifndef MAX_CNTL_RX_TIMEOUT
  92. #define MAX_CNTL_RX_TIMEOUT 1
  93. #endif /* MAX_CNTL_RX_TIMEOUT */
  94. #define DHD_SCAN_ASSOC_ACTIVE_TIME 40 /* ms: Embedded default Active setting from DHD */
  95. #define DHD_SCAN_UNASSOC_ACTIVE_TIME 80 /* ms: Embedded def. Unassoc Active setting from DHD */
  96. #define DHD_SCAN_PASSIVE_TIME 130 /* ms: Embedded default Passive setting from DHD */
  97. #ifndef POWERUP_MAX_RETRY
  98. #define POWERUP_MAX_RETRY 3 /* how many times we retry to power up the chip */
  99. #endif
  100. #ifndef POWERUP_WAIT_MS
  101. #define POWERUP_WAIT_MS 2000 /* ms: time out in waiting wifi to come up */
  102. #endif
  103. enum dhd_bus_wake_state {
  104. WAKE_LOCK_OFF,
  105. WAKE_LOCK_PRIV,
  106. WAKE_LOCK_DPC,
  107. WAKE_LOCK_IOCTL,
  108. WAKE_LOCK_DOWNLOAD,
  109. WAKE_LOCK_TMOUT,
  110. WAKE_LOCK_WATCHDOG,
  111. WAKE_LOCK_LINK_DOWN_TMOUT,
  112. WAKE_LOCK_PNO_FIND_TMOUT,
  113. WAKE_LOCK_SOFTAP_SET,
  114. WAKE_LOCK_SOFTAP_STOP,
  115. WAKE_LOCK_SOFTAP_START,
  116. WAKE_LOCK_SOFTAP_THREAD
  117. };
  118. enum dhd_prealloc_index {
  119. DHD_PREALLOC_PROT = 0,
  120. DHD_PREALLOC_RXBUF,
  121. DHD_PREALLOC_DATABUF,
  122. DHD_PREALLOC_OSL_BUF,
  123. DHD_PREALLOC_WIPHY_ESCAN0 = 5,
  124. DHD_PREALLOC_WIPHY_ESCAN1 = 6,
  125. DHD_PREALLOC_DHD_INFO = 7,
  126. DHD_PREALLOC_DHD_WLFC_INFO = 8,
  127. DHD_PREALLOC_DHD_LOG_DUMP_BUF = 9,
  128. DHD_PREALLOC_SECTION_MAX = DHD_PREALLOC_DHD_LOG_DUMP_BUF
  129. };
  130. #define PREALLOC_MASK_LEN 4
  131. enum dhd_hang_reason {
  132. HANG_REASON_MASK = 0x8000,
  133. HANG_REASON_IOCTL_RESP_TIMEOUT = 0x8001,
  134. HANG_REASON_DONGLE_TRAP = 0x8002,
  135. HANG_REASON_D3_ACK_TIMEOUT = 0x8003,
  136. HANG_REASON_BUS_DOWN = 0x8004,
  137. HANG_REASON_PCIE_LINK_DOWN = 0x8005,
  138. HANG_REASON_MSGBUF_LIVELOCK = 0x8006,
  139. HANG_REASON_P2P_IFACE_DEL_FAILURE = 0x8007,
  140. HANG_REASON_HT_AVAIL_ERROR = 0x8008,
  141. HANG_REASON_MAX = 0x8009
  142. };
  143. /* Packet alignment for most efficient SDIO (can change based on platform) */
  144. #ifndef DHD_SDALIGN
  145. #define DHD_SDALIGN 32
  146. #endif
  147. /* host reordering packts logic */
  148. /* followed the structure to hold the reorder buffers (void **p) */
  149. typedef struct reorder_info {
  150. void **p;
  151. uint8 flow_id;
  152. uint8 cur_idx;
  153. uint8 exp_idx;
  154. uint8 max_idx;
  155. uint8 pend_pkts;
  156. } reorder_info_t;
  157. #ifdef DHDTCPACK_SUPPRESS
  158. #define TCPACK_SUP_OFF 0 /* TCPACK suppress off */
  159. /* Replace TCPACK in txq when new coming one has higher ACK number. */
  160. #define TCPACK_SUP_REPLACE 1
  161. /* TCPACK_SUP_REPLACE + delayed TCPACK TX unless ACK to PSH DATA.
  162. * This will give benefits to Half-Duplex bus interface(e.g. SDIO) that
  163. * 1. we are able to read TCP DATA packets first from the bus
  164. * 2. TCPACKs that do not need to hurry delivered remains longer in TXQ so can be suppressed.
  165. */
  166. #define TCPACK_SUP_DELAYTX 2
  167. #endif /* DHDTCPACK_SUPPRESS */
  168. #ifdef DHD_LOG_DUMP
  169. /* below structure describe ring buffer. */
  170. struct dhd_log_dump_buf
  171. {
  172. spinlock_t lock;
  173. unsigned int wraparound;
  174. unsigned long max;
  175. unsigned int remain;
  176. char* present;
  177. char* front;
  178. char* buffer;
  179. };
  180. #define FW_VER_STR_LEN 128
  181. #define DHD_LOG_DUMP_BUFFER_SIZE (1024 * 1024)
  182. #define DHD_LOG_DUMP_MAX_TEMP_BUFFER_SIZE 256
  183. extern void dhd_log_dump_print(const char *fmt, ...);
  184. extern char *dhd_log_dump_get_timestamp(void);
  185. #endif /* DHD_LOG_DUMP */
  186. #define DHD_COMMON_DUMP_PATH "/data/misc/wifi/log/"
  187. /* Common structure for module and instance linkage */
  188. typedef struct dhd_pub {
  189. /* Linkage ponters */
  190. osl_t *osh; /* OSL handle */
  191. struct dhd_bus *bus; /* Bus module handle */
  192. struct dhd_prot *prot; /* Protocol module handle */
  193. struct dhd_info *info; /* Info module handle */
  194. /* to NDIS developer, the structure dhd_common is redundant,
  195. * please do NOT merge it back from other branches !!!
  196. */
  197. /* Internal dhd items */
  198. bool up; /* Driver up/down (to OS) */
  199. bool txoff; /* Transmit flow-controlled */
  200. bool dongle_reset; /* TRUE = DEVRESET put dongle into reset */
  201. enum dhd_bus_state busstate;
  202. uint hdrlen; /* Total DHD header length (proto + bus) */
  203. uint maxctl; /* Max size rxctl request from proto to bus */
  204. uint rxsz; /* Rx buffer size bus module should use */
  205. uint8 wme_dp; /* wme discard priority */
  206. /* Dongle media info */
  207. bool iswl; /* Dongle-resident driver is wl */
  208. ulong drv_version; /* Version of dongle-resident driver */
  209. struct ether_addr mac; /* MAC address obtained from dongle */
  210. dngl_stats_t dstats; /* Stats for dongle-based data */
  211. /* Additional stats for the bus level */
  212. ulong tx_packets; /* Data packets sent to dongle */
  213. ulong tx_multicast; /* Multicast data packets sent to dongle */
  214. ulong tx_errors; /* Errors in sending data to dongle */
  215. ulong tx_ctlpkts; /* Control packets sent to dongle */
  216. ulong tx_ctlerrs; /* Errors sending control frames to dongle */
  217. ulong rx_packets; /* Packets sent up the network interface */
  218. ulong rx_multicast; /* Multicast packets sent up the network interface */
  219. ulong rx_errors; /* Errors processing rx data packets */
  220. ulong rx_ctlpkts; /* Control frames processed from dongle */
  221. ulong rx_ctlerrs; /* Errors in processing rx control frames */
  222. ulong rx_dropped; /* Packets dropped locally (no memory) */
  223. ulong rx_flushed; /* Packets flushed due to unscheduled sendup thread */
  224. ulong wd_dpc_sched; /* Number of times dhd dpc scheduled by watchdog timer */
  225. ulong rx_readahead_cnt; /* Number of packets where header read-ahead was used. */
  226. ulong tx_realloc; /* Number of tx packets we had to realloc for headroom */
  227. ulong fc_packets; /* Number of flow control pkts recvd */
  228. /* Last error return */
  229. int bcmerror;
  230. uint tickcnt;
  231. /* Last error from dongle */
  232. int dongle_error;
  233. uint8 country_code[WLC_CNTRY_BUF_SZ];
  234. /* Suspend disable flag and "in suspend" flag */
  235. int suspend_disable_flag; /* "1" to disable all extra powersaving during suspend */
  236. int in_suspend; /* flag set to 1 when early suspend called */
  237. #ifdef PNO_SUPPORT
  238. int pno_enable; /* pno status : "1" is pno enable */
  239. int pno_suspend; /* pno suspend status : "1" is pno suspended */
  240. #endif /* PNO_SUPPORT */
  241. /* DTIM skip value, default 0(or 1) means wake each DTIM
  242. * 3 means skip 2 DTIMs and wake up 3rd DTIM(9th beacon when AP DTIM is 3)
  243. */
  244. int suspend_bcn_li_dtim; /* bcn_li_dtim value in suspend mode */
  245. #ifdef PKT_FILTER_SUPPORT
  246. int early_suspended; /* Early suspend status */
  247. int dhcp_in_progress; /* DHCP period */
  248. #endif
  249. /* Pkt filter defination */
  250. char * pktfilter[100];
  251. int pktfilter_count;
  252. wl_country_t dhd_cspec; /* Current Locale info */
  253. char eventmask[WL_EVENTING_MASK_LEN];
  254. char prealloc_malloc_mask[PREALLOC_MASK_LEN];
  255. int op_mode; /* STA, HostAPD, WFD, SoftAP */
  256. /* Set this to 1 to use a seperate interface (p2p0) for p2p operations.
  257. * For ICS MR1 releases it should be disable to be compatable with ICS MR1 Framework
  258. * see target dhd-cdc-sdmmc-panda-cfg80211-icsmr1-gpl-debug in Makefile
  259. */
  260. /* #define WL_ENABLE_P2P_IF 1 */
  261. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25))
  262. struct mutex wl_start_stop_lock; /* lock/unlock for Android start/stop */
  263. struct mutex wl_softap_lock; /* lock/unlock for any SoftAP/STA settings */
  264. #endif
  265. #ifdef WLBTAMP
  266. uint16 maxdatablks;
  267. #endif /* WLBTAMP */
  268. #ifdef PROP_TXSTATUS
  269. bool wlfc_enabled;
  270. int wlfc_mode;
  271. void* wlfc_state;
  272. /*
  273. Mode in which the dhd flow control shall operate. Must be set before
  274. traffic starts to the device.
  275. 0 - Do not do any proptxtstatus flow control
  276. 1 - Use implied credit from a packet status
  277. 2 - Use explicit credit
  278. 3 - Only AMPDU hostreorder used. no wlfc.
  279. */
  280. uint8 proptxstatus_mode;
  281. bool proptxstatus_txoff;
  282. bool proptxstatus_module_ignore;
  283. bool proptxstatus_credit_ignore;
  284. bool proptxstatus_txstatus_ignore;
  285. bool wlfc_rxpkt_chk;
  286. /*
  287. * implement below functions in each platform if needed.
  288. */
  289. /* platform specific function whether to skip flow control */
  290. bool (*skip_fc)(void);
  291. /* platform specific function for wlfc_enable and wlfc_deinit */
  292. void (*plat_init)(void *dhd);
  293. void (*plat_deinit)(void *dhd);
  294. #endif /* PROP_TXSTATUS */
  295. #ifdef PNO_SUPPORT
  296. void *pno_state;
  297. #endif
  298. #ifdef ROAM_AP_ENV_DETECTION
  299. bool roam_env_detection;
  300. #endif
  301. bool dongle_isolation;
  302. bool dongle_trap_occured; /* flag for sending HANG event to upper layer */
  303. int hang_was_sent;
  304. int rxcnt_timeout; /* counter rxcnt timeout to send HANG */
  305. int txcnt_timeout; /* counter txcnt timeout to send HANG */
  306. bool hang_report; /* enable hang report by default */
  307. uint16 hang_reason; /* reason codes for HANG event */
  308. #ifdef WLMEDIA_HTSF
  309. uint8 htsfdlystat_sz; /* Size of delay stats, max 255B */
  310. #endif
  311. #ifdef WLTDLS
  312. bool tdls_enable;
  313. #endif
  314. struct reorder_info *reorder_bufs[WLHOST_REORDERDATA_MAXFLOWS];
  315. char fw_capabilities[WLC_IOCTL_SMLEN];
  316. #define MAXSKBPEND 1024
  317. void *skbbuf[MAXSKBPEND];
  318. uint32 store_idx;
  319. uint32 sent_idx;
  320. #ifdef DHDTCPACK_SUPPRESS
  321. uint8 tcpack_sup_mode; /* TCPACK suppress mode */
  322. void *tcpack_sup_module; /* TCPACK suppress module */
  323. #endif /* DHDTCPACK_SUPPRESS */
  324. #if defined(ARP_OFFLOAD_SUPPORT)
  325. uint32 arp_version;
  326. #endif
  327. #if defined(BCMSUP_4WAY_HANDSHAKE) && defined(WLAN_AKM_SUITE_FT_8021X)
  328. bool fw_4way_handshake; /* Whether firmware will to do the 4way handshake. */
  329. #endif
  330. #if defined(CUSTOMER_HW4)
  331. bool dhd_bug_on;
  332. #endif
  333. #ifdef CUSTOM_SET_CPUCORE
  334. struct task_struct * current_dpc;
  335. struct task_struct * current_rxf;
  336. int chan_isvht80;
  337. #endif /* CUSTOM_SET_CPUCORE */
  338. #if defined(CUSTOMER_HW4) && defined(ARGOS_CPU_SCHEDULER)
  339. cpumask_var_t default_cpu_mask;
  340. cpumask_var_t dpc_affinity_cpu_mask;
  341. cpumask_var_t rxf_affinity_cpu_mask;
  342. bool affinity_isdpc;
  343. bool affinity_isrxf;
  344. #endif /* CUSTOMER_HW4 && ARGOS_CPU_SCHEDULER */
  345. #ifdef KEEP_JP_REGREV
  346. char vars_ccode[WLC_CNTRY_BUF_SZ];
  347. uint vars_regrev;
  348. #endif /* KEEP_JP_REGREV */
  349. #ifdef DHD_LOSSLESS_ROAMING
  350. uint8 dequeue_prec_map;
  351. #endif
  352. #ifdef DHD_LOG_DUMP
  353. struct dhd_log_dump_buf dld_buf;
  354. unsigned int dld_enable;
  355. #endif /* DHD_LOG_DUMP */
  356. } dhd_pub_t;
  357. #if defined(CUSTOMER_HW4)
  358. #define MAX_RESCHED_CNT 600
  359. #endif
  360. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_PM_SLEEP)
  361. #define DHD_PM_RESUME_WAIT_INIT(a) DECLARE_WAIT_QUEUE_HEAD(a);
  362. #define _DHD_PM_RESUME_WAIT(a, b) do {\
  363. int retry = 0; \
  364. SMP_RD_BARRIER_DEPENDS(); \
  365. while (dhd_mmc_suspend && retry++ != b) { \
  366. SMP_RD_BARRIER_DEPENDS(); \
  367. wait_event_interruptible_timeout(a, !dhd_mmc_suspend, 1); \
  368. } \
  369. } while (0)
  370. #define DHD_PM_RESUME_WAIT(a) _DHD_PM_RESUME_WAIT(a, 200)
  371. #define DHD_PM_RESUME_WAIT_FOREVER(a) _DHD_PM_RESUME_WAIT(a, ~0)
  372. #ifdef CUSTOMER_HW4
  373. #define DHD_PM_RESUME_RETURN_ERROR(a) do { \
  374. if (dhd_mmc_suspend) { \
  375. printf("%s[%d]: mmc is still in suspend state!!!\n", \
  376. __FUNCTION__, __LINE__); \
  377. return a; \
  378. } \
  379. } while (0)
  380. #else
  381. #define DHD_PM_RESUME_RETURN_ERROR(a) do { \
  382. if (dhd_mmc_suspend) return a; } while (0)
  383. #endif /* CUSTOMER_HW4 */
  384. #define DHD_PM_RESUME_RETURN do { if (dhd_mmc_suspend) return; } while (0)
  385. #define DHD_SPINWAIT_SLEEP_INIT(a) DECLARE_WAIT_QUEUE_HEAD(a);
  386. #define SPINWAIT_SLEEP(a, exp, us) do { \
  387. uint countdown = (us) + 9999; \
  388. while ((exp) && (countdown >= 10000)) { \
  389. wait_event_interruptible_timeout(a, FALSE, 1); \
  390. countdown -= 10000; \
  391. } \
  392. } while (0)
  393. #else
  394. #define DHD_PM_RESUME_WAIT_INIT(a)
  395. #define DHD_PM_RESUME_WAIT(a)
  396. #define DHD_PM_RESUME_WAIT_FOREVER(a)
  397. #define DHD_PM_RESUME_RETURN_ERROR(a)
  398. #define DHD_PM_RESUME_RETURN
  399. #define DHD_SPINWAIT_SLEEP_INIT(a)
  400. #define SPINWAIT_SLEEP(a, exp, us) do { \
  401. uint countdown = (us) + 9; \
  402. while ((exp) && (countdown >= 10)) { \
  403. OSL_DELAY(10); \
  404. countdown -= 10; \
  405. } \
  406. } while (0)
  407. #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_PM_SLEEP) */
  408. #ifndef OSL_SLEEP
  409. #define OSL_SLEEP(ms) OSL_DELAY(ms*1000)
  410. #endif /* OSL_SLEEP */
  411. #define DHD_IF_VIF 0x01 /* Virtual IF (Hidden from user) */
  412. unsigned long dhd_os_spin_lock(dhd_pub_t *pub);
  413. void dhd_os_spin_unlock(dhd_pub_t *pub, unsigned long flags);
  414. #ifdef PNO_SUPPORT
  415. int dhd_pno_clean(dhd_pub_t *dhd);
  416. #endif /* PNO_SUPPORT */
  417. /*
  418. * Wake locks are an Android power management concept. They are used by applications and services
  419. * to request CPU resources.
  420. */
  421. extern int dhd_os_wake_lock(dhd_pub_t *pub);
  422. extern int dhd_os_wake_unlock(dhd_pub_t *pub);
  423. extern int dhd_os_wake_lock_timeout(dhd_pub_t *pub);
  424. extern int dhd_os_wake_lock_rx_timeout_enable(dhd_pub_t *pub, int val);
  425. extern int dhd_os_wake_lock_ctrl_timeout_enable(dhd_pub_t *pub, int val);
  426. extern int dhd_os_wake_lock_ctrl_timeout_cancel(dhd_pub_t *pub);
  427. extern int dhd_os_wd_wake_lock(dhd_pub_t *pub);
  428. extern int dhd_os_wd_wake_unlock(dhd_pub_t *pub);
  429. extern void dhd_os_wake_lock_init(struct dhd_info *dhd);
  430. extern void dhd_os_wake_lock_destroy(struct dhd_info *dhd);
  431. inline static void MUTEX_LOCK_SOFTAP_SET_INIT(dhd_pub_t * dhdp)
  432. {
  433. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25))
  434. mutex_init(&dhdp->wl_softap_lock);
  435. #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) */
  436. }
  437. inline static void MUTEX_LOCK_SOFTAP_SET(dhd_pub_t * dhdp)
  438. {
  439. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25))
  440. mutex_lock(&dhdp->wl_softap_lock);
  441. #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) */
  442. }
  443. inline static void MUTEX_UNLOCK_SOFTAP_SET(dhd_pub_t * dhdp)
  444. {
  445. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25))
  446. mutex_unlock(&dhdp->wl_softap_lock);
  447. #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) */
  448. }
  449. #ifdef DHD_DEBUG_WAKE_LOCK
  450. #define DHD_OS_WAKE_LOCK(pub) \
  451. do { \
  452. printf("call wake_lock: %s %d\n", \
  453. __FUNCTION__, __LINE__); \
  454. dhd_os_wake_lock(pub); \
  455. } while (0)
  456. #define DHD_OS_WAKE_UNLOCK(pub) \
  457. do { \
  458. printf("call wake_unlock: %s %d\n", \
  459. __FUNCTION__, __LINE__); \
  460. dhd_os_wake_unlock(pub); \
  461. } while (0)
  462. #define DHD_OS_WAKE_LOCK_TIMEOUT(pub) \
  463. do { \
  464. printf("call wake_lock_timeout: %s %d\n", \
  465. __FUNCTION__, __LINE__); \
  466. dhd_os_wake_lock_timeout(pub); \
  467. } while (0)
  468. #define DHD_OS_WAKE_LOCK_RX_TIMEOUT_ENABLE(pub, val) \
  469. do { \
  470. printf("call wake_lock_rx_timeout_enable[%d]: %s %d\n", \
  471. val, __FUNCTION__, __LINE__); \
  472. dhd_os_wake_lock_rx_timeout_enable(pub, val); \
  473. } while (0)
  474. #define DHD_OS_WAKE_LOCK_CTRL_TIMEOUT_ENABLE(pub, val) \
  475. do { \
  476. printf("call wake_lock_ctrl_timeout_enable[%d]: %s %d\n", \
  477. val, __FUNCTION__, __LINE__); \
  478. dhd_os_wake_lock_ctrl_timeout_enable(pub, val); \
  479. } while (0)
  480. #define DHD_OS_WAKE_LOCK_CTRL_TIMEOUT_CANCEL(pub) \
  481. do { \
  482. printf("call wake_lock_ctrl_timeout_cancel: %s %d\n", \
  483. __FUNCTION__, __LINE__); \
  484. dhd_os_wake_lock_ctrl_timeout_cancel(pub); \
  485. } while (0)
  486. #define DHD_OS_WAKE_LOCK_INIT(dhd) \
  487. do { \
  488. printf("call wake_lock_init: %s %d\n", \
  489. __FUNCTION__, __LINE__); \
  490. dhd_os_wake_lock_init(dhd); \
  491. } while (0)
  492. #define DHD_OS_WAKE_LOCK_DESTROY(dhd) \
  493. do { \
  494. printf("call wake_lock_destroy: %s %d\n", \
  495. __FUNCTION__, __LINE__); \
  496. dhd_os_wake_lock_destroy(dhd); \
  497. } while (0)
  498. #else
  499. #define DHD_OS_WAKE_LOCK(pub) dhd_os_wake_lock(pub)
  500. #define DHD_OS_WAKE_UNLOCK(pub) dhd_os_wake_unlock(pub)
  501. #define DHD_OS_WAKE_LOCK_TIMEOUT(pub) dhd_os_wake_lock_timeout(pub)
  502. #define DHD_OS_WAKE_LOCK_RX_TIMEOUT_ENABLE(pub, val) \
  503. dhd_os_wake_lock_rx_timeout_enable(pub, val)
  504. #define DHD_OS_WAKE_LOCK_CTRL_TIMEOUT_ENABLE(pub, val) \
  505. dhd_os_wake_lock_ctrl_timeout_enable(pub, val)
  506. #define DHD_OS_WAKE_LOCK_CTRL_TIMEOUT_CANCEL(pub) \
  507. dhd_os_wake_lock_ctrl_timeout_cancel(pub)
  508. #define DHD_OS_WAKE_LOCK_INIT(dhd) dhd_os_wake_lock_init(dhd)
  509. #define DHD_OS_WAKE_LOCK_DESTROY(dhd) dhd_os_wake_lock_destroy(dhd)
  510. #endif /* DHD_DEBUG_WAKE_LOCK */
  511. #define DHD_OS_WD_WAKE_LOCK(pub) dhd_os_wd_wake_lock(pub)
  512. #define DHD_OS_WD_WAKE_UNLOCK(pub) dhd_os_wd_wake_unlock(pub)
  513. #define DHD_PACKET_TIMEOUT_MS 500
  514. #define DHD_EVENT_TIMEOUT_MS 1500
  515. /* interface operations (register, remove) should be atomic, use this lock to prevent race
  516. * condition among wifi on/off and interface operation functions
  517. */
  518. void dhd_net_if_lock(struct net_device *dev);
  519. void dhd_net_if_unlock(struct net_device *dev);
  520. #if defined(MULTIPLE_SUPPLICANT)
  521. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25))
  522. extern struct mutex _dhd_sdio_mutex_lock_;
  523. #endif
  524. #endif /* MULTIPLE_SUPPLICANT */
  525. typedef enum dhd_attach_states
  526. {
  527. DHD_ATTACH_STATE_INIT = 0x0,
  528. DHD_ATTACH_STATE_NET_ALLOC = 0x1,
  529. DHD_ATTACH_STATE_DHD_ALLOC = 0x2,
  530. DHD_ATTACH_STATE_ADD_IF = 0x4,
  531. DHD_ATTACH_STATE_PROT_ATTACH = 0x8,
  532. DHD_ATTACH_STATE_WL_ATTACH = 0x10,
  533. DHD_ATTACH_STATE_THREADS_CREATED = 0x20,
  534. DHD_ATTACH_STATE_WAKELOCKS_INIT = 0x40,
  535. DHD_ATTACH_STATE_CFG80211 = 0x80,
  536. DHD_ATTACH_STATE_EARLYSUSPEND_DONE = 0x100,
  537. DHD_ATTACH_STATE_DONE = 0x200
  538. } dhd_attach_states_t;
  539. /* Value -1 means we are unsuccessful in creating the kthread. */
  540. #define DHD_PID_KT_INVALID -1
  541. /* Value -2 means we are unsuccessful in both creating the kthread and tasklet */
  542. #define DHD_PID_KT_TL_INVALID -2
  543. /*
  544. * Exported from dhd OS modules (dhd_linux/dhd_ndis)
  545. */
  546. /* Indication from bus module regarding presence/insertion of dongle.
  547. * Return dhd_pub_t pointer, used as handle to OS module in later calls.
  548. * Returned structure should have bus and prot pointers filled in.
  549. * bus_hdrlen specifies required headroom for bus module header.
  550. */
  551. extern dhd_pub_t *dhd_attach(osl_t *osh, struct dhd_bus *bus, uint bus_hdrlen);
  552. #if defined(WLP2P) && defined(WL_CFG80211)
  553. /* To allow attach/detach calls corresponding to p2p0 interface */
  554. extern int dhd_attach_p2p(dhd_pub_t *);
  555. extern int dhd_detach_p2p(dhd_pub_t *);
  556. #endif /* WLP2P && WL_CFG80211 */
  557. extern int dhd_register_if(dhd_pub_t *dhdp, int idx, bool need_rtnl_lock);
  558. /* Indication from bus module regarding removal/absence of dongle */
  559. extern void dhd_detach(dhd_pub_t *dhdp);
  560. extern void dhd_free(dhd_pub_t *dhdp);
  561. /* Indication from bus module to change flow-control state */
  562. extern void dhd_txflowcontrol(dhd_pub_t *dhdp, int ifidx, bool on);
  563. /* Store the status of a connection attempt for later retrieval by an iovar */
  564. extern void dhd_store_conn_status(uint32 event, uint32 status, uint32 reason);
  565. extern bool dhd_prec_enq(dhd_pub_t *dhdp, struct pktq *q, void *pkt, int prec);
  566. /* Receive frame for delivery to OS. Callee disposes of rxp. */
  567. extern void dhd_rx_frame(dhd_pub_t *dhdp, int ifidx, void *rxp, int numpkt, uint8 chan);
  568. /* Return pointer to interface name */
  569. extern char *dhd_ifname(dhd_pub_t *dhdp, int idx);
  570. /* Request scheduling of the bus dpc */
  571. extern void dhd_sched_dpc(dhd_pub_t *dhdp);
  572. /* Notify tx completion */
  573. extern void dhd_txcomplete(dhd_pub_t *dhdp, void *txp, bool success);
  574. /* OS independent layer functions */
  575. extern int dhd_os_proto_block(dhd_pub_t * pub);
  576. extern int dhd_os_proto_unblock(dhd_pub_t * pub);
  577. extern int dhd_os_ioctl_resp_wait(dhd_pub_t * pub, uint * condition, bool * pending);
  578. extern int dhd_os_ioctl_resp_wake(dhd_pub_t * pub);
  579. extern unsigned int dhd_os_get_ioctl_resp_timeout(void);
  580. extern void dhd_os_set_ioctl_resp_timeout(unsigned int timeout_msec);
  581. extern int dhd_os_get_image_block(char * buf, int len, void * image);
  582. extern void * dhd_os_open_image(char * filename);
  583. extern void dhd_os_close_image(void * image);
  584. extern void dhd_os_wd_timer(void *bus, uint wdtick);
  585. extern void dhd_os_sdlock(dhd_pub_t * pub);
  586. extern void dhd_os_sdunlock(dhd_pub_t * pub);
  587. extern void dhd_os_sdlock_txq(dhd_pub_t * pub);
  588. extern void dhd_os_sdunlock_txq(dhd_pub_t * pub);
  589. extern void dhd_os_sdlock_rxq(dhd_pub_t * pub);
  590. extern void dhd_os_sdunlock_rxq(dhd_pub_t * pub);
  591. extern void dhd_os_sdlock_sndup_rxq(dhd_pub_t * pub);
  592. #ifdef DHDTCPACK_SUPPRESS
  593. extern void dhd_os_tcpacklock(dhd_pub_t *pub);
  594. extern void dhd_os_tcpackunlock(dhd_pub_t *pub);
  595. #endif /* DHDTCPACK_SUPPRESS */
  596. extern int dhd_customer_oob_irq_map(void *adapter, unsigned long *irq_flags_ptr);
  597. extern int dhd_customer_gpio_wlan_ctrl(void *adapter, int onoff);
  598. extern int dhd_custom_get_mac_address(void *adapter, unsigned char *buf);
  599. extern void get_customized_country_code(void *adapter, char *country_iso_code, wl_country_t *cspec);
  600. extern void dhd_os_sdunlock_sndup_rxq(dhd_pub_t * pub);
  601. extern void dhd_os_sdlock_eventq(dhd_pub_t * pub);
  602. extern void dhd_os_sdunlock_eventq(dhd_pub_t * pub);
  603. extern bool dhd_os_check_hang(dhd_pub_t *dhdp, int ifidx, int ret);
  604. extern int dhd_os_send_hang_message(dhd_pub_t *dhdp);
  605. extern void dhd_set_version_info(dhd_pub_t *pub, char *fw);
  606. extern bool dhd_os_check_if_up(dhd_pub_t *pub);
  607. extern int dhd_os_check_wakelock(dhd_pub_t *pub);
  608. #ifdef CUSTOM_SET_CPUCORE
  609. extern void dhd_set_cpucore(dhd_pub_t *dhd, int set);
  610. #endif /* CUSTOM_SET_CPUCORE */
  611. #if defined(KEEP_ALIVE)
  612. extern int dhd_keep_alive_onoff(dhd_pub_t *dhd);
  613. #endif /* KEEP_ALIVE */
  614. #ifdef PKT_FILTER_SUPPORT
  615. #define DHD_UNICAST_FILTER_NUM 0
  616. #define DHD_BROADCAST_FILTER_NUM 1
  617. #define DHD_MULTICAST4_FILTER_NUM 2
  618. #define DHD_MULTICAST6_FILTER_NUM 3
  619. #define DHD_MDNS_FILTER_NUM 4
  620. #define DHD_ARP_FILTER_NUM 5
  621. extern int dhd_os_enable_packet_filter(dhd_pub_t *dhdp, int val);
  622. extern void dhd_enable_packet_filter(int value, dhd_pub_t *dhd);
  623. extern int net_os_enable_packet_filter(struct net_device *dev, int val);
  624. extern int net_os_rxfilter_add_remove(struct net_device *dev, int val, int num);
  625. #endif /* PKT_FILTER_SUPPORT */
  626. extern int dhd_get_suspend_bcn_li_dtim(dhd_pub_t *dhd);
  627. extern bool dhd_support_sta_mode(dhd_pub_t *dhd);
  628. #ifdef DHD_DEBUG
  629. extern int write_to_file(dhd_pub_t *dhd, uint8 *buf, int size);
  630. #endif /* DHD_DEBUG */
  631. extern void dhd_os_sdtxlock(dhd_pub_t * pub);
  632. extern void dhd_os_sdtxunlock(dhd_pub_t * pub);
  633. typedef struct {
  634. uint32 limit; /* Expiration time (usec) */
  635. uint32 increment; /* Current expiration increment (usec) */
  636. uint32 elapsed; /* Current elapsed time (usec) */
  637. uint32 tick; /* O/S tick time (usec) */
  638. } dhd_timeout_t;
  639. extern void dhd_timeout_start(dhd_timeout_t *tmo, uint usec);
  640. extern int dhd_timeout_expired(dhd_timeout_t *tmo);
  641. extern int dhd_ifname2idx(struct dhd_info *dhd, char *name);
  642. extern int dhd_net2idx(struct dhd_info *dhd, struct net_device *net);
  643. extern struct net_device * dhd_idx2net(void *pub, int ifidx);
  644. extern int net_os_send_hang_message(struct net_device *dev);
  645. extern int net_os_send_hang_message_reason(struct net_device *dev, const char *string_num);
  646. extern int wl_host_event(dhd_pub_t *dhd_pub, int *idx, void *pktdata,
  647. size_t pktlen, wl_event_msg_t *, void **data_ptr);
  648. extern void wl_event_to_host_order(wl_event_msg_t * evt);
  649. extern int dhd_wl_ioctl(dhd_pub_t *dhd_pub, int ifindex, wl_ioctl_t *ioc, void *buf, int len);
  650. extern int dhd_wl_ioctl_cmd(dhd_pub_t *dhd_pub, int cmd, void *arg, int len, uint8 set,
  651. int ifindex);
  652. extern void dhd_common_init(osl_t *osh);
  653. extern int dhd_do_driver_init(struct net_device *net);
  654. extern int dhd_event_ifadd(struct dhd_info *dhd, struct wl_event_data_if *ifevent,
  655. char *name, uint8 *mac);
  656. extern int dhd_event_ifdel(struct dhd_info *dhd, struct wl_event_data_if *ifevent,
  657. char *name, uint8 *mac);
  658. extern struct net_device* dhd_allocate_if(dhd_pub_t *dhdpub, int ifidx, char *name,
  659. uint8 *mac, uint8 bssidx, bool need_rtnl_lock);
  660. extern int dhd_remove_if(dhd_pub_t *dhdpub, int ifidx, bool need_rtnl_lock);
  661. extern void dhd_vif_add(struct dhd_info *dhd, int ifidx, char * name);
  662. extern void dhd_vif_del(struct dhd_info *dhd, int ifidx);
  663. extern void dhd_event(struct dhd_info *dhd, char *evpkt, uint evlen, int ifidx);
  664. extern void dhd_vif_sendup(struct dhd_info *dhd, int ifidx, uchar *cp, int len);
  665. /* Send packet to dongle via data channel */
  666. extern int dhd_sendpkt(dhd_pub_t *dhdp, int ifidx, void *pkt);
  667. /* send up locally generated event */
  668. extern void dhd_sendup_event_common(dhd_pub_t *dhdp, wl_event_msg_t *event, void *data);
  669. /* Send event to host */
  670. extern void dhd_sendup_event(dhd_pub_t *dhdp, wl_event_msg_t *event, void *data);
  671. #ifdef LOG_INTO_TCPDUMP
  672. extern void dhd_sendup_log(dhd_pub_t *dhdp, void *data, int len);
  673. #endif /* LOG_INTO_TCPDUMP */
  674. extern int dhd_bus_devreset(dhd_pub_t *dhdp, uint8 flag);
  675. extern uint dhd_bus_status(dhd_pub_t *dhdp);
  676. extern int dhd_bus_start(dhd_pub_t *dhdp);
  677. extern int dhd_bus_suspend(dhd_pub_t *dhdpub);
  678. extern int dhd_bus_resume(dhd_pub_t *dhdpub, int stage);
  679. extern int dhd_bus_membytes(dhd_pub_t *dhdp, bool set, uint32 address, uint8 *data, uint size);
  680. extern void dhd_print_buf(void *pbuf, int len, int bytes_per_line);
  681. extern bool dhd_is_associated(dhd_pub_t *dhd, void *bss_buf, int *retval);
  682. extern uint dhd_bus_chip_id(dhd_pub_t *dhdp);
  683. extern uint dhd_bus_chiprev_id(dhd_pub_t *dhdp);
  684. extern uint dhd_bus_chippkg_id(dhd_pub_t *dhdp);
  685. #if defined(KEEP_ALIVE)
  686. extern int dhd_keep_alive_onoff(dhd_pub_t *dhd);
  687. #endif /* KEEP_ALIVE */
  688. extern bool dhd_is_concurrent_mode(dhd_pub_t *dhd);
  689. extern int dhd_iovar(dhd_pub_t *pub, int ifidx, char *name, char *cmd_buf, uint cmd_len, int set);
  690. typedef enum cust_gpio_modes {
  691. WLAN_RESET_ON,
  692. WLAN_RESET_OFF,
  693. WLAN_POWER_ON,
  694. WLAN_POWER_OFF
  695. } cust_gpio_modes_t;
  696. extern int wl_iw_iscan_set_scan_broadcast_prep(struct net_device *dev, uint flag);
  697. extern int wl_iw_send_priv_event(struct net_device *dev, char *flag);
  698. /*
  699. * Insmod parameters for debug/test
  700. */
  701. /* Watchdog timer interval */
  702. extern uint dhd_watchdog_ms;
  703. #if defined(DHD_DEBUG)
  704. /* Console output poll interval */
  705. extern uint dhd_console_ms;
  706. extern uint wl_msg_level;
  707. #endif /* defined(DHD_DEBUG) */
  708. extern uint dhd_slpauto;
  709. /* Use interrupts */
  710. extern uint dhd_intr;
  711. /* Use polling */
  712. extern uint dhd_poll;
  713. /* ARP offload agent mode */
  714. extern uint dhd_arp_mode;
  715. /* ARP offload enable */
  716. extern uint dhd_arp_enable;
  717. /* Pkt filte enable control */
  718. extern uint dhd_pkt_filter_enable;
  719. /* Pkt filter init setup */
  720. extern uint dhd_pkt_filter_init;
  721. /* Pkt filter mode control */
  722. extern uint dhd_master_mode;
  723. /* Roaming mode control */
  724. extern uint dhd_roam_disable;
  725. /* Roaming mode control */
  726. extern uint dhd_radio_up;
  727. /* Initial idletime ticks (may be -1 for immediate idle, 0 for no idle) */
  728. extern int dhd_idletime;
  729. #ifdef DHD_USE_IDLECOUNT
  730. #define DHD_IDLETIME_TICKS 5
  731. #else
  732. #define DHD_IDLETIME_TICKS 1
  733. #endif /* DHD_USE_IDLECOUNT */
  734. /* SDIO Drive Strength */
  735. extern uint dhd_sdiod_drive_strength;
  736. /* Override to force tx queueing all the time */
  737. extern uint dhd_force_tx_queueing;
  738. /* Default KEEP_ALIVE Period is 55 sec to prevent AP from sending Keep Alive probe frame */
  739. #define DEFAULT_KEEP_ALIVE_VALUE 55000 /* msec */
  740. #ifndef CUSTOM_KEEP_ALIVE_SETTING
  741. #define CUSTOM_KEEP_ALIVE_SETTING DEFAULT_KEEP_ALIVE_VALUE
  742. #endif /* DEFAULT_KEEP_ALIVE_VALUE */
  743. #define NULL_PKT_STR "null_pkt"
  744. /* hooks for custom glom setting option via Makefile */
  745. #define DEFAULT_GLOM_VALUE -1
  746. #ifndef CUSTOM_GLOM_SETTING
  747. #define CUSTOM_GLOM_SETTING DEFAULT_GLOM_VALUE
  748. #endif
  749. #define WL_AUTO_ROAM_TRIGGER -75
  750. /* hooks for custom Roaming Trigger setting via Makefile */
  751. #define DEFAULT_ROAM_TRIGGER_VALUE -75 /* dBm default roam trigger all band */
  752. #define DEFAULT_ROAM_TRIGGER_SETTING -1
  753. #ifndef CUSTOM_ROAM_TRIGGER_SETTING
  754. #define CUSTOM_ROAM_TRIGGER_SETTING DEFAULT_ROAM_TRIGGER_VALUE
  755. #endif
  756. /* hooks for custom Roaming Romaing setting via Makefile */
  757. #define DEFAULT_ROAM_DELTA_VALUE 10 /* dBm default roam delta all band */
  758. #define DEFAULT_ROAM_DELTA_SETTING -1
  759. #ifndef CUSTOM_ROAM_DELTA_SETTING
  760. #define CUSTOM_ROAM_DELTA_SETTING DEFAULT_ROAM_DELTA_VALUE
  761. #endif
  762. /* hooks for custom PNO Event wake lock to guarantee enough time
  763. for the Platform to detect Event before system suspended
  764. */
  765. #define DEFAULT_PNO_EVENT_LOCK_xTIME 2 /* multiplay of DHD_PACKET_TIMEOUT_MS */
  766. #ifndef CUSTOM_PNO_EVENT_LOCK_xTIME
  767. #define CUSTOM_PNO_EVENT_LOCK_xTIME DEFAULT_PNO_EVENT_LOCK_xTIME
  768. #endif
  769. /* hooks for custom dhd_dpc_prio setting option via Makefile */
  770. #define DEFAULT_DHP_DPC_PRIO 1
  771. #ifndef CUSTOM_DPC_PRIO_SETTING
  772. #define CUSTOM_DPC_PRIO_SETTING DEFAULT_DHP_DPC_PRIO
  773. #endif
  774. #ifndef CUSTOM_LISTEN_INTERVAL
  775. #define CUSTOM_LISTEN_INTERVAL LISTEN_INTERVAL
  776. #endif /* CUSTOM_LISTEN_INTERVAL */
  777. #define DEFAULT_SUSPEND_BCN_LI_DTIM 3
  778. #ifndef CUSTOM_SUSPEND_BCN_LI_DTIM
  779. #define CUSTOM_SUSPEND_BCN_LI_DTIM DEFAULT_SUSPEND_BCN_LI_DTIM
  780. #endif
  781. #ifndef CUSTOM_RXF_PRIO_SETTING
  782. #define CUSTOM_RXF_PRIO_SETTING MAX((CUSTOM_DPC_PRIO_SETTING - 1), 1)
  783. #endif
  784. #define DEFAULT_WIFI_TURNOFF_DELAY 0
  785. #ifndef WIFI_TURNOFF_DELAY
  786. #define WIFI_TURNOFF_DELAY DEFAULT_WIFI_TURNOFF_DELAY
  787. #endif /* WIFI_TURNOFF_DELAY */
  788. #define DEFAULT_WIFI_TURNON_DELAY 200
  789. #ifndef WIFI_TURNON_DELAY
  790. #define WIFI_TURNON_DELAY DEFAULT_WIFI_TURNON_DELAY
  791. #endif /* WIFI_TURNON_DELAY */
  792. #ifdef WLTDLS
  793. #ifndef CUSTOM_TDLS_IDLE_MODE_SETTING
  794. #define CUSTOM_TDLS_IDLE_MODE_SETTING 60000 /* 60sec to tear down TDLS of not active */
  795. #endif
  796. #ifndef CUSTOM_TDLS_RSSI_THRESHOLD_HIGH
  797. #define CUSTOM_TDLS_RSSI_THRESHOLD_HIGH -70 /* rssi threshold for establishing TDLS link */
  798. #endif
  799. #ifndef CUSTOM_TDLS_RSSI_THRESHOLD_LOW
  800. #define CUSTOM_TDLS_RSSI_THRESHOLD_LOW -80 /* rssi threshold for tearing down TDLS link */
  801. #endif
  802. #endif /* WLTDLS */
  803. #if defined(VSDB) || defined(ROAM_ENABLE)
  804. #define DEFAULT_BCN_TIMEOUT 8
  805. #else
  806. #define DEFAULT_BCN_TIMEOUT 4
  807. #endif /* CUSTOMER_HW4 && (VSDB || ROAM_ENABLE) */
  808. #ifndef CUSTOM_BCN_TIMEOUT
  809. #define CUSTOM_BCN_TIMEOUT DEFAULT_BCN_TIMEOUT
  810. #endif
  811. #define MAX_DTIM_SKIP_BEACON_INTERVAL 100 /* max allowed associated AP beacon for DTIM skip */
  812. #ifndef MAX_DTIM_ALLOWED_INTERVAL
  813. #define MAX_DTIM_ALLOWED_INTERVAL 600 /* max allowed total beacon interval for DTIM skip */
  814. #endif
  815. #define NO_DTIM_SKIP 1
  816. #ifdef SDTEST
  817. /* Echo packet generator (SDIO), pkts/s */
  818. extern uint dhd_pktgen;
  819. /* Echo packet len (0 => sawtooth, max 1800) */
  820. extern uint dhd_pktgen_len;
  821. #define MAX_PKTGEN_LEN 1800
  822. #endif
  823. /* optionally set by a module_param_string() */
  824. #define MOD_PARAM_PATHLEN 2048
  825. #define MOD_PARAM_INFOLEN 512
  826. #ifdef SOFTAP
  827. extern char fw_path2[MOD_PARAM_PATHLEN];
  828. #endif
  829. /* Flag to indicate if we should download firmware on driver load */
  830. extern uint dhd_download_fw_on_driverload;
  831. #if defined(WL_CFG80211) && defined(SUPPORT_DEEP_SLEEP)
  832. /* Flags to indicate if we distingish power off policy when
  833. * user set the memu "Keep Wi-Fi on during sleep" to "Never"
  834. */
  835. extern int trigger_deep_sleep;
  836. int dhd_deepsleep(struct net_device *dev, int flag);
  837. #endif /* WL_CFG80211 && SUPPORT_DEEP_SLEEP */
  838. /* For supporting multiple interfaces */
  839. #define DHD_MAX_IFS 16
  840. #define DHD_DEL_IF -0xe
  841. #define DHD_BAD_IF -0xf
  842. extern void dhd_wait_for_event(dhd_pub_t *dhd, bool *lockvar);
  843. extern void dhd_wait_event_wakeup(dhd_pub_t*dhd);
  844. #define IFLOCK_INIT(lock) *lock = 0
  845. #define IFLOCK(lock) while (InterlockedCompareExchange((lock), 1, 0)) \
  846. NdisStallExecution(1);
  847. #define IFUNLOCK(lock) InterlockedExchange((lock), 0)
  848. #define IFLOCK_FREE(lock)
  849. #define FW_SUPPORTED(dhd, capa) ((strstr(dhd->fw_capabilities, #capa) != NULL))
  850. #ifdef ARP_OFFLOAD_SUPPORT
  851. #define MAX_IPV4_ENTRIES 8
  852. void dhd_arp_offload_set(dhd_pub_t * dhd, int arp_mode);
  853. void dhd_arp_offload_enable(dhd_pub_t * dhd, int arp_enable);
  854. /* dhd_commn arp offload wrapers */
  855. void dhd_aoe_hostip_clr(dhd_pub_t *dhd, int idx);
  856. void dhd_aoe_arp_clr(dhd_pub_t *dhd, int idx);
  857. int dhd_arp_get_arp_hostip_table(dhd_pub_t *dhd, void *buf, int buflen, int idx);
  858. void dhd_arp_offload_add_ip(dhd_pub_t *dhd, uint32 ipaddr, int idx);
  859. #endif /* ARP_OFFLOAD_SUPPORT */
  860. #ifdef WLTDLS
  861. int dhd_tdls_enable(struct net_device *dev, bool tdls_on, bool auto_on, struct ether_addr *mac);
  862. #endif
  863. /* Neighbor Discovery Offload Support */
  864. int dhd_ndo_enable(dhd_pub_t * dhd, int ndo_enable);
  865. int dhd_ndo_add_ip(dhd_pub_t *dhd, char* ipaddr, int idx);
  866. int dhd_ndo_remove_ip(dhd_pub_t *dhd, int idx);
  867. /* ioctl processing for nl80211 */
  868. int dhd_ioctl_process(dhd_pub_t *pub, int ifidx, struct dhd_ioctl *ioc, void *data_buf);
  869. #if defined(SUPPORT_MULTIPLE_REVISION)
  870. extern int
  871. concate_revision(struct dhd_bus *bus, char *fwpath, int fw_path_len, char *nvpath, int nv_path_len);
  872. #if defined(PLATFORM_MPS)
  873. extern int wifi_get_fw_nv_path(char *fw, char *nv);
  874. #endif
  875. #endif /* SUPPORT_MULTIPLE_REVISION */
  876. void dhd_bus_update_fw_nv_path(struct dhd_bus *bus, char *pfw_path, char *pnv_path);
  877. void dhd_set_bus_state(void *bus, uint32 state);
  878. /* Remove proper pkts(either one no-frag pkt or whole fragmented pkts) */
  879. typedef int (*f_droppkt_t)(dhd_pub_t *dhdp, int prec, void* p, bool bPktInQ);
  880. extern bool dhd_prec_drop_pkts(dhd_pub_t *dhdp, struct pktq *pq, int prec, f_droppkt_t fn);
  881. #ifdef PROP_TXSTATUS
  882. int dhd_os_wlfc_block(dhd_pub_t *pub);
  883. int dhd_os_wlfc_unblock(dhd_pub_t *pub);
  884. extern const uint8 prio2fifo[];
  885. #endif /* PROP_TXSTATUS */
  886. uint8* dhd_os_prealloc(dhd_pub_t *dhdpub, int section, uint size, bool kmalloc_if_fail);
  887. void dhd_os_prefree(dhd_pub_t *dhdpub, int section, void *addr, uint size);
  888. #if defined(CONFIG_DHD_USE_STATIC_BUF)
  889. #define DHD_OS_PREALLOC(dhdpub, section, size) dhd_os_prealloc(dhdpub, section, size, TRUE)
  890. #define DHD_OS_PREFREE(dhdpub, section, addr, size) dhd_os_prefree(dhdpub, section, addr, size)
  891. #else
  892. #define DHD_OS_PREALLOC(dhdpub, section, size) MALLOC(dhdpub->osh, size)
  893. #define DHD_OS_PREFREE(dhdpub, section, addr, size) MFREE(dhdpub->osh, addr, size)
  894. #endif /* defined(CONFIG_DHD_USE_STATIC_BUF) */
  895. #if defined(CUSTOMER_HW4) && defined(USE_WFA_CERT_CONF)
  896. enum {
  897. SET_PARAM_BUS_TXGLOM_MODE,
  898. SET_PARAM_ROAMOFF,
  899. #ifdef USE_WL_FRAMEBURST
  900. SET_PARAM_FRAMEBURST,
  901. #endif /* USE_WL_FRAMEBURST */
  902. #ifdef USE_WL_TXBF
  903. SET_PARAM_TXBF,
  904. #endif /* USE_WL_TXBF */
  905. #ifdef PROP_TXSTATUS
  906. SET_PARAM_PROPTX,
  907. SET_PARAM_PROPTXMODE,
  908. #endif /* PROP_TXSTATUS */
  909. PARAM_LAST_VALUE
  910. };
  911. extern int sec_get_param_wfa_cert(dhd_pub_t *dhd, int mode, uint* read_val);
  912. #endif /* CUSTOMER_HW4 && USE_WFA_CERT_CONF */
  913. /*
  914. * Enable this macro if you want to track the calls to wake lock
  915. * This records can be printed using the following command
  916. * cat /sys/bcm-dhd/wklock_trace
  917. * DHD_TRACE_WAKE_LOCK supports over linux 2.6.0 version
  918. */
  919. #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0))
  920. #undef DHD_TRACE_WAKE_LOCK
  921. #endif /* KERNEL_VER < KERNEL_VERSION(2, 6, 0) */
  922. #if defined(DHD_TRACE_WAKE_LOCK)
  923. void dhd_wk_lock_stats_dump(dhd_pub_t *dhdp);
  924. #endif
  925. #endif /* _dhd_h_ */