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.
20 #include <linux/bcma/bcma.h>
21 #include <brcmu_wifi.h>
25 #define BRCMS_NUMRATES 16 /* max # of rates in a rateset */
28 #define PHY_TYPE_A 0 /* Phy type A */
29 #define PHY_TYPE_G 2 /* Phy type G */
30 #define PHY_TYPE_N 4 /* Phy type N */
31 #define PHY_TYPE_LP 5 /* Phy type Low Power A/B/G */
32 #define PHY_TYPE_SSN 6 /* Phy type Single Stream N */
33 #define PHY_TYPE_LCN 8 /* Phy type Single Stream N */
34 #define PHY_TYPE_LCNXN 9 /* Phy type 2-stream N */
35 #define PHY_TYPE_HT 7 /* Phy type 3-Stream N */
38 #define BRCMS_10_MHZ 10 /* 10Mhz nphy channel bandwidth */
39 #define BRCMS_20_MHZ 20 /* 20Mhz nphy channel bandwidth */
40 #define BRCMS_40_MHZ 40 /* 40Mhz nphy channel bandwidth */
42 #define BRCMS_RSSI_MINVAL -200 /* Low value, e.g. for forcing roam */
43 #define BRCMS_RSSI_NO_SIGNAL -91 /* NDIS RSSI link quality cutoffs */
44 #define BRCMS_RSSI_VERY_LOW -80 /* Very low quality cutoffs */
45 #define BRCMS_RSSI_LOW -70 /* Low quality cutoffs */
46 #define BRCMS_RSSI_GOOD -68 /* Good quality cutoffs */
47 #define BRCMS_RSSI_VERY_GOOD -58 /* Very good quality cutoffs */
48 #define BRCMS_RSSI_EXCELLENT -57 /* Excellent quality cutoffs */
50 /* a large TX Power as an init value to factor out of min() calculations,
51 * keep low enough to fit in an s8, units are .25 dBm
53 #define BRCMS_TXPWR_MAX (127) /* ~32 dBm = 1,500 mW */
55 /* rate related definitions */
56 #define BRCMS_RATE_FLAG 0x80 /* Flag to indicate it is a basic rate */
57 #define BRCMS_RATE_MASK 0x7f /* Rate value mask w/o basic rate flag */
59 /* legacy rx Antenna diversity for SISO rates */
60 #define ANT_RX_DIV_FORCE_0 0 /* Use antenna 0 */
61 #define ANT_RX_DIV_FORCE_1 1 /* Use antenna 1 */
62 #define ANT_RX_DIV_START_1 2 /* Choose starting with 1 */
63 #define ANT_RX_DIV_START_0 3 /* Choose starting with 0 */
64 #define ANT_RX_DIV_ENABLE 3 /* APHY bbConfig Enable RX Diversity */
65 /* default antdiv setting */
66 #define ANT_RX_DIV_DEF ANT_RX_DIV_START_0
68 /* legacy rx Antenna diversity for SISO rates */
69 /* Tx on antenna 0, "legacy term Main" */
70 #define ANT_TX_FORCE_0 0
71 /* Tx on antenna 1, "legacy term Aux" */
72 #define ANT_TX_FORCE_1 1
73 /* Tx on phy's last good Rx antenna */
74 #define ANT_TX_LAST_RX 3
75 /* driver's default tx antenna setting */
79 /* def bitmap of txchain */
80 #define TXCHAIN_DEF 0x1
81 /* default bitmap of tx chains for nphy */
82 #define TXCHAIN_DEF_NPHY 0x3
83 /* default bitmap of tx chains for nphy */
84 #define TXCHAIN_DEF_HTPHY 0x7
85 /* def bitmap of rxchain */
86 #define RXCHAIN_DEF 0x1
87 /* default bitmap of rx chains for nphy */
88 #define RXCHAIN_DEF_NPHY 0x3
89 /* default bitmap of rx chains for nphy */
90 #define RXCHAIN_DEF_HTPHY 0x7
91 /* no antenna switch */
92 #define ANTSWITCH_NONE 0
93 /* antenna switch on 4321CB2, 2of3 */
94 #define ANTSWITCH_TYPE_1 1
95 /* antenna switch on 4321MPCI, 2of3 */
96 #define ANTSWITCH_TYPE_2 2
97 /* antenna switch on 4322, 2of3 */
98 #define ANTSWITCH_TYPE_3 3
100 #define RXBUFSZ PKTBUFSZ
102 #define MAX_STREAMS_SUPPORTED 4 /* max number of streams supported */
104 struct brcm_rateset {
105 /* # rates in this set */
107 /* rates in 500kbps units w/hi bit set if basic */
108 u8 rates[WL_NUMRATES];
111 struct brcms_c_rateset {
112 uint count; /* number of rates in rates[] */
113 /* rates in 500kbps units w/hi bit set if basic */
114 u8 rates[BRCMS_NUMRATES];
115 u8 htphy_membership; /* HT PHY Membership */
116 u8 mcs[MCSSET_LEN]; /* supported mcs index bit map */
119 /* All the HT-specific default advertised capabilities (including AMPDU)
120 * should be grouped here at one place
122 #define AMPDU_DEF_MPDU_DENSITY 6 /* default mpdu density (110 ==> 4us) */
124 /* wlc internal bss_info */
125 struct brcms_bss_info {
126 u8 BSSID[ETH_ALEN]; /* network BSSID */
127 u16 flags; /* flags for internal attributes */
128 u8 SSID_len; /* the length of SSID */
129 u8 SSID[32]; /* SSID string */
130 s16 RSSI; /* receive signal strength (in dBm) */
131 s16 SNR; /* receive signal SNR in dB */
132 u16 beacon_period; /* units are Kusec */
133 u16 chanspec; /* Channel num, bw, ctrl_sb and band */
134 struct brcms_c_rateset rateset; /* supported rates */
137 #define MAC80211_PROMISC_BCNS (1 << 0)
138 #define MAC80211_SCAN (1 << 1)
141 * Public portion of common driver state structure.
142 * The wlc handle points at this.
145 struct brcms_c_info *wlc;
146 struct ieee80211_hw *ieee_hw;
147 struct scb_ampdu *global_ampdu;
149 uint unit; /* device instance number */
150 uint corerev; /* core revision */
151 struct si_pub *sih; /* SI handle (cookie for siutils calls) */
152 bool up; /* interface up and running */
153 bool hw_off; /* HW is off */
154 bool hw_up; /* one time hw up/down */
155 bool _piomode; /* true if pio mode */
156 uint _nbands; /* # bands supported */
157 uint now; /* # elapsed seconds */
159 bool delayed_down; /* down delayed */
160 bool associated; /* true:part of [I]BSS, false: not */
161 /* (union of stas_associated, aps_associated) */
162 bool _ampdu; /* ampdu enabled or not */
163 u8 _n_enab; /* bitmap of 11N + HT support */
165 u8 cur_etheraddr[ETH_ALEN]; /* our local ethernet address */
167 u32 radio_disabled; /* bit vector for radio disabled reasons */
169 u16 boardrev; /* version # of particular board */
170 u8 sromrev; /* version # of the srom */
171 char srom_ccode[BRCM_CNTRY_BUF_SZ]; /* Country Code in SROM */
172 u32 boardflags; /* Board specific flags from srom */
173 u32 boardflags2; /* More board flags if sromrev >= 4 */
174 bool phy_11ncapable; /* the PHY/HW is capable of 802.11N */
176 struct wl_cnt *_cnt; /* low-level counters in driver */
177 struct dentry *dbgfs_dir;
184 IOV_BCN_LI_BCN /* Beacon listen interval in # of beacons */
187 /***********************************************
188 * Feature-related macros to optimize out code *
189 * *********************************************
192 #define ENAB_1x1 0x01
193 #define ENAB_2x2 0x02
194 #define ENAB_3x3 0x04
195 #define ENAB_4x4 0x08
196 #define SUPPORT_11N (ENAB_1x1|ENAB_2x2)
197 #define SUPPORT_HT (ENAB_1x1|ENAB_2x2|ENAB_3x3)
200 #define AMPDU_AGG_HOST 1
202 /* network protection config */
203 #define BRCMS_PROT_G_SPEC 1 /* SPEC g protection */
204 #define BRCMS_PROT_G_OVR 2 /* SPEC g prot override */
205 #define BRCMS_PROT_G_USER 3 /* gmode specified by user */
206 #define BRCMS_PROT_OVERLAP 4 /* overlap */
207 #define BRCMS_PROT_N_USER 10 /* nmode specified by user */
208 #define BRCMS_PROT_N_CFG 11 /* n protection */
209 #define BRCMS_PROT_N_CFG_OVR 12 /* n protection override */
210 #define BRCMS_PROT_N_NONGF 13 /* non-GF protection */
211 #define BRCMS_PROT_N_NONGF_OVR 14 /* non-GF protection override */
212 #define BRCMS_PROT_N_PAM_OVR 15 /* n preamble override */
213 #define BRCMS_PROT_N_OBSS 16 /* non-HT OBSS present */
216 * 54g modes (basic bits may still be overridden)
219 * Rateset: 1b, 2b, 5.5, 11
223 * Rateset: 1b, 2b, 5.5b, 11b, 18, 24, 36, 54
224 * Extended Rateset: 6, 9, 12, 48
228 * Rateset: 1b, 2b, 5.5b, 11b, 18, 24b, 36, 54
229 * Extended Rateset: 6b, 9, 12b, 48
230 * Preamble: Short required
233 * Rateset: 1b, 2b, 5.5b, 11b, 18, 24, 36, 54
234 * Extended Rateset: 6, 9, 12, 48
238 * Rateset: 1b, 2b, 5.5b, 6b, 9, 11b, 12b, 18, 24b, 36, 48, 54
239 * Preamble: Short required
240 * Shortslot: On and required
242 * Rateset: 1b, 2b, 5.5b, 11b
243 * Extended Rateset: 6, 9, 12, 18, 24, 36, 48, 54
247 #define GMODE_LEGACY_B 0
250 #define GMODE_B_DEFERRED 3
251 #define GMODE_PERFORMANCE 4
255 /* MCS values greater than this enable multiple streams */
256 #define HIGHEST_SINGLE_STREAM_MCS 7
258 #define MAXBANDS 2 /* Maximum #of bands */
260 /* max number of antenna configurations */
261 #define ANT_SELCFG_MAX 4
263 struct brcms_antselcfg {
264 u8 ant_config[ANT_SELCFG_MAX]; /* antenna configuration */
265 u8 num_antcfg; /* number of available antenna configurations */
268 /* common functions for every port */
269 extern struct brcms_c_info *
270 brcms_c_attach(struct brcms_info *wl, struct bcma_device *core, uint unit,
271 bool piomode, uint *perr);
272 extern uint brcms_c_detach(struct brcms_c_info *wlc);
273 extern int brcms_c_up(struct brcms_c_info *wlc);
274 extern uint brcms_c_down(struct brcms_c_info *wlc);
276 extern bool brcms_c_chipmatch(struct bcma_device *core);
277 extern void brcms_c_init(struct brcms_c_info *wlc, bool mute_tx);
278 extern void brcms_c_reset(struct brcms_c_info *wlc);
280 extern void brcms_c_intrson(struct brcms_c_info *wlc);
281 extern u32 brcms_c_intrsoff(struct brcms_c_info *wlc);
282 extern void brcms_c_intrsrestore(struct brcms_c_info *wlc, u32 macintmask);
283 extern bool brcms_c_intrsupd(struct brcms_c_info *wlc);
284 extern bool brcms_c_isr(struct brcms_c_info *wlc);
285 extern bool brcms_c_dpc(struct brcms_c_info *wlc, bool bounded);
286 extern bool brcms_c_sendpkt_mac80211(struct brcms_c_info *wlc,
288 struct ieee80211_hw *hw);
289 extern bool brcms_c_aggregatable(struct brcms_c_info *wlc, u8 tid);
290 extern void brcms_c_protection_upd(struct brcms_c_info *wlc, uint idx,
292 extern int brcms_c_get_header_len(void);
293 extern void brcms_c_set_addrmatch(struct brcms_c_info *wlc,
294 int match_reg_offset,
296 extern void brcms_c_wme_setparams(struct brcms_c_info *wlc, u16 aci,
297 const struct ieee80211_tx_queue_params *arg,
299 extern struct brcms_pub *brcms_c_pub(struct brcms_c_info *wlc);
300 extern void brcms_c_ampdu_flush(struct brcms_c_info *wlc,
301 struct ieee80211_sta *sta, u16 tid);
302 extern void brcms_c_ampdu_tx_operational(struct brcms_c_info *wlc, u8 tid,
303 u8 ba_wsize, uint max_rx_ampdu_bytes);
304 extern int brcms_c_module_register(struct brcms_pub *pub,
305 const char *name, struct brcms_info *hdl,
306 int (*down_fn)(void *handle));
307 extern int brcms_c_module_unregister(struct brcms_pub *pub, const char *name,
308 struct brcms_info *hdl);
309 extern void brcms_c_suspend_mac_and_wait(struct brcms_c_info *wlc);
310 extern void brcms_c_enable_mac(struct brcms_c_info *wlc);
311 extern void brcms_c_associate_upd(struct brcms_c_info *wlc, bool state);
312 extern void brcms_c_scan_start(struct brcms_c_info *wlc);
313 extern void brcms_c_scan_stop(struct brcms_c_info *wlc);
314 extern int brcms_c_get_curband(struct brcms_c_info *wlc);
315 extern int brcms_c_set_channel(struct brcms_c_info *wlc, u16 channel);
316 extern int brcms_c_set_rate_limit(struct brcms_c_info *wlc, u16 srl, u16 lrl);
317 extern void brcms_c_get_current_rateset(struct brcms_c_info *wlc,
318 struct brcm_rateset *currs);
319 extern int brcms_c_set_rateset(struct brcms_c_info *wlc,
320 struct brcm_rateset *rs);
321 extern int brcms_c_set_beacon_period(struct brcms_c_info *wlc, u16 period);
322 extern u16 brcms_c_get_phy_type(struct brcms_c_info *wlc, int phyidx);
323 extern void brcms_c_set_shortslot_override(struct brcms_c_info *wlc,
325 extern void brcms_c_set_beacon_listen_interval(struct brcms_c_info *wlc,
327 extern u64 brcms_c_tsf_get(struct brcms_c_info *wlc);
328 extern void brcms_c_tsf_set(struct brcms_c_info *wlc, u64 tsf);
329 extern int brcms_c_set_tx_power(struct brcms_c_info *wlc, int txpwr);
330 extern int brcms_c_get_tx_power(struct brcms_c_info *wlc);
331 extern bool brcms_c_check_radio_disabled(struct brcms_c_info *wlc);
332 extern void brcms_c_mute(struct brcms_c_info *wlc, bool on);
333 extern bool brcms_c_tx_flush_completed(struct brcms_c_info *wlc);
334 extern void brcms_c_start_station(struct brcms_c_info *wlc, u8 *addr);
335 extern void brcms_c_update_beacon(struct brcms_c_info *wlc);
336 extern void brcms_c_set_new_beacon(struct brcms_c_info *wlc,
337 struct sk_buff *beacon, u16 tim_offset,
340 #endif /* _BRCM_PUB_H_ */