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