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