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