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