xref: /openbmc/linux/drivers/net/wireless/ti/wl1251/cmd.h (revision 3cf3cdea)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * This file is part of wl1251
4  *
5  * Copyright (c) 1998-2007 Texas Instruments Incorporated
6  * Copyright (C) 2008 Nokia Corporation
7  */
8 
9 #ifndef __WL1251_CMD_H__
10 #define __WL1251_CMD_H__
11 
12 #include "wl1251.h"
13 
14 #include <net/cfg80211.h>
15 
16 struct acx_header;
17 
18 int wl1251_cmd_send(struct wl1251 *wl, u16 type, void *buf, size_t buf_len);
19 int wl1251_cmd_test(struct wl1251 *wl, void *buf, size_t buf_len, u8 answer);
20 int wl1251_cmd_interrogate(struct wl1251 *wl, u16 id, void *buf, size_t len);
21 int wl1251_cmd_configure(struct wl1251 *wl, u16 id, void *buf, size_t len);
22 int wl1251_cmd_vbm(struct wl1251 *wl, u8 identity,
23 		   void *bitmap, u16 bitmap_len, u8 bitmap_control);
24 int wl1251_cmd_data_path_rx(struct wl1251 *wl, u8 channel, bool enable);
25 int wl1251_cmd_data_path_tx(struct wl1251 *wl, u8 channel, bool enable);
26 int wl1251_cmd_join(struct wl1251 *wl, u8 bss_type, u8 channel,
27 		    u16 beacon_interval, u8 dtim_interval);
28 int wl1251_cmd_ps_mode(struct wl1251 *wl, u8 ps_mode);
29 int wl1251_cmd_read_memory(struct wl1251 *wl, u32 addr, void *answer,
30 			   size_t len);
31 int wl1251_cmd_template_set(struct wl1251 *wl, u16 cmd_id,
32 			    void *buf, size_t buf_len);
33 int wl1251_cmd_scan(struct wl1251 *wl, u8 *ssid, size_t ssid_len,
34 		    struct ieee80211_channel *channels[],
35 		    unsigned int n_channels, unsigned int n_probes);
36 int wl1251_cmd_trigger_scan_to(struct wl1251 *wl, u32 timeout);
37 
38 /* unit ms */
39 #define WL1251_COMMAND_TIMEOUT 2000
40 
41 enum wl1251_commands {
42 	CMD_RESET           = 0,
43 	CMD_INTERROGATE     = 1,    /*use this to read information elements*/
44 	CMD_CONFIGURE       = 2,    /*use this to write information elements*/
45 	CMD_ENABLE_RX       = 3,
46 	CMD_ENABLE_TX       = 4,
47 	CMD_DISABLE_RX      = 5,
48 	CMD_DISABLE_TX      = 6,
49 	CMD_SCAN            = 8,
50 	CMD_STOP_SCAN       = 9,
51 	CMD_VBM             = 10,
52 	CMD_START_JOIN      = 11,
53 	CMD_SET_KEYS        = 12,
54 	CMD_READ_MEMORY     = 13,
55 	CMD_WRITE_MEMORY    = 14,
56 	CMD_BEACON          = 19,
57 	CMD_PROBE_RESP      = 20,
58 	CMD_NULL_DATA       = 21,
59 	CMD_PROBE_REQ       = 22,
60 	CMD_TEST            = 23,
61 	CMD_RADIO_CALIBRATE     = 25,   /* OBSOLETE */
62 	CMD_ENABLE_RX_PATH      = 27,   /* OBSOLETE */
63 	CMD_NOISE_HIST      = 28,
64 	CMD_RX_RESET        = 29,
65 	CMD_PS_POLL         = 30,
66 	CMD_QOS_NULL_DATA   = 31,
67 	CMD_LNA_CONTROL     = 32,
68 	CMD_SET_BCN_MODE    = 33,
69 	CMD_MEASUREMENT      = 34,
70 	CMD_STOP_MEASUREMENT = 35,
71 	CMD_DISCONNECT       = 36,
72 	CMD_SET_PS_MODE      = 37,
73 	CMD_CHANNEL_SWITCH   = 38,
74 	CMD_STOP_CHANNEL_SWICTH = 39,
75 	CMD_AP_DISCOVERY     = 40,
76 	CMD_STOP_AP_DISCOVERY = 41,
77 	CMD_SPS_SCAN = 42,
78 	CMD_STOP_SPS_SCAN = 43,
79 	CMD_HEALTH_CHECK     = 45,
80 	CMD_DEBUG            = 46,
81 	CMD_TRIGGER_SCAN_TO  = 47,
82 
83 	NUM_COMMANDS,
84 	MAX_COMMAND_ID = 0xFFFF,
85 };
86 
87 #define MAX_CMD_PARAMS 572
88 
89 struct wl1251_cmd_header {
90 	u16 id;
91 	u16 status;
92 	/* payload */
93 	u8 data[];
94 } __packed;
95 
96 struct  wl1251_command {
97 	struct wl1251_cmd_header header;
98 	u8  parameters[MAX_CMD_PARAMS];
99 } __packed;
100 
101 enum {
102 	CMD_MAILBOX_IDLE              		=  0,
103 	CMD_STATUS_SUCCESS            		=  1,
104 	CMD_STATUS_UNKNOWN_CMD        		=  2,
105 	CMD_STATUS_UNKNOWN_IE         		=  3,
106 	CMD_STATUS_REJECT_MEAS_SG_ACTIVE 	= 11,
107 	CMD_STATUS_RX_BUSY            		= 13,
108 	CMD_STATUS_INVALID_PARAM      		= 14,
109 	CMD_STATUS_TEMPLATE_TOO_LARGE 		= 15,
110 	CMD_STATUS_OUT_OF_MEMORY      		= 16,
111 	CMD_STATUS_STA_TABLE_FULL     		= 17,
112 	CMD_STATUS_RADIO_ERROR        		= 18,
113 	CMD_STATUS_WRONG_NESTING      		= 19,
114 	CMD_STATUS_TIMEOUT            		= 21, /* Driver internal use.*/
115 	CMD_STATUS_FW_RESET           		= 22, /* Driver internal use.*/
116 	MAX_COMMAND_STATUS            		= 0xff
117 };
118 
119 
120 /*
121  * CMD_READ_MEMORY
122  *
123  * The host issues this command to read the WiLink device memory/registers.
124  *
125  * Note: The Base Band address has special handling (16 bits registers and
126  * addresses). For more information, see the hardware specification.
127  */
128 /*
129  * CMD_WRITE_MEMORY
130  *
131  * The host issues this command to write the WiLink device memory/registers.
132  *
133  * The Base Band address has special handling (16 bits registers and
134  * addresses). For more information, see the hardware specification.
135  */
136 #define MAX_READ_SIZE 256
137 
138 struct cmd_read_write_memory {
139 	struct wl1251_cmd_header header;
140 
141 	/* The address of the memory to read from or write to.*/
142 	u32 addr;
143 
144 	/* The amount of data in bytes to read from or write to the WiLink
145 	 * device.*/
146 	u32 size;
147 
148 	/* The actual value read from or written to the Wilink. The source
149 	   of this field is the Host in WRITE command or the Wilink in READ
150 	   command. */
151 	u8 value[MAX_READ_SIZE];
152 } __packed;
153 
154 #define CMDMBOX_HEADER_LEN 4
155 #define CMDMBOX_INFO_ELEM_HEADER_LEN 4
156 
157 #define WL1251_SCAN_OPT_PASSIVE		1
158 #define WL1251_SCAN_OPT_5GHZ_BAND	2
159 #define WL1251_SCAN_OPT_TRIGGERD_SCAN	4
160 #define WL1251_SCAN_OPT_PRIORITY_HIGH	8
161 
162 #define WL1251_SCAN_MIN_DURATION 30000
163 #define WL1251_SCAN_MAX_DURATION 60000
164 
165 #define WL1251_SCAN_NUM_PROBES 3
166 
167 struct wl1251_scan_parameters {
168 	__le32 rx_config_options;
169 	__le32 rx_filter_options;
170 
171 	/*
172 	 * Scan options:
173 	 * bit 0: When this bit is set, passive scan.
174 	 * bit 1: Band, when this bit is set we scan
175 	 * in the 5Ghz band.
176 	 * bit 2: voice mode, 0 for normal scan.
177 	 * bit 3: scan priority, 1 for high priority.
178 	 */
179 	__le16 scan_options;
180 
181 	/* Number of channels to scan */
182 	u8 num_channels;
183 
184 	/* Number opf probe requests to send, per channel */
185 	u8 num_probe_requests;
186 
187 	/* Rate and modulation for probe requests */
188 	__le16 tx_rate;
189 
190 	u8 tid_trigger;
191 	u8 ssid_len;
192 	u8 ssid[32];
193 
194 } __packed;
195 
196 struct wl1251_scan_ch_parameters {
197 	__le32 min_duration; /* in TU */
198 	__le32 max_duration; /* in TU */
199 	u32 bssid_lsb;
200 	u16 bssid_msb;
201 
202 	/*
203 	 * bits 0-3: Early termination count.
204 	 * bits 4-5: Early termination condition.
205 	 */
206 	u8 early_termination;
207 
208 	u8 tx_power_att;
209 	u8 channel;
210 	u8 pad[3];
211 } __packed;
212 
213 /* SCAN parameters */
214 #define SCAN_MAX_NUM_OF_CHANNELS 16
215 
216 struct wl1251_cmd_scan {
217 	struct wl1251_cmd_header header;
218 
219 	struct wl1251_scan_parameters params;
220 	struct wl1251_scan_ch_parameters channels[SCAN_MAX_NUM_OF_CHANNELS];
221 } __packed;
222 
223 enum {
224 	BSS_TYPE_IBSS = 0,
225 	BSS_TYPE_STA_BSS = 2,
226 	BSS_TYPE_AP_BSS = 3,
227 	MAX_BSS_TYPE = 0xFF
228 };
229 
230 #define JOIN_CMD_CTRL_TX_FLUSH             0x80 /* Firmware flushes all Tx */
231 #define JOIN_CMD_CTRL_EARLY_WAKEUP_ENABLE  0x01 /* Early wakeup time */
232 
233 
234 struct cmd_join {
235 	struct wl1251_cmd_header header;
236 
237 	u32 bssid_lsb;
238 	u16 bssid_msb;
239 	u16 beacon_interval; /* in TBTTs */
240 	u32 rx_config_options;
241 	u32 rx_filter_options;
242 
243 	/*
244 	 * The target uses this field to determine the rate at
245 	 * which to transmit control frame responses (such as
246 	 * ACK or CTS frames).
247 	 */
248 	u16 basic_rate_set;
249 	u8 dtim_interval;
250 	u8 tx_ctrl_frame_rate; /* OBSOLETE */
251 	u8 tx_ctrl_frame_mod;  /* OBSOLETE */
252 	/*
253 	 * bits 0-2: This bitwise field specifies the type
254 	 * of BSS to start or join (BSS_TYPE_*).
255 	 * bit 4: Band - The radio band in which to join
256 	 * or start.
257 	 *  0 - 2.4GHz band
258 	 *  1 - 5GHz band
259 	 * bits 3, 5-7: Reserved
260 	 */
261 	u8 bss_type;
262 	u8 channel;
263 	u8 ssid_len;
264 	u8 ssid[IEEE80211_MAX_SSID_LEN];
265 	u8 ctrl; /* JOIN_CMD_CTRL_* */
266 	u8 tx_mgt_frame_rate; /* OBSOLETE */
267 	u8 tx_mgt_frame_mod;  /* OBSOLETE */
268 	u8 reserved;
269 } __packed;
270 
271 struct cmd_enabledisable_path {
272 	struct wl1251_cmd_header header;
273 
274 	u8 channel;
275 	u8 padding[3];
276 } __packed;
277 
278 #define WL1251_MAX_TEMPLATE_SIZE 300
279 
280 struct wl1251_cmd_packet_template {
281 	struct wl1251_cmd_header header;
282 
283 	__le16 size;
284 	u8 data[];
285 } __packed;
286 
287 #define TIM_ELE_ID    5
288 #define PARTIAL_VBM_MAX    251
289 
290 struct wl1251_tim {
291 	u8 identity;
292 	u8 length;
293 	u8 dtim_count;
294 	u8 dtim_period;
295 	u8 bitmap_ctrl;
296 	u8 pvb_field[PARTIAL_VBM_MAX]; /* Partial Virtual Bitmap */
297 } __packed;
298 
299 /* Virtual Bit Map update */
300 struct wl1251_cmd_vbm_update {
301 	struct wl1251_cmd_header header;
302 	__le16 len;
303 	u8  padding[2];
304 	struct wl1251_tim tim;
305 } __packed;
306 
307 enum wl1251_cmd_ps_mode {
308 	CHIP_ACTIVE_MODE,
309 	CHIP_POWER_SAVE_MODE
310 };
311 
312 struct wl1251_cmd_ps_params {
313 	struct wl1251_cmd_header header;
314 
315 	u8 ps_mode; /* STATION_* */
316 	u8 send_null_data; /* Do we have to send NULL data packet ? */
317 	u8 retries; /* Number of retires for the initial NULL data packet */
318 
319 	 /*
320 	  * TUs during which the target stays awake after switching
321 	  * to power save mode.
322 	  */
323 	u8 hang_over_period;
324 	u16 null_data_rate;
325 	u8 pad[2];
326 } __packed;
327 
328 struct wl1251_cmd_trigger_scan_to {
329 	struct wl1251_cmd_header header;
330 
331 	u32 timeout;
332 } __packed;
333 
334 /* HW encryption keys */
335 #define NUM_ACCESS_CATEGORIES_COPY 4
336 #define MAX_KEY_SIZE 32
337 
338 /* When set, disable HW encryption */
339 #define DF_ENCRYPTION_DISABLE      0x01
340 /* When set, disable HW decryption */
341 #define DF_SNIFF_MODE_ENABLE       0x80
342 
343 enum wl1251_cmd_key_action {
344 	KEY_ADD_OR_REPLACE = 1,
345 	KEY_REMOVE         = 2,
346 	KEY_SET_ID         = 3,
347 	MAX_KEY_ACTION     = 0xffff,
348 };
349 
350 enum wl1251_cmd_key_type {
351 	KEY_WEP_DEFAULT       = 0,
352 	KEY_WEP_ADDR          = 1,
353 	KEY_AES_GROUP         = 4,
354 	KEY_AES_PAIRWISE      = 5,
355 	KEY_WEP_GROUP         = 6,
356 	KEY_TKIP_MIC_GROUP    = 10,
357 	KEY_TKIP_MIC_PAIRWISE = 11,
358 };
359 
360 /*
361  *
362  * key_type_e   key size    key format
363  * ----------   ---------   ----------
364  * 0x00         5, 13, 29   Key data
365  * 0x01         5, 13, 29   Key data
366  * 0x04         16          16 bytes of key data
367  * 0x05         16          16 bytes of key data
368  * 0x0a         32          16 bytes of TKIP key data
369  *                          8 bytes of RX MIC key data
370  *                          8 bytes of TX MIC key data
371  * 0x0b         32          16 bytes of TKIP key data
372  *                          8 bytes of RX MIC key data
373  *                          8 bytes of TX MIC key data
374  *
375  */
376 
377 struct wl1251_cmd_set_keys {
378 	struct wl1251_cmd_header header;
379 
380 	/* Ignored for default WEP key */
381 	u8 addr[ETH_ALEN];
382 
383 	/* key_action_e */
384 	u16 key_action;
385 
386 	u16 reserved_1;
387 
388 	/* key size in bytes */
389 	u8 key_size;
390 
391 	/* key_type_e */
392 	u8 key_type;
393 	u8 ssid_profile;
394 
395 	/*
396 	 * TKIP, AES: frame's key id field.
397 	 * For WEP default key: key id;
398 	 */
399 	u8 id;
400 	u8 reserved_2[6];
401 	u8 key[MAX_KEY_SIZE];
402 	u16 ac_seq_num16[NUM_ACCESS_CATEGORIES_COPY];
403 	u32 ac_seq_num32[NUM_ACCESS_CATEGORIES_COPY];
404 } __packed;
405 
406 
407 #endif /* __WL1251_CMD_H__ */
408