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