1 /*
2  * This file is part of wl1271
3  *
4  * Copyright (C) 1998-2009 Texas Instruments. All rights reserved.
5  * Copyright (C) 2009 Nokia Corporation
6  *
7  * Contact: Luciano Coelho <luciano.coelho@nokia.com>
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * version 2 as published by the Free Software Foundation.
12  *
13  * This program is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21  * 02110-1301 USA
22  *
23  */
24 
25 #ifndef __CMD_H__
26 #define __CMD_H__
27 
28 #include "wl12xx.h"
29 
30 struct acx_header;
31 
32 int wl1271_cmd_send(struct wl1271 *wl, u16 id, void *buf, size_t len,
33 		    size_t res_len);
34 int wl1271_cmd_general_parms(struct wl1271 *wl);
35 int wl128x_cmd_general_parms(struct wl1271 *wl);
36 int wl1271_cmd_radio_parms(struct wl1271 *wl);
37 int wl128x_cmd_radio_parms(struct wl1271 *wl);
38 int wl1271_cmd_ext_radio_parms(struct wl1271 *wl);
39 int wl12xx_cmd_role_enable(struct wl1271 *wl, u8 *addr, u8 role_type,
40 			   u8 *role_id);
41 int wl12xx_cmd_role_disable(struct wl1271 *wl, u8 *role_id);
42 int wl12xx_cmd_role_start_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif);
43 int wl12xx_cmd_role_stop_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif);
44 int wl12xx_cmd_role_start_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif);
45 int wl12xx_cmd_role_stop_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif);
46 int wl12xx_cmd_role_start_ibss(struct wl1271 *wl, struct wl12xx_vif *wlvif);
47 int wl12xx_start_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif);
48 int wl12xx_stop_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif);
49 int wl1271_cmd_test(struct wl1271 *wl, void *buf, size_t buf_len, u8 answer);
50 int wl1271_cmd_interrogate(struct wl1271 *wl, u16 id, void *buf, size_t len);
51 int wl1271_cmd_configure(struct wl1271 *wl, u16 id, void *buf, size_t len);
52 int wl1271_cmd_data_path(struct wl1271 *wl, bool enable);
53 int wl1271_cmd_ps_mode(struct wl1271 *wl, struct wl12xx_vif *wlvif,
54 		       u8 ps_mode);
55 int wl1271_cmd_read_memory(struct wl1271 *wl, u32 addr, void *answer,
56 			   size_t len);
57 int wl1271_cmd_template_set(struct wl1271 *wl, u16 template_id,
58 			    void *buf, size_t buf_len, int index, u32 rates);
59 int wl12xx_cmd_build_null_data(struct wl1271 *wl, struct wl12xx_vif *wlvif);
60 int wl1271_cmd_build_ps_poll(struct wl1271 *wl, struct wl12xx_vif *wlvif,
61 			     u16 aid);
62 int wl1271_cmd_build_probe_req(struct wl1271 *wl, struct wl12xx_vif *wlvif,
63 			       const u8 *ssid, size_t ssid_len,
64 			       const u8 *ie, size_t ie_len, u8 band);
65 struct sk_buff *wl1271_cmd_build_ap_probe_req(struct wl1271 *wl,
66 					      struct wl12xx_vif *wlvif,
67 					      struct sk_buff *skb);
68 int wl1271_cmd_build_arp_rsp(struct wl1271 *wl, struct wl12xx_vif *wlvif,
69 			     __be32 ip_addr);
70 int wl1271_build_qos_null_data(struct wl1271 *wl, struct ieee80211_vif *vif);
71 int wl12xx_cmd_build_klv_null_data(struct wl1271 *wl,
72 				   struct wl12xx_vif *wlvif);
73 int wl12xx_cmd_set_default_wep_key(struct wl1271 *wl, u8 id, u8 hlid);
74 int wl1271_cmd_set_sta_key(struct wl1271 *wl, struct wl12xx_vif *wlvif,
75 			   u16 action, u8 id, u8 key_type,
76 			   u8 key_size, const u8 *key, const u8 *addr,
77 			   u32 tx_seq_32, u16 tx_seq_16);
78 int wl1271_cmd_set_ap_key(struct wl1271 *wl, struct wl12xx_vif *wlvif,
79 			  u16 action, u8 id, u8 key_type,
80 			  u8 key_size, const u8 *key, u8 hlid, u32 tx_seq_32,
81 			  u16 tx_seq_16);
82 int wl12xx_cmd_set_peer_state(struct wl1271 *wl, u8 hlid);
83 int wl12xx_roc(struct wl1271 *wl, struct wl12xx_vif *wlvif, u8 role_id);
84 int wl12xx_croc(struct wl1271 *wl, u8 role_id);
85 int wl12xx_cmd_add_peer(struct wl1271 *wl, struct wl12xx_vif *wlvif,
86 			struct ieee80211_sta *sta, u8 hlid);
87 int wl12xx_cmd_remove_peer(struct wl1271 *wl, u8 hlid);
88 int wl12xx_cmd_config_fwlog(struct wl1271 *wl);
89 int wl12xx_cmd_start_fwlog(struct wl1271 *wl);
90 int wl12xx_cmd_stop_fwlog(struct wl1271 *wl);
91 int wl12xx_cmd_channel_switch(struct wl1271 *wl,
92 			      struct ieee80211_channel_switch *ch_switch);
93 int wl12xx_cmd_stop_channel_switch(struct wl1271 *wl);
94 int wl12xx_allocate_link(struct wl1271 *wl, struct wl12xx_vif *wlvif,
95 			 u8 *hlid);
96 void wl12xx_free_link(struct wl1271 *wl, struct wl12xx_vif *wlvif, u8 *hlid);
97 
98 enum wl1271_commands {
99 	CMD_INTERROGATE     = 1,    /*use this to read information elements*/
100 	CMD_CONFIGURE       = 2,    /*use this to write information elements*/
101 	CMD_ENABLE_RX       = 3,
102 	CMD_ENABLE_TX       = 4,
103 	CMD_DISABLE_RX      = 5,
104 	CMD_DISABLE_TX      = 6,
105 	CMD_SCAN            = 8,
106 	CMD_STOP_SCAN       = 9,
107 	CMD_SET_KEYS        = 12,
108 	CMD_READ_MEMORY     = 13,
109 	CMD_WRITE_MEMORY    = 14,
110 	CMD_SET_TEMPLATE    = 19,
111 	CMD_TEST            = 23,
112 	CMD_NOISE_HIST      = 28,
113 	CMD_QUIET_ELEMENT_SET_STATE  = 29,
114 	CMD_SET_BCN_MODE    = 33,
115 	CMD_MEASUREMENT      = 34,
116 	CMD_STOP_MEASUREMENT = 35,
117 	CMD_SET_PS_MODE      = 37,
118 	CMD_CHANNEL_SWITCH   = 38,
119 	CMD_STOP_CHANNEL_SWICTH = 39,
120 	CMD_AP_DISCOVERY     = 40,
121 	CMD_STOP_AP_DISCOVERY = 41,
122 	CMD_HEALTH_CHECK     = 45,
123 	CMD_DEBUG            = 46,
124 	CMD_TRIGGER_SCAN_TO  = 47,
125 	CMD_CONNECTION_SCAN_CFG      = 48,
126 	CMD_CONNECTION_SCAN_SSID_CFG = 49,
127 	CMD_START_PERIODIC_SCAN      = 50,
128 	CMD_STOP_PERIODIC_SCAN       = 51,
129 	CMD_SET_PEER_STATE           = 52,
130 	CMD_REMAIN_ON_CHANNEL        = 53,
131 	CMD_CANCEL_REMAIN_ON_CHANNEL = 54,
132 
133 	CMD_CONFIG_FWLOGGER          = 55,
134 	CMD_START_FWLOGGER           = 56,
135 	CMD_STOP_FWLOGGER            = 57,
136 
137 	/* AP commands */
138 	CMD_ADD_PEER                 = 62,
139 	CMD_REMOVE_PEER              = 63,
140 
141 	/* Role API */
142 	CMD_ROLE_ENABLE              = 70,
143 	CMD_ROLE_DISABLE             = 71,
144 	CMD_ROLE_START               = 72,
145 	CMD_ROLE_STOP                = 73,
146 
147 	/* WIFI Direct */
148 	CMD_WFD_START_DISCOVERY      = 80,
149 	CMD_WFD_STOP_DISCOVERY	     = 81,
150 	CMD_WFD_ATTRIBUTE_CONFIG     = 82,
151 
152 	CMD_NOP                      = 100,
153 
154 	NUM_COMMANDS,
155 	MAX_COMMAND_ID = 0xFFFF,
156 };
157 
158 #define MAX_CMD_PARAMS 572
159 
160 enum {
161 	CMD_TEMPL_KLV_IDX_NULL_DATA = 0,
162 	CMD_TEMPL_KLV_IDX_MAX = 4
163 };
164 
165 enum cmd_templ {
166 	CMD_TEMPL_NULL_DATA = 0,
167 	CMD_TEMPL_BEACON,
168 	CMD_TEMPL_CFG_PROBE_REQ_2_4,
169 	CMD_TEMPL_CFG_PROBE_REQ_5,
170 	CMD_TEMPL_PROBE_RESPONSE,
171 	CMD_TEMPL_QOS_NULL_DATA,
172 	CMD_TEMPL_PS_POLL,
173 	CMD_TEMPL_KLV,
174 	CMD_TEMPL_DISCONNECT,
175 	CMD_TEMPL_PROBE_REQ_2_4, /* for firmware internal use only */
176 	CMD_TEMPL_PROBE_REQ_5,   /* for firmware internal use only */
177 	CMD_TEMPL_BAR,           /* for firmware internal use only */
178 	CMD_TEMPL_CTS,           /*
179 				  * For CTS-to-self (FastCTS) mechanism
180 				  * for BT/WLAN coexistence (SoftGemini). */
181 	CMD_TEMPL_AP_BEACON,
182 	CMD_TEMPL_AP_PROBE_RESPONSE,
183 	CMD_TEMPL_ARP_RSP,
184 	CMD_TEMPL_DEAUTH_AP,
185 	CMD_TEMPL_TEMPORARY,
186 	CMD_TEMPL_LINK_MEASUREMENT_REPORT,
187 
188 	CMD_TEMPL_MAX = 0xff
189 };
190 
191 /* unit ms */
192 #define WL1271_COMMAND_TIMEOUT     2000
193 #define WL1271_CMD_TEMPL_DFLT_SIZE 252
194 #define WL1271_CMD_TEMPL_MAX_SIZE  548
195 #define WL1271_EVENT_TIMEOUT       750
196 
197 struct wl1271_cmd_header {
198 	__le16 id;
199 	__le16 status;
200 	/* payload */
201 	u8 data[0];
202 } __packed;
203 
204 #define WL1271_CMD_MAX_PARAMS 572
205 
206 struct wl1271_command {
207 	struct wl1271_cmd_header header;
208 	u8  parameters[WL1271_CMD_MAX_PARAMS];
209 } __packed;
210 
211 enum {
212 	CMD_MAILBOX_IDLE		=  0,
213 	CMD_STATUS_SUCCESS		=  1,
214 	CMD_STATUS_UNKNOWN_CMD		=  2,
215 	CMD_STATUS_UNKNOWN_IE		=  3,
216 	CMD_STATUS_REJECT_MEAS_SG_ACTIVE	= 11,
217 	CMD_STATUS_RX_BUSY		= 13,
218 	CMD_STATUS_INVALID_PARAM		= 14,
219 	CMD_STATUS_TEMPLATE_TOO_LARGE		= 15,
220 	CMD_STATUS_OUT_OF_MEMORY		= 16,
221 	CMD_STATUS_STA_TABLE_FULL		= 17,
222 	CMD_STATUS_RADIO_ERROR		= 18,
223 	CMD_STATUS_WRONG_NESTING		= 19,
224 	CMD_STATUS_TIMEOUT		= 21, /* Driver internal use.*/
225 	CMD_STATUS_FW_RESET		= 22, /* Driver internal use.*/
226 	CMD_STATUS_TEMPLATE_OOM		= 23,
227 	CMD_STATUS_NO_RX_BA_SESSION	= 24,
228 	MAX_COMMAND_STATUS		= 0xff
229 };
230 
231 #define CMDMBOX_HEADER_LEN 4
232 #define CMDMBOX_INFO_ELEM_HEADER_LEN 4
233 
234 enum {
235 	BSS_TYPE_IBSS = 0,
236 	BSS_TYPE_STA_BSS = 2,
237 	BSS_TYPE_AP_BSS = 3,
238 	MAX_BSS_TYPE = 0xFF
239 };
240 
241 #define WL1271_JOIN_CMD_CTRL_TX_FLUSH     0x80 /* Firmware flushes all Tx */
242 #define WL1271_JOIN_CMD_TX_SESSION_OFFSET 1
243 #define WL1271_JOIN_CMD_BSS_TYPE_5GHZ 0x10
244 
245 struct wl12xx_cmd_role_enable {
246 	struct wl1271_cmd_header header;
247 
248 	u8 role_id;
249 	u8 role_type;
250 	u8 mac_address[ETH_ALEN];
251 } __packed;
252 
253 struct wl12xx_cmd_role_disable {
254 	struct wl1271_cmd_header header;
255 
256 	u8 role_id;
257 	u8 padding[3];
258 } __packed;
259 
260 enum wl12xx_band {
261 	WL12XX_BAND_2_4GHZ		= 0,
262 	WL12XX_BAND_5GHZ		= 1,
263 	WL12XX_BAND_JAPAN_4_9_GHZ	= 2,
264 	WL12XX_BAND_DEFAULT		= WL12XX_BAND_2_4GHZ,
265 	WL12XX_BAND_INVALID		= 0x7E,
266 	WL12XX_BAND_MAX_RADIO		= 0x7F,
267 };
268 
269 struct wl12xx_cmd_role_start {
270 	struct wl1271_cmd_header header;
271 
272 	u8 role_id;
273 	u8 band;
274 	u8 channel;
275 	u8 padding;
276 
277 	union {
278 		struct {
279 			u8 hlid;
280 			u8 session;
281 			u8 padding_1[54];
282 		} __packed device;
283 		/* sta & p2p_cli use the same struct */
284 		struct {
285 			u8 bssid[ETH_ALEN];
286 			u8 hlid; /* data hlid */
287 			u8 session;
288 			__le32 remote_rates; /* remote supported rates */
289 
290 			/*
291 			 * The target uses this field to determine the rate at
292 			 * which to transmit control frame responses (such as
293 			 * ACK or CTS frames).
294 			 */
295 			__le32 basic_rate_set;
296 			__le32 local_rates; /* local supported rates */
297 
298 			u8 ssid_type;
299 			u8 ssid_len;
300 			u8 ssid[IEEE80211_MAX_SSID_LEN];
301 
302 			__le16 beacon_interval; /* in TBTTs */
303 		} __packed sta;
304 		struct {
305 			u8 bssid[ETH_ALEN];
306 			u8 hlid; /* data hlid */
307 			u8 dtim_interval;
308 			__le32 remote_rates; /* remote supported rates */
309 
310 			__le32 basic_rate_set;
311 			__le32 local_rates; /* local supported rates */
312 
313 			u8 ssid_type;
314 			u8 ssid_len;
315 			u8 ssid[IEEE80211_MAX_SSID_LEN];
316 
317 			__le16 beacon_interval; /* in TBTTs */
318 
319 			u8 padding_1[4];
320 		} __packed ibss;
321 		/* ap & p2p_go use the same struct */
322 		struct {
323 			__le16 aging_period; /* in secs */
324 			u8 beacon_expiry; /* in ms */
325 			u8 bss_index;
326 			/* The host link id for the AP's global queue */
327 			u8 global_hlid;
328 			/* The host link id for the AP's broadcast queue */
329 			u8 broadcast_hlid;
330 
331 			__le16 beacon_interval; /* in TBTTs */
332 
333 			__le32 basic_rate_set;
334 			__le32 local_rates; /* local supported rates */
335 
336 			u8 dtim_interval;
337 
338 			u8 ssid_type;
339 			u8 ssid_len;
340 			u8 ssid[IEEE80211_MAX_SSID_LEN];
341 
342 			u8 padding_1[5];
343 		} __packed ap;
344 	};
345 } __packed;
346 
347 struct wl12xx_cmd_role_stop {
348 	struct wl1271_cmd_header header;
349 
350 	u8 role_id;
351 	u8 disc_type; /* only STA and P2P_CLI */
352 	__le16 reason; /* only STA and P2P_CLI */
353 } __packed;
354 
355 struct cmd_enabledisable_path {
356 	struct wl1271_cmd_header header;
357 
358 	u8 channel;
359 	u8 padding[3];
360 } __packed;
361 
362 #define WL1271_RATE_AUTOMATIC  0
363 
364 struct wl1271_cmd_template_set {
365 	struct wl1271_cmd_header header;
366 
367 	__le16 len;
368 	u8 template_type;
369 	u8 index;  /* relevant only for KLV_TEMPLATE type */
370 	__le32 enabled_rates;
371 	u8 short_retry_limit;
372 	u8 long_retry_limit;
373 	u8 aflags;
374 	u8 reserved;
375 	u8 template_data[WL1271_CMD_TEMPL_MAX_SIZE];
376 } __packed;
377 
378 #define TIM_ELE_ID    5
379 #define PARTIAL_VBM_MAX    251
380 
381 struct wl1271_tim {
382 	u8 identity;
383 	u8 length;
384 	u8 dtim_count;
385 	u8 dtim_period;
386 	u8 bitmap_ctrl;
387 	u8 pvb_field[PARTIAL_VBM_MAX]; /* Partial Virtual Bitmap */
388 } __packed;
389 
390 enum wl1271_cmd_ps_mode {
391 	STATION_ACTIVE_MODE,
392 	STATION_POWER_SAVE_MODE
393 };
394 
395 struct wl1271_cmd_ps_params {
396 	struct wl1271_cmd_header header;
397 
398 	u8 role_id;
399 	u8 ps_mode; /* STATION_* */
400 	u8 padding[2];
401 } __packed;
402 
403 /* HW encryption keys */
404 #define NUM_ACCESS_CATEGORIES_COPY 4
405 
406 enum wl1271_cmd_key_action {
407 	KEY_ADD_OR_REPLACE = 1,
408 	KEY_REMOVE         = 2,
409 	KEY_SET_ID         = 3,
410 	MAX_KEY_ACTION     = 0xffff,
411 };
412 
413 enum wl1271_cmd_lid_key_type {
414 	UNICAST_LID_TYPE     = 0,
415 	BROADCAST_LID_TYPE   = 1,
416 	WEP_DEFAULT_LID_TYPE = 2
417 };
418 
419 enum wl1271_cmd_key_type {
420 	KEY_NONE = 0,
421 	KEY_WEP  = 1,
422 	KEY_TKIP = 2,
423 	KEY_AES  = 3,
424 	KEY_GEM  = 4,
425 };
426 
427 struct wl1271_cmd_set_keys {
428 	struct wl1271_cmd_header header;
429 
430 	/*
431 	 * Indicates whether the HLID is a unicast key set
432 	 * or broadcast key set. A special value 0xFF is
433 	 * used to indicate that the HLID is on WEP-default
434 	 * (multi-hlids). of type wl1271_cmd_lid_key_type.
435 	 */
436 	u8 hlid;
437 
438 	/*
439 	 * In WEP-default network (hlid == 0xFF) used to
440 	 * indicate which network STA/IBSS/AP role should be
441 	 * changed
442 	 */
443 	u8 lid_key_type;
444 
445 	/*
446 	 * Key ID - For TKIP and AES key types, this field
447 	 * indicates the value that should be inserted into
448 	 * the KeyID field of frames transmitted using this
449 	 * key entry. For broadcast keys the index use as a
450 	 * marker for TX/RX key.
451 	 * For WEP default network (HLID=0xFF), this field
452 	 * indicates the ID of the key to add or remove.
453 	 */
454 	u8 key_id;
455 	u8 reserved_1;
456 
457 	/* key_action_e */
458 	__le16 key_action;
459 
460 	/* key size in bytes */
461 	u8 key_size;
462 
463 	/* key_type_e */
464 	u8 key_type;
465 
466 	/* This field holds the security key data to add to the STA table */
467 	u8 key[MAX_KEY_SIZE];
468 	__le16 ac_seq_num16[NUM_ACCESS_CATEGORIES_COPY];
469 	__le32 ac_seq_num32[NUM_ACCESS_CATEGORIES_COPY];
470 } __packed;
471 
472 struct wl1271_cmd_test_header {
473 	u8 id;
474 	u8 padding[3];
475 } __packed;
476 
477 enum wl1271_channel_tune_bands {
478 	WL1271_CHANNEL_TUNE_BAND_2_4,
479 	WL1271_CHANNEL_TUNE_BAND_5,
480 	WL1271_CHANNEL_TUNE_BAND_4_9
481 };
482 
483 #define WL1271_PD_REFERENCE_POINT_BAND_B_G  0
484 
485 #define TEST_CMD_INI_FILE_RADIO_PARAM       0x19
486 #define TEST_CMD_INI_FILE_GENERAL_PARAM     0x1E
487 #define TEST_CMD_INI_FILE_RF_EXTENDED_PARAM 0x26
488 
489 struct wl1271_general_parms_cmd {
490 	struct wl1271_cmd_header header;
491 
492 	struct wl1271_cmd_test_header test;
493 
494 	struct wl1271_ini_general_params general_params;
495 
496 	u8 sr_debug_table[WL1271_INI_MAX_SMART_REFLEX_PARAM];
497 	u8 sr_sen_n_p;
498 	u8 sr_sen_n_p_gain;
499 	u8 sr_sen_nrn;
500 	u8 sr_sen_prn;
501 	u8 padding[3];
502 } __packed;
503 
504 struct wl128x_general_parms_cmd {
505 	struct wl1271_cmd_header header;
506 
507 	struct wl1271_cmd_test_header test;
508 
509 	struct wl128x_ini_general_params general_params;
510 
511 	u8 sr_debug_table[WL1271_INI_MAX_SMART_REFLEX_PARAM];
512 	u8 sr_sen_n_p;
513 	u8 sr_sen_n_p_gain;
514 	u8 sr_sen_nrn;
515 	u8 sr_sen_prn;
516 	u8 padding[3];
517 } __packed;
518 
519 struct wl1271_radio_parms_cmd {
520 	struct wl1271_cmd_header header;
521 
522 	struct wl1271_cmd_test_header test;
523 
524 	/* Static radio parameters */
525 	struct wl1271_ini_band_params_2 static_params_2;
526 	struct wl1271_ini_band_params_5 static_params_5;
527 
528 	/* Dynamic radio parameters */
529 	struct wl1271_ini_fem_params_2 dyn_params_2;
530 	u8 padding2;
531 	struct wl1271_ini_fem_params_5 dyn_params_5;
532 	u8 padding3[2];
533 } __packed;
534 
535 struct wl128x_radio_parms_cmd {
536 	struct wl1271_cmd_header header;
537 
538 	struct wl1271_cmd_test_header test;
539 
540 	/* Static radio parameters */
541 	struct wl128x_ini_band_params_2 static_params_2;
542 	struct wl128x_ini_band_params_5 static_params_5;
543 
544 	u8 fem_vendor_and_options;
545 
546 	/* Dynamic radio parameters */
547 	struct wl128x_ini_fem_params_2 dyn_params_2;
548 	u8 padding2;
549 	struct wl128x_ini_fem_params_5 dyn_params_5;
550 } __packed;
551 
552 struct wl1271_ext_radio_parms_cmd {
553 	struct wl1271_cmd_header header;
554 
555 	struct wl1271_cmd_test_header test;
556 
557 	u8 tx_per_channel_power_compensation_2[CONF_TX_PWR_COMPENSATION_LEN_2];
558 	u8 tx_per_channel_power_compensation_5[CONF_TX_PWR_COMPENSATION_LEN_5];
559 	u8 padding[3];
560 } __packed;
561 
562 /*
563  * There are three types of disconnections:
564  *
565  * DISCONNECT_IMMEDIATE: the fw doesn't send any frames
566  * DISCONNECT_DEAUTH:    the fw generates a DEAUTH request with the reason
567  *                       we have passed
568  * DISCONNECT_DISASSOC:  the fw generates a DESASSOC request with the reason
569  *                       we have passed
570  */
571 enum wl1271_disconnect_type {
572 	DISCONNECT_IMMEDIATE,
573 	DISCONNECT_DEAUTH,
574 	DISCONNECT_DISASSOC
575 };
576 
577 #define WL1271_CMD_STA_STATE_CONNECTED  1
578 
579 struct wl12xx_cmd_set_peer_state {
580 	struct wl1271_cmd_header header;
581 
582 	u8 hlid;
583 	u8 state;
584 	u8 padding[2];
585 } __packed;
586 
587 struct wl12xx_cmd_roc {
588 	struct wl1271_cmd_header header;
589 
590 	u8 role_id;
591 	u8 channel;
592 	u8 band;
593 	u8 padding;
594 };
595 
596 struct wl12xx_cmd_croc {
597 	struct wl1271_cmd_header header;
598 
599 	u8 role_id;
600 	u8 padding[3];
601 };
602 
603 enum wl12xx_ssid_type {
604 	WL12XX_SSID_TYPE_PUBLIC = 0,
605 	WL12XX_SSID_TYPE_HIDDEN = 1,
606 	WL12XX_SSID_TYPE_ANY = 2,
607 };
608 
609 enum wl1271_psd_type {
610 	WL1271_PSD_LEGACY = 0,
611 	WL1271_PSD_UPSD_TRIGGER = 1,
612 	WL1271_PSD_LEGACY_PSPOLL = 2,
613 	WL1271_PSD_SAPSD = 3
614 };
615 
616 struct wl12xx_cmd_add_peer {
617 	struct wl1271_cmd_header header;
618 
619 	u8 addr[ETH_ALEN];
620 	u8 hlid;
621 	u8 aid;
622 	u8 psd_type[NUM_ACCESS_CATEGORIES_COPY];
623 	__le32 supported_rates;
624 	u8 bss_index;
625 	u8 sp_len;
626 	u8 wmm;
627 	u8 padding1;
628 } __packed;
629 
630 struct wl12xx_cmd_remove_peer {
631 	struct wl1271_cmd_header header;
632 
633 	u8 hlid;
634 	u8 reason_opcode;
635 	u8 send_deauth_flag;
636 	u8 padding1;
637 } __packed;
638 
639 /*
640  * Continuous mode - packets are transferred to the host periodically
641  * via the data path.
642  * On demand - Log messages are stored in a cyclic buffer in the
643  * firmware, and only transferred to the host when explicitly requested
644  */
645 enum wl12xx_fwlogger_log_mode {
646 	WL12XX_FWLOG_CONTINUOUS,
647 	WL12XX_FWLOG_ON_DEMAND
648 };
649 
650 /* Include/exclude timestamps from the log messages */
651 enum wl12xx_fwlogger_timestamp {
652 	WL12XX_FWLOG_TIMESTAMP_DISABLED,
653 	WL12XX_FWLOG_TIMESTAMP_ENABLED
654 };
655 
656 /*
657  * Logs can be routed to the debug pinouts (where available), to the host bus
658  * (SDIO/SPI), or dropped
659  */
660 enum wl12xx_fwlogger_output {
661 	WL12XX_FWLOG_OUTPUT_NONE,
662 	WL12XX_FWLOG_OUTPUT_DBG_PINS,
663 	WL12XX_FWLOG_OUTPUT_HOST,
664 };
665 
666 struct wl12xx_cmd_config_fwlog {
667 	struct wl1271_cmd_header header;
668 
669 	/* See enum wl12xx_fwlogger_log_mode */
670 	u8 logger_mode;
671 
672 	/* Minimum log level threshold */
673 	u8 log_severity;
674 
675 	/* Include/exclude timestamps from the log messages */
676 	u8 timestamp;
677 
678 	/* See enum wl1271_fwlogger_output */
679 	u8 output;
680 
681 	/* Regulates the frequency of log messages */
682 	u8 threshold;
683 
684 	u8 padding[3];
685 } __packed;
686 
687 struct wl12xx_cmd_start_fwlog {
688 	struct wl1271_cmd_header header;
689 } __packed;
690 
691 struct wl12xx_cmd_stop_fwlog {
692 	struct wl1271_cmd_header header;
693 } __packed;
694 
695 struct wl12xx_cmd_channel_switch {
696 	struct wl1271_cmd_header header;
697 
698 	/* The new serving channel */
699 	u8 channel;
700 	/* Relative time of the serving channel switch in TBTT units */
701 	u8 switch_time;
702 	/* 1: Suspend TX till switch time; 0: Do not suspend TX */
703 	u8 tx_suspend;
704 	/* 1: Flush TX at switch time; 0: Do not flush */
705 	u8 flush;
706 } __packed;
707 
708 struct wl12xx_cmd_stop_channel_switch {
709 	struct wl1271_cmd_header header;
710 } __packed;
711 
712 #endif /* __WL1271_CMD_H__ */
713