bb39b77059473558dbc02f6efd6edce0fa7a3c78
[pandora-kernel.git] / drivers / staging / brcm80211 / brcmsmac / 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         u32 fw_cnt;
57         const struct firmware *fw_bin[WL_MAX_FW];
58         const struct firmware *fw_hdr[WL_MAX_FW];
59         u32 hdr_num_entries[WL_MAX_FW];
60 };
61
62 struct wl_info {
63         struct wlc_pub *pub;            /* pointer to public wlc state */
64         void *wlc;              /* pointer to private common os-independent data */
65         struct osl_info *osh;           /* pointer to os handler */
66         u32 magic;
67
68         int irq;
69
70         spinlock_t lock;        /* per-device perimeter lock */
71         spinlock_t isr_lock;    /* per-device ISR synchronization lock */
72         uint bcm_bustype;       /* bus type */
73         bool piomode;           /* set from insmod argument */
74         void *regsva;           /* opaque chip registers virtual address */
75         atomic_t callbacks;     /* # outstanding callback functions */
76         struct wl_timer *timers;        /* timer cleanup queue */
77         struct tasklet_struct tasklet;  /* dpc tasklet */
78         bool resched;           /* dpc needs to be and is rescheduled */
79 #ifdef LINUXSTA_PS
80         u32 pci_psstate[16];    /* pci ps-state save/restore */
81 #endif
82         /* RPC, handle, lock, txq, workitem */
83         uint stats_id;          /* the current set of stats */
84         /* ping-pong stats counters updated by Linux watchdog */
85         struct net_device_stats stats_watchdog[2];
86         struct wl_firmware fw;
87 };
88
89 #define WL_LOCK(wl)     spin_lock_bh(&(wl)->lock)
90 #define WL_UNLOCK(wl)   spin_unlock_bh(&(wl)->lock)
91
92 /* locking from inside wl_isr */
93 #define WL_ISRLOCK(wl, flags) do {spin_lock(&(wl)->isr_lock); (void)(flags); } while (0)
94 #define WL_ISRUNLOCK(wl, flags) do {spin_unlock(&(wl)->isr_lock); (void)(flags); } while (0)
95
96 /* locking under WL_LOCK() to synchronize with wl_isr */
97 #define INT_LOCK(wl, flags)     spin_lock_irqsave(&(wl)->isr_lock, flags)
98 #define INT_UNLOCK(wl, flags)   spin_unlock_irqrestore(&(wl)->isr_lock, flags)
99
100 #ifndef PCI_D0
101 #define PCI_D0          0
102 #endif
103
104 #ifndef PCI_D3hot
105 #define PCI_D3hot       3
106 #endif
107
108 /* exported functions */
109
110 extern irqreturn_t wl_isr(int irq, void *dev_id);
111
112 extern int __devinit wl_pci_probe(struct pci_dev *pdev,
113                                   const struct pci_device_id *ent);
114 extern void wl_free(struct wl_info *wl);
115 extern int wl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
116
117 #endif                          /* _wl_mac80211_h_ */