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