]> bbs.cooldavid.org Git - net-next-2.6.git/blob - drivers/staging/brcm80211/sys/wlc_pub.h
staging: brcm80211: fix "ERROR: spaces required around that ..."
[net-next-2.6.git] / drivers / staging / brcm80211 / sys / wlc_pub.h
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,
61  * keep low enough to fit in an int8, units are .25 dBm
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[] */
118         uint8 rates[WLC_NUMRATES];      /* rates in 500kbps units w/hi bit set if basic */
119         uint8 htphy_membership; /* HT PHY Membership */
120         uint8 mcs[MCSSET_LEN];  /* supported mcs index bit map */
121 } wlc_rateset_t;
122
123 struct rsn_parms {
124         uint8 flags;            /* misc booleans (e.g., supported) */
125         uint8 multicast;        /* multicast cipher */
126         uint8 ucount;           /* count of unicast ciphers */
127         uint8 unicast[4];       /* unicast ciphers */
128         uint8 acount;           /* count of auth modes */
129         uint8 auth[4];          /* Authentication modes */
130         uint8 PAD[4];           /* padding for future growth */
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 */
169         uint16 flags;           /* flags for internal attributes */
170         uint8 SSID_len;         /* the length of SSID */
171         uint8 SSID[32];         /* SSID string */
172         int16 RSSI;             /* receive signal strength (in dBm) */
173         int16 SNR;              /* receive signal SNR in dB */
174         uint16 beacon_period;   /* units are Kusec */
175         uint16 atim_window;     /* units are Kusec */
176         chanspec_t chanspec;    /* Channel num, bw, ctrl_sb and band */
177         int8 infra;             /* 0=IBSS, 1=infrastructure, 2=unknown */
178         wlc_rateset_t rateset;  /* supported rates */
179         uint8 dtim_period;      /* DTIM period */
180         int8 phy_noise;         /* noise right after tx (in dBm) */
181         uint16 capability;      /* Capability information */
182         struct dot11_bcn_prb *bcn_prb;  /* beacon/probe response frame (ioctl na) */
183         uint16 bcn_prb_len;     /* beacon/probe response frame length (ioctl na) */
184         uint8 wme_qosinfo;      /* QoS Info from WME IE; valid if WLC_BSS_WME flag set */
185         struct rsn_parms wpa;
186         struct rsn_parms wpa2;
187         uint16 qbss_load_aac;   /* qbss load available admission capacity */
188         /* qbss_load_chan_free <- (0xff - channel_utilization of qbss_load_ie_t) */
189         uint8 qbss_load_chan_free;      /* indicates how free the channel is */
190         uint8 mcipher;          /* multicast cipher */
191         uint8 wpacfg;           /* wpa config index */
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);
227 typedef int (*dump_fn_t) (void *handle, struct bcmstrbuf *b);
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  */
242 typedef int (*iovar_fn_t) (void *handle, const bcm_iovar_t *vi,
243                            uint32 actionid, const char *name, void *params,
244                            uint plen, void *arg, int alen, int vsize,
245                            struct wlc_if *wlcif);
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 */
280         uint8 _mbss;            /* MBSS mode on */
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 */
288         uint8 _n_enab;          /* bitmap of 11N + HT support */
289         bool _n_reqd;           /* N support required for clients */
290
291         int8 _coex;             /* 20/40 MHz BSS Management AUTO, ENAB, DISABLE */
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
302         uint16 txmaxpkts;       /* max number of large pkts allowed to be pending */
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 */
311         uint16 roam_time_thresh;        /* Max. # secs. of not hearing beacons
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
325         uint16 boardrev;        /* version # of particular board */
326         uint8 sromrev;          /* version # of the srom */
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
397 /* Structure for Pkttag area in a packet.
398  * CAUTION: Please carefully consider your design before adding any new fields to the pkttag
399  * The size is limited to 32 bytes which on 64-bit machine allows only 4 fields.
400  * If adding a member, be sure to check if wlc_pkttag_info_move should transfer it.
401  */
402 typedef struct {
403         uint32 flags;           /* Describe various packet properties */
404         uint16 seq;             /* preassigned seqnum for AMPDU */
405 #ifdef BCMDBG
406         uint16 _scb_dbgid;      /* Uniqe debug id for the scb pointed by scb pointer */
407 #endif
408         uint8 callbackidx;      /* Index into pkt_callback tables for callback function */
409         int8 _bsscfgidx;        /* Index of bsscfg for this frame */
410         int8 ac_override;       /* fifo on which this frame should go */
411         int8 rssi;              /* RSSI for the recvd. packet */
412         uint32 exptime;         /* Time of expiry for the packet */
413         struct scb *_scb;       /* Pointer to SCB for associated ea */
414         uint32 rspec;           /* Phy rate for received packet */
415         union {
416                 uint32 packetid;
417         } shared;
418 } wlc_pkttag_t;
419
420 #define WLPKTTAG(p) ((wlc_pkttag_t *)PKTTAG(p))
421
422 /* Flags used in wlc_pkttag_t.
423  * If adding a flag, be sure to check if WLPKTTAG_FLAG_MOVE should transfer it.
424  */
425 #define WLF_PSMARK              0x00000001      /* PKT marking for PSQ aging */
426 #define WLF_PSDONTQ             0x00000002      /* PS-Poll response don't queue flag */
427 #define WLF_MPDU                0x00000004      /* Set if pkt is a PDU as opposed to MSDU */
428 #define WLF_NON8023             0x00000008      /* original pkt is not 8023 */
429 #define WLF_8021X               0x00000010      /* original pkt is 802.1x */
430 #define WLF_APSD                0x00000020      /* APSD delivery frame */
431 #define WLF_AMSDU               0x00000040      /* pkt is aggregated msdu */
432 #define WLF_HWAMSDU             0x00000080      /* Rx: HW/ucode has deaggregated this A-MSDU */
433 #define WLF_TXHDR               0x00000080      /* Tx: pkt is 802.11 MPDU with plcp and txhdr */
434 #define WLF_BA                  0x00000100      /* Used by BA module if pkt is not to be acked */
435 #define WLF_EXPTIME             0x00000200      /* pkttag has a valid expiration time for the pkt */
436 #define WLF_AMPDU_MPDU          0x00000400      /* mpdu in a ampdu */
437 #define WLF_MIMO                0x00000800      /* mpdu has a mimo rate */
438 #define WLF_RIFS                0x00001000      /* frameburst with RIFS separated */
439 #define WLF_VRATE_PROBE         0x00002000      /* vertical rate probe mpdu */
440 #define WLF_BSS_DOWN            0x00004000      /* The BSS associated with the pkt has gone down */
441 #define WLF_UMAC_PKT            0x00008000      /* UMAC Packet */
442 #define WLF_EXEMPT_MASK         0x00030000      /* mask for encryption exemption (Vista) */
443 #define WLF_WME_NOACK           0x00040000      /* pkt use WME No ACK policy */
444 #define WLF_USERTS              0x04000000      /* protect the packet with RTS/CTS */
445 #define WLF_RATE_AUTO           0x08000000      /* pkt uses rates from the rate selection module */
446
447 #define WLF_DATA                0x40000000      /* pkt is pure data */
448
449 #define WLPKTFLAG_BA(pkttag)    FALSE
450
451 #define WLPKTFLAG_AMPDU(pkttag) ((pkttag)->flags & WLF_AMPDU_MPDU)
452 #define WLPKTFLAG_RIFS(pkttag)  ((pkttag)->flags & WLF_RIFS)
453
454 /* API for accessing BSSCFG index in WLPKTTAG */
455 #define BSSCFGIDX_ISVALID(bsscfgidx) (((bsscfgidx >= 0) && (bsscfgidx < WLC_MAXBSSCFG)) ? 1 : 0)
456
457 static INLINE int8 wlc_pkttag_bsscfg_get(void *p)
458 {
459         int8 idx = WLPKTTAG(p)->_bsscfgidx;
460 #ifdef BCMDBG
461         ASSERT(BSSCFGIDX_ISVALID(idx));
462 #endif
463         return idx;
464 }
465
466 #define WLPKTTAGBSSCFGGET(p) (wlc_pkttag_bsscfg_get(p))
467 #define WLPKTTAGBSSCFGSET(p, bsscfgidx) (WLPKTTAG(p)->_bsscfgidx = bsscfgidx)
468
469 /* Raw get of bss idx from pkt tag without error checking */
470 #define WLPKTTAG_BSSIDX_GET(pkttag) ((pkttag)->_bsscfgidx)
471
472 /***********************************************
473  * Feature-related macros to optimize out code *
474  * *********************************************
475  */
476
477 /* AP Support (versus STA) */
478 #define AP_ENAB(pub)    (0)
479
480 /* Macro to check if APSTA mode enabled */
481 #define APSTA_ENAB(pub) (0)
482
483 /* Some useful combinations */
484 #define STA_ONLY(pub)   (!AP_ENAB(pub))
485 #define AP_ONLY(pub)    (AP_ENAB(pub) && !APSTA_ENAB(pub))
486
487 #define ENAB_1x1        0x01
488 #define ENAB_2x2        0x02
489 #define ENAB_3x3        0x04
490 #define ENAB_4x4        0x08
491 #define SUPPORT_11N     (ENAB_1x1|ENAB_2x2)
492 #define SUPPORT_HT      (ENAB_1x1|ENAB_2x2|ENAB_3x3)
493 /* WL11N Support */
494 #if ((defined(NCONF) && (NCONF != 0)) || (defined(LCNCONF) && (LCNCONF != 0)) || \
495         (defined(HTCONF) && (HTCONF != 0)) || (defined(SSLPNCONF) && (SSLPNCONF != 0)))
496 #define N_ENAB(pub) ((pub)->_n_enab & SUPPORT_11N)
497 #define N_REQD(pub) ((pub)->_n_reqd)
498 #else
499 #define N_ENAB(pub)     0
500 #define N_REQD(pub)     0
501 #endif
502
503 #if (defined(HTCONF) && (HTCONF != 0))
504 #define HT_ENAB(pub) (((pub)->_n_enab & SUPPORT_HT) == SUPPORT_HT)
505 #else
506 #define HT_ENAB(pub) 0
507 #endif
508
509 #define AMPDU_AGG_HOST  1
510 #define AMPDU_ENAB(pub) ((pub)->_ampdu)
511
512 #define EDCF_ENAB(pub) (WME_ENAB(pub))
513 #define QOS_ENAB(pub) (WME_ENAB(pub) || N_ENAB(pub))
514
515 #define MONITOR_ENAB(wlc)       (bcmspace && (wlc)->monitor)
516
517 #define PROMISC_ENAB(wlc)       (bcmspace && (wlc)->promisc)
518
519 extern void wlc_pkttag_info_move(wlc_pub_t *pub, void *pkt_from, void *pkt_to);
520
521 #define WLPKTTAGSCB(p) (WLPKTTAG(p)->_scb)
522
523 #define WLC_PREC_COUNT          16      /* Max precedence level implemented */
524
525 /* pri is PKTPRIO encoded in the packet. This maps the Packet priority to
526  * enqueue precedence as defined in wlc_prec_map
527  */
528 extern const uint8 wlc_prio2prec_map[];
529 #define WLC_PRIO_TO_PREC(pri)   wlc_prio2prec_map[(pri) & 7]
530
531 /* This maps priority to one precedence higher - Used by PS-Poll response packets to
532  * simulate enqueue-at-head operation, but still maintain the order on the queue
533  */
534 #define WLC_PRIO_TO_HI_PREC(pri)        MIN(WLC_PRIO_TO_PREC(pri) + 1, WLC_PREC_COUNT - 1)
535
536 extern const uint8 wme_fifo2ac[];
537 #define WME_PRIO2AC(prio)       wme_fifo2ac[prio2fifo[(prio)]]
538
539 /* Mask to describe all precedence levels */
540 #define WLC_PREC_BMP_ALL                MAXBITVAL(WLC_PREC_COUNT)
541
542 /* Define a bitmap of precedences comprised by each AC */
543 #define WLC_PREC_BMP_AC_BE      (NBITVAL(WLC_PRIO_TO_PREC(PRIO_8021D_BE)) |     \
544                                 NBITVAL(WLC_PRIO_TO_HI_PREC(PRIO_8021D_BE)) |   \
545                                 NBITVAL(WLC_PRIO_TO_PREC(PRIO_8021D_EE)) |      \
546                                 NBITVAL(WLC_PRIO_TO_HI_PREC(PRIO_8021D_EE)))
547 #define WLC_PREC_BMP_AC_BK      (NBITVAL(WLC_PRIO_TO_PREC(PRIO_8021D_BK)) |     \
548                                 NBITVAL(WLC_PRIO_TO_HI_PREC(PRIO_8021D_BK)) |   \
549                                 NBITVAL(WLC_PRIO_TO_PREC(PRIO_8021D_NONE)) |    \
550                                 NBITVAL(WLC_PRIO_TO_HI_PREC(PRIO_8021D_NONE)))
551 #define WLC_PREC_BMP_AC_VI      (NBITVAL(WLC_PRIO_TO_PREC(PRIO_8021D_CL)) |     \
552                                 NBITVAL(WLC_PRIO_TO_HI_PREC(PRIO_8021D_CL)) |   \
553                                 NBITVAL(WLC_PRIO_TO_PREC(PRIO_8021D_VI)) |      \
554                                 NBITVAL(WLC_PRIO_TO_HI_PREC(PRIO_8021D_VI)))
555 #define WLC_PREC_BMP_AC_VO      (NBITVAL(WLC_PRIO_TO_PREC(PRIO_8021D_VO)) |     \
556                                 NBITVAL(WLC_PRIO_TO_HI_PREC(PRIO_8021D_VO)) |   \
557                                 NBITVAL(WLC_PRIO_TO_PREC(PRIO_8021D_NC)) |      \
558                                 NBITVAL(WLC_PRIO_TO_HI_PREC(PRIO_8021D_NC)))
559
560 /* WME Support */
561 #define WME_ENAB(pub) ((pub)->_wme != OFF)
562 #define WME_AUTO(wlc) ((wlc)->pub->_wme == AUTO)
563
564 #define WLC_USE_COREFLAGS       0xffffffff      /* invalid core flags, use the saved coreflags */
565
566 #define WLC_UPDATE_STATS(wlc)   0       /* No stats support */
567 #define WLCNTINCR(a)            /* No stats support */
568 #define WLCNTDECR(a)            /* No stats support */
569 #define WLCNTADD(a, delta)      /* No stats support */
570 #define WLCNTSET(a, value)      /* No stats support */
571 #define WLCNTVAL(a)             0       /* No stats support */
572
573 /* common functions for every port */
574 extern void *wlc_attach(void *wl, uint16 vendor, uint16 device, uint unit,
575                         bool piomode, osl_t *osh, void *regsva, uint bustype,
576                         void *btparam, uint *perr);
577 extern uint wlc_detach(struct wlc_info *wlc);
578 extern int wlc_up(struct wlc_info *wlc);
579 extern uint wlc_down(struct wlc_info *wlc);
580
581 extern int wlc_set(struct wlc_info *wlc, int cmd, int arg);
582 extern int wlc_get(struct wlc_info *wlc, int cmd, int *arg);
583 extern int wlc_iovar_getint(struct wlc_info *wlc, const char *name, int *arg);
584 extern int wlc_iovar_setint(struct wlc_info *wlc, const char *name, int arg);
585 extern bool wlc_chipmatch(uint16 vendor, uint16 device);
586 extern void wlc_init(struct wlc_info *wlc);
587 extern void wlc_reset(struct wlc_info *wlc);
588
589 extern void wlc_intrson(struct wlc_info *wlc);
590 extern uint32 wlc_intrsoff(struct wlc_info *wlc);
591 extern void wlc_intrsrestore(struct wlc_info *wlc, uint32 macintmask);
592 extern bool wlc_intrsupd(struct wlc_info *wlc);
593 extern bool wlc_isr(struct wlc_info *wlc, bool *wantdpc);
594 extern bool wlc_dpc(struct wlc_info *wlc, bool bounded);
595 extern bool wlc_send80211_raw(struct wlc_info *wlc, wlc_if_t *wlcif, void *p,
596                               uint ac);
597 extern int wlc_iovar_op(struct wlc_info *wlc, const char *name, void *params,
598                         int p_len, void *arg, int len, bool set,
599                         struct wlc_if *wlcif);
600 extern int wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
601                      struct wlc_if *wlcif);
602 /* helper functions */
603 extern void wlc_statsupd(struct wlc_info *wlc);
604 extern int wlc_get_header_len(void);
605
606 extern wlc_pub_t *wlc_pub(void *wlc);
607
608 /* common functions for every port */
609 extern int wlc_bmac_up_prep(struct wlc_hw_info *wlc_hw);
610 extern int wlc_bmac_up_finish(struct wlc_hw_info *wlc_hw);
611 extern int wlc_bmac_down_prep(struct wlc_hw_info *wlc_hw);
612 extern int wlc_bmac_down_finish(struct wlc_hw_info *wlc_hw);
613
614 extern int wlc_nin_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
615                          struct wlc_if *wlcif);
616 extern bool wlc_nin_process_sendup(struct wlc_info *wlc, void *p);
617 void wlc_nin_create_iapp_ind(struct wlc_info *wlc, void *p, int len);
618
619 extern uint32 wlc_reg_read(struct wlc_info *wlc, void *r, uint size);
620 extern void wlc_reg_write(struct wlc_info *wlc, void *r, uint32 v, uint size);
621 extern void wlc_corereset(struct wlc_info *wlc, uint32 flags);
622 extern void wlc_mhf(struct wlc_info *wlc, uint8 idx, uint16 mask, uint16 val,
623                     int bands);
624 extern uint16 wlc_mhf_get(struct wlc_info *wlc, uint8 idx, int bands);
625 extern uint32 wlc_delta_txfunfl(struct wlc_info *wlc, int fifo);
626 extern void wlc_rate_lookup_init(struct wlc_info *wlc, wlc_rateset_t *rateset);
627 extern void wlc_default_rateset(struct wlc_info *wlc, wlc_rateset_t *rs);
628 extern void wlc_join_attempt(struct wlc_bsscfg *cfg);
629 extern void wlc_join_bss_start(struct wlc_bsscfg *cfg);
630 extern void wlc_join_BSS(struct wlc_bsscfg *cfg, wlc_bss_info_t *bi);
631
632 /* wlc_phy.c helper functions */
633 extern bool wlc_scan_inprog(struct wlc_info *wlc);
634 extern bool wlc_associnprog(struct wlc_info *wlc);
635 extern bool wlc_scan_inprog(struct wlc_info *wlc);
636 extern void *wlc_cur_phy(struct wlc_info *wlc);
637 extern void wlc_set_ps_ctrl(struct wlc_info *wlc);
638 extern void wlc_mctrl(struct wlc_info *wlc, uint32 mask, uint32 val);
639 extern void wlc_scb_ratesel_init_all(struct wlc_info *wlc);
640
641 /* ioctl */
642 extern int wlc_iovar_getint8(struct wlc_info *wlc, const char *name,
643                              int8 *arg);
644 extern int wlc_iovar_check(wlc_pub_t *pub, const bcm_iovar_t *vi, void *arg,
645                            int len, bool set);
646
647 extern int wlc_module_register(wlc_pub_t *pub, const bcm_iovar_t *iovars,
648                                const char *name, void *hdl, iovar_fn_t iovar_fn,
649                                watchdog_fn_t watchdog_fn, down_fn_t down_fn);
650 extern int wlc_module_unregister(wlc_pub_t *pub, const char *name, void *hdl);
651 extern void wlc_event_if(struct wlc_info *wlc, struct wlc_bsscfg *cfg,
652                          wlc_event_t *e, const struct ether_addr *addr);
653 extern void wlc_suspend_mac_and_wait(struct wlc_info *wlc);
654 extern void wlc_enable_mac(struct wlc_info *wlc);
655 extern uint16 wlc_rate_shm_offset(struct wlc_info *wlc, uint8 rate);
656 extern uint32 wlc_get_rspec_history(struct wlc_bsscfg *cfg);
657 extern uint32 wlc_get_current_highest_rate(struct wlc_bsscfg *cfg);
658
659 static INLINE int wlc_iovar_getuint(struct wlc_info *wlc, const char *name,
660                                     uint *arg)
661 {
662         return wlc_iovar_getint(wlc, name, (int *)arg);
663 }
664
665 static INLINE int wlc_iovar_getuint8(struct wlc_info *wlc, const char *name,
666                                      uint8 *arg)
667 {
668         return wlc_iovar_getint8(wlc, name, (int8 *) arg);
669 }
670
671 static INLINE int wlc_iovar_setuint(struct wlc_info *wlc, const char *name,
672                                     uint arg)
673 {
674         return wlc_iovar_setint(wlc, name, (int)arg);
675 }
676
677 #if defined(BCMDBG)
678 extern int wlc_iocregchk(struct wlc_info *wlc, uint band);
679 #endif
680 #if defined(BCMDBG)
681 extern int wlc_iocpichk(struct wlc_info *wlc, uint phytype);
682 #endif
683
684 /* helper functions */
685 extern void wlc_getrand(struct wlc_info *wlc, uint8 *buf, int len);
686
687 struct scb;
688 extern void wlc_ps_on(struct wlc_info *wlc, struct scb *scb);
689 extern void wlc_ps_off(struct wlc_info *wlc, struct scb *scb, bool discard);
690 extern bool wlc_radio_monitor_stop(struct wlc_info *wlc);
691
692 #if defined(BCMDBG)
693 extern int wlc_format_ssid(char *buf, const uchar ssid[], uint ssid_len);
694 #endif
695
696 extern void wlc_pmkid_build_cand_list(struct wlc_bsscfg *cfg, bool check_SSID);
697 extern void wlc_pmkid_event(struct wlc_bsscfg *cfg);
698
699 #define MAXBANDS                2       /* Maximum #of bands */
700 /* bandstate array indices */
701 #define BAND_2G_INDEX           0       /* wlc->bandstate[x] index */
702 #define BAND_5G_INDEX           1       /* wlc->bandstate[x] index */
703
704 #define BAND_2G_NAME            "2.4G"
705 #define BAND_5G_NAME            "5G"
706
707 #if defined(BCMSDIO) || defined(WLC_HIGH_ONLY)
708 void wlc_device_removed(void *arg);
709 #endif
710
711 /* BMAC RPC: 7 uint32 params: pkttotlen, fifo, commit, fid, txpktpend, pktflag, rpc_id */
712 #define WLC_RPCTX_PARAMS                32
713
714 #endif                          /* _wlc_pub_h_ */