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