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