Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: ISC
0002 /*
0003  * Copyright (c) 2010 Broadcom Corporation
0004  */
0005 
0006 #ifndef _BRCMU_WIFI_H_
0007 #define _BRCMU_WIFI_H_
0008 
0009 #include <linux/if_ether.h>     /* for ETH_ALEN */
0010 #include <linux/ieee80211.h>        /* for WLAN_PMKID_LEN */
0011 
0012 /*
0013  * A chanspec (u16) holds the channel number, band, bandwidth and control
0014  * sideband
0015  */
0016 
0017 /* channel defines */
0018 #define CH_UPPER_SB         0x01
0019 #define CH_LOWER_SB         0x02
0020 #define CH_EWA_VALID            0x04
0021 #define CH_70MHZ_APART          14
0022 #define CH_50MHZ_APART          10
0023 #define CH_30MHZ_APART          6
0024 #define CH_20MHZ_APART          4
0025 #define CH_10MHZ_APART          2
0026 #define CH_5MHZ_APART           1 /* 2G band channels are 5 Mhz apart */
0027 #define CH_MIN_2G_CHANNEL       1
0028 #define CH_MAX_2G_CHANNEL       14  /* Max channel in 2G band */
0029 #define CH_MIN_5G_CHANNEL       34
0030 
0031 /* bandstate array indices */
0032 #define BAND_2G_INDEX       0   /* wlc->bandstate[x] index */
0033 #define BAND_5G_INDEX       1   /* wlc->bandstate[x] index */
0034 
0035 /*
0036  * max # supported channels. The max channel no is 216, this is that + 1
0037  * rounded up to a multiple of NBBY (8). DO NOT MAKE it > 255: channels are
0038  * u8's all over
0039 */
0040 #define MAXCHANNEL      224
0041 
0042 #define WL_CHANSPEC_CHAN_MASK       0x00ff
0043 #define WL_CHANSPEC_CHAN_SHIFT      0
0044 
0045 #define WL_CHANSPEC_CTL_SB_MASK     0x0300
0046 #define WL_CHANSPEC_CTL_SB_SHIFT         8
0047 #define WL_CHANSPEC_CTL_SB_LOWER    0x0100
0048 #define WL_CHANSPEC_CTL_SB_UPPER    0x0200
0049 #define WL_CHANSPEC_CTL_SB_NONE     0x0300
0050 
0051 #define WL_CHANSPEC_BW_MASK     0x0C00
0052 #define WL_CHANSPEC_BW_SHIFT            10
0053 #define WL_CHANSPEC_BW_10       0x0400
0054 #define WL_CHANSPEC_BW_20       0x0800
0055 #define WL_CHANSPEC_BW_40       0x0C00
0056 #define WL_CHANSPEC_BW_80       0x2000
0057 
0058 #define WL_CHANSPEC_BAND_MASK       0xf000
0059 #define WL_CHANSPEC_BAND_SHIFT      12
0060 #define WL_CHANSPEC_BAND_5G     0x1000
0061 #define WL_CHANSPEC_BAND_2G     0x2000
0062 #define INVCHANSPEC         255
0063 
0064 #define WL_CHAN_VALID_HW        (1 << 0) /* valid with current HW */
0065 #define WL_CHAN_VALID_SW        (1 << 1) /* valid with country sett. */
0066 #define WL_CHAN_BAND_5G         (1 << 2) /* 5GHz-band channel */
0067 #define WL_CHAN_RADAR           (1 << 3) /* radar sensitive  channel */
0068 #define WL_CHAN_INACTIVE        (1 << 4) /* inactive due to radar */
0069 #define WL_CHAN_PASSIVE         (1 << 5) /* channel in passive mode */
0070 #define WL_CHAN_RESTRICTED      (1 << 6) /* restricted use channel */
0071 
0072 /* values for band specific 40MHz capabilities  */
0073 #define WLC_N_BW_20ALL          0
0074 #define WLC_N_BW_40ALL          1
0075 #define WLC_N_BW_20IN2G_40IN5G      2
0076 
0077 #define WLC_BW_20MHZ_BIT        BIT(0)
0078 #define WLC_BW_40MHZ_BIT        BIT(1)
0079 #define WLC_BW_80MHZ_BIT        BIT(2)
0080 #define WLC_BW_160MHZ_BIT       BIT(3)
0081 
0082 /* Bandwidth capabilities */
0083 #define WLC_BW_CAP_20MHZ        (WLC_BW_20MHZ_BIT)
0084 #define WLC_BW_CAP_40MHZ        (WLC_BW_40MHZ_BIT|WLC_BW_20MHZ_BIT)
0085 #define WLC_BW_CAP_80MHZ        (WLC_BW_80MHZ_BIT|WLC_BW_40MHZ_BIT| \
0086                      WLC_BW_20MHZ_BIT)
0087 #define WLC_BW_CAP_160MHZ       (WLC_BW_160MHZ_BIT|WLC_BW_80MHZ_BIT| \
0088                      WLC_BW_40MHZ_BIT|WLC_BW_20MHZ_BIT)
0089 #define WLC_BW_CAP_UNRESTRICTED     0xFF
0090 
0091 /* band types */
0092 #define WLC_BAND_AUTO           0   /* auto-select */
0093 #define WLC_BAND_5G         1   /* 5 Ghz */
0094 #define WLC_BAND_2G         2   /* 2.4 Ghz */
0095 #define WLC_BAND_ALL            3   /* all bands */
0096 
0097 #define CHSPEC_CHANNEL(chspec)  ((u8)((chspec) & WL_CHANSPEC_CHAN_MASK))
0098 #define CHSPEC_BAND(chspec) ((chspec) & WL_CHANSPEC_BAND_MASK)
0099 
0100 #define CHSPEC_CTL_SB(chspec)   ((chspec) & WL_CHANSPEC_CTL_SB_MASK)
0101 #define CHSPEC_BW(chspec)   ((chspec) & WL_CHANSPEC_BW_MASK)
0102 
0103 #define CHSPEC_IS10(chspec) \
0104     (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_10)
0105 
0106 #define CHSPEC_IS20(chspec) \
0107     (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_20)
0108 
0109 #define CHSPEC_IS40(chspec) \
0110     (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_40)
0111 
0112 #define CHSPEC_IS80(chspec) \
0113     (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_80)
0114 
0115 #define CHSPEC_IS5G(chspec) \
0116     (((chspec) & WL_CHANSPEC_BAND_MASK) == WL_CHANSPEC_BAND_5G)
0117 
0118 #define CHSPEC_IS2G(chspec) \
0119     (((chspec) & WL_CHANSPEC_BAND_MASK) == WL_CHANSPEC_BAND_2G)
0120 
0121 #define CHSPEC_SB_NONE(chspec) \
0122     (((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_NONE)
0123 
0124 #define CHSPEC_SB_UPPER(chspec) \
0125     (((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_UPPER)
0126 
0127 #define CHSPEC_SB_LOWER(chspec) \
0128     (((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_LOWER)
0129 
0130 #define CHSPEC_CTL_CHAN(chspec) \
0131     ((CHSPEC_SB_LOWER(chspec)) ? \
0132     (lower_20_sb(((chspec) & WL_CHANSPEC_CHAN_MASK))) : \
0133     (upper_20_sb(((chspec) & WL_CHANSPEC_CHAN_MASK))))
0134 
0135 #define CHSPEC2BAND(chspec) (CHSPEC_IS5G(chspec) ? BRCM_BAND_5G : BRCM_BAND_2G)
0136 
0137 #define CHANSPEC_STR_LEN    8
0138 
0139 static inline int lower_20_sb(int channel)
0140 {
0141     return channel > CH_10MHZ_APART ? (channel - CH_10MHZ_APART) : 0;
0142 }
0143 
0144 static inline int upper_20_sb(int channel)
0145 {
0146     return (channel < (MAXCHANNEL - CH_10MHZ_APART)) ?
0147            channel + CH_10MHZ_APART : 0;
0148 }
0149 
0150 static inline int chspec_bandunit(u16 chspec)
0151 {
0152     return CHSPEC_IS5G(chspec) ? BAND_5G_INDEX : BAND_2G_INDEX;
0153 }
0154 
0155 static inline u16 ch20mhz_chspec(int channel)
0156 {
0157     u16 rc = channel <= CH_MAX_2G_CHANNEL ?
0158          WL_CHANSPEC_BAND_2G : WL_CHANSPEC_BAND_5G;
0159 
0160     return  (u16)((u16)channel | WL_CHANSPEC_BW_20 |
0161               WL_CHANSPEC_CTL_SB_NONE | rc);
0162 }
0163 
0164 static inline int next_20mhz_chan(int channel)
0165 {
0166     return channel < (MAXCHANNEL - CH_20MHZ_APART) ?
0167            channel + CH_20MHZ_APART : 0;
0168 }
0169 
0170 /* defined rate in 500kbps */
0171 #define BRCM_MAXRATE    108 /* in 500kbps units */
0172 #define BRCM_RATE_1M    2   /* in 500kbps units */
0173 #define BRCM_RATE_2M    4   /* in 500kbps units */
0174 #define BRCM_RATE_5M5   11  /* in 500kbps units */
0175 #define BRCM_RATE_11M   22  /* in 500kbps units */
0176 #define BRCM_RATE_6M    12  /* in 500kbps units */
0177 #define BRCM_RATE_9M    18  /* in 500kbps units */
0178 #define BRCM_RATE_12M   24  /* in 500kbps units */
0179 #define BRCM_RATE_18M   36  /* in 500kbps units */
0180 #define BRCM_RATE_24M   48  /* in 500kbps units */
0181 #define BRCM_RATE_36M   72  /* in 500kbps units */
0182 #define BRCM_RATE_48M   96  /* in 500kbps units */
0183 #define BRCM_RATE_54M   108 /* in 500kbps units */
0184 
0185 #define BRCM_2G_25MHZ_OFFSET        5   /* 2.4GHz band channel offset */
0186 
0187 #define MCSSET_LEN  16
0188 
0189 static inline bool ac_bitmap_tst(u8 bitmap, int prec)
0190 {
0191     return (bitmap & (1 << (prec))) != 0;
0192 }
0193 
0194 /* Enumerate crypto algorithms */
0195 #define CRYPTO_ALGO_OFF         0
0196 #define CRYPTO_ALGO_WEP1        1
0197 #define CRYPTO_ALGO_TKIP        2
0198 #define CRYPTO_ALGO_WEP128      3
0199 #define CRYPTO_ALGO_AES_CCM     4
0200 #define CRYPTO_ALGO_AES_RESERVED1   5
0201 #define CRYPTO_ALGO_AES_RESERVED2   6
0202 #define CRYPTO_ALGO_NALG        7
0203 
0204 /* wireless security bitvec */
0205 
0206 #define WEP_ENABLED     0x0001
0207 #define TKIP_ENABLED        0x0002
0208 #define AES_ENABLED     0x0004
0209 #define WSEC_SWFLAG     0x0008
0210 /* to go into transition mode without setting wep */
0211 #define SES_OW_ENABLED      0x0040
0212 /* MFP */
0213 #define MFP_CAPABLE     0x0200
0214 #define MFP_REQUIRED        0x0400
0215 
0216 /* WPA authentication mode bitvec */
0217 #define WPA_AUTH_DISABLED   0x0000  /* Legacy (i.e., non-WPA) */
0218 #define WPA_AUTH_NONE       0x0001  /* none (IBSS) */
0219 #define WPA_AUTH_UNSPECIFIED    0x0002  /* over 802.1x */
0220 #define WPA_AUTH_PSK        0x0004  /* Pre-shared key */
0221 #define WPA_AUTH_RESERVED1  0x0008
0222 #define WPA_AUTH_RESERVED2  0x0010
0223 
0224 #define WPA2_AUTH_RESERVED1 0x0020
0225 #define WPA2_AUTH_UNSPECIFIED   0x0040  /* over 802.1x */
0226 #define WPA2_AUTH_PSK       0x0080  /* Pre-shared key */
0227 #define WPA2_AUTH_RESERVED3 0x0200
0228 #define WPA2_AUTH_RESERVED4 0x0400
0229 #define WPA2_AUTH_RESERVED5 0x0800
0230 #define WPA2_AUTH_1X_SHA256 0x1000  /* 1X with SHA256 key derivation */
0231 #define WPA2_AUTH_FT        0x4000  /* Fast BSS Transition */
0232 #define WPA2_AUTH_PSK_SHA256    0x8000  /* PSK with SHA256 key derivation */
0233 
0234 #define WPA3_AUTH_SAE_PSK   0x40000 /* SAE with 4-way handshake */
0235 
0236 #define DOT11_DEFAULT_RTS_LEN       2347
0237 #define DOT11_DEFAULT_FRAG_LEN      2346
0238 
0239 #define DOT11_ICV_AES_LEN       8
0240 #define DOT11_QOS_LEN           2
0241 #define DOT11_IV_MAX_LEN        8
0242 #define DOT11_A4_HDR_LEN        30
0243 
0244 #define HT_CAP_RX_STBC_NO       0x0
0245 #define HT_CAP_RX_STBC_ONE_STREAM   0x1
0246 
0247 #endif              /* _BRCMU_WIFI_H_ */