Path: blob/main/sys/contrib/dev/broadcom/brcm80211/brcmsmac/pub.h
178665 views
/*1* Copyright (c) 2010 Broadcom Corporation2*3* Permission to use, copy, modify, and/or distribute this software for any4* purpose with or without fee is hereby granted, provided that the above5* copyright notice and this permission notice appear in all copies.6*7* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES8* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF9* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY10* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES11* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION12* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN13* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.14*/1516#ifndef _BRCM_PUB_H_17#define _BRCM_PUB_H_1819#include <linux/bcma/bcma.h>20#include <brcmu_wifi.h>21#include "types.h"22#include "defs.h"2324#define BRCMS_NUMRATES 16 /* max # of rates in a rateset */2526/* phy types */27#define PHY_TYPE_A 0 /* Phy type A */28#define PHY_TYPE_G 2 /* Phy type G */29#define PHY_TYPE_N 4 /* Phy type N */30#define PHY_TYPE_LP 5 /* Phy type Low Power A/B/G */31#define PHY_TYPE_SSN 6 /* Phy type Single Stream N */32#define PHY_TYPE_LCN 8 /* Phy type Single Stream N */33#define PHY_TYPE_LCNXN 9 /* Phy type 2-stream N */34#define PHY_TYPE_HT 7 /* Phy type 3-Stream N */3536/* bw */37#define BRCMS_10_MHZ 10 /* 10Mhz nphy channel bandwidth */38#define BRCMS_20_MHZ 20 /* 20Mhz nphy channel bandwidth */39#define BRCMS_40_MHZ 40 /* 40Mhz nphy channel bandwidth */4041#define BRCMS_RSSI_MINVAL -200 /* Low value, e.g. for forcing roam */42#define BRCMS_RSSI_NO_SIGNAL -91 /* NDIS RSSI link quality cutoffs */43#define BRCMS_RSSI_VERY_LOW -80 /* Very low quality cutoffs */44#define BRCMS_RSSI_LOW -70 /* Low quality cutoffs */45#define BRCMS_RSSI_GOOD -68 /* Good quality cutoffs */46#define BRCMS_RSSI_VERY_GOOD -58 /* Very good quality cutoffs */47#define BRCMS_RSSI_EXCELLENT -57 /* Excellent quality cutoffs */4849/* a large TX Power as an init value to factor out of min() calculations,50* keep low enough to fit in an s8, units are .25 dBm51*/52#define BRCMS_TXPWR_MAX (127) /* ~32 dBm = 1,500 mW */5354/* rate related definitions */55#define BRCMS_RATE_FLAG 0x80 /* Flag to indicate it is a basic rate */56#define BRCMS_RATE_MASK 0x7f /* Rate value mask w/o basic rate flag */5758/* legacy rx Antenna diversity for SISO rates */59#define ANT_RX_DIV_FORCE_0 0 /* Use antenna 0 */60#define ANT_RX_DIV_FORCE_1 1 /* Use antenna 1 */61#define ANT_RX_DIV_START_1 2 /* Choose starting with 1 */62#define ANT_RX_DIV_START_0 3 /* Choose starting with 0 */63#define ANT_RX_DIV_ENABLE 3 /* APHY bbConfig Enable RX Diversity */64/* default antdiv setting */65#define ANT_RX_DIV_DEF ANT_RX_DIV_START_06667/* legacy rx Antenna diversity for SISO rates */68/* Tx on antenna 0, "legacy term Main" */69#define ANT_TX_FORCE_0 070/* Tx on antenna 1, "legacy term Aux" */71#define ANT_TX_FORCE_1 172/* Tx on phy's last good Rx antenna */73#define ANT_TX_LAST_RX 374/* driver's default tx antenna setting */75#define ANT_TX_DEF 37677/* Tx Chain values */78/* def bitmap of txchain */79#define TXCHAIN_DEF 0x180/* default bitmap of tx chains for nphy */81#define TXCHAIN_DEF_NPHY 0x382/* default bitmap of tx chains for nphy */83#define TXCHAIN_DEF_HTPHY 0x784/* def bitmap of rxchain */85#define RXCHAIN_DEF 0x186/* default bitmap of rx chains for nphy */87#define RXCHAIN_DEF_NPHY 0x388/* default bitmap of rx chains for nphy */89#define RXCHAIN_DEF_HTPHY 0x790/* no antenna switch */91#define ANTSWITCH_NONE 092/* antenna switch on 4321CB2, 2of3 */93#define ANTSWITCH_TYPE_1 194/* antenna switch on 4321MPCI, 2of3 */95#define ANTSWITCH_TYPE_2 296/* antenna switch on 4322, 2of3 */97#define ANTSWITCH_TYPE_3 39899#define RXBUFSZ PKTBUFSZ100101#define MAX_STREAMS_SUPPORTED 4 /* max number of streams supported */102103struct brcm_rateset {104/* # rates in this set */105u32 count;106/* rates in 500kbps units w/hi bit set if basic */107u8 rates[WL_NUMRATES];108};109110struct brcms_c_rateset {111uint count; /* number of rates in rates[] */112/* rates in 500kbps units w/hi bit set if basic */113u8 rates[BRCMS_NUMRATES];114u8 htphy_membership; /* HT PHY Membership */115u8 mcs[MCSSET_LEN]; /* supported mcs index bit map */116};117118/* All the HT-specific default advertised capabilities (including AMPDU)119* should be grouped here at one place120*/121#define AMPDU_DEF_MPDU_DENSITY 6 /* default mpdu density (110 ==> 4us) */122123/* wlc internal bss_info */124struct brcms_bss_info {125u8 BSSID[ETH_ALEN]; /* network BSSID */126u16 flags; /* flags for internal attributes */127u8 SSID_len; /* the length of SSID */128u8 SSID[32]; /* SSID string */129s16 RSSI; /* receive signal strength (in dBm) */130s16 SNR; /* receive signal SNR in dB */131u16 beacon_period; /* units are Kusec */132u16 chanspec; /* Channel num, bw, ctrl_sb and band */133struct brcms_c_rateset rateset; /* supported rates */134};135136#define MAC80211_PROMISC_BCNS (1 << 0)137#define MAC80211_SCAN (1 << 1)138139/*140* Public portion of common driver state structure.141* The wlc handle points at this.142*/143struct brcms_pub {144struct brcms_c_info *wlc;145struct ieee80211_hw *ieee_hw;146struct scb_ampdu *global_ampdu;147uint mac80211_state;148uint unit; /* device instance number */149uint corerev; /* core revision */150struct si_pub *sih; /* SI handle (cookie for siutils calls) */151bool up; /* interface up and running */152bool hw_off; /* HW is off */153bool hw_up; /* one time hw up/down */154bool _piomode; /* true if pio mode */155uint _nbands; /* # bands supported */156uint now; /* # elapsed seconds */157158bool delayed_down; /* down delayed */159bool associated; /* true:part of [I]BSS, false: not */160/* (union of stas_associated, aps_associated) */161bool _ampdu; /* ampdu enabled or not */162u8 _n_enab; /* bitmap of 11N + HT support */163164u8 cur_etheraddr[ETH_ALEN]; /* our local ethernet address */165166u32 radio_disabled; /* bit vector for radio disabled reasons */167168u16 boardrev; /* version # of particular board */169u8 sromrev; /* version # of the srom */170char srom_ccode[BRCM_CNTRY_BUF_SZ]; /* Country Code in SROM */171u32 boardflags; /* Board specific flags from srom */172u32 boardflags2; /* More board flags if sromrev >= 4 */173bool phy_11ncapable; /* the PHY/HW is capable of 802.11N */174175struct wl_cnt *_cnt; /* low-level counters in driver */176struct dentry *dbgfs_dir;177};178179enum wlc_par_id {180IOV_MPC = 1,181IOV_RTSTHRESH,182IOV_QTXPOWER,183IOV_BCN_LI_BCN /* Beacon listen interval in # of beacons */184};185186/***********************************************187* Feature-related macros to optimize out code *188* *********************************************189*/190191#define ENAB_1x1 0x01192#define ENAB_2x2 0x02193#define ENAB_3x3 0x04194#define ENAB_4x4 0x08195#define SUPPORT_11N (ENAB_1x1|ENAB_2x2)196#define SUPPORT_HT (ENAB_1x1|ENAB_2x2|ENAB_3x3)197198/* WL11N Support */199#define AMPDU_AGG_HOST 1200201/* network protection config */202#define BRCMS_PROT_G_SPEC 1 /* SPEC g protection */203#define BRCMS_PROT_G_OVR 2 /* SPEC g prot override */204#define BRCMS_PROT_G_USER 3 /* gmode specified by user */205#define BRCMS_PROT_OVERLAP 4 /* overlap */206#define BRCMS_PROT_N_USER 10 /* nmode specified by user */207#define BRCMS_PROT_N_CFG 11 /* n protection */208#define BRCMS_PROT_N_CFG_OVR 12 /* n protection override */209#define BRCMS_PROT_N_NONGF 13 /* non-GF protection */210#define BRCMS_PROT_N_NONGF_OVR 14 /* non-GF protection override */211#define BRCMS_PROT_N_PAM_OVR 15 /* n preamble override */212#define BRCMS_PROT_N_OBSS 16 /* non-HT OBSS present */213214/*215* 54g modes (basic bits may still be overridden)216*217* GMODE_LEGACY_B218* Rateset: 1b, 2b, 5.5, 11219* Preamble: Long220* Shortslot: Off221* GMODE_AUTO222* Rateset: 1b, 2b, 5.5b, 11b, 18, 24, 36, 54223* Extended Rateset: 6, 9, 12, 48224* Preamble: Long225* Shortslot: Auto226* GMODE_ONLY227* Rateset: 1b, 2b, 5.5b, 11b, 18, 24b, 36, 54228* Extended Rateset: 6b, 9, 12b, 48229* Preamble: Short required230* Shortslot: Auto231* GMODE_B_DEFERRED232* Rateset: 1b, 2b, 5.5b, 11b, 18, 24, 36, 54233* Extended Rateset: 6, 9, 12, 48234* Preamble: Long235* Shortslot: On236* GMODE_PERFORMANCE237* Rateset: 1b, 2b, 5.5b, 6b, 9, 11b, 12b, 18, 24b, 36, 48, 54238* Preamble: Short required239* Shortslot: On and required240* GMODE_LRS241* Rateset: 1b, 2b, 5.5b, 11b242* Extended Rateset: 6, 9, 12, 18, 24, 36, 48, 54243* Preamble: Long244* Shortslot: Auto245*/246#define GMODE_LEGACY_B 0247#define GMODE_AUTO 1248#define GMODE_ONLY 2249#define GMODE_B_DEFERRED 3250#define GMODE_PERFORMANCE 4251#define GMODE_LRS 5252#define GMODE_MAX 6253254/* MCS values greater than this enable multiple streams */255#define HIGHEST_SINGLE_STREAM_MCS 7256257#define MAXBANDS 2 /* Maximum #of bands */258259/* max number of antenna configurations */260#define ANT_SELCFG_MAX 4261262struct brcms_antselcfg {263u8 ant_config[ANT_SELCFG_MAX]; /* antenna configuration */264u8 num_antcfg; /* number of available antenna configurations */265};266267/* common functions for every port */268struct brcms_c_info *brcms_c_attach(struct brcms_info *wl,269struct bcma_device *core, uint unit,270bool piomode, uint *perr);271uint brcms_c_detach(struct brcms_c_info *wlc);272int brcms_c_up(struct brcms_c_info *wlc);273uint brcms_c_down(struct brcms_c_info *wlc);274275bool brcms_c_chipmatch(struct bcma_device *core);276void brcms_c_init(struct brcms_c_info *wlc, bool mute_tx);277void brcms_c_reset(struct brcms_c_info *wlc);278279void brcms_c_intrson(struct brcms_c_info *wlc);280u32 brcms_c_intrsoff(struct brcms_c_info *wlc);281void brcms_c_intrsrestore(struct brcms_c_info *wlc, u32 macintmask);282bool brcms_c_intrsupd(struct brcms_c_info *wlc);283bool brcms_c_isr(struct brcms_c_info *wlc);284bool brcms_c_dpc(struct brcms_c_info *wlc, bool bounded);285bool brcms_c_sendpkt_mac80211(struct brcms_c_info *wlc, struct sk_buff *sdu,286struct ieee80211_hw *hw);287bool brcms_c_aggregatable(struct brcms_c_info *wlc, u8 tid);288void brcms_c_protection_upd(struct brcms_c_info *wlc, uint idx, int val);289int brcms_c_get_header_len(void);290void brcms_c_set_addrmatch(struct brcms_c_info *wlc, int match_reg_offset,291const u8 *addr);292void brcms_c_wme_setparams(struct brcms_c_info *wlc, u16 aci,293const struct ieee80211_tx_queue_params *arg,294bool suspend);295struct brcms_pub *brcms_c_pub(struct brcms_c_info *wlc);296void brcms_c_ampdu_flush(struct brcms_c_info *wlc, struct ieee80211_sta *sta,297u16 tid);298void brcms_c_ampdu_tx_operational(struct brcms_c_info *wlc, u8 tid,299uint max_rx_ampdu_bytes);300int brcms_c_module_register(struct brcms_pub *pub, const char *name,301struct brcms_info *hdl,302int (*down_fn)(void *handle));303int brcms_c_module_unregister(struct brcms_pub *pub, const char *name,304struct brcms_info *hdl);305void brcms_c_suspend_mac_and_wait(struct brcms_c_info *wlc);306void brcms_c_enable_mac(struct brcms_c_info *wlc);307void brcms_c_associate_upd(struct brcms_c_info *wlc, bool state);308void brcms_c_scan_start(struct brcms_c_info *wlc);309void brcms_c_scan_stop(struct brcms_c_info *wlc);310int brcms_c_get_curband(struct brcms_c_info *wlc);311int brcms_c_set_channel(struct brcms_c_info *wlc, u16 channel);312int brcms_c_set_rate_limit(struct brcms_c_info *wlc, u16 srl, u16 lrl);313void brcms_c_get_current_rateset(struct brcms_c_info *wlc,314struct brcm_rateset *currs);315int brcms_c_set_rateset(struct brcms_c_info *wlc, struct brcm_rateset *rs);316int brcms_c_set_beacon_period(struct brcms_c_info *wlc, u16 period);317u16 brcms_c_get_phy_type(struct brcms_c_info *wlc, int phyidx);318void brcms_c_set_shortslot_override(struct brcms_c_info *wlc,319s8 sslot_override);320void brcms_c_set_beacon_listen_interval(struct brcms_c_info *wlc, u8 interval);321u64 brcms_c_tsf_get(struct brcms_c_info *wlc);322void brcms_c_tsf_set(struct brcms_c_info *wlc, u64 tsf);323int brcms_c_set_tx_power(struct brcms_c_info *wlc, int txpwr);324int brcms_c_get_tx_power(struct brcms_c_info *wlc);325bool brcms_c_check_radio_disabled(struct brcms_c_info *wlc);326void brcms_c_mute(struct brcms_c_info *wlc, bool on);327bool brcms_c_tx_flush_completed(struct brcms_c_info *wlc);328void brcms_c_start_station(struct brcms_c_info *wlc, u8 *addr);329void brcms_c_start_ap(struct brcms_c_info *wlc, u8 *addr, const u8 *bssid,330u8 *ssid, size_t ssid_len);331void brcms_c_start_adhoc(struct brcms_c_info *wlc, u8 *addr);332void brcms_c_update_beacon(struct brcms_c_info *wlc);333void brcms_c_set_new_beacon(struct brcms_c_info *wlc, struct sk_buff *beacon,334u16 tim_offset, u16 dtim_period);335void brcms_c_set_new_probe_resp(struct brcms_c_info *wlc,336struct sk_buff *probe_resp);337void brcms_c_enable_probe_resp(struct brcms_c_info *wlc, bool enable);338void brcms_c_set_ssid(struct brcms_c_info *wlc, u8 *ssid, size_t ssid_len);339340#endif /* _BRCM_PUB_H_ */341342343