1/* 2 * Misc utility routines for WL and Apps 3 * This header file housing the define and function prototype use by 4 * both the wl driver, tools & Apps. 5 * 6 * Permission to use, copy, modify, and/or distribute this software for any 7 * purpose with or without fee is hereby granted, provided that the above 8 * copyright notice and this permission notice appear in all copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 13 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 15 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 16 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 * software in any way with any other Broadcom software provided under a license 18 * other than the GPL, without Broadcom's express prior written consent. 19 * 20 * $Id: bcmwifi.h,v 1.29.6.3 2010-08-03 17:47:04 Exp $ 21 */ 22 23 24#ifndef _bcmwifi_h_ 25#define _bcmwifi_h_ 26 27 28 29typedef uint16 chanspec_t; 30 31 32#define CH_UPPER_SB 0x01 33#define CH_LOWER_SB 0x02 34#define CH_EWA_VALID 0x04 35#define CH_20MHZ_APART 4 36#define CH_10MHZ_APART 2 37#define CH_5MHZ_APART 1 38#define CH_MAX_2G_CHANNEL 14 39#define WLC_MAX_2G_CHANNEL CH_MAX_2G_CHANNEL 40#define MAXCHANNEL 224 41 42#define WL_CHANSPEC_CHAN_MASK 0x00ff 43#define WL_CHANSPEC_CHAN_SHIFT 0 44 45#define WL_CHANSPEC_CTL_SB_MASK 0x0300 46#define WL_CHANSPEC_CTL_SB_SHIFT 8 47#define WL_CHANSPEC_CTL_SB_LOWER 0x0100 48#define WL_CHANSPEC_CTL_SB_UPPER 0x0200 49#define WL_CHANSPEC_CTL_SB_NONE 0x0300 50 51#define WL_CHANSPEC_BW_MASK 0x0C00 52#define WL_CHANSPEC_BW_SHIFT 10 53#define WL_CHANSPEC_BW_10 0x0400 54#define WL_CHANSPEC_BW_20 0x0800 55#define WL_CHANSPEC_BW_40 0x0C00 56 57#define WL_CHANSPEC_BAND_MASK 0xf000 58#define WL_CHANSPEC_BAND_SHIFT 12 59#define WL_CHANSPEC_BAND_5G 0x1000 60#define WL_CHANSPEC_BAND_2G 0x2000 61#define INVCHANSPEC 255 62 63 64#define WF_CHAN_FACTOR_2_4_G 4814 65#define WF_CHAN_FACTOR_5_G 10000 66#define WF_CHAN_FACTOR_4_G 8000 67 68 69#define LOWER_20_SB(channel) (((channel) > CH_10MHZ_APART) ? ((channel) - CH_10MHZ_APART) : 0) 70#define UPPER_20_SB(channel) (((channel) < (MAXCHANNEL - CH_10MHZ_APART)) ? \ 71 ((channel) + CH_10MHZ_APART) : 0) 72#define CHSPEC_WLCBANDUNIT(chspec) (CHSPEC_IS5G(chspec) ? BAND_5G_INDEX : BAND_2G_INDEX) 73#define CH20MHZ_CHSPEC(channel) (chanspec_t)((chanspec_t)(channel) | WL_CHANSPEC_BW_20 | \ 74 WL_CHANSPEC_CTL_SB_NONE | (((channel) <= CH_MAX_2G_CHANNEL) ? \ 75 WL_CHANSPEC_BAND_2G : WL_CHANSPEC_BAND_5G)) 76#define NEXT_20MHZ_CHAN(channel) (((channel) < (MAXCHANNEL - CH_20MHZ_APART)) ? \ 77 ((channel) + CH_20MHZ_APART) : 0) 78#define CH40MHZ_CHSPEC(channel, ctlsb) (chanspec_t) \ 79 ((channel) | (ctlsb) | WL_CHANSPEC_BW_40 | \ 80 ((channel) <= CH_MAX_2G_CHANNEL ? WL_CHANSPEC_BAND_2G : \ 81 WL_CHANSPEC_BAND_5G)) 82#define CHSPEC_CHANNEL(chspec) ((uint8)((chspec) & WL_CHANSPEC_CHAN_MASK)) 83#define CHSPEC_BAND(chspec) ((chspec) & WL_CHANSPEC_BAND_MASK) 84 85 86#define CHSPEC_CTL_SB(chspec) (chspec & WL_CHANSPEC_CTL_SB_MASK) 87#define CHSPEC_BW(chspec) (chspec & WL_CHANSPEC_BW_MASK) 88 89#ifdef WL11N_20MHZONLY 90 91#define CHSPEC_IS10(chspec) 0 92#define CHSPEC_IS20(chspec) 1 93#ifndef CHSPEC_IS40 94#define CHSPEC_IS40(chspec) 0 95#endif 96 97#else 98 99#define CHSPEC_IS10(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_10) 100#define CHSPEC_IS20(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_20) 101#ifndef CHSPEC_IS40 102#define CHSPEC_IS40(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_40) 103#endif 104 105#endif 106 107#define CHSPEC_IS20_UNCOND(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_20) 108 109#define CHSPEC_IS5G(chspec) (((chspec) & WL_CHANSPEC_BAND_MASK) == WL_CHANSPEC_BAND_5G) 110#define CHSPEC_IS2G(chspec) (((chspec) & WL_CHANSPEC_BAND_MASK) == WL_CHANSPEC_BAND_2G) 111#define CHSPEC_SB_NONE(chspec) (((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_NONE) 112#define CHSPEC_SB_UPPER(chspec) (((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_UPPER) 113#define CHSPEC_SB_LOWER(chspec) (((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_LOWER) 114#define CHSPEC_CTL_CHAN(chspec) ((CHSPEC_SB_LOWER(chspec)) ? \ 115 (LOWER_20_SB(((chspec) & WL_CHANSPEC_CHAN_MASK))) : \ 116 (UPPER_20_SB(((chspec) & WL_CHANSPEC_CHAN_MASK)))) 117#define CHSPEC2WLC_BAND(chspec) (CHSPEC_IS5G(chspec) ? WLC_BAND_5G : WLC_BAND_2G) 118 119#define CHANSPEC_STR_LEN 8 120 121 122#define WLC_MAXRATE 108 123#define WLC_RATE_1M 2 124#define WLC_RATE_2M 4 125#define WLC_RATE_5M5 11 126#define WLC_RATE_11M 22 127#define WLC_RATE_6M 12 128#define WLC_RATE_9M 18 129#define WLC_RATE_12M 24 130#define WLC_RATE_18M 36 131#define WLC_RATE_24M 48 132#define WLC_RATE_36M 72 133#define WLC_RATE_48M 96 134#define WLC_RATE_54M 108 135 136#define WLC_2G_25MHZ_OFFSET 5 137 138 139extern char * wf_chspec_ntoa(chanspec_t chspec, char *buf); 140 141 142extern chanspec_t wf_chspec_aton(char *a); 143 144 145extern bool wf_chspec_malformed(chanspec_t chanspec); 146 147 148extern uint8 wf_chspec_ctlchan(chanspec_t chspec); 149 150 151extern chanspec_t wf_chspec_ctlchspec(chanspec_t chspec); 152 153 154extern int wf_mhz2channel(uint freq, uint start_factor); 155 156 157extern int wf_channel2mhz(uint channel, uint start_factor); 158 159#endif 160