Merge tag 'vfs-5.15-merge-1' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux
[linux-2.6-microblaze.git] / drivers / staging / rtl8712 / ieee80211.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /******************************************************************************
3  *
4  * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
5  *
6  * Modifications for inclusion into the Linux staging tree are
7  * Copyright(c) 2010 Larry Finger. All rights reserved.
8  *
9  * Contact information:
10  * WLAN FAE <wlanfae@realtek.com>
11  * Larry Finger <Larry.Finger@lwfinger.net>
12  *
13  ******************************************************************************/
14 #ifndef __IEEE80211_H
15 #define __IEEE80211_H
16
17 #include <linux/ieee80211.h>
18
19 #define IEEE_CMD_SET_WPA_PARAM                  1
20 #define IEEE_CMD_SET_WPA_IE                     2
21 #define IEEE_CMD_SET_ENCRYPTION                 3
22 #define IEEE_CMD_MLME                           4
23
24 #define IEEE_PARAM_WPA_ENABLED                  1
25 #define IEEE_PARAM_TKIP_COUNTERMEASURES         2
26 #define IEEE_PARAM_DROP_UNENCRYPTED             3
27 #define IEEE_PARAM_PRIVACY_INVOKED              4
28 #define IEEE_PARAM_AUTH_ALGS                    5
29 #define IEEE_PARAM_IEEE_802_1X                  6
30 #define IEEE_PARAM_WPAX_SELECT                  7
31
32 #define AUTH_ALG_OPEN_SYSTEM                    0x1
33 #define AUTH_ALG_SHARED_KEY                     0x2
34 #define AUTH_ALG_LEAP                           0x00000004
35
36 #define IEEE_MLME_STA_DEAUTH                    1
37 #define IEEE_MLME_STA_DISASSOC                  2
38
39 #define IEEE_CRYPT_ERR_UNKNOWN_ALG              2
40 #define IEEE_CRYPT_ERR_UNKNOWN_ADDR             3
41 #define IEEE_CRYPT_ERR_CRYPT_INIT_FAILED        4
42 #define IEEE_CRYPT_ERR_KEY_SET_FAILED           5
43 #define IEEE_CRYPT_ERR_TX_KEY_SET_FAILED        6
44 #define IEEE_CRYPT_ERR_CARD_CONF_FAILED         7
45
46 #define IEEE_CRYPT_ALG_NAME_LEN                 16
47
48 #define WPA_CIPHER_NONE                         BIT(0)
49 #define WPA_CIPHER_WEP40                        BIT(1)
50 #define WPA_CIPHER_WEP104                       BIT(2)
51 #define WPA_CIPHER_TKIP                         BIT(3)
52 #define WPA_CIPHER_CCMP                         BIT(4)
53
54 #define WPA_SELECTOR_LEN                        4
55 #define RSN_HEADER_LEN                          4
56
57 #define RSN_SELECTOR_LEN 4
58
59 enum NETWORK_TYPE {
60         WIRELESS_INVALID        = 0,
61         WIRELESS_11B            = 1,
62         WIRELESS_11G            = 2,
63         WIRELESS_11BG           = (WIRELESS_11B | WIRELESS_11G),
64         WIRELESS_11A            = 4,
65         WIRELESS_11N            = 8,
66         WIRELESS_11GN           = (WIRELESS_11G | WIRELESS_11N),
67         WIRELESS_11BGN          = (WIRELESS_11B | WIRELESS_11G | WIRELESS_11N),
68 };
69
70 struct ieee_param {
71         u32 cmd;
72         u8 sta_addr[ETH_ALEN];
73         union {
74                 struct {
75                         u8 name;
76                         u32 value;
77                 } wpa_param;
78                 struct {
79                         u32 len;
80                         u8 reserved[32];
81                         u8 data[0];
82                 } wpa_ie;
83                 struct {
84                         int command;
85                         int reason_code;
86                 } mlme;
87                 struct {
88                         u8 alg[IEEE_CRYPT_ALG_NAME_LEN];
89                         u8 set_tx;
90                         u32 err;
91                         u8 idx;
92                         u8 seq[8]; /* sequence counter (set: RX, get: TX) */
93                         u16 key_len;
94                         u8 key[0];
95                 } crypt;
96         } u;
97 };
98
99 #define MIN_FRAG_THRESHOLD     256U
100 #define MAX_FRAG_THRESHOLD     2346U
101
102 /* QoS,QOS */
103 #define NORMAL_ACK                      0
104
105 /* IEEE 802.11 defines */
106
107 #define P80211_OUI_LEN 3
108
109 struct ieee80211_snap_hdr {
110         u8    dsap;   /* always 0xAA */
111         u8    ssap;   /* always 0xAA */
112         u8    ctrl;   /* always 0x03 */
113         u8    oui[P80211_OUI_LEN];    /* organizational universal id */
114 } __packed;
115
116 #define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
117
118 #define IEEE80211_CCK_RATE_LEN                  4
119 #define IEEE80211_NUM_OFDM_RATESLEN     8
120
121 #define IEEE80211_CCK_RATE_1MB                  0x02
122 #define IEEE80211_CCK_RATE_2MB                  0x04
123 #define IEEE80211_CCK_RATE_5MB                  0x0B
124 #define IEEE80211_CCK_RATE_11MB                 0x16
125 #define IEEE80211_OFDM_RATE_6MB                 0x0C
126 #define IEEE80211_OFDM_RATE_9MB                 0x12
127 #define IEEE80211_OFDM_RATE_12MB                0x18
128 #define IEEE80211_OFDM_RATE_18MB                0x24
129 #define IEEE80211_OFDM_RATE_24MB                0x30
130 #define IEEE80211_OFDM_RATE_36MB                0x48
131 #define IEEE80211_OFDM_RATE_48MB                0x60
132 #define IEEE80211_OFDM_RATE_54MB                0x6C
133 #define IEEE80211_BASIC_RATE_MASK               0x80
134
135 #define WEP_KEYS 4
136
137 /* MAX_RATES_LENGTH needs to be 12.  The spec says 8, and many APs
138  * only use 8, and then use extended rates for the remaining supported
139  * rates.  Other APs, however, stick all of their supported rates on the
140  * main rates information element...
141  */
142 #define MAX_RATES_LENGTH                  ((u8)12)
143 #define MAX_WPA_IE_LEN 128
144
145 struct registry_priv;
146
147 u8 *r8712_set_ie(u8 *pbuf, sint index, uint len, u8 *source, uint *frlen);
148 u8 *r8712_get_ie(u8 *pbuf, sint index, uint *len, sint limit);
149 unsigned char *r8712_get_wpa_ie(unsigned char *pie, uint *rsn_ie_len,
150                                 int limit);
151 unsigned char *r8712_get_wpa2_ie(unsigned char *pie, uint *rsn_ie_len,
152                                  int limit);
153 int r8712_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher,
154                        int *pairwise_cipher);
155 int r8712_parse_wpa2_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher,
156                         int *pairwise_cipher);
157 int r8712_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len,
158                      u8 *wpa_ie, u16 *wpa_len);
159 int r8712_get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen);
160 int r8712_generate_ie(struct registry_priv *pregistrypriv);
161 uint r8712_is_cckrates_included(u8 *rate);
162 uint r8712_is_cckratesonly_included(u8 *rate);
163
164 #endif /* IEEE80211_H */
165