]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - drivers/staging/brcm80211/sys/wlc_scb.h
Staging: Add initial release of brcm80211 - Broadcom 802.11n wireless LAN driver.
[mirror_ubuntu-artful-kernel.git] / drivers / staging / brcm80211 / sys / wlc_scb.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 _wlc_scb_h_
18 #define _wlc_scb_h_
19
20 #include <proto/802.1d.h>
21
22 extern bool wlc_aggregatable(wlc_info_t * wlc, uint8 tid);
23
24 #define AMPDU_TX_BA_MAX_WSIZE 64 /* max Tx ba window size (in pdu) */
25 /* structure to store per-tid state for the ampdu initiator */
26 typedef struct scb_ampdu_tid_ini {
27 uint32 magic;
28 uint8 tx_in_transit; /* number of pending mpdus in transit in driver */
29 uint8 tid; /* initiator tid for easy lookup */
30 uint8 txretry[AMPDU_TX_BA_MAX_WSIZE]; /* tx retry count; indexed by seq modulo */
31 struct scb *scb; /* backptr for easy lookup */
32 } scb_ampdu_tid_ini_t;
33
34 #define AMPDU_MAX_SCB_TID NUMPRIO
35
36 typedef struct scb_ampdu {
37 struct scb *scb; /* back pointer for easy reference */
38 uint8 mpdu_density; /* mpdu density */
39 uint8 max_pdu; /* max pdus allowed in ampdu */
40 uint8 release; /* # of mpdus released at a time */
41 uint16 min_len; /* min mpdu len to support the density */
42 uint32 max_rxlen; /* max ampdu rcv length; 8k, 16k, 32k, 64k */
43 struct pktq txq; /* sdu transmit queue pending aggregation */
44
45 /* This could easily be a ini[] pointer and we keep this info in wl itself instead
46 * of having mac80211 hold it for us. Also could be made dynamic per tid instead of
47 * static.
48 */
49 scb_ampdu_tid_ini_t ini[AMPDU_MAX_SCB_TID]; /* initiator info - per tid (NUMPRIO) */
50 } scb_ampdu_t;
51
52 #define SCB_MAGIC 0xbeefcafe
53 #define INI_MAGIC 0xabcd1234
54
55 /* station control block - one per remote MAC address */
56 struct scb {
57 uint32 magic;
58 uint32 flags; /* various bit flags as defined below */
59 uint32 flags2; /* various bit flags2 as defined below */
60 uint8 state; /* current state bitfield of auth/assoc process */
61 struct ether_addr ea; /* station address */
62 void *fragbuf[NUMPRIO]; /* defragmentation buffer per prio */
63 uint fragresid[NUMPRIO]; /* #bytes unused in frag buffer per prio */
64
65 uint16 seqctl[NUMPRIO]; /* seqctl of last received frame (for dups) */
66 uint16 seqctl_nonqos; /* seqctl of last received frame (for dups) for
67 * non-QoS data and management
68 */
69 uint16 seqnum[NUMPRIO]; /* WME: driver maintained sw seqnum per priority */
70
71 scb_ampdu_t scb_ampdu; /* AMPDU state including per tid info */
72 };
73
74 /* SCB flags */
75 #define SCB_NONERP 0x0001 /* No ERP */
76 #define SCB_LONGSLOT 0x0002 /* Long Slot */
77 #define SCB_SHORTPREAMBLE 0x0004 /* Short Preamble ok */
78 #define SCB_8021XHDR 0x0008 /* 802.1x Header */
79 #define SCB_WPA_SUP 0x0010 /* 0 - authenticator, 1 - supplicant */
80 #define SCB_DEAUTH 0x0020 /* 0 - ok to deauth, 1 - no (just did) */
81 #define SCB_WMECAP 0x0040 /* WME Cap; may ONLY be set if WME_ENAB(wlc) */
82 #define SCB_BRCM 0x0100 /* BRCM AP or STA */
83 #define SCB_WDS_LINKUP 0x0200 /* WDS link up */
84 #define SCB_RESERVED1 0x0400
85 #define SCB_RESERVED2 0x0800
86 #define SCB_MYAP 0x1000 /* We are associated to this AP */
87 #define SCB_PENDING_PROBE 0x2000 /* Probe is pending to this SCB */
88 #define SCB_AMSDUCAP 0x4000 /* A-MSDU capable */
89 #define SCB_BACAP 0x8000 /* pre-n blockack capable */
90 #define SCB_HTCAP 0x10000 /* HT (MIMO) capable device */
91 #define SCB_RECV_PM 0x20000 /* state of PM bit in last data frame recv'd */
92 #define SCB_AMPDUCAP 0x40000 /* A-MPDU capable */
93 #define SCB_IS40 0x80000 /* 40MHz capable */
94 #define SCB_NONGF 0x100000 /* Not Green Field capable */
95 #define SCB_APSDCAP 0x200000 /* APSD capable */
96 #define SCB_PENDING_FREE 0x400000 /* marked for deletion - clip recursion */
97 #define SCB_PENDING_PSPOLL 0x800000 /* PS-Poll is pending to this SCB */
98 #define SCB_RIFSCAP 0x1000000 /* RIFS capable */
99 #define SCB_HT40INTOLERANT 0x2000000 /* 40 Intolerant */
100 #define SCB_WMEPS 0x4000000 /* PS + WME w/o APSD capable */
101 #define SCB_SENT_APSD_TRIG 0x8000000 /* APSD Trigger Null Frame was recently sent */
102 #define SCB_COEX_MGMT 0x10000000 /* Coexistence Management supported */
103 #define SCB_IBSS_PEER 0x20000000 /* Station is an IBSS peer */
104 #define SCB_STBCCAP 0x40000000 /* STBC Capable */
105
106 /* scb flags2 */
107 #define SCB2_SGI20_CAP 0x00000001 /* 20MHz SGI Capable */
108 #define SCB2_SGI40_CAP 0x00000002 /* 40MHz SGI Capable */
109 #define SCB2_RX_LARGE_AGG 0x00000004 /* device can rx large aggs */
110 #define SCB2_INTERNAL 0x00000008 /* This scb is an internal scb */
111 #define SCB2_IN_ASSOC 0x00000010 /* Incoming assocation in progress */
112 #define SCB2_RESERVED1 0x00000040
113 #define SCB2_LDPCCAP 0x00000080 /* LDPC Cap */
114
115 /* scb association state bitfield */
116 #define UNAUTHENTICATED 0 /* unknown */
117 #define AUTHENTICATED 1 /* 802.11 authenticated (open or shared key) */
118 #define ASSOCIATED 2 /* 802.11 associated */
119 #define PENDING_AUTH 4 /* Waiting for 802.11 authentication response */
120 #define PENDING_ASSOC 8 /* Waiting for 802.11 association response */
121 #define AUTHORIZED 0x10 /* 802.1X authorized */
122 #define TAKEN4IBSS 0x80 /* Taken */
123
124 /* scb association state helpers */
125 #define SCB_ASSOCIATED(a) ((a)->state & ASSOCIATED)
126 #define SCB_AUTHENTICATED(a) ((a)->state & AUTHENTICATED)
127 #define SCB_AUTHORIZED(a) ((a)->state & AUTHORIZED)
128
129 /* flag access */
130 #define SCB_ISMYAP(a) ((a)->flags & SCB_MYAP)
131 #define SCB_ISPERMANENT(a) ((a)->permanent)
132 #define SCB_INTERNAL(a) ((a)->flags2 & SCB2_INTERNAL)
133 /* scb association state helpers w/ respect to ssid (in case of multi ssids)
134 * The bit set in the bit field is relative to the current state (i.e. if
135 * the current state is "associated", a 1 at the position "i" means the
136 * sta is associated to ssid "i"
137 */
138 #define SCB_ASSOCIATED_BSSCFG(a, i) \
139 (((a)->state & ASSOCIATED) && isset(&(scb->auth_bsscfg), i))
140
141 #define SCB_AUTHENTICATED_BSSCFG(a, i) \
142 (((a)->state & AUTHENTICATED) && isset(&(scb->auth_bsscfg), i))
143
144 #define SCB_AUTHORIZED_BSSCFG(a, i) \
145 (((a)->state & AUTHORIZED) && isset(&(scb->auth_bsscfg), i))
146
147 #define SCB_LONG_TIMEOUT 3600 /* # seconds of idle time after which we proactively
148 * free an authenticated SCB
149 */
150 #define SCB_SHORT_TIMEOUT 60 /* # seconds of idle time after which we will reclaim an
151 * authenticated SCB if we would otherwise fail
152 * an SCB allocation.
153 */
154 #define SCB_TIMEOUT 60 /* # seconds: interval to probe idle STAs */
155 #define SCB_ACTIVITY_TIME 5 /* # seconds: skip probe if activity during this time */
156 #define SCB_GRACE_ATTEMPTS 3 /* # attempts to probe sta beyond scb_activity_time */
157
158 /* scb_info macros */
159 #define SCB_PS(a) NULL
160 #define SCB_WDS(a) NULL
161 #define SCB_INTERFACE(a) ((a)->bsscfg->wlcif->wlif)
162 #define SCB_WLCIFP(a) (((a)->bsscfg->wlcif))
163 #define WLC_BCMC_PSMODE(wlc, bsscfg) (TRUE)
164
165 #define SCB_WME(a) ((a)->flags & SCB_WMECAP) /* Also implies WME_ENAB(wlc) */
166
167 #define SCB_AMPDU(a) TRUE
168 #define SCB_AMSDU(a) FALSE
169
170 #define SCB_HT_CAP(a) ((a)->flags & SCB_HTCAP)
171 #define SCB_ISGF_CAP(a) (((a)->flags & (SCB_HTCAP | SCB_NONGF)) == SCB_HTCAP)
172 #define SCB_NONGF_CAP(a) (((a)->flags & (SCB_HTCAP | SCB_NONGF)) == \
173 (SCB_HTCAP | SCB_NONGF))
174 #define SCB_COEX_CAP(a) ((a)->flags & SCB_COEX_MGMT)
175 #define SCB_STBC_CAP(a) ((a)->flags & SCB_STBCCAP)
176 #define SCB_LDPC_CAP(a) (SCB_HT_CAP(a) && ((a)->flags2 & SCB2_LDPCCAP))
177
178 #define SCB_IS_IBSS_PEER(a) ((a)->flags & SCB_IBSS_PEER)
179 #define SCB_SET_IBSS_PEER(a) ((a)->flags |= SCB_IBSS_PEER)
180 #define SCB_UNSET_IBSS_PEER(a) ((a)->flags &= ~SCB_IBSS_PEER)
181
182 #define SCB_11E(a) FALSE
183
184 #define SCB_QOS(a) ((a)->flags & (SCB_WMECAP | SCB_HTCAP))
185
186 #define SCB_BSSCFG(a) ((a)->bsscfg)
187
188 #define SCB_SEQNUM(scb, prio) (scb)->seqnum[(prio)]
189
190 #define SCB_ISMULTI(a) ETHER_ISMULTI((a)->ea.octet)
191 #define SCB_ISVALID(a, _pkttag_dbgid) ((a) && (a)->_dbgid == (_pkttag_dbgid))
192
193 /* API for accessing SCB pointer in WLPKTTAG */
194 #ifdef BCMDBG
195 #define WLPKTTAGSCBSET(p, scb) { WLPKTTAG(p)->_scb = scb; WLPKTTAG(p)->_scb_dbgid = scb->_dbgid; }
196 #define WLPKTTAGSCBCLR(p) { WLPKTTAG(p)->_scb = NULL; WLPKTTAG(p)->_scb_dbgid = 0; }
197 #else
198 #define WLPKTTAGSCBSET(p, scb) (WLPKTTAG(p)->_scb = scb)
199 #define WLPKTTAGSCBCLR(p) (WLPKTTAG(p)->_scb = NULL)
200 #endif
201
202 #define WLCNTSCBINCR(a) /* No stats support */
203 #define WLCNTSCBDECR(a) /* No stats support */
204 #define WLCNTSCBADD(a,delta) /* No stats support */
205 #define WLCNTSCBSET(a,value) /* No stats support */
206 #define WLCNTSCBVAL(a) 0 /* No stats support */
207 #define WLCNTSCB_COND_SET(c, a, v) /* No stats support */
208 #define WLCNTSCB_COND_ADD(c, a, d) /* No stats support */
209 #define WLCNTSCB_COND_INCR(c, a) /* No stats support */
210
211 #endif /* _wlc_scb_h_ */