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