xref: /linux/drivers/net/wireless/ti/wl1251/cmd.h (revision 93d4e8bb3f137e8037a65ea96f175f81c25c50e5)
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 } __packed;
93 
94 struct  wl1251_command {
95 	struct wl1251_cmd_header header;
96 	u8  parameters[MAX_CMD_PARAMS];
97 } __packed;
98 
99 enum {
100 	CMD_MAILBOX_IDLE              		=  0,
101 	CMD_STATUS_SUCCESS            		=  1,
102 	CMD_STATUS_UNKNOWN_CMD        		=  2,
103 	CMD_STATUS_UNKNOWN_IE         		=  3,
104 	CMD_STATUS_REJECT_MEAS_SG_ACTIVE 	= 11,
105 	CMD_STATUS_RX_BUSY            		= 13,
106 	CMD_STATUS_INVALID_PARAM      		= 14,
107 	CMD_STATUS_TEMPLATE_TOO_LARGE 		= 15,
108 	CMD_STATUS_OUT_OF_MEMORY      		= 16,
109 	CMD_STATUS_STA_TABLE_FULL     		= 17,
110 	CMD_STATUS_RADIO_ERROR        		= 18,
111 	CMD_STATUS_WRONG_NESTING      		= 19,
112 	CMD_STATUS_TIMEOUT            		= 21, /* Driver internal use.*/
113 	CMD_STATUS_FW_RESET           		= 22, /* Driver internal use.*/
114 	MAX_COMMAND_STATUS            		= 0xff
115 };
116 
117 
118 /*
119  * CMD_READ_MEMORY
120  *
121  * The host issues this command to read the WiLink device memory/registers.
122  *
123  * Note: The Base Band address has special handling (16 bits registers and
124  * addresses). For more information, see the hardware specification.
125  */
126 /*
127  * CMD_WRITE_MEMORY
128  *
129  * The host issues this command to write the WiLink device memory/registers.
130  *
131  * The Base Band address has special handling (16 bits registers and
132  * addresses). For more information, see the hardware specification.
133  */
134 #define MAX_READ_SIZE 256
135 
136 struct cmd_read_write_memory {
137 	struct wl1251_cmd_header header;
138 
139 	/* The address of the memory to read from or write to.*/
140 	u32 addr;
141 
142 	/* The amount of data in bytes to read from or write to the WiLink
143 	 * device.*/
144 	u32 size;
145 
146 	/* The actual value read from or written to the Wilink. The source
147 	   of this field is the Host in WRITE command or the Wilink in READ
148 	   command. */
149 	u8 value[MAX_READ_SIZE];
150 } __packed;
151 
152 #define CMDMBOX_HEADER_LEN 4
153 #define CMDMBOX_INFO_ELEM_HEADER_LEN 4
154 
155 #define WL1251_SCAN_OPT_PASSIVE		1
156 #define WL1251_SCAN_OPT_5GHZ_BAND	2
157 #define WL1251_SCAN_OPT_TRIGGERD_SCAN	4
158 #define WL1251_SCAN_OPT_PRIORITY_HIGH	8
159 
160 #define WL1251_SCAN_MIN_DURATION 30000
161 #define WL1251_SCAN_MAX_DURATION 60000
162 
163 #define WL1251_SCAN_NUM_PROBES 3
164 
165 struct wl1251_scan_parameters {
166 	__le32 rx_config_options;
167 	__le32 rx_filter_options;
168 
169 	/*
170 	 * Scan options:
171 	 * bit 0: When this bit is set, passive scan.
172 	 * bit 1: Band, when this bit is set we scan
173 	 * in the 5Ghz band.
174 	 * bit 2: voice mode, 0 for normal scan.
175 	 * bit 3: scan priority, 1 for high priority.
176 	 */
177 	__le16 scan_options;
178 
179 	/* Number of channels to scan */
180 	u8 num_channels;
181 
182 	/* Number opf probe requests to send, per channel */
183 	u8 num_probe_requests;
184 
185 	/* Rate and modulation for probe requests */
186 	__le16 tx_rate;
187 
188 	u8 tid_trigger;
189 	u8 ssid_len;
190 	u8 ssid[32];
191 
192 } __packed;
193 
194 struct wl1251_scan_ch_parameters {
195 	__le32 min_duration; /* in TU */
196 	__le32 max_duration; /* in TU */
197 	u32 bssid_lsb;
198 	u16 bssid_msb;
199 
200 	/*
201 	 * bits 0-3: Early termination count.
202 	 * bits 4-5: Early termination condition.
203 	 */
204 	u8 early_termination;
205 
206 	u8 tx_power_att;
207 	u8 channel;
208 	u8 pad[3];
209 } __packed;
210 
211 /* SCAN parameters */
212 #define SCAN_MAX_NUM_OF_CHANNELS 16
213 
214 struct wl1251_cmd_scan {
215 	struct wl1251_cmd_header header;
216 
217 	struct wl1251_scan_parameters params;
218 	struct wl1251_scan_ch_parameters channels[SCAN_MAX_NUM_OF_CHANNELS];
219 } __packed;
220 
221 enum {
222 	BSS_TYPE_IBSS = 0,
223 	BSS_TYPE_STA_BSS = 2,
224 	BSS_TYPE_AP_BSS = 3,
225 	MAX_BSS_TYPE = 0xFF
226 };
227 
228 #define JOIN_CMD_CTRL_TX_FLUSH             0x80 /* Firmware flushes all Tx */
229 #define JOIN_CMD_CTRL_EARLY_WAKEUP_ENABLE  0x01 /* Early wakeup time */
230 
231 
232 struct cmd_join {
233 	struct wl1251_cmd_header header;
234 
235 	u32 bssid_lsb;
236 	u16 bssid_msb;
237 	u16 beacon_interval; /* in TBTTs */
238 	u32 rx_config_options;
239 	u32 rx_filter_options;
240 
241 	/*
242 	 * The target uses this field to determine the rate at
243 	 * which to transmit control frame responses (such as
244 	 * ACK or CTS frames).
245 	 */
246 	u16 basic_rate_set;
247 	u8 dtim_interval;
248 	u8 tx_ctrl_frame_rate; /* OBSOLETE */
249 	u8 tx_ctrl_frame_mod;  /* OBSOLETE */
250 	/*
251 	 * bits 0-2: This bitwise field specifies the type
252 	 * of BSS to start or join (BSS_TYPE_*).
253 	 * bit 4: Band - The radio band in which to join
254 	 * or start.
255 	 *  0 - 2.4GHz band
256 	 *  1 - 5GHz band
257 	 * bits 3, 5-7: Reserved
258 	 */
259 	u8 bss_type;
260 	u8 channel;
261 	u8 ssid_len;
262 	u8 ssid[IEEE80211_MAX_SSID_LEN];
263 	u8 ctrl; /* JOIN_CMD_CTRL_* */
264 	u8 tx_mgt_frame_rate; /* OBSOLETE */
265 	u8 tx_mgt_frame_mod;  /* OBSOLETE */
266 	u8 reserved;
267 } __packed;
268 
269 struct cmd_enabledisable_path {
270 	struct wl1251_cmd_header header;
271 
272 	u8 channel;
273 	u8 padding[3];
274 } __packed;
275 
276 #define WL1251_MAX_TEMPLATE_SIZE 300
277 
278 struct wl1251_cmd_packet_template {
279 	struct wl1251_cmd_header header;
280 
281 	__le16 size;
282 	u8 data[];
283 } __packed;
284 
285 #define TIM_ELE_ID    5
286 #define PARTIAL_VBM_MAX    251
287 
288 struct wl1251_tim {
289 	u8 identity;
290 	u8 length;
291 	u8 dtim_count;
292 	u8 dtim_period;
293 	u8 bitmap_ctrl;
294 	u8 pvb_field[PARTIAL_VBM_MAX]; /* Partial Virtual Bitmap */
295 } __packed;
296 
297 /* Virtual Bit Map update */
298 struct wl1251_cmd_vbm_update {
299 	struct wl1251_cmd_header header;
300 	__le16 len;
301 	u8  padding[2];
302 	struct wl1251_tim tim;
303 } __packed;
304 
305 enum wl1251_cmd_ps_mode {
306 	CHIP_ACTIVE_MODE,
307 	CHIP_POWER_SAVE_MODE
308 };
309 
310 struct wl1251_cmd_ps_params {
311 	struct wl1251_cmd_header header;
312 
313 	u8 ps_mode; /* STATION_* */
314 	u8 send_null_data; /* Do we have to send NULL data packet ? */
315 	u8 retries; /* Number of retires for the initial NULL data packet */
316 
317 	 /*
318 	  * TUs during which the target stays awake after switching
319 	  * to power save mode.
320 	  */
321 	u8 hang_over_period;
322 	u16 null_data_rate;
323 	u8 pad[2];
324 } __packed;
325 
326 struct wl1251_cmd_trigger_scan_to {
327 	struct wl1251_cmd_header header;
328 
329 	u32 timeout;
330 } __packed;
331 
332 /* HW encryption keys */
333 #define NUM_ACCESS_CATEGORIES_COPY 4
334 #define MAX_KEY_SIZE 32
335 
336 /* When set, disable HW encryption */
337 #define DF_ENCRYPTION_DISABLE      0x01
338 /* When set, disable HW decryption */
339 #define DF_SNIFF_MODE_ENABLE       0x80
340 
341 enum wl1251_cmd_key_action {
342 	KEY_ADD_OR_REPLACE = 1,
343 	KEY_REMOVE         = 2,
344 	KEY_SET_ID         = 3,
345 	MAX_KEY_ACTION     = 0xffff,
346 };
347 
348 enum wl1251_cmd_key_type {
349 	KEY_WEP_DEFAULT       = 0,
350 	KEY_WEP_ADDR          = 1,
351 	KEY_AES_GROUP         = 4,
352 	KEY_AES_PAIRWISE      = 5,
353 	KEY_WEP_GROUP         = 6,
354 	KEY_TKIP_MIC_GROUP    = 10,
355 	KEY_TKIP_MIC_PAIRWISE = 11,
356 };
357 
358 /*
359  *
360  * key_type_e   key size    key format
361  * ----------   ---------   ----------
362  * 0x00         5, 13, 29   Key data
363  * 0x01         5, 13, 29   Key data
364  * 0x04         16          16 bytes of key data
365  * 0x05         16          16 bytes of key data
366  * 0x0a         32          16 bytes of TKIP key data
367  *                          8 bytes of RX MIC key data
368  *                          8 bytes of TX MIC key data
369  * 0x0b         32          16 bytes of TKIP key data
370  *                          8 bytes of RX MIC key data
371  *                          8 bytes of TX MIC key data
372  *
373  */
374 
375 struct wl1251_cmd_set_keys {
376 	struct wl1251_cmd_header header;
377 
378 	/* Ignored for default WEP key */
379 	u8 addr[ETH_ALEN];
380 
381 	/* key_action_e */
382 	u16 key_action;
383 
384 	u16 reserved_1;
385 
386 	/* key size in bytes */
387 	u8 key_size;
388 
389 	/* key_type_e */
390 	u8 key_type;
391 	u8 ssid_profile;
392 
393 	/*
394 	 * TKIP, AES: frame's key id field.
395 	 * For WEP default key: key id;
396 	 */
397 	u8 id;
398 	u8 reserved_2[6];
399 	u8 key[MAX_KEY_SIZE];
400 	u16 ac_seq_num16[NUM_ACCESS_CATEGORIES_COPY];
401 	u32 ac_seq_num32[NUM_ACCESS_CATEGORIES_COPY];
402 } __packed;
403 
404 
405 #endif /* __WL1251_CMD_H__ */
406