1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * This header file contains definition for global types
4  */
5 #ifndef _LBS_TYPES_H_
6 #define _LBS_TYPES_H_
7 
8 #include <linux/if_ether.h>
9 #include <linux/ieee80211.h>
10 #include <asm/byteorder.h>
11 
12 struct ieee_ie_header {
13 	u8 id;
14 	u8 len;
15 } __packed;
16 
17 struct ieee_ie_cf_param_set {
18 	struct ieee_ie_header header;
19 
20 	u8 cfpcnt;
21 	u8 cfpperiod;
22 	__le16 cfpmaxduration;
23 	__le16 cfpdurationremaining;
24 } __packed;
25 
26 
27 struct ieee_ie_ibss_param_set {
28 	struct ieee_ie_header header;
29 
30 	__le16 atimwindow;
31 } __packed;
32 
33 union ieee_ss_param_set {
34 	struct ieee_ie_cf_param_set cf;
35 	struct ieee_ie_ibss_param_set ibss;
36 } __packed;
37 
38 struct ieee_ie_fh_param_set {
39 	struct ieee_ie_header header;
40 
41 	__le16 dwelltime;
42 	u8 hopset;
43 	u8 hoppattern;
44 	u8 hopindex;
45 } __packed;
46 
47 struct ieee_ie_ds_param_set {
48 	struct ieee_ie_header header;
49 
50 	u8 channel;
51 } __packed;
52 
53 union ieee_phy_param_set {
54 	struct ieee_ie_fh_param_set fh;
55 	struct ieee_ie_ds_param_set ds;
56 } __packed;
57 
58 /* TLV  type ID definition */
59 #define PROPRIETARY_TLV_BASE_ID		0x0100
60 
61 /* Terminating TLV type */
62 #define MRVL_TERMINATE_TLV_ID		0xffff
63 
64 #define TLV_TYPE_SSID				0x0000
65 #define TLV_TYPE_RATES				0x0001
66 #define TLV_TYPE_PHY_FH				0x0002
67 #define TLV_TYPE_PHY_DS				0x0003
68 #define TLV_TYPE_CF				    0x0004
69 #define TLV_TYPE_IBSS				0x0006
70 
71 #define TLV_TYPE_DOMAIN				0x0007
72 
73 #define TLV_TYPE_POWER_CAPABILITY	0x0021
74 
75 #define TLV_TYPE_KEY_MATERIAL       (PROPRIETARY_TLV_BASE_ID + 0)
76 #define TLV_TYPE_CHANLIST           (PROPRIETARY_TLV_BASE_ID + 1)
77 #define TLV_TYPE_NUMPROBES          (PROPRIETARY_TLV_BASE_ID + 2)
78 #define TLV_TYPE_RSSI_LOW           (PROPRIETARY_TLV_BASE_ID + 4)
79 #define TLV_TYPE_SNR_LOW            (PROPRIETARY_TLV_BASE_ID + 5)
80 #define TLV_TYPE_FAILCOUNT          (PROPRIETARY_TLV_BASE_ID + 6)
81 #define TLV_TYPE_BCNMISS            (PROPRIETARY_TLV_BASE_ID + 7)
82 #define TLV_TYPE_LED_GPIO           (PROPRIETARY_TLV_BASE_ID + 8)
83 #define TLV_TYPE_LEDBEHAVIOR        (PROPRIETARY_TLV_BASE_ID + 9)
84 #define TLV_TYPE_PASSTHROUGH        (PROPRIETARY_TLV_BASE_ID + 10)
85 #define TLV_TYPE_REASSOCAP          (PROPRIETARY_TLV_BASE_ID + 11)
86 #define TLV_TYPE_POWER_TBL_2_4GHZ   (PROPRIETARY_TLV_BASE_ID + 12)
87 #define TLV_TYPE_POWER_TBL_5GHZ     (PROPRIETARY_TLV_BASE_ID + 13)
88 #define TLV_TYPE_BCASTPROBE	    (PROPRIETARY_TLV_BASE_ID + 14)
89 #define TLV_TYPE_NUMSSID_PROBE	    (PROPRIETARY_TLV_BASE_ID + 15)
90 #define TLV_TYPE_WMMQSTATUS   	    (PROPRIETARY_TLV_BASE_ID + 16)
91 #define TLV_TYPE_CRYPTO_DATA	    (PROPRIETARY_TLV_BASE_ID + 17)
92 #define TLV_TYPE_WILDCARDSSID	    (PROPRIETARY_TLV_BASE_ID + 18)
93 #define TLV_TYPE_TSFTIMESTAMP	    (PROPRIETARY_TLV_BASE_ID + 19)
94 #define TLV_TYPE_RSSI_HIGH          (PROPRIETARY_TLV_BASE_ID + 22)
95 #define TLV_TYPE_SNR_HIGH           (PROPRIETARY_TLV_BASE_ID + 23)
96 #define TLV_TYPE_AUTH_TYPE          (PROPRIETARY_TLV_BASE_ID + 31)
97 #define TLV_TYPE_MESH_ID            (PROPRIETARY_TLV_BASE_ID + 37)
98 #define TLV_TYPE_OLD_MESH_ID        (PROPRIETARY_TLV_BASE_ID + 291)
99 
100 /* TLV related data structures */
101 struct mrvl_ie_header {
102 	__le16 type;
103 	__le16 len;
104 } __packed;
105 
106 struct mrvl_ie_data {
107 	struct mrvl_ie_header header;
108 	u8 Data[1];
109 } __packed;
110 
111 struct mrvl_ie_rates_param_set {
112 	struct mrvl_ie_header header;
113 	u8 rates[1];
114 } __packed;
115 
116 struct mrvl_ie_ssid_param_set {
117 	struct mrvl_ie_header header;
118 	u8 ssid[1];
119 } __packed;
120 
121 struct mrvl_ie_wildcard_ssid_param_set {
122 	struct mrvl_ie_header header;
123 	u8 MaxSsidlength;
124 	u8 ssid[1];
125 } __packed;
126 
127 struct chanscanmode {
128 #ifdef __BIG_ENDIAN_BITFIELD
129 	u8 reserved_2_7:6;
130 	u8 disablechanfilt:1;
131 	u8 passivescan:1;
132 #else
133 	u8 passivescan:1;
134 	u8 disablechanfilt:1;
135 	u8 reserved_2_7:6;
136 #endif
137 } __packed;
138 
139 struct chanscanparamset {
140 	u8 radiotype;
141 	u8 channumber;
142 	struct chanscanmode chanscanmode;
143 	__le16 minscantime;
144 	__le16 maxscantime;
145 } __packed;
146 
147 struct mrvl_ie_chanlist_param_set {
148 	struct mrvl_ie_header header;
149 	struct chanscanparamset chanscanparam[1];
150 } __packed;
151 
152 struct mrvl_ie_cf_param_set {
153 	struct mrvl_ie_header header;
154 	u8 cfpcnt;
155 	u8 cfpperiod;
156 	__le16 cfpmaxduration;
157 	__le16 cfpdurationremaining;
158 } __packed;
159 
160 struct mrvl_ie_ds_param_set {
161 	struct mrvl_ie_header header;
162 	u8 channel;
163 } __packed;
164 
165 struct mrvl_ie_rsn_param_set {
166 	struct mrvl_ie_header header;
167 	u8 rsnie[1];
168 } __packed;
169 
170 struct mrvl_ie_tsf_timestamp {
171 	struct mrvl_ie_header header;
172 	__le64 tsftable[1];
173 } __packed;
174 
175 /* v9 and later firmware only */
176 struct mrvl_ie_auth_type {
177 	struct mrvl_ie_header header;
178 	__le16 auth;
179 } __packed;
180 
181 /*  Local Power capability */
182 struct mrvl_ie_power_capability {
183 	struct mrvl_ie_header header;
184 	s8 minpower;
185 	s8 maxpower;
186 } __packed;
187 
188 /* used in CMD_802_11_SUBSCRIBE_EVENT for SNR, RSSI and Failure */
189 struct mrvl_ie_thresholds {
190 	struct mrvl_ie_header header;
191 	u8 value;
192 	u8 freq;
193 } __packed;
194 
195 struct mrvl_ie_beacons_missed {
196 	struct mrvl_ie_header header;
197 	u8 beaconmissed;
198 	u8 reserved;
199 } __packed;
200 
201 struct mrvl_ie_num_probes {
202 	struct mrvl_ie_header header;
203 	__le16 numprobes;
204 } __packed;
205 
206 struct mrvl_ie_bcast_probe {
207 	struct mrvl_ie_header header;
208 	__le16 bcastprobe;
209 } __packed;
210 
211 struct mrvl_ie_num_ssid_probe {
212 	struct mrvl_ie_header header;
213 	__le16 numssidprobe;
214 } __packed;
215 
216 struct led_pin {
217 	u8 led;
218 	u8 pin;
219 } __packed;
220 
221 struct mrvl_ie_ledgpio {
222 	struct mrvl_ie_header header;
223 	struct led_pin ledpin[1];
224 } __packed;
225 
226 struct led_bhv {
227 	uint8_t	firmwarestate;
228 	uint8_t	led;
229 	uint8_t	ledstate;
230 	uint8_t	ledarg;
231 } __packed;
232 
233 
234 struct mrvl_ie_ledbhv {
235 	struct mrvl_ie_header header;
236 	struct led_bhv ledbhv[1];
237 } __packed;
238 
239 /*
240  * Meant to be packed as the value member of a struct ieee80211_info_element.
241  * Note that the len member of the ieee80211_info_element varies depending on
242  * the mesh_id_len
243  */
244 struct mrvl_meshie_val {
245 	uint8_t oui[3];
246 	uint8_t type;
247 	uint8_t subtype;
248 	uint8_t version;
249 	uint8_t active_protocol_id;
250 	uint8_t active_metric_id;
251 	uint8_t mesh_capability;
252 	uint8_t mesh_id_len;
253 	uint8_t mesh_id[IEEE80211_MAX_SSID_LEN];
254 } __packed;
255 
256 struct mrvl_meshie {
257 	u8 id, len;
258 	struct mrvl_meshie_val val;
259 } __packed;
260 
261 struct mrvl_mesh_defaults {
262 	__le32 bootflag;
263 	uint8_t boottime;
264 	uint8_t reserved;
265 	__le16 channel;
266 	struct mrvl_meshie meshie;
267 } __packed;
268 
269 #endif
270