Path: blob/main/sys/contrib/dev/broadcom/brcm80211/include/brcmu_wifi.h
178665 views
// SPDX-License-Identifier: ISC1/*2* Copyright (c) 2010 Broadcom Corporation3*/45#ifndef _BRCMU_WIFI_H_6#define _BRCMU_WIFI_H_78#include <linux/if_ether.h> /* for ETH_ALEN */9#include <linux/ieee80211.h> /* for WLAN_PMKID_LEN */1011/*12* A chanspec (u16) holds the channel number, band, bandwidth and control13* sideband14*/1516/* channel defines */17#define CH_UPPER_SB 0x0118#define CH_LOWER_SB 0x0219#define CH_EWA_VALID 0x0420#define CH_70MHZ_APART 1421#define CH_50MHZ_APART 1022#define CH_30MHZ_APART 623#define CH_20MHZ_APART 424#define CH_10MHZ_APART 225#define CH_5MHZ_APART 1 /* 2G band channels are 5 Mhz apart */26#define CH_MIN_2G_CHANNEL 127#define CH_MAX_2G_CHANNEL 14 /* Max channel in 2G band */28#define CH_MIN_5G_CHANNEL 342930/* bandstate array indices */31#define BAND_2G_INDEX 0 /* wlc->bandstate[x] index */32#define BAND_5G_INDEX 1 /* wlc->bandstate[x] index */3334/*35* max # supported channels. The max channel no is 216, this is that + 136* rounded up to a multiple of NBBY (8). DO NOT MAKE it > 255: channels are37* u8's all over38*/39#define MAXCHANNEL 2244041#define WL_CHANSPEC_CHAN_MASK 0x00ff42#define WL_CHANSPEC_CHAN_SHIFT 04344#define WL_CHANSPEC_CTL_SB_MASK 0x030045#define WL_CHANSPEC_CTL_SB_SHIFT 846#define WL_CHANSPEC_CTL_SB_LOWER 0x010047#define WL_CHANSPEC_CTL_SB_UPPER 0x020048#define WL_CHANSPEC_CTL_SB_NONE 0x03004950#define WL_CHANSPEC_BW_MASK 0x0C0051#define WL_CHANSPEC_BW_SHIFT 1052#define WL_CHANSPEC_BW_10 0x040053#define WL_CHANSPEC_BW_20 0x080054#define WL_CHANSPEC_BW_40 0x0C0055#define WL_CHANSPEC_BW_80 0x20005657#define WL_CHANSPEC_BAND_MASK 0xf00058#define WL_CHANSPEC_BAND_SHIFT 1259#define WL_CHANSPEC_BAND_5G 0x100060#define WL_CHANSPEC_BAND_2G 0x200061#define INVCHANSPEC 2556263#define WL_CHAN_VALID_HW (1 << 0) /* valid with current HW */64#define WL_CHAN_VALID_SW (1 << 1) /* valid with country sett. */65#define WL_CHAN_BAND_5G (1 << 2) /* 5GHz-band channel */66#define WL_CHAN_RADAR (1 << 3) /* radar sensitive channel */67#define WL_CHAN_INACTIVE (1 << 4) /* inactive due to radar */68#define WL_CHAN_PASSIVE (1 << 5) /* channel in passive mode */69#define WL_CHAN_RESTRICTED (1 << 6) /* restricted use channel */7071/* values for band specific 40MHz capabilities */72#define WLC_N_BW_20ALL 073#define WLC_N_BW_40ALL 174#define WLC_N_BW_20IN2G_40IN5G 27576#define WLC_BW_20MHZ_BIT BIT(0)77#define WLC_BW_40MHZ_BIT BIT(1)78#define WLC_BW_80MHZ_BIT BIT(2)79#define WLC_BW_160MHZ_BIT BIT(3)8081/* Bandwidth capabilities */82#define WLC_BW_CAP_20MHZ (WLC_BW_20MHZ_BIT)83#define WLC_BW_CAP_40MHZ (WLC_BW_40MHZ_BIT|WLC_BW_20MHZ_BIT)84#define WLC_BW_CAP_80MHZ (WLC_BW_80MHZ_BIT|WLC_BW_40MHZ_BIT| \85WLC_BW_20MHZ_BIT)86#define WLC_BW_CAP_160MHZ (WLC_BW_160MHZ_BIT|WLC_BW_80MHZ_BIT| \87WLC_BW_40MHZ_BIT|WLC_BW_20MHZ_BIT)88#define WLC_BW_CAP_UNRESTRICTED 0xFF8990/* band types */91#define WLC_BAND_AUTO 0 /* auto-select */92#define WLC_BAND_5G 1 /* 5 Ghz */93#define WLC_BAND_2G 2 /* 2.4 Ghz */94#define WLC_BAND_ALL 3 /* all bands */9596#define CHSPEC_CHANNEL(chspec) ((u8)((chspec) & WL_CHANSPEC_CHAN_MASK))97#define CHSPEC_BAND(chspec) ((chspec) & WL_CHANSPEC_BAND_MASK)9899#define CHSPEC_CTL_SB(chspec) ((chspec) & WL_CHANSPEC_CTL_SB_MASK)100#define CHSPEC_BW(chspec) ((chspec) & WL_CHANSPEC_BW_MASK)101102#define CHSPEC_IS10(chspec) \103(((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_10)104105#define CHSPEC_IS20(chspec) \106(((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_20)107108#define CHSPEC_IS40(chspec) \109(((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_40)110111#define CHSPEC_IS80(chspec) \112(((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_80)113114#define CHSPEC_IS5G(chspec) \115(((chspec) & WL_CHANSPEC_BAND_MASK) == WL_CHANSPEC_BAND_5G)116117#define CHSPEC_IS2G(chspec) \118(((chspec) & WL_CHANSPEC_BAND_MASK) == WL_CHANSPEC_BAND_2G)119120#define CHSPEC_SB_NONE(chspec) \121(((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_NONE)122123#define CHSPEC_SB_UPPER(chspec) \124(((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_UPPER)125126#define CHSPEC_SB_LOWER(chspec) \127(((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_LOWER)128129#define CHSPEC_CTL_CHAN(chspec) \130((CHSPEC_SB_LOWER(chspec)) ? \131(lower_20_sb(((chspec) & WL_CHANSPEC_CHAN_MASK))) : \132(upper_20_sb(((chspec) & WL_CHANSPEC_CHAN_MASK))))133134#define CHSPEC2BAND(chspec) (CHSPEC_IS5G(chspec) ? BRCM_BAND_5G : BRCM_BAND_2G)135136#define CHANSPEC_STR_LEN 8137138static inline int lower_20_sb(int channel)139{140return channel > CH_10MHZ_APART ? (channel - CH_10MHZ_APART) : 0;141}142143static inline int upper_20_sb(int channel)144{145return (channel < (MAXCHANNEL - CH_10MHZ_APART)) ?146channel + CH_10MHZ_APART : 0;147}148149static inline int chspec_bandunit(u16 chspec)150{151return CHSPEC_IS5G(chspec) ? BAND_5G_INDEX : BAND_2G_INDEX;152}153154static inline u16 ch20mhz_chspec(int channel)155{156u16 rc = channel <= CH_MAX_2G_CHANNEL ?157WL_CHANSPEC_BAND_2G : WL_CHANSPEC_BAND_5G;158159return (u16)((u16)channel | WL_CHANSPEC_BW_20 |160WL_CHANSPEC_CTL_SB_NONE | rc);161}162163static inline int next_20mhz_chan(int channel)164{165return channel < (MAXCHANNEL - CH_20MHZ_APART) ?166channel + CH_20MHZ_APART : 0;167}168169/* defined rate in 500kbps */170#define BRCM_MAXRATE 108 /* in 500kbps units */171#define BRCM_RATE_1M 2 /* in 500kbps units */172#define BRCM_RATE_2M 4 /* in 500kbps units */173#define BRCM_RATE_5M5 11 /* in 500kbps units */174#define BRCM_RATE_11M 22 /* in 500kbps units */175#define BRCM_RATE_6M 12 /* in 500kbps units */176#define BRCM_RATE_9M 18 /* in 500kbps units */177#define BRCM_RATE_12M 24 /* in 500kbps units */178#define BRCM_RATE_18M 36 /* in 500kbps units */179#define BRCM_RATE_24M 48 /* in 500kbps units */180#define BRCM_RATE_36M 72 /* in 500kbps units */181#define BRCM_RATE_48M 96 /* in 500kbps units */182#define BRCM_RATE_54M 108 /* in 500kbps units */183184#define BRCM_2G_25MHZ_OFFSET 5 /* 2.4GHz band channel offset */185186#define MCSSET_LEN 16187188static inline bool ac_bitmap_tst(u8 bitmap, int prec)189{190return (bitmap & (1 << (prec))) != 0;191}192193/* Enumerate crypto algorithms */194#define CRYPTO_ALGO_OFF 0195#define CRYPTO_ALGO_WEP1 1196#define CRYPTO_ALGO_TKIP 2197#define CRYPTO_ALGO_WEP128 3198#define CRYPTO_ALGO_AES_CCM 4199#define CRYPTO_ALGO_AES_RESERVED1 5200#define CRYPTO_ALGO_AES_RESERVED2 6201#define CRYPTO_ALGO_NALG 7202203/* wireless security bitvec */204205#define WEP_ENABLED 0x0001206#define TKIP_ENABLED 0x0002207#define AES_ENABLED 0x0004208#define WSEC_SWFLAG 0x0008209/* to go into transition mode without setting wep */210#define SES_OW_ENABLED 0x0040211/* MFP */212#define MFP_CAPABLE 0x0200213#define MFP_REQUIRED 0x0400214215/* WPA authentication mode bitvec */216#define WPA_AUTH_DISABLED 0x0000 /* Legacy (i.e., non-WPA) */217#define WPA_AUTH_NONE 0x0001 /* none (IBSS) */218#define WPA_AUTH_UNSPECIFIED 0x0002 /* over 802.1x */219#define WPA_AUTH_PSK 0x0004 /* Pre-shared key */220#define WPA_AUTH_RESERVED1 0x0008221#define WPA_AUTH_RESERVED2 0x0010222223#define WPA2_AUTH_RESERVED1 0x0020224#define WPA2_AUTH_UNSPECIFIED 0x0040 /* over 802.1x */225#define WPA2_AUTH_PSK 0x0080 /* Pre-shared key */226#define WPA2_AUTH_RESERVED3 0x0200227#define WPA2_AUTH_RESERVED4 0x0400228#define WPA2_AUTH_RESERVED5 0x0800229#define WPA2_AUTH_1X_SHA256 0x1000 /* 1X with SHA256 key derivation */230#define WPA2_AUTH_FT 0x4000 /* Fast BSS Transition */231#define WPA2_AUTH_PSK_SHA256 0x8000 /* PSK with SHA256 key derivation */232233#define WPA3_AUTH_SAE_PSK 0x40000 /* SAE with 4-way handshake */234235#define DOT11_DEFAULT_RTS_LEN 2347236#define DOT11_DEFAULT_FRAG_LEN 2346237238#define DOT11_ICV_AES_LEN 8239#define DOT11_QOS_LEN 2240#define DOT11_IV_MAX_LEN 8241#define DOT11_A4_HDR_LEN 30242243#define HT_CAP_RX_STBC_NO 0x0244#define HT_CAP_RX_STBC_ONE_STREAM 0x1245246#endif /* _BRCMU_WIFI_H_ */247248249