~ubuntu-branches/debian/wheezy/linux-2.6/wheezy

« back to all changes in this revision

Viewing changes to drivers/staging/brcm80211/include/bcmwifi.h

  • Committer: Bazaar Package Importer
  • Author(s): Ben Hutchings, Ben Hutchings, Aurelien Jarno, Martin Michlmayr
  • Date: 2011-04-06 13:53:30 UTC
  • mfrom: (43.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20110406135330-wjufxhd0tvn3zx4z
Tags: 2.6.38-3
[ Ben Hutchings ]
* [ppc64] Add to linux-tools package architectures (Closes: #620124)
* [amd64] Save cr4 to mmu_cr4_features at boot time (Closes: #620284)
* appletalk: Fix bugs introduced when removing use of BKL
* ALSA: Fix yet another race in disconnection
* cciss: Fix lost command issue
* ath9k: Fix kernel panic in AR2427
* ses: Avoid kernel panic when lun 0 is not mapped
* PCI/ACPI: Report ASPM support to BIOS if not disabled from command line

[ Aurelien Jarno ]
* rtlwifi: fix build when PCI is not enabled.

[ Martin Michlmayr ]
* rtlwifi: Eliminate udelay calls with too large values (Closes: #620204)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 _bcmwifi_h_
 
18
#define _bcmwifi_h_
 
19
 
 
20
/* A chanspec holds the channel number, band, bandwidth and control sideband */
 
21
typedef u16 chanspec_t;
 
22
 
 
23
/* channel defines */
 
24
#define CH_UPPER_SB                     0x01
 
25
#define CH_LOWER_SB                     0x02
 
26
#define CH_EWA_VALID                    0x04
 
27
#define CH_20MHZ_APART                  4
 
28
#define CH_10MHZ_APART                  2
 
29
#define CH_5MHZ_APART                   1       /* 2G band channels are 5 Mhz apart */
 
30
#define CH_MAX_2G_CHANNEL               14      /* Max channel in 2G band */
 
31
#define WLC_MAX_2G_CHANNEL              CH_MAX_2G_CHANNEL       /* legacy define */
 
32
#define MAXCHANNEL              224     /* max # supported channels. The max channel no is 216,
 
33
                                         * this is that + 1 rounded up to a multiple of NBBY (8).
 
34
                                         * DO NOT MAKE it > 255: channels are u8's all over
 
35
                                         */
 
36
 
 
37
#define WL_CHANSPEC_CHAN_MASK           0x00ff
 
38
#define WL_CHANSPEC_CHAN_SHIFT          0
 
39
 
 
40
#define WL_CHANSPEC_CTL_SB_MASK         0x0300
 
41
#define WL_CHANSPEC_CTL_SB_SHIFT             8
 
42
#define WL_CHANSPEC_CTL_SB_LOWER        0x0100
 
43
#define WL_CHANSPEC_CTL_SB_UPPER        0x0200
 
44
#define WL_CHANSPEC_CTL_SB_NONE         0x0300
 
45
 
 
46
#define WL_CHANSPEC_BW_MASK             0x0C00
 
47
#define WL_CHANSPEC_BW_SHIFT                10
 
48
#define WL_CHANSPEC_BW_10               0x0400
 
49
#define WL_CHANSPEC_BW_20               0x0800
 
50
#define WL_CHANSPEC_BW_40               0x0C00
 
51
 
 
52
#define WL_CHANSPEC_BAND_MASK           0xf000
 
53
#define WL_CHANSPEC_BAND_SHIFT          12
 
54
#define WL_CHANSPEC_BAND_5G             0x1000
 
55
#define WL_CHANSPEC_BAND_2G             0x2000
 
56
#define INVCHANSPEC                     255
 
57
 
 
58
/* used to calculate the chan_freq = chan_factor * 500Mhz + 5 * chan_number */
 
59
#define WF_CHAN_FACTOR_2_4_G            4814    /* 2.4 GHz band, 2407 MHz */
 
60
#define WF_CHAN_FACTOR_5_G              10000   /* 5   GHz band, 5000 MHz */
 
61
#define WF_CHAN_FACTOR_4_G              8000    /* 4.9 GHz band for Japan */
 
62
 
 
63
/* channel defines */
 
64
#define LOWER_20_SB(channel)    (((channel) > CH_10MHZ_APART) ? ((channel) - CH_10MHZ_APART) : 0)
 
65
#define UPPER_20_SB(channel)    (((channel) < (MAXCHANNEL - CH_10MHZ_APART)) ? \
 
66
                                ((channel) + CH_10MHZ_APART) : 0)
 
67
#define CHSPEC_WLCBANDUNIT(chspec)      (CHSPEC_IS5G(chspec) ? BAND_5G_INDEX : BAND_2G_INDEX)
 
68
#define CH20MHZ_CHSPEC(channel) (chanspec_t)((chanspec_t)(channel) | WL_CHANSPEC_BW_20 | \
 
69
                                WL_CHANSPEC_CTL_SB_NONE | (((channel) <= CH_MAX_2G_CHANNEL) ? \
 
70
                                WL_CHANSPEC_BAND_2G : WL_CHANSPEC_BAND_5G))
 
71
#define NEXT_20MHZ_CHAN(channel)        (((channel) < (MAXCHANNEL - CH_20MHZ_APART)) ? \
 
72
                                        ((channel) + CH_20MHZ_APART) : 0)
 
73
#define CH40MHZ_CHSPEC(channel, ctlsb)  (chanspec_t) \
 
74
                                        ((channel) | (ctlsb) | WL_CHANSPEC_BW_40 | \
 
75
                                        ((channel) <= CH_MAX_2G_CHANNEL ? WL_CHANSPEC_BAND_2G : \
 
76
                                        WL_CHANSPEC_BAND_5G))
 
77
#define CHSPEC_CHANNEL(chspec)  ((u8)((chspec) & WL_CHANSPEC_CHAN_MASK))
 
78
#define CHSPEC_BAND(chspec)     ((chspec) & WL_CHANSPEC_BAND_MASK)
 
79
 
 
80
#ifdef WL11N_20MHZONLY
 
81
 
 
82
#define CHSPEC_CTL_SB(chspec)   WL_CHANSPEC_CTL_SB_NONE
 
83
#define CHSPEC_BW(chspec)       WL_CHANSPEC_BW_20
 
84
#define CHSPEC_IS10(chspec)     0
 
85
#define CHSPEC_IS20(chspec)     1
 
86
#ifndef CHSPEC_IS40
 
87
#define CHSPEC_IS40(chspec)     0
 
88
#endif
 
89
 
 
90
#else                           /* !WL11N_20MHZONLY */
 
91
 
 
92
#define CHSPEC_CTL_SB(chspec)   ((chspec) & WL_CHANSPEC_CTL_SB_MASK)
 
93
#define CHSPEC_BW(chspec)       ((chspec) & WL_CHANSPEC_BW_MASK)
 
94
#define CHSPEC_IS10(chspec)     (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_10)
 
95
#define CHSPEC_IS20(chspec)     (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_20)
 
96
#ifndef CHSPEC_IS40
 
97
#define CHSPEC_IS40(chspec)     (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_40)
 
98
#endif
 
99
 
 
100
#endif                          /* !WL11N_20MHZONLY */
 
101
 
 
102
#define CHSPEC_IS5G(chspec)     (((chspec) & WL_CHANSPEC_BAND_MASK) == WL_CHANSPEC_BAND_5G)
 
103
#define CHSPEC_IS2G(chspec)     (((chspec) & WL_CHANSPEC_BAND_MASK) == WL_CHANSPEC_BAND_2G)
 
104
#define CHSPEC_SB_NONE(chspec)  (((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_NONE)
 
105
#define CHSPEC_SB_UPPER(chspec) (((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_UPPER)
 
106
#define CHSPEC_SB_LOWER(chspec) (((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_LOWER)
 
107
#define CHSPEC_CTL_CHAN(chspec)  ((CHSPEC_SB_LOWER(chspec)) ? \
 
108
                                  (LOWER_20_SB(((chspec) & WL_CHANSPEC_CHAN_MASK))) : \
 
109
                                  (UPPER_20_SB(((chspec) & WL_CHANSPEC_CHAN_MASK))))
 
110
#define CHSPEC2WLC_BAND(chspec) (CHSPEC_IS5G(chspec) ? WLC_BAND_5G : WLC_BAND_2G)
 
111
 
 
112
#define CHANSPEC_STR_LEN    8
 
113
 
 
114
/* defined rate in 500kbps */
 
115
#define WLC_MAXRATE     108     /* in 500kbps units */
 
116
#define WLC_RATE_1M     2       /* in 500kbps units */
 
117
#define WLC_RATE_2M     4       /* in 500kbps units */
 
118
#define WLC_RATE_5M5    11      /* in 500kbps units */
 
119
#define WLC_RATE_11M    22      /* in 500kbps units */
 
120
#define WLC_RATE_6M     12      /* in 500kbps units */
 
121
#define WLC_RATE_9M     18      /* in 500kbps units */
 
122
#define WLC_RATE_12M    24      /* in 500kbps units */
 
123
#define WLC_RATE_18M    36      /* in 500kbps units */
 
124
#define WLC_RATE_24M    48      /* in 500kbps units */
 
125
#define WLC_RATE_36M    72      /* in 500kbps units */
 
126
#define WLC_RATE_48M    96      /* in 500kbps units */
 
127
#define WLC_RATE_54M    108     /* in 500kbps units */
 
128
 
 
129
#define WLC_2G_25MHZ_OFFSET             5       /* 2.4GHz band channel offset */
 
130
 
 
131
/*
 
132
 * Verify the chanspec is using a legal set of parameters, i.e. that the
 
133
 * chanspec specified a band, bw, ctl_sb and channel and that the
 
134
 * combination could be legal given any set of circumstances.
 
135
 * RETURNS: true is the chanspec is malformed, false if it looks good.
 
136
 */
 
137
extern bool wf_chspec_malformed(chanspec_t chanspec);
 
138
 
 
139
/*
 
140
 * This function returns the channel number that control traffic is being sent on, for legacy
 
141
 * channels this is just the channel number, for 40MHZ channels it is the upper or lowre 20MHZ
 
142
 * sideband depending on the chanspec selected
 
143
 */
 
144
extern u8 wf_chspec_ctlchan(chanspec_t chspec);
 
145
 
 
146
/*
 
147
 * This function returns the chanspec that control traffic is being sent on, for legacy
 
148
 * channels this is just the chanspec, for 40MHZ channels it is the upper or lowre 20MHZ
 
149
 * sideband depending on the chanspec selected
 
150
 */
 
151
extern chanspec_t wf_chspec_ctlchspec(chanspec_t chspec);
 
152
 
 
153
/*
 
154
 * Return the channel number for a given frequency and base frequency.
 
155
 * The returned channel number is relative to the given base frequency.
 
156
 * If the given base frequency is zero, a base frequency of 5 GHz is assumed for
 
157
 * frequencies from 5 - 6 GHz, and 2.407 GHz is assumed for 2.4 - 2.5 GHz.
 
158
 *
 
159
 * Frequency is specified in MHz.
 
160
 * The base frequency is specified as (start_factor * 500 kHz).
 
161
 * Constants WF_CHAN_FACTOR_2_4_G, WF_CHAN_FACTOR_5_G are defined for
 
162
 * 2.4 GHz and 5 GHz bands.
 
163
 *
 
164
 * The returned channel will be in the range [1, 14] in the 2.4 GHz band
 
165
 * and [0, 200] otherwise.
 
166
 * -1 is returned if the start_factor is WF_CHAN_FACTOR_2_4_G and the
 
167
 * frequency is not a 2.4 GHz channel, or if the frequency is not and even
 
168
 * multiple of 5 MHz from the base frequency to the base plus 1 GHz.
 
169
 *
 
170
 * Reference 802.11 REVma, section 17.3.8.3, and 802.11B section 18.4.6.2
 
171
 */
 
172
extern int wf_mhz2channel(uint freq, uint start_factor);
 
173
 
 
174
/*
 
175
 * Return the center frequency in MHz of the given channel and base frequency.
 
176
 * The channel number is interpreted relative to the given base frequency.
 
177
 *
 
178
 * The valid channel range is [1, 14] in the 2.4 GHz band and [0, 200] otherwise.
 
179
 * The base frequency is specified as (start_factor * 500 kHz).
 
180
 * Constants WF_CHAN_FACTOR_2_4_G, WF_CHAN_FACTOR_5_G are defined for
 
181
 * 2.4 GHz and 5 GHz bands.
 
182
 * The channel range of [1, 14] is only checked for a start_factor of
 
183
 * WF_CHAN_FACTOR_2_4_G (4814).
 
184
 * Odd start_factors produce channels on .5 MHz boundaries, in which case
 
185
 * the answer is rounded down to an integral MHz.
 
186
 * -1 is returned for an out of range channel.
 
187
 *
 
188
 * Reference 802.11 REVma, section 17.3.8.3, and 802.11B section 18.4.6.2
 
189
 */
 
190
extern int wf_channel2mhz(uint channel, uint start_factor);
 
191
 
 
192
#endif                          /* _bcmwifi_h_ */