Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging-2.6
[pandora-kernel.git] / drivers / staging / brcm80211 / sys / wlc_cfg.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_cfg_h_
18 #define _wlc_cfg_h_
19
20 #define NBANDS(wlc) ((wlc)->pub->_nbands)
21 #define NBANDS_PUB(pub) ((pub)->_nbands)
22 #define NBANDS_HW(hw) ((hw)->_nbands)
23
24 #define IS_SINGLEBAND_5G(device)        0
25
26 /* Keep WLC_HIGH_ONLY, WLC_SPLIT for USB extension later on */
27 #if !defined(WLC_LOW)
28 #define WLC_HIGH_ONLY
29 #endif
30 #if !defined(WLC_LOW)
31 #define WLC_SPLIT
32 #endif
33
34 /* **** Core type/rev defaults **** */
35 #define D11_DEFAULT     0x0fffffb0      /* Supported  D11 revs: 4, 5, 7-27
36                                          * also need to update wlc.h MAXCOREREV
37                                          */
38
39 #define NPHY_DEFAULT    0x000001ff      /* Supported nphy revs:
40                                          *      0       4321a0
41                                          *      1       4321a1
42                                          *      2       4321b0/b1/c0/c1
43                                          *      3       4322a0
44                                          *      4       4322a1
45                                          *      5       4716a0
46                                          *      6       43222a0, 43224a0
47                                          *      7       43226a0
48                                          *      8       5357a0, 43236a0
49                                          */
50
51 #define LCNPHY_DEFAULT  0x00000007      /* Supported lcnphy revs:
52                                          *      0       4313a0, 4336a0, 4330a0
53                                          *      1
54                                          *      2       4330a0
55                                          */
56
57 #define SSLPNPHY_DEFAULT 0x0000000f     /* Supported sslpnphy revs:
58                                          *      0       4329a0/k0
59                                          *      1       4329b0/4329C0
60                                          *      2       4319a0
61                                          *      3       5356a0
62                                          */
63
64 #ifdef BCMSDIO
65 #define D11CONF 0x100000
66 #define SSLPNCONF 2
67 #define GCCONF  0
68 #define ACCONF  0
69 #define NCONF   0
70 #define LPCONF  0
71 #define LCNCONF 0
72 #define NTXD 32
73 #define NRXD 16
74 #define NRXBUFPOST 8
75 #define WLC_DATAHIWAT 32
76 #define RXBND 8
77 #define MAXPKTCB 64
78 #define AMPDU_NUM_MPDU 8
79 #endif
80
81 /* For undefined values, use defaults */
82 #ifndef D11CONF
83 #define D11CONF D11_DEFAULT
84 #endif
85 #ifndef NCONF
86 #define NCONF   NPHY_DEFAULT
87 #endif
88 #ifndef LCNCONF
89 #define LCNCONF LCNPHY_DEFAULT
90 #endif
91
92 #ifndef SSLPNCONF
93 #define SSLPNCONF       SSLPNPHY_DEFAULT
94 #endif
95
96 #define BAND2G
97 #define BAND5G
98 #define WLANTSEL        1
99
100 /********************************************************************
101  * Phy/Core Configuration.  Defines macros to to check core phy/rev *
102  * compile-time configuration.  Defines default core support.       *
103  * ******************************************************************
104  */
105
106 /* Basic macros to check a configuration bitmask */
107
108 #define CONF_HAS(config, val)   ((config) & (1 << (val)))
109 #define CONF_MSK(config, mask)  ((config) & (mask))
110 #define MSK_RANGE(low, hi)      ((1 << ((hi)+1)) - (1 << (low)))
111 #define CONF_RANGE(config, low, hi) (CONF_MSK(config, MSK_RANGE(low, high)))
112
113 #define CONF_IS(config, val)    ((config) == (1 << (val)))
114 #define CONF_GE(config, val)    ((config) & (0-(1 << (val))))
115 #define CONF_GT(config, val)    ((config) & (0-2*(1 << (val))))
116 #define CONF_LT(config, val)    ((config) & ((1 << (val))-1))
117 #define CONF_LE(config, val)    ((config) & (2*(1 << (val))-1))
118
119 /* Wrappers for some of the above, specific to config constants */
120
121 #define NCONF_HAS(val)  CONF_HAS(NCONF, val)
122 #define NCONF_MSK(mask) CONF_MSK(NCONF, mask)
123 #define NCONF_IS(val)   CONF_IS(NCONF, val)
124 #define NCONF_GE(val)   CONF_GE(NCONF, val)
125 #define NCONF_GT(val)   CONF_GT(NCONF, val)
126 #define NCONF_LT(val)   CONF_LT(NCONF, val)
127 #define NCONF_LE(val)   CONF_LE(NCONF, val)
128
129 #define LCNCONF_HAS(val)        CONF_HAS(LCNCONF, val)
130 #define LCNCONF_MSK(mask)       CONF_MSK(LCNCONF, mask)
131 #define LCNCONF_IS(val)         CONF_IS(LCNCONF, val)
132 #define LCNCONF_GE(val)         CONF_GE(LCNCONF, val)
133 #define LCNCONF_GT(val)         CONF_GT(LCNCONF, val)
134 #define LCNCONF_LT(val)         CONF_LT(LCNCONF, val)
135 #define LCNCONF_LE(val)         CONF_LE(LCNCONF, val)
136
137 #define D11CONF_HAS(val) CONF_HAS(D11CONF, val)
138 #define D11CONF_MSK(mask) CONF_MSK(D11CONF, mask)
139 #define D11CONF_IS(val) CONF_IS(D11CONF, val)
140 #define D11CONF_GE(val) CONF_GE(D11CONF, val)
141 #define D11CONF_GT(val) CONF_GT(D11CONF, val)
142 #define D11CONF_LT(val) CONF_LT(D11CONF, val)
143 #define D11CONF_LE(val) CONF_LE(D11CONF, val)
144
145 #define PHYCONF_HAS(val) CONF_HAS(PHYTYPE, val)
146 #define PHYCONF_IS(val) CONF_IS(PHYTYPE, val)
147
148 #define NREV_IS(var, val)       (NCONF_HAS(val) && (NCONF_IS(val) || ((var) == (val))))
149 #define NREV_GE(var, val)       (NCONF_GE(val) && (!NCONF_LT(val) || ((var) >= (val))))
150 #define NREV_GT(var, val)       (NCONF_GT(val) && (!NCONF_LE(val) || ((var) > (val))))
151 #define NREV_LT(var, val)       (NCONF_LT(val) && (!NCONF_GE(val) || ((var) < (val))))
152 #define NREV_LE(var, val)       (NCONF_LE(val) && (!NCONF_GT(val) || ((var) <= (val))))
153
154 #define LCNREV_IS(var, val)     (LCNCONF_HAS(val) && (LCNCONF_IS(val) || ((var) == (val))))
155 #define LCNREV_GE(var, val)     (LCNCONF_GE(val) && (!LCNCONF_LT(val) || ((var) >= (val))))
156 #define LCNREV_GT(var, val)     (LCNCONF_GT(val) && (!LCNCONF_LE(val) || ((var) > (val))))
157 #define LCNREV_LT(var, val)     (LCNCONF_LT(val) && (!LCNCONF_GE(val) || ((var) < (val))))
158 #define LCNREV_LE(var, val)     (LCNCONF_LE(val) && (!LCNCONF_GT(val) || ((var) <= (val))))
159
160 #define D11REV_IS(var, val)     (D11CONF_HAS(val) && (D11CONF_IS(val) || ((var) == (val))))
161 #define D11REV_GE(var, val)     (D11CONF_GE(val) && (!D11CONF_LT(val) || ((var) >= (val))))
162 #define D11REV_GT(var, val)     (D11CONF_GT(val) && (!D11CONF_LE(val) || ((var) > (val))))
163 #define D11REV_LT(var, val)     (D11CONF_LT(val) && (!D11CONF_GE(val) || ((var) < (val))))
164 #define D11REV_LE(var, val)     (D11CONF_LE(val) && (!D11CONF_GT(val) || ((var) <= (val))))
165
166 #define PHYTYPE_IS(var, val)    (PHYCONF_HAS(val) && (PHYCONF_IS(val) || ((var) == (val))))
167
168 /* Finally, early-exit from switch case if anyone wants it... */
169
170 #define CASECHECK(config, val)  if (!(CONF_HAS(config, val))) break
171 #define CASEMSK(config, mask)   if (!(CONF_MSK(config, mask))) break
172
173 #if (D11CONF ^ (D11CONF & D11_DEFAULT))
174 #error "Unsupported MAC revision configured"
175 #endif
176 #if (NCONF ^ (NCONF & NPHY_DEFAULT))
177 #error "Unsupported NPHY revision configured"
178 #endif
179 #if (LCNCONF ^ (LCNCONF & LCNPHY_DEFAULT))
180 #error "Unsupported LPPHY revision configured"
181 #endif
182
183 /* *** Consistency checks *** */
184 #if !D11CONF
185 #error "No MAC revisions configured!"
186 #endif
187
188 #if !NCONF && !LCNCONF && !SSLPNCONF
189 #error "No PHY configured!"
190 #endif
191
192 /* Set up PHYTYPE automatically: (depends on PHY_TYPE_X, from d11.h) */
193
194 #define _PHYCONF_N (1 << PHY_TYPE_N)
195
196 #if LCNCONF
197 #define _PHYCONF_LCN (1 << PHY_TYPE_LCN)
198 #else
199 #define _PHYCONF_LCN 0
200 #endif                          /* LCNCONF */
201
202 #if SSLPNCONF
203 #define _PHYCONF_SSLPN (1 << PHY_TYPE_SSN)
204 #else
205 #define _PHYCONF_SSLPN 0
206 #endif                          /* SSLPNCONF */
207
208 #define PHYTYPE (_PHYCONF_N | _PHYCONF_LCN | _PHYCONF_SSLPN)
209
210 /* Utility macro to identify 802.11n (HT) capable PHYs */
211 #define PHYTYPE_11N_CAP(phytype) \
212         (PHYTYPE_IS(phytype, PHY_TYPE_N) ||     \
213          PHYTYPE_IS(phytype, PHY_TYPE_LCN) || \
214          PHYTYPE_IS(phytype, PHY_TYPE_SSN))
215
216 /* Last but not least: shorter wlc-specific var checks */
217 #define WLCISNPHY(band)         PHYTYPE_IS((band)->phytype, PHY_TYPE_N)
218 #define WLCISLCNPHY(band)       PHYTYPE_IS((band)->phytype, PHY_TYPE_LCN)
219 #define WLCISSSLPNPHY(band)     PHYTYPE_IS((band)->phytype, PHY_TYPE_SSN)
220
221 #define WLC_PHY_11N_CAP(band)   PHYTYPE_11N_CAP((band)->phytype)
222
223 /**********************************************************************
224  * ------------- End of Core phy/rev configuration. ----------------- *
225  * ********************************************************************
226  */
227
228 /*************************************************
229  * Defaults for tunables (e.g. sizing constants)
230  *
231  * For each new tunable, add a member to the end
232  * of wlc_tunables_t in wlc_pub.h to enable
233  * runtime checks of tunable values. (Directly
234  * using the macros in code invalidates ROM code)
235  *
236  * ***********************************************
237  */
238 #ifndef NTXD
239 #define NTXD            256     /* Max # of entries in Tx FIFO based on 4kb page size */
240 #endif                          /* NTXD */
241 #ifndef NRXD
242 #define NRXD            256     /* Max # of entries in Rx FIFO based on 4kb page size */
243 #endif                          /* NRXD */
244
245 #ifndef NRXBUFPOST
246 #define NRXBUFPOST      32      /* try to keep this # rbufs posted to the chip */
247 #endif                          /* NRXBUFPOST */
248
249 #ifndef MAXSCB                  /* station control blocks in cache */
250 #define MAXSCB          32      /* Maximum SCBs in cache for STA */
251 #endif                          /* MAXSCB */
252
253 #ifndef AMPDU_NUM_MPDU
254 #define AMPDU_NUM_MPDU          16      /* max allowed number of mpdus in an ampdu (2 streams) */
255 #endif                          /* AMPDU_NUM_MPDU */
256
257 #ifndef AMPDU_NUM_MPDU_3STREAMS
258 #define AMPDU_NUM_MPDU_3STREAMS 32      /* max allowed number of mpdus in an ampdu for 3+ streams */
259 #endif                          /* AMPDU_NUM_MPDU_3STREAMS */
260
261 /* Count of packet callback structures. either of following
262  * 1. Set to the number of SCBs since a STA
263  * can queue up a rate callback for each IBSS STA it knows about, and an AP can
264  * queue up an "are you there?" Null Data callback for each associated STA
265  * 2. controlled by tunable config file
266  */
267 #ifndef MAXPKTCB
268 #define MAXPKTCB        MAXSCB  /* Max number of packet callbacks */
269 #endif                          /* MAXPKTCB */
270
271 #ifndef CTFPOOLSZ
272 #define CTFPOOLSZ       128
273 #endif                          /* CTFPOOLSZ */
274
275 /* NetBSD also needs to keep track of this */
276 #define WLC_MAX_UCODE_BSS       (16)    /* Number of BSS handled in ucode bcn/prb */
277 #define WLC_MAX_UCODE_BSS4      (4)     /* Number of BSS handled in sw bcn/prb */
278 #ifndef WLC_MAXBSSCFG
279 #define WLC_MAXBSSCFG           (1)     /* max # BSS configs */
280 #endif                          /* WLC_MAXBSSCFG */
281
282 #ifndef MAXBSS
283 #define MAXBSS          64      /* max # available networks */
284 #endif                          /* MAXBSS */
285
286 #ifndef WLC_DATAHIWAT
287 #define WLC_DATAHIWAT           50      /* data msg txq hiwat mark */
288 #endif                          /* WLC_DATAHIWAT */
289
290 #ifndef WLC_AMPDUDATAHIWAT
291 #define WLC_AMPDUDATAHIWAT 255
292 #endif                          /* WLC_AMPDUDATAHIWAT */
293
294 /* bounded rx loops */
295 #ifndef RXBND
296 #define RXBND           8       /* max # frames to process in wlc_recv() */
297 #endif                          /* RXBND */
298 #ifndef TXSBND
299 #define TXSBND          8       /* max # tx status to process in wlc_txstatus() */
300 #endif                          /* TXSBND */
301
302 #define BAND_5G(bt)     ((bt) == WLC_BAND_5G)
303 #define BAND_2G(bt)     ((bt) == WLC_BAND_2G)
304
305 #define WLBANDINITDATA(_data)   _data
306 #define WLBANDINITFN(_fn)       _fn
307
308 #define WLANTSEL_ENAB(wlc)      1
309
310 #endif                          /* _wlc_cfg_h_ */