Commit | Line | Data |
---|---|---|
a9533e7e HP |
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_pub_h_ | |
18 | #define _wlc_pub_h_ | |
19 | ||
20 | #include <wlc_types.h> | |
21 | #include <wlc_scb.h> | |
22 | ||
23 | #define WLC_NUMRATES 16 /* max # of rates in a rateset */ | |
24 | #define MAXMULTILIST 32 /* max # multicast addresses */ | |
25 | #define D11_PHY_HDR_LEN 6 /* Phy header length - 6 bytes */ | |
26 | ||
27 | /* phy types */ | |
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 */ | |
36 | ||
37 | /* bw */ | |
38 | #define WLC_10_MHZ 10 /* 10Mhz nphy channel bandwidth */ | |
39 | #define WLC_20_MHZ 20 /* 20Mhz nphy channel bandwidth */ | |
40 | #define WLC_40_MHZ 40 /* 40Mhz nphy channel bandwidth */ | |
41 | ||
42 | #define CHSPEC_WLC_BW(chanspec) (CHSPEC_IS40(chanspec) ? WLC_40_MHZ : \ | |
43 | CHSPEC_IS20(chanspec) ? WLC_20_MHZ : \ | |
44 | WLC_10_MHZ) | |
45 | ||
46 | #define WLC_RSSI_MINVAL -200 /* Low value, e.g. for forcing roam */ | |
47 | #define WLC_RSSI_NO_SIGNAL -91 /* NDIS RSSI link quality cutoffs */ | |
48 | #define WLC_RSSI_VERY_LOW -80 /* Very low quality cutoffs */ | |
49 | #define WLC_RSSI_LOW -70 /* Low quality cutoffs */ | |
50 | #define WLC_RSSI_GOOD -68 /* Good quality cutoffs */ | |
51 | #define WLC_RSSI_VERY_GOOD -58 /* Very good quality cutoffs */ | |
52 | #define WLC_RSSI_EXCELLENT -57 /* Excellent quality cutoffs */ | |
53 | ||
54 | #define WLC_PHYTYPE(_x) (_x) /* macro to perform WLC PHY -> D11 PHY TYPE, currently 1:1 */ | |
55 | ||
56 | #define MA_WINDOW_SZ 8 /* moving average window size */ | |
57 | ||
58 | #define WLC_SNR_INVALID 0 /* invalid SNR value */ | |
59 | ||
60 | /* a large TX Power as an init value to factor out of MIN() calculations, | |
562c8850 | 61 | * keep low enough to fit in an s8, units are .25 dBm |
a9533e7e HP |
62 | */ |
63 | #define WLC_TXPWR_MAX (127) /* ~32 dBm = 1,500 mW */ | |
64 | ||
65 | /* legacy rx Antenna diversity for SISO rates */ | |
66 | #define ANT_RX_DIV_FORCE_0 0 /* Use antenna 0 */ | |
67 | #define ANT_RX_DIV_FORCE_1 1 /* Use antenna 1 */ | |
68 | #define ANT_RX_DIV_START_1 2 /* Choose starting with 1 */ | |
69 | #define ANT_RX_DIV_START_0 3 /* Choose starting with 0 */ | |
70 | #define ANT_RX_DIV_ENABLE 3 /* APHY bbConfig Enable RX Diversity */ | |
71 | #define ANT_RX_DIV_DEF ANT_RX_DIV_START_0 /* default antdiv setting */ | |
72 | ||
73 | /* legacy rx Antenna diversity for SISO rates */ | |
74 | #define ANT_TX_FORCE_0 0 /* Tx on antenna 0, "legacy term Main" */ | |
75 | #define ANT_TX_FORCE_1 1 /* Tx on antenna 1, "legacy term Aux" */ | |
76 | #define ANT_TX_LAST_RX 3 /* Tx on phy's last good Rx antenna */ | |
77 | #define ANT_TX_DEF 3 /* driver's default tx antenna setting */ | |
78 | ||
79 | #define TXCORE_POLICY_ALL 0x1 /* use all available core for transmit */ | |
80 | ||
81 | /* Tx Chain values */ | |
82 | #define TXCHAIN_DEF 0x1 /* def bitmap of txchain */ | |
83 | #define TXCHAIN_DEF_NPHY 0x3 /* default bitmap of tx chains for nphy */ | |
84 | #define TXCHAIN_DEF_HTPHY 0x7 /* default bitmap of tx chains for nphy */ | |
85 | #define RXCHAIN_DEF 0x1 /* def bitmap of rxchain */ | |
86 | #define RXCHAIN_DEF_NPHY 0x3 /* default bitmap of rx chains for nphy */ | |
87 | #define RXCHAIN_DEF_HTPHY 0x7 /* default bitmap of rx chains for nphy */ | |
88 | #define ANTSWITCH_NONE 0 /* no antenna switch */ | |
89 | #define ANTSWITCH_TYPE_1 1 /* antenna switch on 4321CB2, 2of3 */ | |
90 | #define ANTSWITCH_TYPE_2 2 /* antenna switch on 4321MPCI, 2of3 */ | |
91 | #define ANTSWITCH_TYPE_3 3 /* antenna switch on 4322, 2of3 */ | |
92 | ||
93 | #define RXBUFSZ PKTBUFSZ | |
94 | #ifndef AIDMAPSZ | |
95 | #define AIDMAPSZ (ROUNDUP(MAXSCB, NBBY)/NBBY) /* aid bitmap size in bytes */ | |
96 | #endif /* AIDMAPSZ */ | |
97 | ||
98 | typedef struct wlc_tunables { | |
99 | int ntxd; /* size of tx descriptor table */ | |
100 | int nrxd; /* size of rx descriptor table */ | |
101 | int rxbufsz; /* size of rx buffers to post */ | |
102 | int nrxbufpost; /* # of rx buffers to post */ | |
103 | int maxscb; /* # of SCBs supported */ | |
104 | int ampdunummpdu; /* max number of mpdu in an ampdu */ | |
105 | int maxpktcb; /* max # of packet callbacks */ | |
106 | int maxucodebss; /* max # of BSS handled in ucode bcn/prb */ | |
107 | int maxucodebss4; /* max # of BSS handled in sw bcn/prb */ | |
108 | int maxbss; /* max # of bss info elements in scan list */ | |
109 | int datahiwat; /* data msg txq hiwat mark */ | |
110 | int ampdudatahiwat; /* AMPDU msg txq hiwat mark */ | |
111 | int rxbnd; /* max # of rx bufs to process before deferring to dpc */ | |
112 | int txsbnd; /* max # tx status to process in wlc_txstatus() */ | |
113 | int memreserved; /* memory reserved for BMAC's USB dma rx */ | |
114 | } wlc_tunables_t; | |
115 | ||
116 | typedef struct wlc_rateset { | |
117 | uint count; /* number of rates in rates[] */ | |
41feb5ed GKH |
118 | u8 rates[WLC_NUMRATES]; /* rates in 500kbps units w/hi bit set if basic */ |
119 | u8 htphy_membership; /* HT PHY Membership */ | |
120 | u8 mcs[MCSSET_LEN]; /* supported mcs index bit map */ | |
a9533e7e HP |
121 | } wlc_rateset_t; |
122 | ||
123 | struct rsn_parms { | |
41feb5ed GKH |
124 | u8 flags; /* misc booleans (e.g., supported) */ |
125 | u8 multicast; /* multicast cipher */ | |
126 | u8 ucount; /* count of unicast ciphers */ | |
127 | u8 unicast[4]; /* unicast ciphers */ | |
128 | u8 acount; /* count of auth modes */ | |
129 | u8 auth[4]; /* Authentication modes */ | |
130 | u8 PAD[4]; /* padding for future growth */ | |
a9533e7e HP |
131 | }; |
132 | ||
133 | /* | |
134 | * buffer length needed for wlc_format_ssid | |
135 | * 32 SSID chars, max of 4 chars for each SSID char "\xFF", plus NULL. | |
136 | */ | |
137 | #define SSID_FMT_BUF_LEN ((4 * DOT11_MAX_SSID_LEN) + 1) | |
138 | ||
139 | #define RSN_FLAGS_SUPPORTED 0x1 /* Flag for rsn_params */ | |
140 | #define RSN_FLAGS_PREAUTH 0x2 /* Flag for WPA2 rsn_params */ | |
141 | ||
142 | /* All the HT-specific default advertised capabilities (including AMPDU) | |
143 | * should be grouped here at one place | |
144 | */ | |
145 | #define AMPDU_DEF_MPDU_DENSITY 6 /* default mpdu density (110 ==> 4us) */ | |
146 | ||
147 | /* defaults for the HT (MIMO) bss */ | |
148 | #define HT_CAP ((HT_CAP_MIMO_PS_OFF << HT_CAP_MIMO_PS_SHIFT) | HT_CAP_40MHZ | \ | |
149 | HT_CAP_GF | HT_CAP_MAX_AMSDU | HT_CAP_DSSS_CCK) | |
150 | ||
151 | /* WLC packet type is a void * */ | |
152 | typedef void *wlc_pkt_t; | |
153 | ||
154 | /* Event data type */ | |
155 | typedef struct wlc_event { | |
156 | wl_event_msg_t event; /* encapsulated event */ | |
157 | struct ether_addr *addr; /* used to keep a trace of the potential present of | |
158 | * an address in wlc_event_msg_t | |
159 | */ | |
160 | int bsscfgidx; /* BSS config when needed */ | |
161 | struct wl_if *wlif; /* pointer to wlif */ | |
162 | void *data; /* used to hang additional data on an event */ | |
163 | struct wlc_event *next; /* enables ordered list of pending events */ | |
164 | } wlc_event_t; | |
165 | ||
166 | /* wlc internal bss_info, wl external one is in wlioctl.h */ | |
167 | typedef struct wlc_bss_info { | |
168 | struct ether_addr BSSID; /* network BSSID */ | |
7d4df48e | 169 | u16 flags; /* flags for internal attributes */ |
41feb5ed GKH |
170 | u8 SSID_len; /* the length of SSID */ |
171 | u8 SSID[32]; /* SSID string */ | |
a9533e7e HP |
172 | int16 RSSI; /* receive signal strength (in dBm) */ |
173 | int16 SNR; /* receive signal SNR in dB */ | |
7d4df48e GKH |
174 | u16 beacon_period; /* units are Kusec */ |
175 | u16 atim_window; /* units are Kusec */ | |
a9533e7e | 176 | chanspec_t chanspec; /* Channel num, bw, ctrl_sb and band */ |
562c8850 | 177 | s8 infra; /* 0=IBSS, 1=infrastructure, 2=unknown */ |
a9533e7e | 178 | wlc_rateset_t rateset; /* supported rates */ |
41feb5ed | 179 | u8 dtim_period; /* DTIM period */ |
562c8850 | 180 | s8 phy_noise; /* noise right after tx (in dBm) */ |
7d4df48e | 181 | u16 capability; /* Capability information */ |
a9533e7e | 182 | struct dot11_bcn_prb *bcn_prb; /* beacon/probe response frame (ioctl na) */ |
7d4df48e | 183 | u16 bcn_prb_len; /* beacon/probe response frame length (ioctl na) */ |
41feb5ed | 184 | u8 wme_qosinfo; /* QoS Info from WME IE; valid if WLC_BSS_WME flag set */ |
a9533e7e HP |
185 | struct rsn_parms wpa; |
186 | struct rsn_parms wpa2; | |
7d4df48e | 187 | u16 qbss_load_aac; /* qbss load available admission capacity */ |
a9533e7e | 188 | /* qbss_load_chan_free <- (0xff - channel_utilization of qbss_load_ie_t) */ |
41feb5ed GKH |
189 | u8 qbss_load_chan_free; /* indicates how free the channel is */ |
190 | u8 mcipher; /* multicast cipher */ | |
191 | u8 wpacfg; /* wpa config index */ | |
a9533e7e HP |
192 | } wlc_bss_info_t; |
193 | ||
194 | /* forward declarations */ | |
195 | struct wlc_if; | |
196 | ||
197 | /* wlc_ioctl error codes */ | |
198 | #define WLC_ENOIOCTL 1 /* No such Ioctl */ | |
199 | #define WLC_EINVAL 2 /* Invalid value */ | |
200 | #define WLC_ETOOSMALL 3 /* Value too small */ | |
201 | #define WLC_ETOOBIG 4 /* Value too big */ | |
202 | #define WLC_ERANGE 5 /* Out of range */ | |
203 | #define WLC_EDOWN 6 /* Down */ | |
204 | #define WLC_EUP 7 /* Up */ | |
205 | #define WLC_ENOMEM 8 /* No Memory */ | |
206 | #define WLC_EBUSY 9 /* Busy */ | |
207 | ||
208 | /* IOVar flags for common error checks */ | |
209 | #define IOVF_MFG (1<<3) /* flag for mfgtest iovars */ | |
210 | #define IOVF_WHL (1<<4) /* value must be whole (0-max) */ | |
211 | #define IOVF_NTRL (1<<5) /* value must be natural (1-max) */ | |
212 | ||
213 | #define IOVF_SET_UP (1<<6) /* set requires driver be up */ | |
214 | #define IOVF_SET_DOWN (1<<7) /* set requires driver be down */ | |
215 | #define IOVF_SET_CLK (1<<8) /* set requires core clock */ | |
216 | #define IOVF_SET_BAND (1<<9) /* set requires fixed band */ | |
217 | ||
218 | #define IOVF_GET_UP (1<<10) /* get requires driver be up */ | |
219 | #define IOVF_GET_DOWN (1<<11) /* get requires driver be down */ | |
220 | #define IOVF_GET_CLK (1<<12) /* get requires core clock */ | |
221 | #define IOVF_GET_BAND (1<<13) /* get requires fixed band */ | |
222 | #define IOVF_OPEN_ALLOW (1<<14) /* set allowed iovar for opensrc */ | |
223 | ||
224 | /* watchdog down and dump callback function proto's */ | |
225 | typedef int (*watchdog_fn_t) (void *handle); | |
226 | typedef int (*down_fn_t) (void *handle); | |
7cc4a4c0 | 227 | typedef int (*dump_fn_t) (void *handle, struct bcmstrbuf *b); |
a9533e7e HP |
228 | |
229 | /* IOVar handler | |
230 | * | |
231 | * handle - a pointer value registered with the function | |
232 | * vi - iovar_info that was looked up | |
233 | * actionid - action ID, calculated by IOV_GVAL() and IOV_SVAL() based on varid. | |
234 | * name - the actual iovar name | |
235 | * params/plen - parameters and length for a get, input only. | |
236 | * arg/len - buffer and length for value to be set or retrieved, input or output. | |
237 | * vsize - value size, valid for integer type only. | |
238 | * wlcif - interface context (wlc_if pointer) | |
239 | * | |
240 | * All pointers may point into the same buffer. | |
241 | */ | |
7cc4a4c0 | 242 | typedef int (*iovar_fn_t) (void *handle, const bcm_iovar_t *vi, |
a9533e7e HP |
243 | uint32 actionid, const char *name, void *params, |
244 | uint plen, void *arg, int alen, int vsize, | |
7cc4a4c0 | 245 | struct wlc_if *wlcif); |
a9533e7e HP |
246 | |
247 | #define MAC80211_PROMISC_BCNS (1 << 0) | |
248 | #define MAC80211_SCAN (1 << 1) | |
249 | ||
250 | /* | |
251 | * Public portion of "common" os-independent state structure. | |
252 | * The wlc handle points at this. | |
253 | */ | |
254 | typedef struct wlc_pub { | |
255 | void *wlc; | |
256 | ||
257 | struct ieee80211_hw *ieee_hw; | |
258 | struct scb *global_scb; | |
259 | scb_ampdu_t *global_ampdu; | |
260 | uint mac80211_state; | |
261 | uint unit; /* device instance number */ | |
262 | uint corerev; /* core revision */ | |
263 | osl_t *osh; /* pointer to os handle */ | |
264 | si_t *sih; /* SB handle (cookie for siutils calls) */ | |
265 | char *vars; /* "environment" name=value */ | |
266 | bool up; /* interface up and running */ | |
267 | bool hw_off; /* HW is off */ | |
268 | wlc_tunables_t *tunables; /* tunables: ntxd, nrxd, maxscb, etc. */ | |
269 | bool hw_up; /* one time hw up/down(from boot or hibernation) */ | |
270 | bool _piomode; /* true if pio mode *//* BMAC_NOTE: NEED In both */ | |
271 | uint _nbands; /* # bands supported */ | |
272 | uint now; /* # elapsed seconds */ | |
273 | ||
274 | bool promisc; /* promiscuous destination address */ | |
275 | bool delayed_down; /* down delayed */ | |
276 | bool _ap; /* AP mode enabled */ | |
277 | bool _apsta; /* simultaneous AP/STA mode enabled */ | |
278 | bool _assoc_recreate; /* association recreation on up transitions */ | |
279 | int _wme; /* WME QoS mode */ | |
41feb5ed | 280 | u8 _mbss; /* MBSS mode on */ |
a9533e7e HP |
281 | bool allmulti; /* enable all multicasts */ |
282 | bool associated; /* true:part of [I]BSS, false: not */ | |
283 | /* (union of stas_associated, aps_associated) */ | |
284 | bool phytest_on; /* whether a PHY test is running */ | |
285 | bool bf_preempt_4306; /* True to enable 'darwin' mode */ | |
286 | bool _ampdu; /* ampdu enabled or not */ | |
287 | bool _cac; /* 802.11e CAC enabled */ | |
41feb5ed | 288 | u8 _n_enab; /* bitmap of 11N + HT support */ |
a9533e7e HP |
289 | bool _n_reqd; /* N support required for clients */ |
290 | ||
562c8850 | 291 | s8 _coex; /* 20/40 MHz BSS Management AUTO, ENAB, DISABLE */ |
a9533e7e HP |
292 | bool _priofc; /* Priority-based flowcontrol */ |
293 | ||
294 | struct ether_addr cur_etheraddr; /* our local ethernet address */ | |
295 | ||
296 | struct ether_addr *multicast; /* ptr to list of multicast addresses */ | |
297 | uint nmulticast; /* # enabled multicast addresses */ | |
298 | ||
299 | uint32 wlfeatureflag; /* Flags to control sw features from registry */ | |
300 | int psq_pkts_total; /* total num of ps pkts */ | |
301 | ||
7d4df48e | 302 | u16 txmaxpkts; /* max number of large pkts allowed to be pending */ |
a9533e7e HP |
303 | |
304 | /* s/w decryption counters */ | |
305 | uint32 swdecrypt; /* s/w decrypt attempts */ | |
306 | ||
307 | int bcmerror; /* last bcm error */ | |
308 | ||
309 | mbool radio_disabled; /* bit vector for radio disabled reasons */ | |
310 | bool radio_active; /* radio on/off state */ | |
7d4df48e | 311 | u16 roam_time_thresh; /* Max. # secs. of not hearing beacons |
a9533e7e HP |
312 | * before roaming. |
313 | */ | |
314 | bool align_wd_tbtt; /* Align watchdog with tbtt indication | |
315 | * handling. This flag is cleared by default | |
316 | * and is set by per port code explicitly and | |
317 | * you need to make sure the OSL_SYSUPTIME() | |
318 | * is implemented properly in osl of that port | |
319 | * when it enables this Power Save feature. | |
320 | */ | |
321 | #ifdef BCMSDIO | |
322 | uint sdiod_drive_strength; /* SDIO drive strength */ | |
323 | #endif /* BCMSDIO */ | |
324 | ||
7d4df48e | 325 | u16 boardrev; /* version # of particular board */ |
41feb5ed | 326 | u8 sromrev; /* version # of the srom */ |
a9533e7e HP |
327 | char srom_ccode[WLC_CNTRY_BUF_SZ]; /* Country Code in SROM */ |
328 | uint32 boardflags; /* Board specific flags from srom */ | |
329 | uint32 boardflags2; /* More board flags if sromrev >= 4 */ | |
330 | bool tempsense_disable; /* disable periodic tempsense check */ | |
331 | ||
332 | bool _lmac; /* lmac module included and enabled */ | |
333 | bool _lmacproto; /* lmac protocol module included and enabled */ | |
334 | bool phy_11ncapable; /* the PHY/HW is capable of 802.11N */ | |
335 | bool _ampdumac; /* mac assist ampdu enabled or not */ | |
336 | } wlc_pub_t; | |
337 | ||
338 | /* wl_monitor rx status per packet */ | |
339 | typedef struct wl_rxsts { | |
340 | uint pkterror; /* error flags per pkt */ | |
341 | uint phytype; /* 802.11 A/B/G ... */ | |
342 | uint channel; /* channel */ | |
343 | uint datarate; /* rate in 500kbps */ | |
344 | uint antenna; /* antenna pkts received on */ | |
345 | uint pktlength; /* pkt length minus bcm phy hdr */ | |
346 | uint32 mactime; /* time stamp from mac, count per 1us */ | |
347 | uint sq; /* signal quality */ | |
348 | int32 signal; /* in dbm */ | |
349 | int32 noise; /* in dbm */ | |
350 | uint preamble; /* Unknown, short, long */ | |
351 | uint encoding; /* Unknown, CCK, PBCC, OFDM */ | |
352 | uint nfrmtype; /* special 802.11n frames(AMPDU, AMSDU) */ | |
353 | struct wl_if *wlif; /* wl interface */ | |
354 | } wl_rxsts_t; | |
355 | ||
356 | /* status per error RX pkt */ | |
357 | #define WL_RXS_CRC_ERROR 0x00000001 /* CRC Error in packet */ | |
358 | #define WL_RXS_RUNT_ERROR 0x00000002 /* Runt packet */ | |
359 | #define WL_RXS_ALIGN_ERROR 0x00000004 /* Misaligned packet */ | |
360 | #define WL_RXS_OVERSIZE_ERROR 0x00000008 /* packet bigger than RX_LENGTH (usually 1518) */ | |
361 | #define WL_RXS_WEP_ICV_ERROR 0x00000010 /* Integrity Check Value error */ | |
362 | #define WL_RXS_WEP_ENCRYPTED 0x00000020 /* Encrypted with WEP */ | |
363 | #define WL_RXS_PLCP_SHORT 0x00000040 /* Short PLCP error */ | |
364 | #define WL_RXS_DECRYPT_ERR 0x00000080 /* Decryption error */ | |
365 | #define WL_RXS_OTHER_ERR 0x80000000 /* Other errors */ | |
366 | ||
367 | /* phy type */ | |
368 | #define WL_RXS_PHY_A 0x00000000 /* A phy type */ | |
369 | #define WL_RXS_PHY_B 0x00000001 /* B phy type */ | |
370 | #define WL_RXS_PHY_G 0x00000002 /* G phy type */ | |
371 | #define WL_RXS_PHY_N 0x00000004 /* N phy type */ | |
372 | ||
373 | /* encoding */ | |
374 | #define WL_RXS_ENCODING_CCK 0x00000000 /* CCK encoding */ | |
375 | #define WL_RXS_ENCODING_OFDM 0x00000001 /* OFDM encoding */ | |
376 | ||
377 | /* preamble */ | |
378 | #define WL_RXS_UNUSED_STUB 0x0 /* stub to match with wlc_ethereal.h */ | |
379 | #define WL_RXS_PREAMBLE_SHORT 0x00000001 /* Short preamble */ | |
380 | #define WL_RXS_PREAMBLE_LONG 0x00000002 /* Long preamble */ | |
381 | #define WL_RXS_PREAMBLE_MIMO_MM 0x00000003 /* MIMO mixed mode preamble */ | |
382 | #define WL_RXS_PREAMBLE_MIMO_GF 0x00000004 /* MIMO green field preamble */ | |
383 | ||
384 | #define WL_RXS_NFRM_AMPDU_FIRST 0x00000001 /* first MPDU in A-MPDU */ | |
385 | #define WL_RXS_NFRM_AMPDU_SUB 0x00000002 /* subsequent MPDU(s) in A-MPDU */ | |
386 | #define WL_RXS_NFRM_AMSDU_FIRST 0x00000004 /* first MSDU in A-MSDU */ | |
387 | #define WL_RXS_NFRM_AMSDU_SUB 0x00000008 /* subsequent MSDU(s) in A-MSDU */ | |
388 | ||
389 | /* forward declare and use the struct notation so we don't have to | |
390 | * have it defined if not necessary. | |
391 | */ | |
392 | struct wlc_info; | |
393 | struct wlc_hw_info; | |
394 | struct wlc_bsscfg; | |
395 | struct wlc_if; | |
396 | ||
a9533e7e HP |
397 | /*********************************************** |
398 | * Feature-related macros to optimize out code * | |
399 | * ********************************************* | |
400 | */ | |
401 | ||
402 | /* AP Support (versus STA) */ | |
403 | #define AP_ENAB(pub) (0) | |
404 | ||
405 | /* Macro to check if APSTA mode enabled */ | |
406 | #define APSTA_ENAB(pub) (0) | |
407 | ||
408 | /* Some useful combinations */ | |
409 | #define STA_ONLY(pub) (!AP_ENAB(pub)) | |
410 | #define AP_ONLY(pub) (AP_ENAB(pub) && !APSTA_ENAB(pub)) | |
411 | ||
412 | #define ENAB_1x1 0x01 | |
413 | #define ENAB_2x2 0x02 | |
414 | #define ENAB_3x3 0x04 | |
415 | #define ENAB_4x4 0x08 | |
416 | #define SUPPORT_11N (ENAB_1x1|ENAB_2x2) | |
417 | #define SUPPORT_HT (ENAB_1x1|ENAB_2x2|ENAB_3x3) | |
418 | /* WL11N Support */ | |
419 | #if ((defined(NCONF) && (NCONF != 0)) || (defined(LCNCONF) && (LCNCONF != 0)) || \ | |
420 | (defined(HTCONF) && (HTCONF != 0)) || (defined(SSLPNCONF) && (SSLPNCONF != 0))) | |
421 | #define N_ENAB(pub) ((pub)->_n_enab & SUPPORT_11N) | |
422 | #define N_REQD(pub) ((pub)->_n_reqd) | |
423 | #else | |
424 | #define N_ENAB(pub) 0 | |
425 | #define N_REQD(pub) 0 | |
426 | #endif | |
427 | ||
428 | #if (defined(HTCONF) && (HTCONF != 0)) | |
429 | #define HT_ENAB(pub) (((pub)->_n_enab & SUPPORT_HT) == SUPPORT_HT) | |
430 | #else | |
431 | #define HT_ENAB(pub) 0 | |
432 | #endif | |
433 | ||
434 | #define AMPDU_AGG_HOST 1 | |
435 | #define AMPDU_ENAB(pub) ((pub)->_ampdu) | |
436 | ||
437 | #define EDCF_ENAB(pub) (WME_ENAB(pub)) | |
438 | #define QOS_ENAB(pub) (WME_ENAB(pub) || N_ENAB(pub)) | |
439 | ||
440 | #define MONITOR_ENAB(wlc) (bcmspace && (wlc)->monitor) | |
441 | ||
442 | #define PROMISC_ENAB(wlc) (bcmspace && (wlc)->promisc) | |
443 | ||
7cc4a4c0 | 444 | extern void wlc_pkttag_info_move(wlc_pub_t *pub, void *pkt_from, void *pkt_to); |
a9533e7e HP |
445 | |
446 | #define WLPKTTAGSCB(p) (WLPKTTAG(p)->_scb) | |
447 | ||
448 | #define WLC_PREC_COUNT 16 /* Max precedence level implemented */ | |
449 | ||
450 | /* pri is PKTPRIO encoded in the packet. This maps the Packet priority to | |
451 | * enqueue precedence as defined in wlc_prec_map | |
452 | */ | |
41feb5ed | 453 | extern const u8 wlc_prio2prec_map[]; |
a9533e7e HP |
454 | #define WLC_PRIO_TO_PREC(pri) wlc_prio2prec_map[(pri) & 7] |
455 | ||
456 | /* This maps priority to one precedence higher - Used by PS-Poll response packets to | |
457 | * simulate enqueue-at-head operation, but still maintain the order on the queue | |
458 | */ | |
459 | #define WLC_PRIO_TO_HI_PREC(pri) MIN(WLC_PRIO_TO_PREC(pri) + 1, WLC_PREC_COUNT - 1) | |
460 | ||
41feb5ed | 461 | extern const u8 wme_fifo2ac[]; |
a9533e7e HP |
462 | #define WME_PRIO2AC(prio) wme_fifo2ac[prio2fifo[(prio)]] |
463 | ||
464 | /* Mask to describe all precedence levels */ | |
465 | #define WLC_PREC_BMP_ALL MAXBITVAL(WLC_PREC_COUNT) | |
466 | ||
467 | /* Define a bitmap of precedences comprised by each AC */ | |
468 | #define WLC_PREC_BMP_AC_BE (NBITVAL(WLC_PRIO_TO_PREC(PRIO_8021D_BE)) | \ | |
469 | NBITVAL(WLC_PRIO_TO_HI_PREC(PRIO_8021D_BE)) | \ | |
470 | NBITVAL(WLC_PRIO_TO_PREC(PRIO_8021D_EE)) | \ | |
471 | NBITVAL(WLC_PRIO_TO_HI_PREC(PRIO_8021D_EE))) | |
472 | #define WLC_PREC_BMP_AC_BK (NBITVAL(WLC_PRIO_TO_PREC(PRIO_8021D_BK)) | \ | |
473 | NBITVAL(WLC_PRIO_TO_HI_PREC(PRIO_8021D_BK)) | \ | |
474 | NBITVAL(WLC_PRIO_TO_PREC(PRIO_8021D_NONE)) | \ | |
475 | NBITVAL(WLC_PRIO_TO_HI_PREC(PRIO_8021D_NONE))) | |
476 | #define WLC_PREC_BMP_AC_VI (NBITVAL(WLC_PRIO_TO_PREC(PRIO_8021D_CL)) | \ | |
477 | NBITVAL(WLC_PRIO_TO_HI_PREC(PRIO_8021D_CL)) | \ | |
478 | NBITVAL(WLC_PRIO_TO_PREC(PRIO_8021D_VI)) | \ | |
479 | NBITVAL(WLC_PRIO_TO_HI_PREC(PRIO_8021D_VI))) | |
480 | #define WLC_PREC_BMP_AC_VO (NBITVAL(WLC_PRIO_TO_PREC(PRIO_8021D_VO)) | \ | |
481 | NBITVAL(WLC_PRIO_TO_HI_PREC(PRIO_8021D_VO)) | \ | |
482 | NBITVAL(WLC_PRIO_TO_PREC(PRIO_8021D_NC)) | \ | |
483 | NBITVAL(WLC_PRIO_TO_HI_PREC(PRIO_8021D_NC))) | |
484 | ||
485 | /* WME Support */ | |
486 | #define WME_ENAB(pub) ((pub)->_wme != OFF) | |
487 | #define WME_AUTO(wlc) ((wlc)->pub->_wme == AUTO) | |
488 | ||
489 | #define WLC_USE_COREFLAGS 0xffffffff /* invalid core flags, use the saved coreflags */ | |
490 | ||
491 | #define WLC_UPDATE_STATS(wlc) 0 /* No stats support */ | |
492 | #define WLCNTINCR(a) /* No stats support */ | |
493 | #define WLCNTDECR(a) /* No stats support */ | |
914d69d6 JC |
494 | #define WLCNTADD(a, delta) /* No stats support */ |
495 | #define WLCNTSET(a, value) /* No stats support */ | |
a9533e7e HP |
496 | #define WLCNTVAL(a) 0 /* No stats support */ |
497 | ||
498 | /* common functions for every port */ | |
7d4df48e | 499 | extern void *wlc_attach(void *wl, u16 vendor, u16 device, uint unit, |
7cc4a4c0 JC |
500 | bool piomode, osl_t *osh, void *regsva, uint bustype, |
501 | void *btparam, uint *perr); | |
a9533e7e HP |
502 | extern uint wlc_detach(struct wlc_info *wlc); |
503 | extern int wlc_up(struct wlc_info *wlc); | |
504 | extern uint wlc_down(struct wlc_info *wlc); | |
505 | ||
506 | extern int wlc_set(struct wlc_info *wlc, int cmd, int arg); | |
507 | extern int wlc_get(struct wlc_info *wlc, int cmd, int *arg); | |
508 | extern int wlc_iovar_getint(struct wlc_info *wlc, const char *name, int *arg); | |
509 | extern int wlc_iovar_setint(struct wlc_info *wlc, const char *name, int arg); | |
7d4df48e | 510 | extern bool wlc_chipmatch(u16 vendor, u16 device); |
a9533e7e HP |
511 | extern void wlc_init(struct wlc_info *wlc); |
512 | extern void wlc_reset(struct wlc_info *wlc); | |
513 | ||
514 | extern void wlc_intrson(struct wlc_info *wlc); | |
515 | extern uint32 wlc_intrsoff(struct wlc_info *wlc); | |
516 | extern void wlc_intrsrestore(struct wlc_info *wlc, uint32 macintmask); | |
517 | extern bool wlc_intrsupd(struct wlc_info *wlc); | |
7cc4a4c0 | 518 | extern bool wlc_isr(struct wlc_info *wlc, bool *wantdpc); |
a9533e7e | 519 | extern bool wlc_dpc(struct wlc_info *wlc, bool bounded); |
7cc4a4c0 | 520 | extern bool wlc_send80211_raw(struct wlc_info *wlc, wlc_if_t *wlcif, void *p, |
a9533e7e HP |
521 | uint ac); |
522 | extern int wlc_iovar_op(struct wlc_info *wlc, const char *name, void *params, | |
523 | int p_len, void *arg, int len, bool set, | |
524 | struct wlc_if *wlcif); | |
525 | extern int wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len, | |
526 | struct wlc_if *wlcif); | |
527 | /* helper functions */ | |
528 | extern void wlc_statsupd(struct wlc_info *wlc); | |
529 | extern int wlc_get_header_len(void); | |
530 | ||
531 | extern wlc_pub_t *wlc_pub(void *wlc); | |
532 | ||
533 | /* common functions for every port */ | |
534 | extern int wlc_bmac_up_prep(struct wlc_hw_info *wlc_hw); | |
535 | extern int wlc_bmac_up_finish(struct wlc_hw_info *wlc_hw); | |
536 | extern int wlc_bmac_down_prep(struct wlc_hw_info *wlc_hw); | |
537 | extern int wlc_bmac_down_finish(struct wlc_hw_info *wlc_hw); | |
538 | ||
a9533e7e HP |
539 | extern uint32 wlc_reg_read(struct wlc_info *wlc, void *r, uint size); |
540 | extern void wlc_reg_write(struct wlc_info *wlc, void *r, uint32 v, uint size); | |
541 | extern void wlc_corereset(struct wlc_info *wlc, uint32 flags); | |
7d4df48e | 542 | extern void wlc_mhf(struct wlc_info *wlc, u8 idx, u16 mask, u16 val, |
a9533e7e | 543 | int bands); |
7d4df48e | 544 | extern u16 wlc_mhf_get(struct wlc_info *wlc, u8 idx, int bands); |
a9533e7e | 545 | extern uint32 wlc_delta_txfunfl(struct wlc_info *wlc, int fifo); |
7cc4a4c0 JC |
546 | extern void wlc_rate_lookup_init(struct wlc_info *wlc, wlc_rateset_t *rateset); |
547 | extern void wlc_default_rateset(struct wlc_info *wlc, wlc_rateset_t *rs); | |
a9533e7e HP |
548 | |
549 | /* wlc_phy.c helper functions */ | |
a9533e7e HP |
550 | extern void wlc_set_ps_ctrl(struct wlc_info *wlc); |
551 | extern void wlc_mctrl(struct wlc_info *wlc, uint32 mask, uint32 val); | |
552 | extern void wlc_scb_ratesel_init_all(struct wlc_info *wlc); | |
553 | ||
554 | /* ioctl */ | |
562c8850 GKH |
555 | extern int wlc_iovar_gets8(struct wlc_info *wlc, const char *name, |
556 | s8 *arg); | |
7cc4a4c0 | 557 | extern int wlc_iovar_check(wlc_pub_t *pub, const bcm_iovar_t *vi, void *arg, |
a9533e7e HP |
558 | int len, bool set); |
559 | ||
7cc4a4c0 | 560 | extern int wlc_module_register(wlc_pub_t *pub, const bcm_iovar_t *iovars, |
a9533e7e HP |
561 | const char *name, void *hdl, iovar_fn_t iovar_fn, |
562 | watchdog_fn_t watchdog_fn, down_fn_t down_fn); | |
7cc4a4c0 | 563 | extern int wlc_module_unregister(wlc_pub_t *pub, const char *name, void *hdl); |
a9533e7e | 564 | extern void wlc_event_if(struct wlc_info *wlc, struct wlc_bsscfg *cfg, |
7cc4a4c0 | 565 | wlc_event_t *e, const struct ether_addr *addr); |
a9533e7e HP |
566 | extern void wlc_suspend_mac_and_wait(struct wlc_info *wlc); |
567 | extern void wlc_enable_mac(struct wlc_info *wlc); | |
7d4df48e | 568 | extern u16 wlc_rate_shm_offset(struct wlc_info *wlc, u8 rate); |
a9533e7e HP |
569 | extern uint32 wlc_get_rspec_history(struct wlc_bsscfg *cfg); |
570 | extern uint32 wlc_get_current_highest_rate(struct wlc_bsscfg *cfg); | |
571 | ||
2d956e22 | 572 | static inline int wlc_iovar_getuint(struct wlc_info *wlc, const char *name, |
7cc4a4c0 | 573 | uint *arg) |
a9533e7e HP |
574 | { |
575 | return wlc_iovar_getint(wlc, name, (int *)arg); | |
576 | } | |
577 | ||
41feb5ed GKH |
578 | static inline int wlc_iovar_getu8(struct wlc_info *wlc, const char *name, |
579 | u8 *arg) | |
a9533e7e | 580 | { |
562c8850 | 581 | return wlc_iovar_gets8(wlc, name, (s8 *) arg); |
a9533e7e HP |
582 | } |
583 | ||
2d956e22 | 584 | static inline int wlc_iovar_setuint(struct wlc_info *wlc, const char *name, |
a9533e7e HP |
585 | uint arg) |
586 | { | |
587 | return wlc_iovar_setint(wlc, name, (int)arg); | |
588 | } | |
589 | ||
590 | #if defined(BCMDBG) | |
591 | extern int wlc_iocregchk(struct wlc_info *wlc, uint band); | |
592 | #endif | |
593 | #if defined(BCMDBG) | |
594 | extern int wlc_iocpichk(struct wlc_info *wlc, uint phytype); | |
595 | #endif | |
596 | ||
597 | /* helper functions */ | |
41feb5ed | 598 | extern void wlc_getrand(struct wlc_info *wlc, u8 *buf, int len); |
a9533e7e HP |
599 | |
600 | struct scb; | |
601 | extern void wlc_ps_on(struct wlc_info *wlc, struct scb *scb); | |
602 | extern void wlc_ps_off(struct wlc_info *wlc, struct scb *scb, bool discard); | |
603 | extern bool wlc_radio_monitor_stop(struct wlc_info *wlc); | |
604 | ||
605 | #if defined(BCMDBG) | |
580a0bd9 | 606 | extern int wlc_format_ssid(char *buf, const unsigned char ssid[], uint ssid_len); |
a9533e7e HP |
607 | #endif |
608 | ||
609 | extern void wlc_pmkid_build_cand_list(struct wlc_bsscfg *cfg, bool check_SSID); | |
610 | extern void wlc_pmkid_event(struct wlc_bsscfg *cfg); | |
611 | ||
612 | #define MAXBANDS 2 /* Maximum #of bands */ | |
613 | /* bandstate array indices */ | |
614 | #define BAND_2G_INDEX 0 /* wlc->bandstate[x] index */ | |
615 | #define BAND_5G_INDEX 1 /* wlc->bandstate[x] index */ | |
616 | ||
617 | #define BAND_2G_NAME "2.4G" | |
618 | #define BAND_5G_NAME "5G" | |
619 | ||
620 | #if defined(BCMSDIO) || defined(WLC_HIGH_ONLY) | |
621 | void wlc_device_removed(void *arg); | |
622 | #endif | |
623 | ||
624 | /* BMAC RPC: 7 uint32 params: pkttotlen, fifo, commit, fid, txpktpend, pktflag, rpc_id */ | |
625 | #define WLC_RPCTX_PARAMS 32 | |
626 | ||
627 | #endif /* _wlc_pub_h_ */ |