staging: brcm80211: cleaned bcmdefs.h
[cascardo/linux.git] / drivers / staging / brcm80211 / brcmsmac / 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"          /* forward structure declarations */
21 #include "bcmwifi.h"            /* for chanspec_t */
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 s8, units are .25 dBm
62  */
63 #define WLC_TXPWR_MAX           (127)   /* ~32 dBm = 1,500 mW */
64
65 /* rate related definitions */
66 #define WLC_RATE_FLAG   0x80    /* Flag to indicate it is a basic rate */
67 #define WLC_RATE_MASK   0x7f    /* Rate value mask w/o basic rate flag */
68
69 /* legacy rx Antenna diversity for SISO rates */
70 #define ANT_RX_DIV_FORCE_0              0       /* Use antenna 0 */
71 #define ANT_RX_DIV_FORCE_1              1       /* Use antenna 1 */
72 #define ANT_RX_DIV_START_1              2       /* Choose starting with 1 */
73 #define ANT_RX_DIV_START_0              3       /* Choose starting with 0 */
74 #define ANT_RX_DIV_ENABLE               3       /* APHY bbConfig Enable RX Diversity */
75 #define ANT_RX_DIV_DEF          ANT_RX_DIV_START_0      /* default antdiv setting */
76
77 /* legacy rx Antenna diversity for SISO rates */
78 #define ANT_TX_FORCE_0          0       /* Tx on antenna 0, "legacy term Main" */
79 #define ANT_TX_FORCE_1          1       /* Tx on antenna 1, "legacy term Aux" */
80 #define ANT_TX_LAST_RX          3       /* Tx on phy's last good Rx antenna */
81 #define ANT_TX_DEF                      3       /* driver's default tx antenna setting */
82
83 #define TXCORE_POLICY_ALL       0x1     /* use all available core for transmit */
84
85 /* Tx Chain values */
86 #define TXCHAIN_DEF             0x1     /* def bitmap of txchain */
87 #define TXCHAIN_DEF_NPHY        0x3     /* default bitmap of tx chains for nphy */
88 #define TXCHAIN_DEF_HTPHY       0x7     /* default bitmap of tx chains for nphy */
89 #define RXCHAIN_DEF             0x1     /* def bitmap of rxchain */
90 #define RXCHAIN_DEF_NPHY        0x3     /* default bitmap of rx chains for nphy */
91 #define RXCHAIN_DEF_HTPHY       0x7     /* default bitmap of rx chains for nphy */
92 #define ANTSWITCH_NONE          0       /* no antenna switch */
93 #define ANTSWITCH_TYPE_1        1       /* antenna switch on 4321CB2, 2of3 */
94 #define ANTSWITCH_TYPE_2        2       /* antenna switch on 4321MPCI, 2of3 */
95 #define ANTSWITCH_TYPE_3        3       /* antenna switch on 4322, 2of3 */
96
97 #define RXBUFSZ         PKTBUFSZ
98 #ifndef AIDMAPSZ
99 #define AIDMAPSZ        (roundup(MAXSCB, NBBY)/NBBY)    /* aid bitmap size in bytes */
100 #endif                          /* AIDMAPSZ */
101
102 #define MAX_STREAMS_SUPPORTED   4       /* max number of streams supported */
103
104 #define WL_SPURAVOID_OFF        0
105 #define WL_SPURAVOID_ON1        1
106 #define WL_SPURAVOID_ON2        2
107
108 struct ieee80211_tx_queue_params;
109
110 typedef struct wlc_tunables {
111         int ntxd;               /* size of tx descriptor table */
112         int nrxd;               /* size of rx descriptor table */
113         int rxbufsz;            /* size of rx buffers to post */
114         int nrxbufpost;         /* # of rx buffers to post */
115         int maxscb;             /* # of SCBs supported */
116         int ampdunummpdu;       /* max number of mpdu in an ampdu */
117         int maxpktcb;           /* max # of packet callbacks */
118         int maxucodebss;        /* max # of BSS handled in ucode bcn/prb */
119         int maxucodebss4;       /* max # of BSS handled in sw bcn/prb */
120         int maxbss;             /* max # of bss info elements in scan list */
121         int datahiwat;          /* data msg txq hiwat mark */
122         int ampdudatahiwat;     /* AMPDU msg txq hiwat mark */
123         int rxbnd;              /* max # of rx bufs to process before deferring to dpc */
124         int txsbnd;             /* max # tx status to process in wlc_txstatus() */
125         int memreserved;        /* memory reserved for BMAC's USB dma rx */
126 } wlc_tunables_t;
127
128 typedef struct wlc_rateset {
129         uint count;             /* number of rates in rates[] */
130         u8 rates[WLC_NUMRATES]; /* rates in 500kbps units w/hi bit set if basic */
131         u8 htphy_membership;    /* HT PHY Membership */
132         u8 mcs[MCSSET_LEN];     /* supported mcs index bit map */
133 } wlc_rateset_t;
134
135 struct rsn_parms {
136         u8 flags;               /* misc booleans (e.g., supported) */
137         u8 multicast;   /* multicast cipher */
138         u8 ucount;              /* count of unicast ciphers */
139         u8 unicast[4];  /* unicast ciphers */
140         u8 acount;              /* count of auth modes */
141         u8 auth[4];             /* Authentication modes */
142         u8 PAD[4];              /* padding for future growth */
143 };
144
145 /*
146  * 32 SSID chars, max of 4 chars for each SSID char "\xFF", plus NULL.
147  */
148 #define SSID_FMT_BUF_LEN        ((4 * IEEE80211_MAX_SSID_LEN) + 1)
149
150 #define RSN_FLAGS_SUPPORTED             0x1     /* Flag for rsn_params */
151 #define RSN_FLAGS_PREAUTH               0x2     /* Flag for WPA2 rsn_params */
152
153 /* All the HT-specific default advertised capabilities (including AMPDU)
154  * should be grouped here at one place
155  */
156 #define AMPDU_DEF_MPDU_DENSITY  6       /* default mpdu density (110 ==> 4us) */
157
158 /* defaults for the HT (MIMO) bss */
159 #define HT_CAP  (IEEE80211_HT_CAP_SM_PS |\
160         IEEE80211_HT_CAP_SUP_WIDTH_20_40 | IEEE80211_HT_CAP_GRN_FLD |\
161         IEEE80211_HT_CAP_MAX_AMSDU | IEEE80211_HT_CAP_DSSSCCK40)
162
163 /* wlc internal bss_info */
164 typedef struct wlc_bss_info {
165         u8 BSSID[ETH_ALEN];     /* network BSSID */
166         u16 flags;              /* flags for internal attributes */
167         u8 SSID_len;            /* the length of SSID */
168         u8 SSID[32];            /* SSID string */
169         s16 RSSI;               /* receive signal strength (in dBm) */
170         s16 SNR;                /* receive signal SNR in dB */
171         u16 beacon_period;      /* units are Kusec */
172         u16 atim_window;        /* units are Kusec */
173         chanspec_t chanspec;    /* Channel num, bw, ctrl_sb and band */
174         s8 infra;               /* 0=IBSS, 1=infrastructure, 2=unknown */
175         wlc_rateset_t rateset;  /* supported rates */
176         u8 dtim_period; /* DTIM period */
177         s8 phy_noise;           /* noise right after tx (in dBm) */
178         u16 capability; /* Capability information */
179         u8 wme_qosinfo; /* QoS Info from WME IE; valid if WLC_BSS_WME flag set */
180         struct rsn_parms wpa;
181         struct rsn_parms wpa2;
182         u16 qbss_load_aac;      /* qbss load available admission capacity */
183         /* qbss_load_chan_free <- (0xff - channel_utilization of qbss_load_ie_t) */
184         u8 qbss_load_chan_free; /* indicates how free the channel is */
185         u8 mcipher;             /* multicast cipher */
186         u8 wpacfg;              /* wpa config index */
187 } wlc_bss_info_t;
188
189 /* forward declarations */
190 struct wlc_if;
191
192 /* wlc_ioctl error codes */
193 #define WLC_ENOIOCTL    1       /* No such Ioctl */
194 #define WLC_EINVAL      2       /* Invalid value */
195 #define WLC_ETOOSMALL   3       /* Value too small */
196 #define WLC_ETOOBIG     4       /* Value too big */
197 #define WLC_ERANGE      5       /* Out of range */
198 #define WLC_EDOWN       6       /* Down */
199 #define WLC_EUP         7       /* Up */
200 #define WLC_ENOMEM      8       /* No Memory */
201 #define WLC_EBUSY       9       /* Busy */
202
203 /* IOVar flags for common error checks */
204 #define IOVF_MFG        (1<<3)  /* flag for mfgtest iovars */
205 #define IOVF_WHL        (1<<4)  /* value must be whole (0-max) */
206 #define IOVF_NTRL       (1<<5)  /* value must be natural (1-max) */
207
208 #define IOVF_SET_UP     (1<<6)  /* set requires driver be up */
209 #define IOVF_SET_DOWN   (1<<7)  /* set requires driver be down */
210 #define IOVF_SET_CLK    (1<<8)  /* set requires core clock */
211 #define IOVF_SET_BAND   (1<<9)  /* set requires fixed band */
212
213 #define IOVF_GET_UP     (1<<10) /* get requires driver be up */
214 #define IOVF_GET_DOWN   (1<<11) /* get requires driver be down */
215 #define IOVF_GET_CLK    (1<<12) /* get requires core clock */
216 #define IOVF_GET_BAND   (1<<13) /* get requires fixed band */
217 #define IOVF_OPEN_ALLOW (1<<14) /* set allowed iovar for opensrc */
218
219 /* watchdog down and dump callback function proto's */
220 typedef int (*watchdog_fn_t) (void *handle);
221 typedef int (*down_fn_t) (void *handle);
222 typedef int (*dump_fn_t) (void *handle, struct bcmstrbuf *b);
223
224 /* IOVar handler
225  *
226  * handle - a pointer value registered with the function
227  * vi - iovar_info that was looked up
228  * actionid - action ID, calculated by IOV_GVAL() and IOV_SVAL() based on varid.
229  * name - the actual iovar name
230  * params/plen - parameters and length for a get, input only.
231  * arg/len - buffer and length for value to be set or retrieved, input or output.
232  * vsize - value size, valid for integer type only.
233  * wlcif - interface context (wlc_if pointer)
234  *
235  * All pointers may point into the same buffer.
236  */
237 typedef int (*iovar_fn_t) (void *handle, const bcm_iovar_t *vi,
238                            u32 actionid, const char *name, void *params,
239                            uint plen, void *arg, int alen, int vsize,
240                            struct wlc_if *wlcif);
241
242 #define MAC80211_PROMISC_BCNS   (1 << 0)
243 #define MAC80211_SCAN           (1 << 1)
244
245 /*
246  * Public portion of "common" os-independent state structure.
247  * The wlc handle points at this.
248  */
249 struct wlc_pub {
250         void *wlc;
251
252         struct ieee80211_hw *ieee_hw;
253         struct scb *global_scb;
254         scb_ampdu_t *global_ampdu;
255         uint mac80211_state;
256         uint unit;              /* device instance number */
257         uint corerev;           /* core revision */
258         si_t *sih;              /* SB handle (cookie for siutils calls) */
259         char *vars;             /* "environment" name=value */
260         bool up;                /* interface up and running */
261         bool hw_off;            /* HW is off */
262         wlc_tunables_t *tunables;       /* tunables: ntxd, nrxd, maxscb, etc. */
263         bool hw_up;             /* one time hw up/down(from boot or hibernation) */
264         bool _piomode;          /* true if pio mode *//* BMAC_NOTE: NEED In both */
265         uint _nbands;           /* # bands supported */
266         uint now;               /* # elapsed seconds */
267
268         bool promisc;           /* promiscuous destination address */
269         bool delayed_down;      /* down delayed */
270         bool _ap;               /* AP mode enabled */
271         bool _apsta;            /* simultaneous AP/STA mode enabled */
272         bool _assoc_recreate;   /* association recreation on up transitions */
273         int _wme;               /* WME QoS mode */
274         u8 _mbss;               /* MBSS mode on */
275         bool allmulti;          /* enable all multicasts */
276         bool associated;        /* true:part of [I]BSS, false: not */
277         /* (union of stas_associated, aps_associated) */
278         bool phytest_on;        /* whether a PHY test is running */
279         bool bf_preempt_4306;   /* True to enable 'darwin' mode */
280         bool _ampdu;            /* ampdu enabled or not */
281         bool _cac;              /* 802.11e CAC enabled */
282         u8 _n_enab;             /* bitmap of 11N + HT support */
283         bool _n_reqd;           /* N support required for clients */
284
285         s8 _coex;               /* 20/40 MHz BSS Management AUTO, ENAB, DISABLE */
286         bool _priofc;           /* Priority-based flowcontrol */
287
288         u8 cur_etheraddr[ETH_ALEN];     /* our local ethernet address */
289
290         u8 *multicast;  /* ptr to list of multicast addresses */
291         uint nmulticast;        /* # enabled multicast addresses */
292
293         u32 wlfeatureflag;      /* Flags to control sw features from registry */
294         int psq_pkts_total;     /* total num of ps pkts */
295
296         u16 txmaxpkts;  /* max number of large pkts allowed to be pending */
297
298         /* s/w decryption counters */
299         u32 swdecrypt;  /* s/w decrypt attempts */
300
301         int bcmerror;           /* last bcm error */
302
303         mbool radio_disabled;   /* bit vector for radio disabled reasons */
304         bool radio_active;      /* radio on/off state */
305         u16 roam_time_thresh;   /* Max. # secs. of not hearing beacons
306                                          * before roaming.
307                                          */
308         bool align_wd_tbtt;     /* Align watchdog with tbtt indication
309                                  * handling. This flag is cleared by default
310                                  * and is set by per port code explicitly and
311                                  * you need to make sure the OSL_SYSUPTIME()
312                                  * is implemented properly in osl of that port
313                                  * when it enables this Power Save feature.
314                                  */
315
316         u16 boardrev;   /* version # of particular board */
317         u8 sromrev;             /* version # of the srom */
318         char srom_ccode[WLC_CNTRY_BUF_SZ];      /* Country Code in SROM */
319         u32 boardflags; /* Board specific flags from srom */
320         u32 boardflags2;        /* More board flags if sromrev >= 4 */
321         bool tempsense_disable; /* disable periodic tempsense check */
322
323         bool _lmac;             /* lmac module included and enabled */
324         bool _lmacproto;        /* lmac protocol module included and enabled */
325         bool phy_11ncapable;    /* the PHY/HW is capable of 802.11N */
326         bool _ampdumac;         /* mac assist ampdu enabled or not */
327
328         struct wl_cnt *_cnt;    /* low-level counters in driver */
329 };
330
331 /* wl_monitor rx status per packet */
332 typedef struct wl_rxsts {
333         uint pkterror;          /* error flags per pkt */
334         uint phytype;           /* 802.11 A/B/G ... */
335         uint channel;           /* channel */
336         uint datarate;          /* rate in 500kbps */
337         uint antenna;           /* antenna pkts received on */
338         uint pktlength;         /* pkt length minus bcm phy hdr */
339         u32 mactime;            /* time stamp from mac, count per 1us */
340         uint sq;                /* signal quality */
341         s32 signal;             /* in dbm */
342         s32 noise;              /* in dbm */
343         uint preamble;          /* Unknown, short, long */
344         uint encoding;          /* Unknown, CCK, PBCC, OFDM */
345         uint nfrmtype;          /* special 802.11n frames(AMPDU, AMSDU) */
346         struct wl_if *wlif;     /* wl interface */
347 } wl_rxsts_t;
348
349 /* status per error RX pkt */
350 #define WL_RXS_CRC_ERROR                0x00000001      /* CRC Error in packet */
351 #define WL_RXS_RUNT_ERROR               0x00000002      /* Runt packet */
352 #define WL_RXS_ALIGN_ERROR              0x00000004      /* Misaligned packet */
353 #define WL_RXS_OVERSIZE_ERROR           0x00000008      /* packet bigger than RX_LENGTH (usually 1518) */
354 #define WL_RXS_WEP_ICV_ERROR            0x00000010      /* Integrity Check Value error */
355 #define WL_RXS_WEP_ENCRYPTED            0x00000020      /* Encrypted with WEP */
356 #define WL_RXS_PLCP_SHORT               0x00000040      /* Short PLCP error */
357 #define WL_RXS_DECRYPT_ERR              0x00000080      /* Decryption error */
358 #define WL_RXS_OTHER_ERR                0x80000000      /* Other errors */
359
360 /* phy type */
361 #define WL_RXS_PHY_A                    0x00000000      /* A phy type */
362 #define WL_RXS_PHY_B                    0x00000001      /* B phy type */
363 #define WL_RXS_PHY_G                    0x00000002      /* G phy type */
364 #define WL_RXS_PHY_N                    0x00000004      /* N phy type */
365
366 /* encoding */
367 #define WL_RXS_ENCODING_CCK             0x00000000      /* CCK encoding */
368 #define WL_RXS_ENCODING_OFDM            0x00000001      /* OFDM encoding */
369
370 /* preamble */
371 #define WL_RXS_UNUSED_STUB              0x0     /* stub to match with wlc_ethereal.h */
372 #define WL_RXS_PREAMBLE_SHORT           0x00000001      /* Short preamble */
373 #define WL_RXS_PREAMBLE_LONG            0x00000002      /* Long preamble */
374 #define WL_RXS_PREAMBLE_MIMO_MM         0x00000003      /* MIMO mixed mode preamble */
375 #define WL_RXS_PREAMBLE_MIMO_GF         0x00000004      /* MIMO green field preamble */
376
377 #define WL_RXS_NFRM_AMPDU_FIRST         0x00000001      /* first MPDU in A-MPDU */
378 #define WL_RXS_NFRM_AMPDU_SUB           0x00000002      /* subsequent MPDU(s) in A-MPDU */
379 #define WL_RXS_NFRM_AMSDU_FIRST         0x00000004      /* first MSDU in A-MSDU */
380 #define WL_RXS_NFRM_AMSDU_SUB           0x00000008      /* subsequent MSDU(s) in A-MSDU */
381
382 enum wlc_par_id {
383         IOV_MPC = 1,
384         IOV_RTSTHRESH,
385         IOV_QTXPOWER,
386         IOV_BCN_LI_BCN          /* Beacon listen interval in # of beacons */
387 };
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 /***********************************************
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)       ((wlc)->monitor)
441
442 #define PROMISC_ENAB(wlc)       ((wlc)->promisc)
443
444 #define WLC_PREC_COUNT          16      /* Max precedence level implemented */
445
446 /* pri is priority encoded in the packet. This maps the Packet priority to
447  * enqueue precedence as defined in wlc_prec_map
448  */
449 extern const u8 wlc_prio2prec_map[];
450 #define WLC_PRIO_TO_PREC(pri)   wlc_prio2prec_map[(pri) & 7]
451
452 /* This maps priority to one precedence higher - Used by PS-Poll response packets to
453  * simulate enqueue-at-head operation, but still maintain the order on the queue
454  */
455 #define WLC_PRIO_TO_HI_PREC(pri)        min(WLC_PRIO_TO_PREC(pri) + 1, WLC_PREC_COUNT - 1)
456
457 extern const u8 wme_fifo2ac[];
458 #define WME_PRIO2AC(prio)       wme_fifo2ac[prio2fifo[(prio)]]
459
460 /* Mask to describe all precedence levels */
461 #define WLC_PREC_BMP_ALL                MAXBITVAL(WLC_PREC_COUNT)
462
463 /* Define a bitmap of precedences comprised by each AC */
464 #define WLC_PREC_BMP_AC_BE      (NBITVAL(WLC_PRIO_TO_PREC(PRIO_8021D_BE)) |     \
465                                 NBITVAL(WLC_PRIO_TO_HI_PREC(PRIO_8021D_BE)) |   \
466                                 NBITVAL(WLC_PRIO_TO_PREC(PRIO_8021D_EE)) |      \
467                                 NBITVAL(WLC_PRIO_TO_HI_PREC(PRIO_8021D_EE)))
468 #define WLC_PREC_BMP_AC_BK      (NBITVAL(WLC_PRIO_TO_PREC(PRIO_8021D_BK)) |     \
469                                 NBITVAL(WLC_PRIO_TO_HI_PREC(PRIO_8021D_BK)) |   \
470                                 NBITVAL(WLC_PRIO_TO_PREC(PRIO_8021D_NONE)) |    \
471                                 NBITVAL(WLC_PRIO_TO_HI_PREC(PRIO_8021D_NONE)))
472 #define WLC_PREC_BMP_AC_VI      (NBITVAL(WLC_PRIO_TO_PREC(PRIO_8021D_CL)) |     \
473                                 NBITVAL(WLC_PRIO_TO_HI_PREC(PRIO_8021D_CL)) |   \
474                                 NBITVAL(WLC_PRIO_TO_PREC(PRIO_8021D_VI)) |      \
475                                 NBITVAL(WLC_PRIO_TO_HI_PREC(PRIO_8021D_VI)))
476 #define WLC_PREC_BMP_AC_VO      (NBITVAL(WLC_PRIO_TO_PREC(PRIO_8021D_VO)) |     \
477                                 NBITVAL(WLC_PRIO_TO_HI_PREC(PRIO_8021D_VO)) |   \
478                                 NBITVAL(WLC_PRIO_TO_PREC(PRIO_8021D_NC)) |      \
479                                 NBITVAL(WLC_PRIO_TO_HI_PREC(PRIO_8021D_NC)))
480
481 /* WME Support */
482 #define WME_ENAB(pub) ((pub)->_wme != OFF)
483 #define WME_AUTO(wlc) ((wlc)->pub->_wme == AUTO)
484
485 #define WLC_USE_COREFLAGS       0xffffffff      /* invalid core flags, use the saved coreflags */
486
487
488 /* network protection config */
489 #define WLC_PROT_G_SPEC         1       /* SPEC g protection */
490 #define WLC_PROT_G_OVR          2       /* SPEC g prot override */
491 #define WLC_PROT_G_USER         3       /* gmode specified by user */
492 #define WLC_PROT_OVERLAP        4       /* overlap */
493 #define WLC_PROT_N_USER         10      /* nmode specified by user */
494 #define WLC_PROT_N_CFG          11      /* n protection */
495 #define WLC_PROT_N_CFG_OVR      12      /* n protection override */
496 #define WLC_PROT_N_NONGF        13      /* non-GF protection */
497 #define WLC_PROT_N_NONGF_OVR    14      /* non-GF protection override */
498 #define WLC_PROT_N_PAM_OVR      15      /* n preamble override */
499 #define WLC_PROT_N_OBSS         16      /* non-HT OBSS present */
500
501 /*
502  * 54g modes (basic bits may still be overridden)
503  *
504  * GMODE_LEGACY_B                       Rateset: 1b, 2b, 5.5, 11
505  *                                      Preamble: Long
506  *                                      Shortslot: Off
507  * GMODE_AUTO                           Rateset: 1b, 2b, 5.5b, 11b, 18, 24, 36, 54
508  *                                      Extended Rateset: 6, 9, 12, 48
509  *                                      Preamble: Long
510  *                                      Shortslot: Auto
511  * GMODE_ONLY                           Rateset: 1b, 2b, 5.5b, 11b, 18, 24b, 36, 54
512  *                                      Extended Rateset: 6b, 9, 12b, 48
513  *                                      Preamble: Short required
514  *                                      Shortslot: Auto
515  * GMODE_B_DEFERRED                     Rateset: 1b, 2b, 5.5b, 11b, 18, 24, 36, 54
516  *                                      Extended Rateset: 6, 9, 12, 48
517  *                                      Preamble: Long
518  *                                      Shortslot: On
519  * GMODE_PERFORMANCE                    Rateset: 1b, 2b, 5.5b, 6b, 9, 11b, 12b, 18, 24b, 36, 48, 54
520  *                                      Preamble: Short required
521  *                                      Shortslot: On and required
522  * GMODE_LRS                            Rateset: 1b, 2b, 5.5b, 11b
523  *                                      Extended Rateset: 6, 9, 12, 18, 24, 36, 48, 54
524  *                                      Preamble: Long
525  *                                      Shortslot: Auto
526  */
527 #define GMODE_LEGACY_B          0
528 #define GMODE_AUTO              1
529 #define GMODE_ONLY              2
530 #define GMODE_B_DEFERRED        3
531 #define GMODE_PERFORMANCE       4
532 #define GMODE_LRS               5
533 #define GMODE_MAX               6
534
535 /* values for PLCPHdr_override */
536 #define WLC_PLCP_AUTO   -1
537 #define WLC_PLCP_SHORT  0
538 #define WLC_PLCP_LONG   1
539
540 /* values for g_protection_override and n_protection_override */
541 #define WLC_PROTECTION_AUTO             -1
542 #define WLC_PROTECTION_OFF              0
543 #define WLC_PROTECTION_ON               1
544 #define WLC_PROTECTION_MMHDR_ONLY       2
545 #define WLC_PROTECTION_CTS_ONLY         3
546
547 /* values for g_protection_control and n_protection_control */
548 #define WLC_PROTECTION_CTL_OFF          0
549 #define WLC_PROTECTION_CTL_LOCAL        1
550 #define WLC_PROTECTION_CTL_OVERLAP      2
551
552 /* values for n_protection */
553 #define WLC_N_PROTECTION_OFF            0
554 #define WLC_N_PROTECTION_OPTIONAL       1
555 #define WLC_N_PROTECTION_20IN40         2
556 #define WLC_N_PROTECTION_MIXEDMODE      3
557
558 /* values for band specific 40MHz capabilities */
559 #define WLC_N_BW_20ALL                  0
560 #define WLC_N_BW_40ALL                  1
561 #define WLC_N_BW_20IN2G_40IN5G          2
562
563 /* bitflags for SGI support (sgi_rx iovar) */
564 #define WLC_N_SGI_20                    0x01
565 #define WLC_N_SGI_40                    0x02
566
567 /* defines used by the nrate iovar */
568 #define NRATE_MCS_INUSE 0x00000080      /* MSC in use,indicates b0-6 holds an mcs */
569 #define NRATE_RATE_MASK 0x0000007f      /* rate/mcs value */
570 #define NRATE_STF_MASK  0x0000ff00      /* stf mode mask: siso, cdd, stbc, sdm */
571 #define NRATE_STF_SHIFT 8       /* stf mode shift */
572 #define NRATE_OVERRIDE  0x80000000      /* bit indicates override both rate & mode */
573 #define NRATE_OVERRIDE_MCS_ONLY 0x40000000      /* bit indicate to override mcs only */
574 #define NRATE_SGI_MASK  0x00800000      /* sgi mode */
575 #define NRATE_SGI_SHIFT 23      /* sgi mode */
576 #define NRATE_LDPC_CODING 0x00400000    /* bit indicates adv coding in use */
577 #define NRATE_LDPC_SHIFT 22     /* ldpc shift */
578
579 #define NRATE_STF_SISO  0       /* stf mode SISO */
580 #define NRATE_STF_CDD   1       /* stf mode CDD */
581 #define NRATE_STF_STBC  2       /* stf mode STBC */
582 #define NRATE_STF_SDM   3       /* stf mode SDM */
583
584 #define ANT_SELCFG_MAX          4       /* max number of antenna configurations */
585
586 #define HIGHEST_SINGLE_STREAM_MCS       7       /* MCS values greater than this enable multiple streams */
587
588 typedef struct {
589         u8 ant_config[ANT_SELCFG_MAX];  /* antenna configuration */
590         u8 num_antcfg;  /* number of available antenna configurations */
591 } wlc_antselcfg_t;
592
593 /* common functions for every port */
594 extern void *wlc_attach(struct wl_info *wl, u16 vendor, u16 device, uint unit,
595                         bool piomode, void *regsva, uint bustype, void *btparam,
596                         uint *perr);
597 extern uint wlc_detach(struct wlc_info *wlc);
598 extern int wlc_up(struct wlc_info *wlc);
599 extern uint wlc_down(struct wlc_info *wlc);
600
601 extern int wlc_set(struct wlc_info *wlc, int cmd, int arg);
602 extern int wlc_get(struct wlc_info *wlc, int cmd, int *arg);
603 extern bool wlc_chipmatch(u16 vendor, u16 device);
604 extern void wlc_init(struct wlc_info *wlc);
605 extern void wlc_reset(struct wlc_info *wlc);
606
607 extern void wlc_intrson(struct wlc_info *wlc);
608 extern u32 wlc_intrsoff(struct wlc_info *wlc);
609 extern void wlc_intrsrestore(struct wlc_info *wlc, u32 macintmask);
610 extern bool wlc_intrsupd(struct wlc_info *wlc);
611 extern bool wlc_isr(struct wlc_info *wlc, bool *wantdpc);
612 extern bool wlc_dpc(struct wlc_info *wlc, bool bounded);
613 extern bool wlc_sendpkt_mac80211(struct wlc_info *wlc, struct sk_buff *sdu,
614                                  struct ieee80211_hw *hw);
615 extern int wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
616                      struct wlc_if *wlcif);
617 extern bool wlc_aggregatable(struct wlc_info *wlc, u8 tid);
618
619 /* helper functions */
620 extern void wlc_statsupd(struct wlc_info *wlc);
621 extern void wlc_protection_upd(struct wlc_info *wlc, uint idx, int val);
622 extern int wlc_get_header_len(void);
623 extern void wlc_mac_bcn_promisc_change(struct wlc_info *wlc, bool promisc);
624 extern void wlc_set_addrmatch(struct wlc_info *wlc, int match_reg_offset,
625                               const u8 *addr);
626 extern void wlc_wme_setparams(struct wlc_info *wlc, u16 aci,
627                               const struct ieee80211_tx_queue_params *arg,
628                               bool suspend);
629 extern struct wlc_pub *wlc_pub(void *wlc);
630
631 /* common functions for every port */
632 extern void wlc_mhf(struct wlc_info *wlc, u8 idx, u16 mask, u16 val,
633                     int bands);
634 extern void wlc_rate_lookup_init(struct wlc_info *wlc, wlc_rateset_t *rateset);
635 extern void wlc_default_rateset(struct wlc_info *wlc, wlc_rateset_t *rs);
636
637 struct ieee80211_sta;
638 extern void wlc_ampdu_flush(struct wlc_info *wlc, struct ieee80211_sta *sta,
639                             u16 tid);
640 int wlc_set_par(struct wlc_info *wlc, enum wlc_par_id par_id, int val);
641 int wlc_get_par(struct wlc_info *wlc, enum wlc_par_id par_id, int *ret_int_ptr);
642
643 /* wlc_phy.c helper functions */
644 extern void wlc_set_ps_ctrl(struct wlc_info *wlc);
645 extern void wlc_mctrl(struct wlc_info *wlc, u32 mask, u32 val);
646
647 extern int wlc_module_register(struct wlc_pub *pub,
648                                const char *name, void *hdl,
649                                watchdog_fn_t watchdog_fn, down_fn_t down_fn);
650 extern int wlc_module_unregister(struct wlc_pub *pub, const char *name,
651                                  void *hdl);
652 extern void wlc_suspend_mac_and_wait(struct wlc_info *wlc);
653 extern void wlc_enable_mac(struct wlc_info *wlc);
654 extern void wlc_associate_upd(struct wlc_info *wlc, bool state);
655 extern void wlc_scan_start(struct wlc_info *wlc);
656 extern void wlc_scan_stop(struct wlc_info *wlc);
657 extern int wlc_get_curband(struct wlc_info *wlc);
658 extern void wlc_wait_for_tx_completion(struct wlc_info *wlc, bool drop);
659
660 /* helper functions */
661 extern bool wlc_check_radio_disabled(struct wlc_info *wlc);
662 extern bool wlc_radio_monitor_stop(struct wlc_info *wlc);
663
664 #define MAXBANDS                2       /* Maximum #of bands */
665 /* bandstate array indices */
666 #define BAND_2G_INDEX           0       /* wlc->bandstate[x] index */
667 #define BAND_5G_INDEX           1       /* wlc->bandstate[x] index */
668
669 #define BAND_2G_NAME            "2.4G"
670 #define BAND_5G_NAME            "5G"
671
672 /* BMAC RPC: 7 u32 params: pkttotlen, fifo, commit, fid, txpktpend, pktflag, rpc_id */
673 #define WLC_RPCTX_PARAMS                32
674
675 #endif                          /* _wlc_pub_h_ */