c878690c06276a5c5aca6ddb0dbf20edc6d7d4f3
[linux-drm-fsl-dcu.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 /* BMAC Note: High-only driver is no longer working in softirq context as it needs to block and
21  * sleep so perimeter lock has to be a semaphore instead of spinlock. This requires timers to be
22  * submitted to workqueue instead of being on kernel timer
23  */
24 struct wl_timer {
25         struct timer_list timer;
26         struct wl_info *wl;
27         void (*fn) (void *);
28         void *arg;              /* argument to fn */
29         uint ms;
30         bool periodic;
31         bool set;
32         struct wl_timer *next;
33 #ifdef BCMDBG
34         char *name;             /* Description of the timer */
35 #endif
36 };
37
38 struct wl_if {
39         uint subunit;           /* WDS/BSS unit */
40         struct pci_dev *pci_dev;
41 };
42
43 #define WL_MAX_FW               4
44 struct wl_firmware {
45         u32 fw_cnt;
46         const struct firmware *fw_bin[WL_MAX_FW];
47         const struct firmware *fw_hdr[WL_MAX_FW];
48         u32 hdr_num_entries[WL_MAX_FW];
49 };
50
51 struct wl_info {
52         struct wlc_pub *pub;            /* pointer to public wlc state */
53         void *wlc;              /* pointer to private common os-independent data */
54         u32 magic;
55
56         int irq;
57
58         spinlock_t lock;        /* per-device perimeter lock */
59         spinlock_t isr_lock;    /* per-device ISR synchronization lock */
60
61         /* bus type and regsva for unmap in wl_free() */
62         uint bcm_bustype;       /* bus type */
63         void *regsva;           /* opaque chip registers virtual address */
64
65         /* timer related fields */
66         atomic_t callbacks;     /* # outstanding callback functions */
67         struct wl_timer *timers;        /* timer cleanup queue */
68
69         struct tasklet_struct tasklet;  /* dpc tasklet */
70         bool resched;           /* dpc needs to be and is rescheduled */
71 #ifdef LINUXSTA_PS
72         u32 pci_psstate[16];    /* pci ps-state save/restore */
73 #endif
74         struct wl_firmware fw;
75         struct wiphy *wiphy;
76 };
77
78 #define WL_LOCK(wl)     spin_lock_bh(&(wl)->lock)
79 #define WL_UNLOCK(wl)   spin_unlock_bh(&(wl)->lock)
80
81 /* locking from inside wl_isr */
82 #define WL_ISRLOCK(wl, flags) do {spin_lock(&(wl)->isr_lock); (void)(flags); } while (0)
83 #define WL_ISRUNLOCK(wl, flags) do {spin_unlock(&(wl)->isr_lock); (void)(flags); } while (0)
84
85 /* locking under WL_LOCK() to synchronize with wl_isr */
86 #define INT_LOCK(wl, flags)     spin_lock_irqsave(&(wl)->isr_lock, flags)
87 #define INT_UNLOCK(wl, flags)   spin_unlock_irqrestore(&(wl)->isr_lock, flags)
88
89 #endif                          /* _wl_mac80211_h_ */