xref: /linux/drivers/net/wireless/ti/wl1251/wl12xx_80211.h (revision 6e7fd890f1d6ac83805409e9c346240de2705584)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __WL12XX_80211_H__
3 #define __WL12XX_80211_H__
4 
5 #include <linux/if_ether.h>	/* ETH_ALEN */
6 
7 /* RATES */
8 #define IEEE80211_CCK_RATE_1MB		        0x02
9 #define IEEE80211_CCK_RATE_2MB		        0x04
10 #define IEEE80211_CCK_RATE_5MB		        0x0B
11 #define IEEE80211_CCK_RATE_11MB		        0x16
12 #define IEEE80211_OFDM_RATE_6MB		        0x0C
13 #define IEEE80211_OFDM_RATE_9MB		        0x12
14 #define IEEE80211_OFDM_RATE_12MB		0x18
15 #define IEEE80211_OFDM_RATE_18MB		0x24
16 #define IEEE80211_OFDM_RATE_24MB		0x30
17 #define IEEE80211_OFDM_RATE_36MB		0x48
18 #define IEEE80211_OFDM_RATE_48MB		0x60
19 #define IEEE80211_OFDM_RATE_54MB		0x6C
20 #define IEEE80211_BASIC_RATE_MASK		0x80
21 
22 #define IEEE80211_CCK_RATE_1MB_MASK		(1<<0)
23 #define IEEE80211_CCK_RATE_2MB_MASK		(1<<1)
24 #define IEEE80211_CCK_RATE_5MB_MASK		(1<<2)
25 #define IEEE80211_CCK_RATE_11MB_MASK		(1<<3)
26 #define IEEE80211_OFDM_RATE_6MB_MASK		(1<<4)
27 #define IEEE80211_OFDM_RATE_9MB_MASK		(1<<5)
28 #define IEEE80211_OFDM_RATE_12MB_MASK		(1<<6)
29 #define IEEE80211_OFDM_RATE_18MB_MASK		(1<<7)
30 #define IEEE80211_OFDM_RATE_24MB_MASK		(1<<8)
31 #define IEEE80211_OFDM_RATE_36MB_MASK		(1<<9)
32 #define IEEE80211_OFDM_RATE_48MB_MASK		(1<<10)
33 #define IEEE80211_OFDM_RATE_54MB_MASK		(1<<11)
34 
35 #define IEEE80211_CCK_RATES_MASK	  0x0000000F
36 #define IEEE80211_CCK_BASIC_RATES_MASK	 (IEEE80211_CCK_RATE_1MB_MASK | \
37 	IEEE80211_CCK_RATE_2MB_MASK)
38 #define IEEE80211_CCK_DEFAULT_RATES_MASK (IEEE80211_CCK_BASIC_RATES_MASK | \
39 	IEEE80211_CCK_RATE_5MB_MASK | \
40 	IEEE80211_CCK_RATE_11MB_MASK)
41 
42 #define IEEE80211_OFDM_RATES_MASK	  0x00000FF0
43 #define IEEE80211_OFDM_BASIC_RATES_MASK	  (IEEE80211_OFDM_RATE_6MB_MASK | \
44 	IEEE80211_OFDM_RATE_12MB_MASK | \
45 	IEEE80211_OFDM_RATE_24MB_MASK)
46 #define IEEE80211_OFDM_DEFAULT_RATES_MASK (IEEE80211_OFDM_BASIC_RATES_MASK | \
47 	IEEE80211_OFDM_RATE_9MB_MASK  | \
48 	IEEE80211_OFDM_RATE_18MB_MASK | \
49 	IEEE80211_OFDM_RATE_36MB_MASK | \
50 	IEEE80211_OFDM_RATE_48MB_MASK | \
51 	IEEE80211_OFDM_RATE_54MB_MASK)
52 #define IEEE80211_DEFAULT_RATES_MASK (IEEE80211_OFDM_DEFAULT_RATES_MASK | \
53 				      IEEE80211_CCK_DEFAULT_RATES_MASK)
54 
55 
56 /* This really should be 8, but not for our firmware */
57 #define MAX_SUPPORTED_RATES 32
58 #define MAX_COUNTRY_TRIPLETS 32
59 
60 /* Headers */
61 struct ieee80211_header {
62 	__le16 frame_ctl;
63 	__le16 duration_id;
64 	u8 da[ETH_ALEN];
65 	u8 sa[ETH_ALEN];
66 	u8 bssid[ETH_ALEN];
67 	__le16 seq_ctl;
68 } __packed;
69 
70 struct wl12xx_ie_header {
71 	u8 id;
72 	u8 len;
73 } __packed;
74 
75 /* IEs */
76 
77 struct wl12xx_ie_ssid {
78 	struct wl12xx_ie_header header;
79 	char ssid[IEEE80211_MAX_SSID_LEN];
80 } __packed;
81 
82 struct wl12xx_ie_rates {
83 	struct wl12xx_ie_header header;
84 	u8 rates[MAX_SUPPORTED_RATES];
85 } __packed;
86 
87 struct wl12xx_ie_ds_params {
88 	struct wl12xx_ie_header header;
89 	u8 channel;
90 } __packed;
91 
92 struct country_triplet {
93 	u8 channel;
94 	u8 num_channels;
95 	u8 max_tx_power;
96 } __packed;
97 
98 struct wl12xx_ie_country {
99 	struct wl12xx_ie_header header;
100 	u8 country_string[IEEE80211_COUNTRY_STRING_LEN];
101 	struct country_triplet triplets[MAX_COUNTRY_TRIPLETS];
102 } __packed;
103 
104 
105 /* Templates */
106 
107 struct wl12xx_beacon_template {
108 	struct ieee80211_header header;
109 	__le32 time_stamp[2];
110 	__le16 beacon_interval;
111 	__le16 capability;
112 	struct wl12xx_ie_ssid ssid;
113 	struct wl12xx_ie_rates rates;
114 	struct wl12xx_ie_rates ext_rates;
115 	struct wl12xx_ie_ds_params ds_params;
116 	struct wl12xx_ie_country country;
117 } __packed;
118 
119 struct wl12xx_null_data_template {
120 	struct ieee80211_header header;
121 } __packed;
122 
123 struct wl12xx_ps_poll_template {
124 	__le16 fc;
125 	__le16 aid;
126 	u8 bssid[ETH_ALEN];
127 	u8 ta[ETH_ALEN];
128 } __packed;
129 
130 struct wl12xx_qos_null_data_template {
131 	struct ieee80211_header header;
132 	__le16 qos_ctl;
133 } __packed;
134 
135 struct wl12xx_probe_req_template {
136 	struct ieee80211_header header;
137 	struct wl12xx_ie_ssid ssid;
138 	struct wl12xx_ie_rates rates;
139 	struct wl12xx_ie_rates ext_rates;
140 } __packed;
141 
142 
143 struct wl12xx_probe_resp_template {
144 	struct ieee80211_header header;
145 	__le32 time_stamp[2];
146 	__le16 beacon_interval;
147 	__le16 capability;
148 	struct wl12xx_ie_ssid ssid;
149 	struct wl12xx_ie_rates rates;
150 	struct wl12xx_ie_rates ext_rates;
151 	struct wl12xx_ie_ds_params ds_params;
152 	struct wl12xx_ie_country country;
153 } __packed;
154 
155 #endif
156