17e5677deSArend van Spriel // SPDX-License-Identifier: ISC 205491d2cSKalle Valo /* 305491d2cSKalle Valo * Copyright (c) 2010 Broadcom Corporation 405491d2cSKalle Valo */ 505491d2cSKalle Valo 605491d2cSKalle Valo #ifndef _BRCMU_WIFI_H_ 705491d2cSKalle Valo #define _BRCMU_WIFI_H_ 805491d2cSKalle Valo 905491d2cSKalle Valo #include <linux/if_ether.h> /* for ETH_ALEN */ 1005491d2cSKalle Valo #include <linux/ieee80211.h> /* for WLAN_PMKID_LEN */ 1105491d2cSKalle Valo 1205491d2cSKalle Valo /* 1305491d2cSKalle Valo * A chanspec (u16) holds the channel number, band, bandwidth and control 1405491d2cSKalle Valo * sideband 1505491d2cSKalle Valo */ 1605491d2cSKalle Valo 1705491d2cSKalle Valo /* channel defines */ 1805491d2cSKalle Valo #define CH_UPPER_SB 0x01 1905491d2cSKalle Valo #define CH_LOWER_SB 0x02 2005491d2cSKalle Valo #define CH_EWA_VALID 0x04 21330994e8SArend van Spriel #define CH_70MHZ_APART 14 22330994e8SArend van Spriel #define CH_50MHZ_APART 10 2305491d2cSKalle Valo #define CH_30MHZ_APART 6 2405491d2cSKalle Valo #define CH_20MHZ_APART 4 2505491d2cSKalle Valo #define CH_10MHZ_APART 2 2605491d2cSKalle Valo #define CH_5MHZ_APART 1 /* 2G band channels are 5 Mhz apart */ 2705491d2cSKalle Valo #define CH_MIN_2G_CHANNEL 1 2805491d2cSKalle Valo #define CH_MAX_2G_CHANNEL 14 /* Max channel in 2G band */ 2905491d2cSKalle Valo #define CH_MIN_5G_CHANNEL 34 3005491d2cSKalle Valo 3105491d2cSKalle Valo /* bandstate array indices */ 3205491d2cSKalle Valo #define BAND_2G_INDEX 0 /* wlc->bandstate[x] index */ 3305491d2cSKalle Valo #define BAND_5G_INDEX 1 /* wlc->bandstate[x] index */ 3405491d2cSKalle Valo 3505491d2cSKalle Valo /* 3605491d2cSKalle Valo * max # supported channels. The max channel no is 216, this is that + 1 3705491d2cSKalle Valo * rounded up to a multiple of NBBY (8). DO NOT MAKE it > 255: channels are 3805491d2cSKalle Valo * u8's all over 3905491d2cSKalle Valo */ 4005491d2cSKalle Valo #define MAXCHANNEL 224 4105491d2cSKalle Valo 4205491d2cSKalle Valo #define WL_CHANSPEC_CHAN_MASK 0x00ff 4305491d2cSKalle Valo #define WL_CHANSPEC_CHAN_SHIFT 0 4405491d2cSKalle Valo 4505491d2cSKalle Valo #define WL_CHANSPEC_CTL_SB_MASK 0x0300 4605491d2cSKalle Valo #define WL_CHANSPEC_CTL_SB_SHIFT 8 4705491d2cSKalle Valo #define WL_CHANSPEC_CTL_SB_LOWER 0x0100 4805491d2cSKalle Valo #define WL_CHANSPEC_CTL_SB_UPPER 0x0200 4905491d2cSKalle Valo #define WL_CHANSPEC_CTL_SB_NONE 0x0300 5005491d2cSKalle Valo 5105491d2cSKalle Valo #define WL_CHANSPEC_BW_MASK 0x0C00 5205491d2cSKalle Valo #define WL_CHANSPEC_BW_SHIFT 10 5305491d2cSKalle Valo #define WL_CHANSPEC_BW_10 0x0400 5405491d2cSKalle Valo #define WL_CHANSPEC_BW_20 0x0800 5505491d2cSKalle Valo #define WL_CHANSPEC_BW_40 0x0C00 5605491d2cSKalle Valo #define WL_CHANSPEC_BW_80 0x2000 5705491d2cSKalle Valo 5805491d2cSKalle Valo #define WL_CHANSPEC_BAND_MASK 0xf000 5905491d2cSKalle Valo #define WL_CHANSPEC_BAND_SHIFT 12 6005491d2cSKalle Valo #define WL_CHANSPEC_BAND_5G 0x1000 6105491d2cSKalle Valo #define WL_CHANSPEC_BAND_2G 0x2000 6205491d2cSKalle Valo #define INVCHANSPEC 255 6305491d2cSKalle Valo 6405491d2cSKalle Valo #define WL_CHAN_VALID_HW (1 << 0) /* valid with current HW */ 6505491d2cSKalle Valo #define WL_CHAN_VALID_SW (1 << 1) /* valid with country sett. */ 6605491d2cSKalle Valo #define WL_CHAN_BAND_5G (1 << 2) /* 5GHz-band channel */ 6705491d2cSKalle Valo #define WL_CHAN_RADAR (1 << 3) /* radar sensitive channel */ 6805491d2cSKalle Valo #define WL_CHAN_INACTIVE (1 << 4) /* inactive due to radar */ 6905491d2cSKalle Valo #define WL_CHAN_PASSIVE (1 << 5) /* channel in passive mode */ 7005491d2cSKalle Valo #define WL_CHAN_RESTRICTED (1 << 6) /* restricted use channel */ 7105491d2cSKalle Valo 7205491d2cSKalle Valo /* values for band specific 40MHz capabilities */ 7305491d2cSKalle Valo #define WLC_N_BW_20ALL 0 7405491d2cSKalle Valo #define WLC_N_BW_40ALL 1 7505491d2cSKalle Valo #define WLC_N_BW_20IN2G_40IN5G 2 7605491d2cSKalle Valo 7705491d2cSKalle Valo #define WLC_BW_20MHZ_BIT BIT(0) 7805491d2cSKalle Valo #define WLC_BW_40MHZ_BIT BIT(1) 7905491d2cSKalle Valo #define WLC_BW_80MHZ_BIT BIT(2) 8005491d2cSKalle Valo #define WLC_BW_160MHZ_BIT BIT(3) 8105491d2cSKalle Valo 8205491d2cSKalle Valo /* Bandwidth capabilities */ 8305491d2cSKalle Valo #define WLC_BW_CAP_20MHZ (WLC_BW_20MHZ_BIT) 8405491d2cSKalle Valo #define WLC_BW_CAP_40MHZ (WLC_BW_40MHZ_BIT|WLC_BW_20MHZ_BIT) 8505491d2cSKalle Valo #define WLC_BW_CAP_80MHZ (WLC_BW_80MHZ_BIT|WLC_BW_40MHZ_BIT| \ 8605491d2cSKalle Valo WLC_BW_20MHZ_BIT) 8705491d2cSKalle Valo #define WLC_BW_CAP_160MHZ (WLC_BW_160MHZ_BIT|WLC_BW_80MHZ_BIT| \ 8805491d2cSKalle Valo WLC_BW_40MHZ_BIT|WLC_BW_20MHZ_BIT) 8905491d2cSKalle Valo #define WLC_BW_CAP_UNRESTRICTED 0xFF 9005491d2cSKalle Valo 9105491d2cSKalle Valo /* band types */ 9205491d2cSKalle Valo #define WLC_BAND_AUTO 0 /* auto-select */ 9305491d2cSKalle Valo #define WLC_BAND_5G 1 /* 5 Ghz */ 9405491d2cSKalle Valo #define WLC_BAND_2G 2 /* 2.4 Ghz */ 9505491d2cSKalle Valo #define WLC_BAND_ALL 3 /* all bands */ 9605491d2cSKalle Valo 9705491d2cSKalle Valo #define CHSPEC_CHANNEL(chspec) ((u8)((chspec) & WL_CHANSPEC_CHAN_MASK)) 9805491d2cSKalle Valo #define CHSPEC_BAND(chspec) ((chspec) & WL_CHANSPEC_BAND_MASK) 9905491d2cSKalle Valo 10005491d2cSKalle Valo #define CHSPEC_CTL_SB(chspec) ((chspec) & WL_CHANSPEC_CTL_SB_MASK) 10105491d2cSKalle Valo #define CHSPEC_BW(chspec) ((chspec) & WL_CHANSPEC_BW_MASK) 10205491d2cSKalle Valo 10305491d2cSKalle Valo #define CHSPEC_IS10(chspec) \ 10405491d2cSKalle Valo (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_10) 10505491d2cSKalle Valo 10605491d2cSKalle Valo #define CHSPEC_IS20(chspec) \ 10705491d2cSKalle Valo (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_20) 10805491d2cSKalle Valo 10905491d2cSKalle Valo #define CHSPEC_IS40(chspec) \ 11005491d2cSKalle Valo (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_40) 11105491d2cSKalle Valo 11205491d2cSKalle Valo #define CHSPEC_IS80(chspec) \ 11305491d2cSKalle Valo (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_80) 11405491d2cSKalle Valo 11505491d2cSKalle Valo #define CHSPEC_IS5G(chspec) \ 11605491d2cSKalle Valo (((chspec) & WL_CHANSPEC_BAND_MASK) == WL_CHANSPEC_BAND_5G) 11705491d2cSKalle Valo 11805491d2cSKalle Valo #define CHSPEC_IS2G(chspec) \ 11905491d2cSKalle Valo (((chspec) & WL_CHANSPEC_BAND_MASK) == WL_CHANSPEC_BAND_2G) 12005491d2cSKalle Valo 12105491d2cSKalle Valo #define CHSPEC_SB_NONE(chspec) \ 12205491d2cSKalle Valo (((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_NONE) 12305491d2cSKalle Valo 12405491d2cSKalle Valo #define CHSPEC_SB_UPPER(chspec) \ 12505491d2cSKalle Valo (((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_UPPER) 12605491d2cSKalle Valo 12705491d2cSKalle Valo #define CHSPEC_SB_LOWER(chspec) \ 12805491d2cSKalle Valo (((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_LOWER) 12905491d2cSKalle Valo 13005491d2cSKalle Valo #define CHSPEC_CTL_CHAN(chspec) \ 13105491d2cSKalle Valo ((CHSPEC_SB_LOWER(chspec)) ? \ 13205491d2cSKalle Valo (lower_20_sb(((chspec) & WL_CHANSPEC_CHAN_MASK))) : \ 13305491d2cSKalle Valo (upper_20_sb(((chspec) & WL_CHANSPEC_CHAN_MASK)))) 13405491d2cSKalle Valo 13505491d2cSKalle Valo #define CHSPEC2BAND(chspec) (CHSPEC_IS5G(chspec) ? BRCM_BAND_5G : BRCM_BAND_2G) 13605491d2cSKalle Valo 13705491d2cSKalle Valo #define CHANSPEC_STR_LEN 8 13805491d2cSKalle Valo lower_20_sb(int channel)13905491d2cSKalle Valostatic inline int lower_20_sb(int channel) 14005491d2cSKalle Valo { 14105491d2cSKalle Valo return channel > CH_10MHZ_APART ? (channel - CH_10MHZ_APART) : 0; 14205491d2cSKalle Valo } 14305491d2cSKalle Valo upper_20_sb(int channel)14405491d2cSKalle Valostatic inline int upper_20_sb(int channel) 14505491d2cSKalle Valo { 14605491d2cSKalle Valo return (channel < (MAXCHANNEL - CH_10MHZ_APART)) ? 14705491d2cSKalle Valo channel + CH_10MHZ_APART : 0; 14805491d2cSKalle Valo } 14905491d2cSKalle Valo chspec_bandunit(u16 chspec)15005491d2cSKalle Valostatic inline int chspec_bandunit(u16 chspec) 15105491d2cSKalle Valo { 15205491d2cSKalle Valo return CHSPEC_IS5G(chspec) ? BAND_5G_INDEX : BAND_2G_INDEX; 15305491d2cSKalle Valo } 15405491d2cSKalle Valo ch20mhz_chspec(int channel)15505491d2cSKalle Valostatic inline u16 ch20mhz_chspec(int channel) 15605491d2cSKalle Valo { 15705491d2cSKalle Valo u16 rc = channel <= CH_MAX_2G_CHANNEL ? 15805491d2cSKalle Valo WL_CHANSPEC_BAND_2G : WL_CHANSPEC_BAND_5G; 15905491d2cSKalle Valo 16005491d2cSKalle Valo return (u16)((u16)channel | WL_CHANSPEC_BW_20 | 16105491d2cSKalle Valo WL_CHANSPEC_CTL_SB_NONE | rc); 16205491d2cSKalle Valo } 16305491d2cSKalle Valo next_20mhz_chan(int channel)16405491d2cSKalle Valostatic inline int next_20mhz_chan(int channel) 16505491d2cSKalle Valo { 16605491d2cSKalle Valo return channel < (MAXCHANNEL - CH_20MHZ_APART) ? 16705491d2cSKalle Valo channel + CH_20MHZ_APART : 0; 16805491d2cSKalle Valo } 16905491d2cSKalle Valo 17005491d2cSKalle Valo /* defined rate in 500kbps */ 17105491d2cSKalle Valo #define BRCM_MAXRATE 108 /* in 500kbps units */ 17205491d2cSKalle Valo #define BRCM_RATE_1M 2 /* in 500kbps units */ 17305491d2cSKalle Valo #define BRCM_RATE_2M 4 /* in 500kbps units */ 17405491d2cSKalle Valo #define BRCM_RATE_5M5 11 /* in 500kbps units */ 17505491d2cSKalle Valo #define BRCM_RATE_11M 22 /* in 500kbps units */ 17605491d2cSKalle Valo #define BRCM_RATE_6M 12 /* in 500kbps units */ 17705491d2cSKalle Valo #define BRCM_RATE_9M 18 /* in 500kbps units */ 17805491d2cSKalle Valo #define BRCM_RATE_12M 24 /* in 500kbps units */ 17905491d2cSKalle Valo #define BRCM_RATE_18M 36 /* in 500kbps units */ 18005491d2cSKalle Valo #define BRCM_RATE_24M 48 /* in 500kbps units */ 18105491d2cSKalle Valo #define BRCM_RATE_36M 72 /* in 500kbps units */ 18205491d2cSKalle Valo #define BRCM_RATE_48M 96 /* in 500kbps units */ 18305491d2cSKalle Valo #define BRCM_RATE_54M 108 /* in 500kbps units */ 18405491d2cSKalle Valo 18505491d2cSKalle Valo #define BRCM_2G_25MHZ_OFFSET 5 /* 2.4GHz band channel offset */ 18605491d2cSKalle Valo 18705491d2cSKalle Valo #define MCSSET_LEN 16 18805491d2cSKalle Valo ac_bitmap_tst(u8 bitmap,int prec)18905491d2cSKalle Valostatic inline bool ac_bitmap_tst(u8 bitmap, int prec) 19005491d2cSKalle Valo { 19105491d2cSKalle Valo return (bitmap & (1 << (prec))) != 0; 19205491d2cSKalle Valo } 19305491d2cSKalle Valo 19405491d2cSKalle Valo /* Enumerate crypto algorithms */ 19505491d2cSKalle Valo #define CRYPTO_ALGO_OFF 0 19605491d2cSKalle Valo #define CRYPTO_ALGO_WEP1 1 19705491d2cSKalle Valo #define CRYPTO_ALGO_TKIP 2 19805491d2cSKalle Valo #define CRYPTO_ALGO_WEP128 3 19905491d2cSKalle Valo #define CRYPTO_ALGO_AES_CCM 4 20005491d2cSKalle Valo #define CRYPTO_ALGO_AES_RESERVED1 5 20105491d2cSKalle Valo #define CRYPTO_ALGO_AES_RESERVED2 6 20205491d2cSKalle Valo #define CRYPTO_ALGO_NALG 7 20305491d2cSKalle Valo 20405491d2cSKalle Valo /* wireless security bitvec */ 20505491d2cSKalle Valo 20605491d2cSKalle Valo #define WEP_ENABLED 0x0001 20705491d2cSKalle Valo #define TKIP_ENABLED 0x0002 20805491d2cSKalle Valo #define AES_ENABLED 0x0004 20905491d2cSKalle Valo #define WSEC_SWFLAG 0x0008 21005491d2cSKalle Valo /* to go into transition mode without setting wep */ 21105491d2cSKalle Valo #define SES_OW_ENABLED 0x0040 21205491d2cSKalle Valo /* MFP */ 21305491d2cSKalle Valo #define MFP_CAPABLE 0x0200 21405491d2cSKalle Valo #define MFP_REQUIRED 0x0400 21505491d2cSKalle Valo 21605491d2cSKalle Valo /* WPA authentication mode bitvec */ 21705491d2cSKalle Valo #define WPA_AUTH_DISABLED 0x0000 /* Legacy (i.e., non-WPA) */ 21805491d2cSKalle Valo #define WPA_AUTH_NONE 0x0001 /* none (IBSS) */ 21905491d2cSKalle Valo #define WPA_AUTH_UNSPECIFIED 0x0002 /* over 802.1x */ 22005491d2cSKalle Valo #define WPA_AUTH_PSK 0x0004 /* Pre-shared key */ 22105491d2cSKalle Valo #define WPA_AUTH_RESERVED1 0x0008 22205491d2cSKalle Valo #define WPA_AUTH_RESERVED2 0x0010 22305491d2cSKalle Valo 22405491d2cSKalle Valo #define WPA2_AUTH_RESERVED1 0x0020 22505491d2cSKalle Valo #define WPA2_AUTH_UNSPECIFIED 0x0040 /* over 802.1x */ 22605491d2cSKalle Valo #define WPA2_AUTH_PSK 0x0080 /* Pre-shared key */ 22705491d2cSKalle Valo #define WPA2_AUTH_RESERVED3 0x0200 22805491d2cSKalle Valo #define WPA2_AUTH_RESERVED4 0x0400 22905491d2cSKalle Valo #define WPA2_AUTH_RESERVED5 0x0800 230240d61a9SHante Meuleman #define WPA2_AUTH_1X_SHA256 0x1000 /* 1X with SHA256 key derivation */ 2314ad298daSChung-Hsien Hsu #define WPA2_AUTH_FT 0x4000 /* Fast BSS Transition */ 232240d61a9SHante Meuleman #define WPA2_AUTH_PSK_SHA256 0x8000 /* PSK with SHA256 key derivation */ 23305491d2cSKalle Valo 234*3b1e0a7bSChung-Hsien Hsu #define WPA3_AUTH_SAE_PSK 0x40000 /* SAE with 4-way handshake */ 235*3b1e0a7bSChung-Hsien Hsu 23605491d2cSKalle Valo #define DOT11_DEFAULT_RTS_LEN 2347 23705491d2cSKalle Valo #define DOT11_DEFAULT_FRAG_LEN 2346 23805491d2cSKalle Valo 23905491d2cSKalle Valo #define DOT11_ICV_AES_LEN 8 24005491d2cSKalle Valo #define DOT11_QOS_LEN 2 24105491d2cSKalle Valo #define DOT11_IV_MAX_LEN 8 24205491d2cSKalle Valo #define DOT11_A4_HDR_LEN 30 24305491d2cSKalle Valo 24405491d2cSKalle Valo #define HT_CAP_RX_STBC_NO 0x0 24505491d2cSKalle Valo #define HT_CAP_RX_STBC_ONE_STREAM 0x1 24605491d2cSKalle Valo 24705491d2cSKalle Valo #endif /* _BRCMU_WIFI_H_ */ 248