]> Pileus Git - ~andy/linux/blob - drivers/staging/brcm80211/sys/wl_mac80211.h
dcac7f571349da1fa1116d3b565814663077c1e5
[~andy/linux] / drivers / staging / brcm80211 / sys / wl_mac80211.h
1 /*
2  * Copyright (c) 2010 Broadcom Corporation
3  *
4  * Permission to use, copy, modify, and/or distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11  * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16
17 #ifndef _wl_mac80211_h_
18 #define _wl_mac80211_h_
19
20 #include <wlc_types.h>
21
22 /* BMAC Note: High-only driver is no longer working in softirq context as it needs to block and
23  * sleep so perimeter lock has to be a semaphore instead of spinlock. This requires timers to be
24  * submitted to workqueue instead of being on kernel timer
25  */
26 typedef struct wl_timer {
27         struct timer_list timer;
28         struct wl_info *wl;
29         void (*fn) (void *);
30         void *arg;              /* argument to fn */
31         uint ms;
32         bool periodic;
33         bool set;
34         struct wl_timer *next;
35 #ifdef BCMDBG
36         char *name;             /* Description of the timer */
37 #endif
38 } wl_timer_t;
39
40 /* contortion to call functions at safe time */
41 /* In 2.6.20 kernels work functions get passed a pointer to the struct work, so things
42  * will continue to work as long as the work structure is the first component of the task structure.
43  */
44 typedef struct wl_task {
45         struct work_struct work;
46         void *context;
47 } wl_task_t;
48
49 struct wl_if {
50         uint subunit;           /* WDS/BSS unit */
51         struct pci_dev *pci_dev;
52 };
53
54 #define WL_MAX_FW               4
55 struct wl_firmware {
56         uint32 fw_cnt;
57         const struct firmware *fw_bin[WL_MAX_FW];
58         const struct firmware *fw_hdr[WL_MAX_FW];
59         uint32 hdr_num_entries[WL_MAX_FW];
60 };
61
62 struct wl_info {
63         wlc_pub_t *pub;         /* pointer to public wlc state */
64         void *wlc;              /* pointer to private common os-independent data */
65         osl_t *osh;             /* pointer to os handler */
66         uint32 magic;
67
68         int irq;
69
70 #ifdef WLC_HIGH_ONLY
71         struct semaphore sem;   /* use semaphore to allow sleep */
72 #else
73         spinlock_t lock;        /* per-device perimeter lock */
74         spinlock_t isr_lock;    /* per-device ISR synchronization lock */
75 #endif
76         uint bcm_bustype;       /* bus type */
77         bool piomode;           /* set from insmod argument */
78         void *regsva;           /* opaque chip registers virtual address */
79         atomic_t callbacks;     /* # outstanding callback functions */
80         struct wl_timer *timers;        /* timer cleanup queue */
81         struct tasklet_struct tasklet;  /* dpc tasklet */
82 #ifdef BCMSDIO
83         bcmsdh_info_t *sdh;     /* pointer to sdio bus handler */
84         ulong flags;            /* current irq flags */
85 #endif                          /* BCMSDIO */
86         bool resched;           /* dpc needs to be and is rescheduled */
87 #ifdef LINUXSTA_PS
88         uint32 pci_psstate[16]; /* pci ps-state save/restore */
89 #endif
90         /* RPC, handle, lock, txq, workitem */
91 #ifdef WLC_HIGH_ONLY
92         rpc_info_t *rpc;        /* RPC handle */
93         rpc_tp_info_t *rpc_th;  /* RPC transport handle */
94         wlc_rpc_ctx_t rpc_dispatch_ctx;
95
96         bool rpcq_dispatched;   /* Avoid scheduling multiple tasks */
97         spinlock_t rpcq_lock;   /* Lock for the queue */
98         rpc_buf_t *rpcq_head;   /* RPC Q */
99         rpc_buf_t *rpcq_tail;   /* Points to the last buf */
100
101         bool txq_dispatched;    /* Avoid scheduling multiple tasks */
102         spinlock_t txq_lock;    /* Lock for the queue */
103         struct sk_buff *txq_head;       /* TX Q */
104         struct sk_buff *txq_tail;       /* Points to the last buf */
105
106         wl_task_t txq_task;     /* work queue for wl_start() */
107 #endif                          /* WLC_HIGH_ONLY */
108         uint stats_id;          /* the current set of stats */
109         /* ping-pong stats counters updated by Linux watchdog */
110         struct net_device_stats stats_watchdog[2];
111
112         struct proc_dir_entry *proc_entry;
113         char *ioctlbuf;
114         unsigned int ioctlbuf_sz;
115         wl_ioctl_t ioc;
116         int proc_state;
117         bool ioctl_in_progress;
118         struct wl_firmware fw;
119 };
120 #define WL_PROC_IDLE            (0)
121 #define WL_PROC_HAVE_IOC        (1)
122 #define WL_PROC_HAVE_BUF        (2)
123
124 #ifndef WLC_HIGH_ONLY
125 #define WL_LOCK(wl)     spin_lock_bh(&(wl)->lock)
126 #define WL_UNLOCK(wl)   spin_unlock_bh(&(wl)->lock)
127
128 /* locking from inside wl_isr */
129 #define WL_ISRLOCK(wl, flags) do {spin_lock(&(wl)->isr_lock); (void)(flags);} while (0)
130 #define WL_ISRUNLOCK(wl, flags) do {spin_unlock(&(wl)->isr_lock); (void)(flags);} while (0)
131
132 /* locking under WL_LOCK() to synchronize with wl_isr */
133 #define INT_LOCK(wl, flags)     spin_lock_irqsave(&(wl)->isr_lock, flags)
134 #define INT_UNLOCK(wl, flags)   spin_unlock_irqrestore(&(wl)->isr_lock, flags)
135 #else                           /* BCMSDIO */
136
137 #define WL_LOCK(wl)     down(&(wl)->sem)
138 #define WL_UNLOCK(wl)   up(&(wl)->sem)
139
140 #define WL_ISRLOCK(wl)
141 #define WL_ISRUNLOCK(wl)
142 #endif                          /* WLC_HIGH_ONLY */
143
144 /* handle forward declaration */
145 typedef struct wl_info wl_info_t;
146
147 #ifndef PCI_D0
148 #define PCI_D0          0
149 #endif
150
151 #ifndef PCI_D3hot
152 #define PCI_D3hot       3
153 #endif
154
155 /* exported functions */
156
157 extern irqreturn_t wl_isr(int irq, void *dev_id);
158
159 extern int __devinit wl_pci_probe(struct pci_dev *pdev,
160                                   const struct pci_device_id *ent);
161 extern void wl_free(wl_info_t *wl);
162 extern int wl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
163 extern int wl_ucode_data_init(wl_info_t *wl);
164 extern void wl_ucode_data_free(void);
165 #ifdef WLC_LOW
166 extern void wl_ucode_free_buf(void *);
167 extern int wl_ucode_init_buf(wl_info_t *wl, void **pbuf, uint32 idx);
168 extern int wl_ucode_init_uint(wl_info_t *wl, uint32 *data, uint32 idx);
169 #endif                          /* WLC_LOW */
170
171 #endif                          /* _wl_mac80211_h_ */