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