dhd.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753
  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-2011, 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 328934 2012-04-23 05:15:42Z $
  28. */
  29. /****************
  30. * Common types *
  31. */
  32. #ifndef _dhd_h_
  33. #define _dhd_h_
  34. #if defined(CHROMIUMOS_COMPAT_WIRELESS)
  35. #include <linux/sched.h>
  36. #endif
  37. #include <linux/init.h>
  38. #include <linux/kernel.h>
  39. #include <linux/slab.h>
  40. #include <linux/skbuff.h>
  41. #include <linux/netdevice.h>
  42. #include <linux/etherdevice.h>
  43. #include <linux/random.h>
  44. #include <linux/spinlock.h>
  45. #include <linux/ethtool.h>
  46. #include <asm/uaccess.h>
  47. #include <asm/unaligned.h>
  48. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_HAS_WAKELOCK)
  49. #include <linux/wakelock.h>
  50. #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined (CONFIG_HAS_WAKELOCK) */
  51. /* The kernel threading is sdio-specific */
  52. struct task_struct;
  53. struct sched_param;
  54. int setScheduler(struct task_struct *p, int policy, struct sched_param *param);
  55. #define ALL_INTERFACES 0xff
  56. #include <wlioctl.h>
  57. /* Forward decls */
  58. struct dhd_bus;
  59. struct dhd_prot;
  60. struct dhd_info;
  61. struct dhd_cmn;
  62. /* The level of bus communication with the dongle */
  63. enum dhd_bus_state {
  64. DHD_BUS_DOWN, /* Not ready for frame transfers */
  65. DHD_BUS_LOAD, /* Download access only (CPU reset) */
  66. DHD_BUS_DATA /* Ready for frame transfers */
  67. };
  68. /* Firmware requested operation mode */
  69. #define STA_MASK 0x0001
  70. #define HOSTAPD_MASK 0x0002
  71. #define WFD_MASK 0x0004
  72. #define SOFTAP_FW_MASK 0x0008
  73. #define P2P_GO_ENABLED 0x0010
  74. #define P2P_GC_ENABLED 0x0020
  75. #define CONCURENT_MASK 0x00F0
  76. #define MANUFACTRING_FW "WLTEST"
  77. /* max sequential rxcntl timeouts to set HANG event */
  78. #define MAX_CNTL_TIMEOUT 2
  79. #define DHD_SCAN_ACTIVE_TIME 40 /* ms : Embedded default Active setting from DHD Driver */
  80. #define DHD_SCAN_PASSIVE_TIME 130 /* ms: Embedded default Passive setting from DHD Driver */
  81. #define DHD_BEACON_TIMEOUT_NORMAL 4
  82. #define DHD_BEACON_TIMEOUT_HIGH 10
  83. enum dhd_bus_wake_state {
  84. WAKE_LOCK_OFF,
  85. WAKE_LOCK_PRIV,
  86. WAKE_LOCK_DPC,
  87. WAKE_LOCK_IOCTL,
  88. WAKE_LOCK_DOWNLOAD,
  89. WAKE_LOCK_TMOUT,
  90. WAKE_LOCK_WATCHDOG,
  91. WAKE_LOCK_LINK_DOWN_TMOUT,
  92. WAKE_LOCK_PNO_FIND_TMOUT,
  93. WAKE_LOCK_SOFTAP_SET,
  94. WAKE_LOCK_SOFTAP_STOP,
  95. WAKE_LOCK_SOFTAP_START,
  96. WAKE_LOCK_SOFTAP_THREAD,
  97. WAKE_LOCK_MAX
  98. };
  99. enum dhd_prealloc_index {
  100. DHD_PREALLOC_PROT = 0,
  101. DHD_PREALLOC_RXBUF,
  102. DHD_PREALLOC_DATABUF,
  103. DHD_PREALLOC_OSL_BUF
  104. };
  105. typedef enum {
  106. DHD_IF_NONE = 0,
  107. DHD_IF_ADD,
  108. DHD_IF_DEL,
  109. DHD_IF_CHANGE,
  110. DHD_IF_DELETING
  111. } dhd_if_state_t;
  112. #if defined(CONFIG_DHD_USE_STATIC_BUF)
  113. uint8* dhd_os_prealloc(void *osh, int section, uint size);
  114. void dhd_os_prefree(void *osh, void *addr, uint size);
  115. #define DHD_OS_PREALLOC(osh, section, size) dhd_os_prealloc(osh, section, size)
  116. #define DHD_OS_PREFREE(osh, addr, size) dhd_os_prefree(osh, addr, size)
  117. #else
  118. #define DHD_OS_PREALLOC(osh, section, size) MALLOC(osh, size)
  119. #define DHD_OS_PREFREE(osh, addr, size) MFREE(osh, addr, size)
  120. #endif /* defined(CONFIG_DHD_USE_STATIC_BUF) */
  121. /* Packet alignment for most efficient SDIO (can change based on platform) */
  122. #ifndef DHD_SDALIGN
  123. #define DHD_SDALIGN 32
  124. #endif
  125. /* Common structure for module and instance linkage */
  126. typedef struct dhd_pub {
  127. /* Linkage ponters */
  128. osl_t *osh; /* OSL handle */
  129. struct dhd_bus *bus; /* Bus module handle */
  130. struct dhd_prot *prot; /* Protocol module handle */
  131. struct dhd_info *info; /* Info module handle */
  132. struct dhd_cmn *cmn; /* dhd_common module handle */
  133. /* Internal dhd items */
  134. bool up; /* Driver up/down (to OS) */
  135. bool txoff; /* Transmit flow-controlled */
  136. bool dongle_reset; /* TRUE = DEVRESET put dongle into reset */
  137. enum dhd_bus_state busstate;
  138. uint hdrlen; /* Total DHD header length (proto + bus) */
  139. uint maxctl; /* Max size rxctl request from proto to bus */
  140. uint rxsz; /* Rx buffer size bus module should use */
  141. uint8 wme_dp; /* wme discard priority */
  142. /* Dongle media info */
  143. bool iswl; /* Dongle-resident driver is wl */
  144. ulong drv_version; /* Version of dongle-resident driver */
  145. struct ether_addr mac; /* MAC address obtained from dongle */
  146. dngl_stats_t dstats; /* Stats for dongle-based data */
  147. /* Additional stats for the bus level */
  148. ulong tx_packets; /* Data packets sent to dongle */
  149. ulong tx_multicast; /* Multicast data packets sent to dongle */
  150. ulong tx_errors; /* Errors in sending data to dongle */
  151. ulong tx_ctlpkts; /* Control packets sent to dongle */
  152. ulong tx_ctlerrs; /* Errors sending control frames to dongle */
  153. ulong rx_packets; /* Packets sent up the network interface */
  154. ulong rx_multicast; /* Multicast packets sent up the network interface */
  155. ulong rx_errors; /* Errors processing rx data packets */
  156. ulong rx_ctlpkts; /* Control frames processed from dongle */
  157. ulong rx_ctlerrs; /* Errors in processing rx control frames */
  158. ulong rx_dropped; /* Packets dropped locally (no memory) */
  159. ulong rx_flushed; /* Packets flushed due to unscheduled sendup thread */
  160. ulong wd_dpc_sched; /* Number of times dhd dpc scheduled by watchdog timer */
  161. ulong rx_readahead_cnt; /* Number of packets where header read-ahead was used. */
  162. ulong tx_realloc; /* Number of tx packets we had to realloc for headroom */
  163. ulong fc_packets; /* Number of flow control pkts recvd */
  164. /* Last error return */
  165. int bcmerror;
  166. uint tickcnt;
  167. /* Last error from dongle */
  168. int dongle_error;
  169. /* Suspend disable flag and "in suspend" flag */
  170. int suspend_disable_flag; /* "1" to disable all extra powersaving during suspend */
  171. int in_suspend; /* flag set to 1 when early suspend called */
  172. #ifdef PNO_SUPPORT
  173. int pno_enable; /* pno status : "1" is pno enable */
  174. #endif /* PNO_SUPPORT */
  175. int dtim_skip; /* dtim skip , default 0 means wake each dtim */
  176. /* Pkt filter defination */
  177. char * pktfilter[100];
  178. int pktfilter_count;
  179. wl_country_t dhd_cspec; /* Current Locale info */
  180. char eventmask[WL_EVENTING_MASK_LEN];
  181. int op_mode; /* STA, HostAPD, WFD, SoftAP */
  182. /* Set this to 1 to use a seperate interface (p2p0) for p2p operations.
  183. * For ICS MR1 releases it should be disable to be compatable with ICS MR1 Framework
  184. * see target dhd-cdc-sdmmc-panda-cfg80211-icsmr1-gpl-debug in Makefile
  185. */
  186. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) && 1
  187. struct mutex wl_start_stop_lock; /* lock/unlock for Android start/stop */
  188. struct mutex wl_softap_lock; /* lock/unlock for any SoftAP/STA settings */
  189. #endif
  190. uint16 maxdatablks;
  191. #ifdef PROP_TXSTATUS
  192. int wlfc_enabled;
  193. void* wlfc_state;
  194. #endif
  195. bool dongle_isolation;
  196. int hang_was_sent;
  197. int rxcnt_timeout; /* counter rxcnt timeout to send HANG */
  198. int txcnt_timeout; /* counter txcnt timeout to send HANG */
  199. #ifdef WLMEDIA_HTSF
  200. uint8 htsfdlystat_sz; /* Size of delay stats, max 255B */
  201. #endif
  202. } dhd_pub_t;
  203. typedef struct dhd_cmn {
  204. osl_t *osh; /* OSL handle */
  205. dhd_pub_t *dhd;
  206. } dhd_cmn_t;
  207. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_PM_SLEEP)
  208. #define DHD_PM_RESUME_WAIT_INIT(a) DECLARE_WAIT_QUEUE_HEAD(a);
  209. #define _DHD_PM_RESUME_WAIT(a, b) do {\
  210. int retry = 0; \
  211. SMP_RD_BARRIER_DEPENDS(); \
  212. while (dhd_mmc_suspend && retry++ != b) { \
  213. SMP_RD_BARRIER_DEPENDS(); \
  214. wait_event_interruptible_timeout(a, !dhd_mmc_suspend, HZ/100); \
  215. } \
  216. } while (0)
  217. #define DHD_PM_RESUME_WAIT(a) _DHD_PM_RESUME_WAIT(a, 200)
  218. #define DHD_PM_RESUME_WAIT_FOREVER(a) _DHD_PM_RESUME_WAIT(a, ~0)
  219. #define DHD_PM_RESUME_RETURN_ERROR(a) do { if (dhd_mmc_suspend) return a; } while (0)
  220. #define DHD_PM_RESUME_RETURN do { if (dhd_mmc_suspend) return; } while (0)
  221. #define DHD_SPINWAIT_SLEEP_INIT(a) DECLARE_WAIT_QUEUE_HEAD(a);
  222. #define SPINWAIT_SLEEP(a, exp, us) do { \
  223. uint countdown = (us) + 9999; \
  224. while ((exp) && (countdown >= 10000)) { \
  225. wait_event_interruptible_timeout(a, FALSE, HZ/100); \
  226. countdown -= 10000; \
  227. } \
  228. } while (0)
  229. #else
  230. #define DHD_PM_RESUME_WAIT_INIT(a)
  231. #define DHD_PM_RESUME_WAIT(a)
  232. #define DHD_PM_RESUME_WAIT_FOREVER(a)
  233. #define DHD_PM_RESUME_RETURN_ERROR(a)
  234. #define DHD_PM_RESUME_RETURN
  235. #define DHD_SPINWAIT_SLEEP_INIT(a)
  236. #define SPINWAIT_SLEEP(a, exp, us) do { \
  237. uint countdown = (us) + 9; \
  238. while ((exp) && (countdown >= 10)) { \
  239. OSL_DELAY(10); \
  240. countdown -= 10; \
  241. } \
  242. } while (0)
  243. #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_PM_SLEEP) */
  244. #ifndef DHDTHREAD
  245. #undef SPINWAIT_SLEEP
  246. #define SPINWAIT_SLEEP(a, exp, us) SPINWAIT(exp, us)
  247. #endif /* DHDTHREAD */
  248. #define DHD_IF_VIF 0x01 /* Virtual IF (Hidden from user) */
  249. unsigned long dhd_os_spin_lock(dhd_pub_t *pub);
  250. void dhd_os_spin_unlock(dhd_pub_t *pub, unsigned long flags);
  251. /* Wakelock Functions */
  252. extern int dhd_os_wake_lock(dhd_pub_t *pub);
  253. extern int dhd_os_wake_unlock(dhd_pub_t *pub);
  254. extern int dhd_os_wake_lock_timeout(dhd_pub_t *pub);
  255. extern int dhd_os_wake_lock_rx_timeout_enable(dhd_pub_t *pub, int val);
  256. extern int dhd_os_wake_lock_ctrl_timeout_enable(dhd_pub_t *pub, int val);
  257. inline static void MUTEX_LOCK_SOFTAP_SET_INIT(dhd_pub_t * dhdp)
  258. {
  259. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) && 1
  260. mutex_init(&dhdp->wl_softap_lock);
  261. #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) */
  262. }
  263. inline static void MUTEX_LOCK_SOFTAP_SET(dhd_pub_t * dhdp)
  264. {
  265. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) && 1
  266. mutex_lock(&dhdp->wl_softap_lock);
  267. #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) */
  268. }
  269. inline static void MUTEX_UNLOCK_SOFTAP_SET(dhd_pub_t * dhdp)
  270. {
  271. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) && 1
  272. mutex_unlock(&dhdp->wl_softap_lock);
  273. #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) */
  274. }
  275. #define DHD_OS_WAKE_LOCK(pub) dhd_os_wake_lock(pub)
  276. #define DHD_OS_WAKE_UNLOCK(pub) dhd_os_wake_unlock(pub)
  277. #define DHD_OS_WAKE_LOCK_TIMEOUT(pub) dhd_os_wake_lock_timeout(pub)
  278. #define DHD_OS_WAKE_LOCK_RX_TIMEOUT_ENABLE(pub, val) dhd_os_wake_lock_rx_timeout_enable(pub, val)
  279. #define DHD_OS_WAKE_LOCK_CTRL_TIMEOUT_ENABLE(pub, val) dhd_os_wake_lock_ctrl_timeout_enable(pub, val)
  280. #define DHD_PACKET_TIMEOUT_MS 1000
  281. #define DHD_EVENT_TIMEOUT_MS 1500
  282. /* interface operations (register, remove) should be atomic, use this lock to prevent race
  283. * condition among wifi on/off and interface operation functions
  284. */
  285. void dhd_net_if_lock(struct net_device *dev);
  286. void dhd_net_if_unlock(struct net_device *dev);
  287. typedef struct dhd_if_event {
  288. uint8 ifidx;
  289. uint8 action;
  290. uint8 flags;
  291. uint8 bssidx;
  292. uint8 is_AP;
  293. } dhd_if_event_t;
  294. typedef enum dhd_attach_states
  295. {
  296. DHD_ATTACH_STATE_INIT = 0x0,
  297. DHD_ATTACH_STATE_NET_ALLOC = 0x1,
  298. DHD_ATTACH_STATE_DHD_ALLOC = 0x2,
  299. DHD_ATTACH_STATE_ADD_IF = 0x4,
  300. DHD_ATTACH_STATE_PROT_ATTACH = 0x8,
  301. DHD_ATTACH_STATE_WL_ATTACH = 0x10,
  302. DHD_ATTACH_STATE_THREADS_CREATED = 0x20,
  303. DHD_ATTACH_STATE_WAKELOCKS_INIT = 0x40,
  304. DHD_ATTACH_STATE_CFG80211 = 0x80,
  305. DHD_ATTACH_STATE_EARLYSUSPEND_DONE = 0x100,
  306. DHD_ATTACH_STATE_DONE = 0x200
  307. } dhd_attach_states_t;
  308. /* Value -1 means we are unsuccessful in creating the kthread. */
  309. #define DHD_PID_KT_INVALID -1
  310. /* Value -2 means we are unsuccessful in both creating the kthread and tasklet */
  311. #define DHD_PID_KT_TL_INVALID -2
  312. /*
  313. * Exported from dhd OS modules (dhd_linux/dhd_ndis)
  314. */
  315. /* To allow osl_attach/detach calls from os-independent modules */
  316. osl_t *dhd_osl_attach(void *pdev, uint bustype);
  317. void dhd_osl_detach(osl_t *osh);
  318. /* Indication from bus module regarding presence/insertion of dongle.
  319. * Return dhd_pub_t pointer, used as handle to OS module in later calls.
  320. * Returned structure should have bus and prot pointers filled in.
  321. * bus_hdrlen specifies required headroom for bus module header.
  322. */
  323. extern dhd_pub_t *dhd_attach(osl_t *osh, struct dhd_bus *bus, uint bus_hdrlen);
  324. #if defined(WLP2P) && defined(WL_CFG80211)
  325. /* To allow attach/detach calls corresponding to p2p0 interface */
  326. extern int dhd_attach_p2p(dhd_pub_t *);
  327. extern int dhd_detach_p2p(dhd_pub_t *);
  328. #endif /* WLP2P && WL_CFG80211 */
  329. extern int dhd_net_attach(dhd_pub_t *dhdp, int idx);
  330. /* Indication from bus module regarding removal/absence of dongle */
  331. extern void dhd_detach(dhd_pub_t *dhdp);
  332. extern void dhd_free(dhd_pub_t *dhdp);
  333. /* Indication from bus module to change flow-control state */
  334. extern void dhd_txflowcontrol(dhd_pub_t *dhdp, int ifidx, bool on);
  335. extern bool dhd_prec_enq(dhd_pub_t *dhdp, struct pktq *q, void *pkt, int prec);
  336. /* Receive frame for delivery to OS. Callee disposes of rxp. */
  337. extern void dhd_rx_frame(dhd_pub_t *dhdp, int ifidx, void *rxp, int numpkt, uint8 chan);
  338. /* Return pointer to interface name */
  339. extern char *dhd_ifname(dhd_pub_t *dhdp, int idx);
  340. /* Request scheduling of the bus dpc */
  341. extern void dhd_sched_dpc(dhd_pub_t *dhdp);
  342. /* Notify tx completion */
  343. extern void dhd_txcomplete(dhd_pub_t *dhdp, void *txp, bool success);
  344. /* OS independent layer functions */
  345. extern int dhd_os_proto_block(dhd_pub_t * pub);
  346. extern int dhd_os_proto_unblock(dhd_pub_t * pub);
  347. extern int dhd_os_ioctl_resp_wait(dhd_pub_t * pub, uint * condition, bool * pending);
  348. extern int dhd_os_ioctl_resp_wake(dhd_pub_t * pub);
  349. extern unsigned int dhd_os_get_ioctl_resp_timeout(void);
  350. extern void dhd_os_set_ioctl_resp_timeout(unsigned int timeout_msec);
  351. extern void * dhd_os_open_image(char * filename);
  352. extern int dhd_os_get_image_block(char * buf, int len, void * image);
  353. extern void dhd_os_close_image(void * image);
  354. extern void dhd_os_wd_timer(void *bus, uint wdtick);
  355. extern void dhd_os_sdlock(dhd_pub_t * pub);
  356. extern void dhd_os_sdunlock(dhd_pub_t * pub);
  357. extern void dhd_os_sdlock_txq(dhd_pub_t * pub);
  358. extern void dhd_os_sdunlock_txq(dhd_pub_t * pub);
  359. extern void dhd_os_sdlock_rxq(dhd_pub_t * pub);
  360. extern void dhd_os_sdunlock_rxq(dhd_pub_t * pub);
  361. extern void dhd_os_sdlock_sndup_rxq(dhd_pub_t * pub);
  362. extern void dhd_customer_gpio_wlan_ctrl(int onoff);
  363. extern int dhd_custom_get_mac_address(unsigned char *buf);
  364. extern void dhd_os_sdunlock_sndup_rxq(dhd_pub_t * pub);
  365. extern void dhd_os_sdlock_eventq(dhd_pub_t * pub);
  366. extern void dhd_os_sdunlock_eventq(dhd_pub_t * pub);
  367. extern bool dhd_os_check_hang(dhd_pub_t *dhdp, int ifidx, int ret);
  368. #ifdef PNO_SUPPORT
  369. extern int dhd_pno_enable(dhd_pub_t *dhd, int pfn_enabled);
  370. extern int dhd_pno_clean(dhd_pub_t *dhd);
  371. extern int dhd_pno_set(dhd_pub_t *dhd, wlc_ssid_t* ssids_local, int nssid,
  372. ushort scan_fr, int pno_repeat, int pno_freq_expo_max);
  373. extern int dhd_pno_get_status(dhd_pub_t *dhd);
  374. extern int dhd_dev_pno_reset(struct net_device *dev);
  375. extern int dhd_dev_pno_set(struct net_device *dev, wlc_ssid_t* ssids_local,
  376. int nssid, ushort scan_fr, int pno_repeat, int pno_freq_expo_max);
  377. extern int dhd_dev_pno_enable(struct net_device *dev, int pfn_enabled);
  378. extern int dhd_dev_get_pno_status(struct net_device *dev);
  379. #endif /* PNO_SUPPORT */
  380. #define DHD_UNICAST_FILTER_NUM 0
  381. #define DHD_BROADCAST_FILTER_NUM 1
  382. #define DHD_MULTICAST4_FILTER_NUM 2
  383. #define DHD_MULTICAST6_FILTER_NUM 3
  384. #define DHD_MDNS_FILTER_NUM 4
  385. extern int net_os_set_packet_filter(struct net_device *dev, int val);
  386. extern int net_os_rxfilter_add_remove(struct net_device *dev, int val, int num);
  387. extern int dhd_get_dtim_skip(dhd_pub_t *dhd);
  388. extern bool dhd_check_ap_wfd_mode_set(dhd_pub_t *dhd);
  389. #ifdef DHD_DEBUG
  390. extern int write_to_file(dhd_pub_t *dhd, uint8 *buf, int size);
  391. #endif /* DHD_DEBUG */
  392. #if defined(OOB_INTR_ONLY)
  393. extern int dhd_customer_oob_irq_map(unsigned long *irq_flags_ptr);
  394. #endif /* defined(OOB_INTR_ONLY) */
  395. extern void dhd_os_sdtxlock(dhd_pub_t * pub);
  396. extern void dhd_os_sdtxunlock(dhd_pub_t * pub);
  397. typedef struct {
  398. uint32 limit; /* Expiration time (usec) */
  399. uint32 increment; /* Current expiration increment (usec) */
  400. uint32 elapsed; /* Current elapsed time (usec) */
  401. uint32 tick; /* O/S tick time (usec) */
  402. } dhd_timeout_t;
  403. extern void dhd_timeout_start(dhd_timeout_t *tmo, uint usec);
  404. extern int dhd_timeout_expired(dhd_timeout_t *tmo);
  405. extern int dhd_ifname2idx(struct dhd_info *dhd, char *name);
  406. extern int dhd_net2idx(struct dhd_info *dhd, struct net_device *net);
  407. extern struct net_device * dhd_idx2net(void *pub, int ifidx);
  408. extern int wl_host_event(dhd_pub_t *dhd_pub, int *idx, void *pktdata,
  409. wl_event_msg_t *, void **data_ptr);
  410. extern void wl_event_to_host_order(wl_event_msg_t * evt);
  411. extern int dhd_wl_ioctl(dhd_pub_t *dhd_pub, int ifindex, wl_ioctl_t *ioc, void *buf, int len);
  412. extern int dhd_wl_ioctl_cmd(dhd_pub_t *dhd_pub, int cmd, void *arg, int len, uint8 set,
  413. int ifindex);
  414. extern struct dhd_cmn *dhd_common_init(osl_t *osh);
  415. extern void dhd_common_deinit(dhd_pub_t *dhd_pub, dhd_cmn_t *sa_cmn);
  416. extern int dhd_do_driver_init(struct net_device *net);
  417. extern int dhd_add_if(struct dhd_info *dhd, int ifidx, void *handle,
  418. char *name, uint8 *mac_addr, uint32 flags, uint8 bssidx);
  419. extern void dhd_del_if(struct dhd_info *dhd, int ifidx);
  420. extern void dhd_vif_add(struct dhd_info *dhd, int ifidx, char * name);
  421. extern void dhd_vif_del(struct dhd_info *dhd, int ifidx);
  422. extern void dhd_event(struct dhd_info *dhd, char *evpkt, int evlen, int ifidx);
  423. extern void dhd_vif_sendup(struct dhd_info *dhd, int ifidx, uchar *cp, int len);
  424. /* Send packet to dongle via data channel */
  425. extern int dhd_sendpkt(dhd_pub_t *dhdp, int ifidx, void *pkt);
  426. /* send up locally generated event */
  427. extern void dhd_sendup_event_common(dhd_pub_t *dhdp, wl_event_msg_t *event, void *data);
  428. /* Send event to host */
  429. extern void dhd_sendup_event(dhd_pub_t *dhdp, wl_event_msg_t *event, void *data);
  430. extern int dhd_bus_devreset(dhd_pub_t *dhdp, uint8 flag);
  431. extern uint dhd_bus_status(dhd_pub_t *dhdp);
  432. extern int dhd_bus_start(dhd_pub_t *dhdp);
  433. extern int dhd_bus_membytes(dhd_pub_t *dhdp, bool set, uint32 address, uint8 *data, uint size);
  434. extern void dhd_print_buf(void *pbuf, int len, int bytes_per_line);
  435. extern bool dhd_is_associated(dhd_pub_t *dhd, void *bss_buf, int *retval);
  436. extern uint dhd_bus_chip_id(dhd_pub_t *dhdp);
  437. #if defined(KEEP_ALIVE)
  438. extern int dhd_keep_alive_onoff(dhd_pub_t *dhd);
  439. #endif /* KEEP_ALIVE */
  440. #ifdef ARP_OFFLOAD_SUPPORT
  441. extern void dhd_arp_offload_set(dhd_pub_t * dhd, int arp_mode);
  442. extern void dhd_arp_offload_enable(dhd_pub_t * dhd, int arp_enable);
  443. #endif /* ARP_OFFLOAD_SUPPORT */
  444. typedef enum cust_gpio_modes {
  445. WLAN_RESET_ON,
  446. WLAN_RESET_OFF,
  447. WLAN_POWER_ON,
  448. WLAN_POWER_OFF
  449. } cust_gpio_modes_t;
  450. extern int wl_iw_iscan_set_scan_broadcast_prep(struct net_device *dev, uint flag);
  451. extern int wl_iw_send_priv_event(struct net_device *dev, char *flag);
  452. /*
  453. * Insmod parameters for debug/test
  454. */
  455. /* Watchdog timer interval */
  456. extern uint dhd_watchdog_ms;
  457. #if defined(DHD_DEBUG)
  458. /* Console output poll interval */
  459. extern uint dhd_console_ms;
  460. extern uint wl_msg_level;
  461. #endif /* defined(DHD_DEBUG) */
  462. /* Use interrupts */
  463. extern uint dhd_intr;
  464. /* Use polling */
  465. extern uint dhd_poll;
  466. /* ARP offload agent mode */
  467. extern uint dhd_arp_mode;
  468. /* ARP offload enable */
  469. extern uint dhd_arp_enable;
  470. /* Pkt filte enable control */
  471. extern uint dhd_pkt_filter_enable;
  472. /* Pkt filter init setup */
  473. extern uint dhd_pkt_filter_init;
  474. /* Pkt filter mode control */
  475. extern uint dhd_master_mode;
  476. /* Roaming mode control */
  477. extern uint dhd_roam_disable;
  478. /* Roaming mode control */
  479. extern uint dhd_radio_up;
  480. /* Initial idletime ticks (may be -1 for immediate idle, 0 for no idle) */
  481. extern int dhd_idletime;
  482. #define DHD_IDLETIME_TICKS 1
  483. /* SDIO Drive Strength */
  484. extern uint dhd_sdiod_drive_strength;
  485. /* Override to force tx queueing all the time */
  486. extern uint dhd_force_tx_queueing;
  487. /* Default KEEP_ALIVE Period is 55 sec to prevent AP from sending Keep Alive probe frame */
  488. #define KEEP_ALIVE_PERIOD 55000
  489. #define NULL_PKT_STR "null_pkt"
  490. #ifdef SDTEST
  491. /* Echo packet generator (SDIO), pkts/s */
  492. extern uint dhd_pktgen;
  493. /* Echo packet len (0 => sawtooth, max 1800) */
  494. extern uint dhd_pktgen_len;
  495. #define MAX_PKTGEN_LEN 1800
  496. #endif
  497. /* optionally set by a module_param_string() */
  498. #define MOD_PARAM_PATHLEN 2048
  499. extern char fw_path[MOD_PARAM_PATHLEN];
  500. extern char nv_path[MOD_PARAM_PATHLEN];
  501. #ifdef SOFTAP
  502. extern char fw_path2[MOD_PARAM_PATHLEN];
  503. #endif
  504. /* Flag to indicate if we should download firmware on driver load */
  505. extern uint dhd_download_fw_on_driverload;
  506. /* For supporting multiple interfaces */
  507. #define DHD_MAX_IFS 16
  508. #define DHD_DEL_IF -0xe
  509. #define DHD_BAD_IF -0xf
  510. #ifdef PROP_TXSTATUS
  511. /* Please be mindful that total pkttag space is 32 octets only */
  512. typedef struct dhd_pkttag {
  513. /*
  514. b[11 ] - 1 = this packet was sent in response to one time packet request,
  515. do not increment credit on status for this one. [WLFC_CTL_TYPE_MAC_REQUEST_PACKET].
  516. b[10 ] - 1 = signal-only-packet to firmware [i.e. nothing to piggyback on]
  517. b[9 ] - 1 = packet is host->firmware (transmit direction)
  518. - 0 = packet received from firmware (firmware->host)
  519. b[8 ] - 1 = packet was sent due to credit_request (pspoll),
  520. packet does not count against FIFO credit.
  521. - 0 = normal transaction, packet counts against FIFO credit
  522. b[7 ] - 1 = AP, 0 = STA
  523. b[6:4] - AC FIFO number
  524. b[3:0] - interface index
  525. */
  526. uint16 if_flags;
  527. /* destination MAC address for this packet so that not every
  528. module needs to open the packet to find this
  529. */
  530. uint8 dstn_ether[ETHER_ADDR_LEN];
  531. /*
  532. This 32-bit goes from host to device for every packet.
  533. */
  534. uint32 htod_tag;
  535. /* bus specific stuff */
  536. union {
  537. struct {
  538. void* stuff;
  539. uint32 thing1;
  540. uint32 thing2;
  541. } sd;
  542. struct {
  543. void* bus;
  544. void* urb;
  545. } usb;
  546. } bus_specific;
  547. } dhd_pkttag_t;
  548. #define DHD_PKTTAG_SET_H2DTAG(tag, h2dvalue) ((dhd_pkttag_t*)(tag))->htod_tag = (h2dvalue)
  549. #define DHD_PKTTAG_H2DTAG(tag) (((dhd_pkttag_t*)(tag))->htod_tag)
  550. #define DHD_PKTTAG_IFMASK 0xf
  551. #define DHD_PKTTAG_IFTYPE_MASK 0x1
  552. #define DHD_PKTTAG_IFTYPE_SHIFT 7
  553. #define DHD_PKTTAG_FIFO_MASK 0x7
  554. #define DHD_PKTTAG_FIFO_SHIFT 4
  555. #define DHD_PKTTAG_SIGNALONLY_MASK 0x1
  556. #define DHD_PKTTAG_SIGNALONLY_SHIFT 10
  557. #define DHD_PKTTAG_ONETIMEPKTRQST_MASK 0x1
  558. #define DHD_PKTTAG_ONETIMEPKTRQST_SHIFT 11
  559. #define DHD_PKTTAG_PKTDIR_MASK 0x1
  560. #define DHD_PKTTAG_PKTDIR_SHIFT 9
  561. #define DHD_PKTTAG_CREDITCHECK_MASK 0x1
  562. #define DHD_PKTTAG_CREDITCHECK_SHIFT 8
  563. #define DHD_PKTTAG_INVALID_FIFOID 0x7
  564. #define DHD_PKTTAG_SETFIFO(tag, fifo) ((dhd_pkttag_t*)(tag))->if_flags = \
  565. (((dhd_pkttag_t*)(tag))->if_flags & ~(DHD_PKTTAG_FIFO_MASK << DHD_PKTTAG_FIFO_SHIFT)) | \
  566. (((fifo) & DHD_PKTTAG_FIFO_MASK) << DHD_PKTTAG_FIFO_SHIFT)
  567. #define DHD_PKTTAG_FIFO(tag) ((((dhd_pkttag_t*)(tag))->if_flags >> \
  568. DHD_PKTTAG_FIFO_SHIFT) & DHD_PKTTAG_FIFO_MASK)
  569. #define DHD_PKTTAG_SETIF(tag, if) ((dhd_pkttag_t*)(tag))->if_flags = \
  570. (((dhd_pkttag_t*)(tag))->if_flags & ~DHD_PKTTAG_IFMASK) | ((if) & DHD_PKTTAG_IFMASK)
  571. #define DHD_PKTTAG_IF(tag) (((dhd_pkttag_t*)(tag))->if_flags & DHD_PKTTAG_IFMASK)
  572. #define DHD_PKTTAG_SETIFTYPE(tag, isAP) ((dhd_pkttag_t*)(tag))->if_flags = \
  573. (((dhd_pkttag_t*)(tag))->if_flags & \
  574. ~(DHD_PKTTAG_IFTYPE_MASK << DHD_PKTTAG_IFTYPE_SHIFT)) | \
  575. (((isAP) & DHD_PKTTAG_IFTYPE_MASK) << DHD_PKTTAG_IFTYPE_SHIFT)
  576. #define DHD_PKTTAG_IFTYPE(tag) ((((dhd_pkttag_t*)(tag))->if_flags >> \
  577. DHD_PKTTAG_IFTYPE_SHIFT) & DHD_PKTTAG_IFTYPE_MASK)
  578. #define DHD_PKTTAG_SETCREDITCHECK(tag, check) ((dhd_pkttag_t*)(tag))->if_flags = \
  579. (((dhd_pkttag_t*)(tag))->if_flags & \
  580. ~(DHD_PKTTAG_CREDITCHECK_MASK << DHD_PKTTAG_CREDITCHECK_SHIFT)) | \
  581. (((check) & DHD_PKTTAG_CREDITCHECK_MASK) << DHD_PKTTAG_CREDITCHECK_SHIFT)
  582. #define DHD_PKTTAG_CREDITCHECK(tag) ((((dhd_pkttag_t*)(tag))->if_flags >> \
  583. DHD_PKTTAG_CREDITCHECK_SHIFT) & DHD_PKTTAG_CREDITCHECK_MASK)
  584. #define DHD_PKTTAG_SETPKTDIR(tag, dir) ((dhd_pkttag_t*)(tag))->if_flags = \
  585. (((dhd_pkttag_t*)(tag))->if_flags & \
  586. ~(DHD_PKTTAG_PKTDIR_MASK << DHD_PKTTAG_PKTDIR_SHIFT)) | \
  587. (((dir) & DHD_PKTTAG_PKTDIR_MASK) << DHD_PKTTAG_PKTDIR_SHIFT)
  588. #define DHD_PKTTAG_PKTDIR(tag) ((((dhd_pkttag_t*)(tag))->if_flags >> \
  589. DHD_PKTTAG_PKTDIR_SHIFT) & DHD_PKTTAG_PKTDIR_MASK)
  590. #define DHD_PKTTAG_SETSIGNALONLY(tag, signalonly) ((dhd_pkttag_t*)(tag))->if_flags = \
  591. (((dhd_pkttag_t*)(tag))->if_flags & \
  592. ~(DHD_PKTTAG_SIGNALONLY_MASK << DHD_PKTTAG_SIGNALONLY_SHIFT)) | \
  593. (((signalonly) & DHD_PKTTAG_SIGNALONLY_MASK) << DHD_PKTTAG_SIGNALONLY_SHIFT)
  594. #define DHD_PKTTAG_SIGNALONLY(tag) ((((dhd_pkttag_t*)(tag))->if_flags >> \
  595. DHD_PKTTAG_SIGNALONLY_SHIFT) & DHD_PKTTAG_SIGNALONLY_MASK)
  596. #define DHD_PKTTAG_SETONETIMEPKTRQST(tag) ((dhd_pkttag_t*)(tag))->if_flags = \
  597. (((dhd_pkttag_t*)(tag))->if_flags & \
  598. ~(DHD_PKTTAG_ONETIMEPKTRQST_MASK << DHD_PKTTAG_ONETIMEPKTRQST_SHIFT)) | \
  599. (1 << DHD_PKTTAG_ONETIMEPKTRQST_SHIFT)
  600. #define DHD_PKTTAG_ONETIMEPKTRQST(tag) ((((dhd_pkttag_t*)(tag))->if_flags >> \
  601. DHD_PKTTAG_ONETIMEPKTRQST_SHIFT) & DHD_PKTTAG_ONETIMEPKTRQST_MASK)
  602. #define DHD_PKTTAG_SETDSTN(tag, dstn_MAC_ea) memcpy(((dhd_pkttag_t*)((tag)))->dstn_ether, \
  603. (dstn_MAC_ea), ETHER_ADDR_LEN)
  604. #define DHD_PKTTAG_DSTN(tag) ((dhd_pkttag_t*)(tag))->dstn_ether
  605. typedef int (*f_commitpkt_t)(void* ctx, void* p);
  606. #ifdef PROP_TXSTATUS_DEBUG
  607. #define DHD_WLFC_CTRINC_MAC_CLOSE(entry) do { (entry)->closed_ct++; } while (0)
  608. #define DHD_WLFC_CTRINC_MAC_OPEN(entry) do { (entry)->opened_ct++; } while (0)
  609. #else
  610. #define DHD_WLFC_CTRINC_MAC_CLOSE(entry) do {} while (0)
  611. #define DHD_WLFC_CTRINC_MAC_OPEN(entry) do {} while (0)
  612. #endif
  613. #endif /* PROP_TXSTATUS */
  614. extern void dhd_wait_for_event(dhd_pub_t *dhd, bool *lockvar);
  615. extern void dhd_wait_event_wakeup(dhd_pub_t*dhd);
  616. #ifdef ARP_OFFLOAD_SUPPORT
  617. #define MAX_IPV4_ENTRIES 8
  618. /* dhd_commn arp offload wrapers */
  619. void dhd_aoe_hostip_clr(dhd_pub_t *dhd);
  620. void dhd_aoe_arp_clr(dhd_pub_t *dhd);
  621. int dhd_arp_get_arp_hostip_table(dhd_pub_t *dhd, void *buf, int buflen);
  622. void dhd_arp_offload_add_ip(dhd_pub_t *dhd, uint32 ipaddr);
  623. #endif /* ARP_OFFLOAD_SUPPORT */
  624. #endif /* _dhd_h_ */