Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright (c) 2010 Broadcom Corporation
0003  *
0004  * Permission to use, copy, modify, and/or distribute this software for any
0005  * purpose with or without fee is hereby granted, provided that the above
0006  * copyright notice and this permission notice appear in all copies.
0007  *
0008  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
0009  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
0010  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
0011  * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
0012  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
0013  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
0014  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
0015  */
0016 
0017 #ifndef _BRCM_PUB_H_
0018 #define _BRCM_PUB_H_
0019 
0020 #include <linux/bcma/bcma.h>
0021 #include <brcmu_wifi.h>
0022 #include "types.h"
0023 #include "defs.h"
0024 
0025 #define BRCMS_NUMRATES  16  /* max # of rates in a rateset */
0026 
0027 /* phy types */
0028 #define PHY_TYPE_A  0   /* Phy type A */
0029 #define PHY_TYPE_G  2   /* Phy type G */
0030 #define PHY_TYPE_N  4   /* Phy type N */
0031 #define PHY_TYPE_LP 5   /* Phy type Low Power A/B/G */
0032 #define PHY_TYPE_SSN    6   /* Phy type Single Stream N */
0033 #define PHY_TYPE_LCN    8   /* Phy type Single Stream N */
0034 #define PHY_TYPE_LCNXN  9   /* Phy type 2-stream N */
0035 #define PHY_TYPE_HT 7   /* Phy type 3-Stream N */
0036 
0037 /* bw */
0038 #define BRCMS_10_MHZ    10  /* 10Mhz nphy channel bandwidth */
0039 #define BRCMS_20_MHZ    20  /* 20Mhz nphy channel bandwidth */
0040 #define BRCMS_40_MHZ    40  /* 40Mhz nphy channel bandwidth */
0041 
0042 #define BRCMS_RSSI_MINVAL   -200    /* Low value, e.g. for forcing roam */
0043 #define BRCMS_RSSI_NO_SIGNAL    -91 /* NDIS RSSI link quality cutoffs */
0044 #define BRCMS_RSSI_VERY_LOW -80 /* Very low quality cutoffs */
0045 #define BRCMS_RSSI_LOW      -70 /* Low quality cutoffs */
0046 #define BRCMS_RSSI_GOOD     -68 /* Good quality cutoffs */
0047 #define BRCMS_RSSI_VERY_GOOD    -58 /* Very good quality cutoffs */
0048 #define BRCMS_RSSI_EXCELLENT    -57 /* Excellent quality cutoffs */
0049 
0050 /* a large TX Power as an init value to factor out of min() calculations,
0051  * keep low enough to fit in an s8, units are .25 dBm
0052  */
0053 #define BRCMS_TXPWR_MAX     (127)   /* ~32 dBm = 1,500 mW */
0054 
0055 /* rate related definitions */
0056 #define BRCMS_RATE_FLAG 0x80    /* Flag to indicate it is a basic rate */
0057 #define BRCMS_RATE_MASK 0x7f    /* Rate value mask w/o basic rate flag */
0058 
0059 /* legacy rx Antenna diversity for SISO rates */
0060 #define ANT_RX_DIV_FORCE_0  0   /* Use antenna 0 */
0061 #define ANT_RX_DIV_FORCE_1  1   /* Use antenna 1 */
0062 #define ANT_RX_DIV_START_1  2   /* Choose starting with 1 */
0063 #define ANT_RX_DIV_START_0  3   /* Choose starting with 0 */
0064 #define ANT_RX_DIV_ENABLE   3   /* APHY bbConfig Enable RX Diversity */
0065 /* default antdiv setting */
0066 #define ANT_RX_DIV_DEF      ANT_RX_DIV_START_0
0067 
0068 /* legacy rx Antenna diversity for SISO rates */
0069 /* Tx on antenna 0, "legacy term Main" */
0070 #define ANT_TX_FORCE_0      0
0071 /* Tx on antenna 1, "legacy term Aux" */
0072 #define ANT_TX_FORCE_1      1
0073 /* Tx on phy's last good Rx antenna */
0074 #define ANT_TX_LAST_RX      3
0075 /* driver's default tx antenna setting */
0076 #define ANT_TX_DEF      3
0077 
0078 /* Tx Chain values */
0079 /* def bitmap of txchain */
0080 #define TXCHAIN_DEF     0x1
0081 /* default bitmap of tx chains for nphy */
0082 #define TXCHAIN_DEF_NPHY    0x3
0083 /* default bitmap of tx chains for nphy */
0084 #define TXCHAIN_DEF_HTPHY   0x7
0085 /* def bitmap of rxchain */
0086 #define RXCHAIN_DEF     0x1
0087 /* default bitmap of rx chains for nphy */
0088 #define RXCHAIN_DEF_NPHY    0x3
0089 /* default bitmap of rx chains for nphy */
0090 #define RXCHAIN_DEF_HTPHY   0x7
0091 /* no antenna switch */
0092 #define ANTSWITCH_NONE      0
0093 /* antenna switch on 4321CB2, 2of3 */
0094 #define ANTSWITCH_TYPE_1    1
0095 /* antenna switch on 4321MPCI, 2of3 */
0096 #define ANTSWITCH_TYPE_2    2
0097 /* antenna switch on 4322, 2of3 */
0098 #define ANTSWITCH_TYPE_3    3
0099 
0100 #define RXBUFSZ     PKTBUFSZ
0101 
0102 #define MAX_STREAMS_SUPPORTED   4   /* max number of streams supported */
0103 
0104 struct brcm_rateset {
0105     /* # rates in this set */
0106     u32 count;
0107     /* rates in 500kbps units w/hi bit set if basic */
0108     u8 rates[WL_NUMRATES];
0109 };
0110 
0111 struct brcms_c_rateset {
0112     uint count;     /* number of rates in rates[] */
0113      /* rates in 500kbps units w/hi bit set if basic */
0114     u8 rates[BRCMS_NUMRATES];
0115     u8 htphy_membership;    /* HT PHY Membership */
0116     u8 mcs[MCSSET_LEN]; /* supported mcs index bit map */
0117 };
0118 
0119 /* All the HT-specific default advertised capabilities (including AMPDU)
0120  * should be grouped here at one place
0121  */
0122 #define AMPDU_DEF_MPDU_DENSITY  6   /* default mpdu density (110 ==> 4us) */
0123 
0124 /* wlc internal bss_info */
0125 struct brcms_bss_info {
0126     u8 BSSID[ETH_ALEN]; /* network BSSID */
0127     u16 flags;      /* flags for internal attributes */
0128     u8 SSID_len;        /* the length of SSID */
0129     u8 SSID[32];        /* SSID string */
0130     s16 RSSI;       /* receive signal strength (in dBm) */
0131     s16 SNR;        /* receive signal SNR in dB */
0132     u16 beacon_period;  /* units are Kusec */
0133     u16 chanspec;   /* Channel num, bw, ctrl_sb and band */
0134     struct brcms_c_rateset rateset; /* supported rates */
0135 };
0136 
0137 #define MAC80211_PROMISC_BCNS   (1 << 0)
0138 #define MAC80211_SCAN       (1 << 1)
0139 
0140 /*
0141  * Public portion of common driver state structure.
0142  * The wlc handle points at this.
0143  */
0144 struct brcms_pub {
0145     struct brcms_c_info *wlc;
0146     struct ieee80211_hw *ieee_hw;
0147     struct scb_ampdu *global_ampdu;
0148     uint mac80211_state;
0149     uint unit;      /* device instance number */
0150     uint corerev;       /* core revision */
0151     struct si_pub *sih; /* SI handle (cookie for siutils calls) */
0152     bool up;        /* interface up and running */
0153     bool hw_off;        /* HW is off */
0154     bool hw_up;     /* one time hw up/down */
0155     bool _piomode;      /* true if pio mode */
0156     uint _nbands;       /* # bands supported */
0157     uint now;       /* # elapsed seconds */
0158 
0159     bool delayed_down;  /* down delayed */
0160     bool associated;    /* true:part of [I]BSS, false: not */
0161     /* (union of stas_associated, aps_associated) */
0162     bool _ampdu;        /* ampdu enabled or not */
0163     u8 _n_enab;     /* bitmap of 11N + HT support */
0164 
0165     u8 cur_etheraddr[ETH_ALEN]; /* our local ethernet address */
0166 
0167     u32 radio_disabled; /* bit vector for radio disabled reasons */
0168 
0169     u16 boardrev;   /* version # of particular board */
0170     u8 sromrev;     /* version # of the srom */
0171     char srom_ccode[BRCM_CNTRY_BUF_SZ]; /* Country Code in SROM */
0172     u32 boardflags; /* Board specific flags from srom */
0173     u32 boardflags2;    /* More board flags if sromrev >= 4 */
0174     bool phy_11ncapable;    /* the PHY/HW is capable of 802.11N */
0175 
0176     struct wl_cnt *_cnt;    /* low-level counters in driver */
0177     struct dentry *dbgfs_dir;
0178 };
0179 
0180 enum wlc_par_id {
0181     IOV_MPC = 1,
0182     IOV_RTSTHRESH,
0183     IOV_QTXPOWER,
0184     IOV_BCN_LI_BCN      /* Beacon listen interval in # of beacons */
0185 };
0186 
0187 /***********************************************
0188  * Feature-related macros to optimize out code *
0189  * *********************************************
0190  */
0191 
0192 #define ENAB_1x1    0x01
0193 #define ENAB_2x2    0x02
0194 #define ENAB_3x3    0x04
0195 #define ENAB_4x4    0x08
0196 #define SUPPORT_11N (ENAB_1x1|ENAB_2x2)
0197 #define SUPPORT_HT  (ENAB_1x1|ENAB_2x2|ENAB_3x3)
0198 
0199 /* WL11N Support */
0200 #define AMPDU_AGG_HOST  1
0201 
0202 /* network protection config */
0203 #define BRCMS_PROT_G_SPEC       1   /* SPEC g protection */
0204 #define BRCMS_PROT_G_OVR        2   /* SPEC g prot override */
0205 #define BRCMS_PROT_G_USER       3   /* gmode specified by user */
0206 #define BRCMS_PROT_OVERLAP  4   /* overlap */
0207 #define BRCMS_PROT_N_USER       10  /* nmode specified by user */
0208 #define BRCMS_PROT_N_CFG        11  /* n protection */
0209 #define BRCMS_PROT_N_CFG_OVR    12  /* n protection override */
0210 #define BRCMS_PROT_N_NONGF  13  /* non-GF protection */
0211 #define BRCMS_PROT_N_NONGF_OVR  14  /* non-GF protection override */
0212 #define BRCMS_PROT_N_PAM_OVR    15  /* n preamble override */
0213 #define BRCMS_PROT_N_OBSS       16  /* non-HT OBSS present */
0214 
0215 /*
0216  * 54g modes (basic bits may still be overridden)
0217  *
0218  * GMODE_LEGACY_B
0219  *  Rateset: 1b, 2b, 5.5, 11
0220  *  Preamble: Long
0221  *  Shortslot: Off
0222  * GMODE_AUTO
0223  *  Rateset: 1b, 2b, 5.5b, 11b, 18, 24, 36, 54
0224  *  Extended Rateset: 6, 9, 12, 48
0225  *  Preamble: Long
0226  *  Shortslot: Auto
0227  * GMODE_ONLY
0228  *  Rateset: 1b, 2b, 5.5b, 11b, 18, 24b, 36, 54
0229  *  Extended Rateset: 6b, 9, 12b, 48
0230  *  Preamble: Short required
0231  *  Shortslot: Auto
0232  * GMODE_B_DEFERRED
0233  *  Rateset: 1b, 2b, 5.5b, 11b, 18, 24, 36, 54
0234  *  Extended Rateset: 6, 9, 12, 48
0235  *  Preamble: Long
0236  *  Shortslot: On
0237  * GMODE_PERFORMANCE
0238  *  Rateset: 1b, 2b, 5.5b, 6b, 9, 11b, 12b, 18, 24b, 36, 48, 54
0239  *  Preamble: Short required
0240  *  Shortslot: On and required
0241  * GMODE_LRS
0242  *  Rateset: 1b, 2b, 5.5b, 11b
0243  *  Extended Rateset: 6, 9, 12, 18, 24, 36, 48, 54
0244  *  Preamble: Long
0245  *  Shortslot: Auto
0246  */
0247 #define GMODE_LEGACY_B      0
0248 #define GMODE_AUTO      1
0249 #define GMODE_ONLY      2
0250 #define GMODE_B_DEFERRED    3
0251 #define GMODE_PERFORMANCE   4
0252 #define GMODE_LRS       5
0253 #define GMODE_MAX       6
0254 
0255 /* MCS values greater than this enable multiple streams */
0256 #define HIGHEST_SINGLE_STREAM_MCS   7
0257 
0258 #define MAXBANDS        2   /* Maximum #of bands */
0259 
0260 /* max number of antenna configurations */
0261 #define ANT_SELCFG_MAX      4
0262 
0263 struct brcms_antselcfg {
0264     u8 ant_config[ANT_SELCFG_MAX];  /* antenna configuration */
0265     u8 num_antcfg;  /* number of available antenna configurations */
0266 };
0267 
0268 /* common functions for every port */
0269 struct brcms_c_info *brcms_c_attach(struct brcms_info *wl,
0270                     struct bcma_device *core, uint unit,
0271                     bool piomode, uint *perr);
0272 uint brcms_c_detach(struct brcms_c_info *wlc);
0273 int brcms_c_up(struct brcms_c_info *wlc);
0274 uint brcms_c_down(struct brcms_c_info *wlc);
0275 
0276 bool brcms_c_chipmatch(struct bcma_device *core);
0277 void brcms_c_init(struct brcms_c_info *wlc, bool mute_tx);
0278 void brcms_c_reset(struct brcms_c_info *wlc);
0279 
0280 void brcms_c_intrson(struct brcms_c_info *wlc);
0281 u32 brcms_c_intrsoff(struct brcms_c_info *wlc);
0282 void brcms_c_intrsrestore(struct brcms_c_info *wlc, u32 macintmask);
0283 bool brcms_c_intrsupd(struct brcms_c_info *wlc);
0284 bool brcms_c_isr(struct brcms_c_info *wlc);
0285 bool brcms_c_dpc(struct brcms_c_info *wlc, bool bounded);
0286 bool brcms_c_sendpkt_mac80211(struct brcms_c_info *wlc, struct sk_buff *sdu,
0287                   struct ieee80211_hw *hw);
0288 bool brcms_c_aggregatable(struct brcms_c_info *wlc, u8 tid);
0289 void brcms_c_protection_upd(struct brcms_c_info *wlc, uint idx, int val);
0290 int brcms_c_get_header_len(void);
0291 void brcms_c_set_addrmatch(struct brcms_c_info *wlc, int match_reg_offset,
0292                const u8 *addr);
0293 void brcms_c_wme_setparams(struct brcms_c_info *wlc, u16 aci,
0294                const struct ieee80211_tx_queue_params *arg,
0295                bool suspend);
0296 struct brcms_pub *brcms_c_pub(struct brcms_c_info *wlc);
0297 void brcms_c_ampdu_flush(struct brcms_c_info *wlc, struct ieee80211_sta *sta,
0298              u16 tid);
0299 void brcms_c_ampdu_tx_operational(struct brcms_c_info *wlc, u8 tid,
0300                   u8 ba_wsize, uint max_rx_ampdu_bytes);
0301 int brcms_c_module_register(struct brcms_pub *pub, const char *name,
0302                 struct brcms_info *hdl,
0303                 int (*down_fn)(void *handle));
0304 int brcms_c_module_unregister(struct brcms_pub *pub, const char *name,
0305                   struct brcms_info *hdl);
0306 void brcms_c_suspend_mac_and_wait(struct brcms_c_info *wlc);
0307 void brcms_c_enable_mac(struct brcms_c_info *wlc);
0308 void brcms_c_associate_upd(struct brcms_c_info *wlc, bool state);
0309 void brcms_c_scan_start(struct brcms_c_info *wlc);
0310 void brcms_c_scan_stop(struct brcms_c_info *wlc);
0311 int brcms_c_get_curband(struct brcms_c_info *wlc);
0312 int brcms_c_set_channel(struct brcms_c_info *wlc, u16 channel);
0313 int brcms_c_set_rate_limit(struct brcms_c_info *wlc, u16 srl, u16 lrl);
0314 void brcms_c_get_current_rateset(struct brcms_c_info *wlc,
0315                  struct brcm_rateset *currs);
0316 int brcms_c_set_rateset(struct brcms_c_info *wlc, struct brcm_rateset *rs);
0317 int brcms_c_set_beacon_period(struct brcms_c_info *wlc, u16 period);
0318 u16 brcms_c_get_phy_type(struct brcms_c_info *wlc, int phyidx);
0319 void brcms_c_set_shortslot_override(struct brcms_c_info *wlc,
0320                     s8 sslot_override);
0321 void brcms_c_set_beacon_listen_interval(struct brcms_c_info *wlc, u8 interval);
0322 u64 brcms_c_tsf_get(struct brcms_c_info *wlc);
0323 void brcms_c_tsf_set(struct brcms_c_info *wlc, u64 tsf);
0324 int brcms_c_set_tx_power(struct brcms_c_info *wlc, int txpwr);
0325 int brcms_c_get_tx_power(struct brcms_c_info *wlc);
0326 bool brcms_c_check_radio_disabled(struct brcms_c_info *wlc);
0327 void brcms_c_mute(struct brcms_c_info *wlc, bool on);
0328 bool brcms_c_tx_flush_completed(struct brcms_c_info *wlc);
0329 void brcms_c_start_station(struct brcms_c_info *wlc, u8 *addr);
0330 void brcms_c_start_ap(struct brcms_c_info *wlc, u8 *addr, const u8 *bssid,
0331               u8 *ssid, size_t ssid_len);
0332 void brcms_c_start_adhoc(struct brcms_c_info *wlc, u8 *addr);
0333 void brcms_c_update_beacon(struct brcms_c_info *wlc);
0334 void brcms_c_set_new_beacon(struct brcms_c_info *wlc, struct sk_buff *beacon,
0335                 u16 tim_offset, u16 dtim_period);
0336 void brcms_c_set_new_probe_resp(struct brcms_c_info *wlc,
0337                 struct sk_buff *probe_resp);
0338 void brcms_c_enable_probe_resp(struct brcms_c_info *wlc, bool enable);
0339 void brcms_c_set_ssid(struct brcms_c_info *wlc, u8 *ssid, size_t ssid_len);
0340 
0341 #endif              /* _BRCM_PUB_H_ */