net:wireless:Support eswin usb wifi ECR6600U
[platform/kernel/linux-starfive.git] / drivers / net / wireless / eswin / lmac_mac.h
1 /**
2  ****************************************************************************************
3  *
4  * @file lmac_mac_types.h
5  *
6  * @brief MAC related definitions.
7  *
8  * Adapted from mac_types.h to used lmac_types.h instead of standard types
9  * eg: perl -pi -e '$_ =~ s/uint(\d{1,2})_t/u$1_l/g; \
10  *                  $_ =~ s/int(\d{1,2})_t/s$1_l/g; \
11  *                  $_ =~ s/CO_BIT/BIT/g;' lmac_mac.h
12  *
13  * Copyright (C) ESWIN 2015-2020
14  *
15  ****************************************************************************************
16  */
17
18 #ifndef LMAC_MAC_H_
19 #define LMAC_MAC_H_
20
21 #include "lmac_types.h"
22
23 /// Interface types
24 enum mac_vif_type
25 {
26     /// ESS STA interface
27     VIF_STA,
28     /// IBSS STA interface
29     VIF_IBSS,
30     /// AP interface
31     VIF_AP,
32     /// Mesh Point interface
33     VIF_MESH_POINT,
34     /// Monitor interface
35     VIF_MONITOR,
36     /// Unknown type
37     VIF_UNKNOWN
38 };
39
40 /// MAC address length in bytes.
41 #define MAC_ADDR_LEN 6
42
43 /// MAC address structure.
44 struct mac_addr
45 {
46     /// Array of 16-bit words that make up the MAC address.
47     u16_l array[MAC_ADDR_LEN/2];
48 };
49
50 /// SSID maximum length.
51 #define MAC_SSID_LEN 32
52
53 /// SSID.
54 struct mac_ssid
55 {
56     /// Actual length of the SSID.
57     u8_l length;
58     /// Array containing the SSID name.
59     u8_l array[MAC_SSID_LEN];
60 };
61
62 /// BSS type
63 enum mac_bss_type
64 {
65     INFRASTRUCTURE_MODE = 1,
66     INDEPENDENT_BSS_MODE,
67     ANY_BSS_MODE
68 };
69
70 /// Channel Band
71 enum mac_chan_band
72 {
73     /// 2.4GHz Band
74     PHY_BAND_2G4,
75     /// 5GHz band
76     PHY_BAND_5G,
77     /// Number of bands
78     PHY_BAND_MAX,
79 };
80
81 /// Operating Channel Bandwidth
82 enum mac_chan_bandwidth
83 {
84     /// 20MHz BW
85     PHY_CHNL_BW_20,
86     /// 40MHz BW
87     PHY_CHNL_BW_40,
88     /// 80MHz BW
89     PHY_CHNL_BW_80,
90     /// 160MHz BW
91     PHY_CHNL_BW_160,
92     /// 80+80MHz BW
93     PHY_CHNL_BW_80P80,
94     /// Reserved BW
95     PHY_CHNL_BW_OTHER,
96 };
97
98 /// max number of channels in the 2.4 GHZ band
99 #define MAC_DOMAINCHANNEL_24G_MAX 14
100
101 /// max number of channels in the 5 GHZ band
102 #define MAC_DOMAINCHANNEL_5G_MAX 28
103
104 /// Channel Flag
105 enum mac_chan_flags
106 {
107     /// Cannot initiate radiation on this channel
108     CHAN_NO_IR = BIT(0),
109     /// Channel is not allowed
110     CHAN_DISABLED = BIT(1),
111     /// Radar detection required on this channel
112     CHAN_RADAR = BIT(2),
113 };
114
115 /// Primary Channel definition
116 struct mac_chan_def
117 {
118     /// Frequency of the channel (in MHz)
119     u16_l freq;
120     /// RF band (@ref mac_chan_band)
121     u8_l band;
122     /// Additional information (@ref mac_chan_flags)
123     u8_l flags;
124     /// Max transmit power allowed on this channel (dBm)
125     s8_l tx_power;
126 };
127
128 /// Operating Channel
129 struct mac_chan_op
130 {
131     /// Band (@ref mac_chan_band)
132     u8_l band;
133     /// Channel type (@ref mac_chan_bandwidth)
134     u8_l type;
135     /// Frequency for Primary 20MHz channel (in MHz)
136     u16_l prim20_freq;
137     /// Frequency center of the contiguous channel or center of Primary 80+80 (in MHz)
138     u16_l center1_freq;
139     /// Frequency center of the non-contiguous secondary 80+80 (in MHz)
140     u16_l center2_freq;
141     /// Max transmit power allowed on this channel (dBm)
142     s8_l tx_power;
143     /// Additional information (@ref mac_chan_flags)
144     u8_l flags;
145 };
146
147 /// Cipher suites (order is important as it is used by MACHW)
148 enum mac_cipher_suite
149 {
150     /// 00-0F-AC 1
151     MAC_CIPHER_WEP40 = 0,
152     /// 00-0F-AC 2
153     MAC_CIPHER_TKIP = 1,
154     /// 00-0F-AC 4
155     MAC_CIPHER_CCMP = 2,
156     /// 00-0F-AC 5
157     MAC_CIPHER_WEP104 = 3,
158     /// 00-14-72 1
159     MAC_CIPHER_WPI_SMS4 = 4,
160     /// 00-0F-AC 6  (aka AES_CMAC)
161     MAC_CIPHER_BIP_CMAC_128 = 5,
162
163     // following cipher are not supported by MACHW
164     /// 00-0F-AC 08
165     MAC_CIPHER_GCMP_128,
166     /// 00-0F-AC 09
167     MAC_CIPHER_GCMP_256,
168     /// 00-0F-AC 10
169     MAC_CIPHER_CCMP_256,
170     /// 00-0F-AC 11
171     MAC_CIPHER_BIP_GMAC_128,
172     /// 00-0F-AC 12
173     MAC_CIPHER_BIP_GMAC_256,
174     /// 00-0F-AC 13
175     MAC_CIPHER_BIP_CMAC_256,
176
177     MAC_CIPHER_INVALID = 0xFF
178 };
179
180 /// Authentication and Key Management suite
181 enum mac_akm_suite
182 {
183     /// No security
184     MAC_AKM_NONE,
185     /// Pre RSN (WEP or WPA)
186     MAC_AKM_PRE_RSN,
187     /// 00-0F-AC 1
188     MAC_AKM_8021X,
189     /// 00-0F-AC 2
190     MAC_AKM_PSK,
191     /// 00-0F-AC 3
192     MAC_AKM_FT_8021X,
193     /// 00-0F-AC 4
194     MAC_AKM_FT_PSK,
195     /// 00-0F-AC 5
196     MAC_AKM_8021X_SHA256,
197     /// 00-0F-AC 6
198     MAC_AKM_PSK_SHA256,
199     /// 00-0F-AC 7
200     MAC_AKM_TDLS,
201     /// 00-0F-AC 8
202     MAC_AKM_SAE,
203     /// 00-0F-AC 9
204     MAC_AKM_FT_OVER_SAE,
205     /// 00-0F-AC 11
206     MAC_AKM_8021X_SUITE_B,
207     /// 00-0F-AC 12
208     MAC_AKM_8021X_SUITE_B_192,
209     /// 00-0F-AC 14
210     MAC_AKM_FILS_SHA256,
211     /// 00-0F-AC 15
212     MAC_AKM_FILS_SHA384,
213     /// 00-0F-AC 16
214     MAC_AKM_FT_FILS_SHA256,
215     /// 00-0F-AC 17
216     MAC_AKM_FT_FILS_SHA384,
217     /// 00-0F-AC 18
218     MAC_AKM_OWE,
219
220     /// 00-14-72 1
221     MAC_AKM_WAPI_CERT,
222     /// 00-14-72 2
223     MAC_AKM_WAPI_PSK,
224 };
225
226 /// Scan result element, parsed from beacon or probe response frames.
227 struct mac_scan_result
228 {
229     /// Scan result is valid
230     bool valid_flag;
231     /// Network BSSID.
232     struct mac_addr bssid;
233     /// Network name.
234     struct mac_ssid ssid;
235     /// Network type (@ref mac_bss_type).
236     u16_l bsstype;
237     /// Network channel.
238     struct mac_chan_def *chan;
239     /// Network beacon period (in TU).
240     u16_l beacon_period;
241     /// Capability information
242     u16_l cap_info;
243     /// Supported AKM (bit-field of @ref mac_akm_suite)
244     u32_l akm;
245     /// Group cipher (bit-field of @ref mac_cipher_suite)
246     u16_l group_cipher;
247     /// Group cipher (bit-field of @ref mac_cipher_suite)
248     u16_l pairwise_cipher;
249     /// RSSI of the scanned BSS (in dBm)
250     s8_l rssi;
251     /// Multi-BSSID index (0 if this is the reference (i.e. transmitted) BSSID)
252     u8_l multi_bssid_index;
253     /// Maximum BSSID indicator
254     u8_l max_bssid_indicator;
255 };
256
257 /// Legacy rate 802.11 definitions
258 enum mac_legacy_rates
259 {
260     /// DSSS/CCK 1Mbps
261     MAC_RATE_1MBPS   =   2,
262     /// DSSS/CCK 2Mbps
263     MAC_RATE_2MBPS   =   4,
264     /// DSSS/CCK 5.5Mbps
265     MAC_RATE_5_5MBPS =  11,
266     /// OFDM 6Mbps
267     MAC_RATE_6MBPS   =  12,
268     /// OFDM 9Mbps
269     MAC_RATE_9MBPS   =  18,
270     /// DSSS/CCK 11Mbps
271     MAC_RATE_11MBPS  =  22,
272     /// OFDM 12Mbps
273     MAC_RATE_12MBPS  =  24,
274     /// OFDM 18Mbps
275     MAC_RATE_18MBPS  =  36,
276     /// OFDM 24Mbps
277     MAC_RATE_24MBPS  =  48,
278     /// OFDM 36Mbps
279     MAC_RATE_36MBPS  =  72,
280     /// OFDM 48Mbps
281     MAC_RATE_48MBPS  =  96,
282     /// OFDM 54Mbps
283     MAC_RATE_54MBPS  = 108
284 };
285
286 /// BSS Membership Selector definitions
287 enum mac_bss_membership
288 {
289     /// HT PHY
290     MAC_BSS_MEMBERSHIP_HT_PHY = 127,
291     /// VHT PHY
292     MAC_BSS_MEMBERSHIP_VHT_PHY = 126,
293 };
294
295 /// MAC rateset maximum length
296 #define MAC_RATESET_LEN 12
297
298 /// Structure containing the legacy rateset of a station
299 struct mac_rateset
300 {
301     /// Number of legacy rates supported
302     u8_l length;
303     /// Array of legacy rates
304     u8_l array[MAC_RATESET_LEN];
305 };
306
307 /// MAC Security Key maximum length
308 #define MAC_SEC_KEY_LEN 32  // TKIP keys 256 bits (max length) with MIC keys
309
310 /// Structure defining a security key
311 struct mac_sec_key
312 {
313     /// Key material length
314     u8_l length;
315     /// Key material
316     u32_l array[MAC_SEC_KEY_LEN/4];
317 };
318
319 /// Access Category enumeration
320 enum mac_ac
321 {
322     /// Background
323     AC_BK = 0,
324     /// Best-effort
325     AC_BE,
326     /// Video
327     AC_VI,
328     /// Voice
329     AC_VO,
330     /// Number of access categories
331     AC_MAX
332 };
333
334 /// Traffic ID enumeration
335 enum mac_tid
336 {
337     /// TID_0. Mapped to @ref AC_BE as per 802.11 standard.
338     TID_0,
339     /// TID_1. Mapped to @ref AC_BK as per 802.11 standard.
340     TID_1,
341     /// TID_2. Mapped to @ref AC_BK as per 802.11 standard.
342     TID_2,
343     /// TID_3. Mapped to @ref AC_BE as per 802.11 standard.
344     TID_3,
345     /// TID_4. Mapped to @ref AC_VI as per 802.11 standard.
346     TID_4,
347     /// TID_5. Mapped to @ref AC_VI as per 802.11 standard.
348     TID_5,
349     /// TID_6. Mapped to @ref AC_VO as per 802.11 standard.
350     TID_6,
351     /// TID_7. Mapped to @ref AC_VO as per 802.11 standard.
352     TID_7,
353     /// Non standard Management TID used internally
354     TID_MGT,
355     /// Number of TID supported
356     TID_MAX
357 };
358
359 /// MCS bitfield maximum size (in bytes)
360 #define MAX_MCS_LEN 16 // 16 * 8 = 128
361
362 /// MAC HT capability information element
363 struct mac_htcapability
364 {
365     /// HT capability information
366     u16_l ht_capa_info;
367     /// A-MPDU parameters
368     u8_l a_mpdu_param;
369     /// Supported MCS
370     u8_l mcs_rate[MAX_MCS_LEN];
371     /// HT extended capability information
372     u16_l ht_extended_capa;
373     /// Beamforming capability information
374     u32_l tx_beamforming_capa;
375     /// Antenna selection capability information
376     u8_l asel_capa;
377 };
378
379 /// MAC VHT capability information element
380 struct mac_vhtcapability
381 {
382     /// VHT capability information
383     u32_l vht_capa_info;
384     /// RX MCS map
385     u16_l rx_mcs_map;
386     /// RX highest data rate
387     u16_l rx_highest;
388     /// TX MCS map
389     u16_l tx_mcs_map;
390     /// TX highest data rate
391     u16_l tx_highest;
392 };
393
394 /// Length (in bytes) of the MAC HE capability field
395 #define MAC_HE_MAC_CAPA_LEN 6
396 /// Length (in bytes) of the PHY HE capability field
397 #define MAC_HE_PHY_CAPA_LEN 11
398 /// Maximum length (in bytes) of the PPE threshold data
399 #define MAC_HE_PPE_THRES_MAX_LEN 25
400
401 /// Structure listing the per-NSS, per-BW supported MCS combinations
402 struct mac_he_mcs_nss_supp
403 {
404     /// per-NSS supported MCS in RX, for BW <= 80MHz
405     u16_l rx_mcs_80;
406     /// per-NSS supported MCS in TX, for BW <= 80MHz
407     u16_l tx_mcs_80;
408     /// per-NSS supported MCS in RX, for BW = 160MHz
409     u16_l rx_mcs_160;
410     /// per-NSS supported MCS in TX, for BW = 160MHz
411     u16_l tx_mcs_160;
412     /// per-NSS supported MCS in RX, for BW = 80+80MHz
413     u16_l rx_mcs_80p80;
414     /// per-NSS supported MCS in TX, for BW = 80+80MHz
415     u16_l tx_mcs_80p80;
416 };
417
418 /// MAC HE capability information element
419 struct mac_hecapability
420 {
421     /// MAC HE capabilities
422     u8_l mac_cap_info[MAC_HE_MAC_CAPA_LEN];
423     /// PHY HE capabilities
424     u8_l phy_cap_info[MAC_HE_PHY_CAPA_LEN];
425     /// Supported MCS combinations
426     struct mac_he_mcs_nss_supp mcs_supp;
427     /// PPE Thresholds data
428     u8_l ppe_thres[MAC_HE_PPE_THRES_MAX_LEN];
429 };
430
431 /// Station flags
432 enum mac_sta_flags
433 {
434     /// Bit indicating that a STA has QoS (WMM) capability
435     STA_QOS_CAPA = BIT(0),
436     /// Bit indicating that a STA has HT capability
437     STA_HT_CAPA = BIT(1),
438     /// Bit indicating that a STA has VHT capability
439     STA_VHT_CAPA = BIT(2),
440     /// Bit indicating that a STA has MFP capability
441     STA_MFP_CAPA = BIT(3),
442     /// Bit indicating that the STA included the Operation Notification IE
443     STA_OPMOD_NOTIF = BIT(4),
444     /// Bit indicating that a STA has HE capability
445     STA_HE_CAPA = BIT(5),
446     /// Bit Inidcating supprot for short Preamble in ERP
447     STA_SHORT_PREAMBLE_CAPA = BIT(6),
448 };
449
450 /// Connection flags
451 enum mac_connection_flags
452 {
453     /// Flag indicating whether the control port is controlled by host or not
454     CONTROL_PORT_HOST = BIT(0),
455     /// Flag indicating whether the control port frame shall be sent unencrypted
456     CONTROL_PORT_NO_ENC = BIT(1),
457     /// Flag indicating whether HT and VHT shall be disabled or not
458     DISABLE_HT = BIT(2),
459     /// Flag indicating whether WPA or WPA2 authentication is in use
460     WPA_WPA2_IN_USE = BIT(3),
461     /// Flag indicating whether MFP is in use
462     MFP_IN_USE = BIT(4),
463     REASSOCIATION = BIT(5),
464     FT_OVER_DS = BIT(6),
465 };
466
467 #endif // LMAC_MAC_H_