Kalle Valo | 2f01a1f | 2009-04-29 23:33:31 +0300 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of wl12xx |
| 3 | * |
| 4 | * Copyright (c) 1998-2007 Texas Instruments Incorporated |
| 5 | * Copyright (C) 2008 Nokia Corporation |
| 6 | * |
| 7 | * Contact: Kalle Valo <kalle.valo@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 __WL12XX_CMD_H__ |
| 26 | #define __WL12XX_CMD_H__ |
| 27 | |
| 28 | #include "wl12xx.h" |
| 29 | |
| 30 | int wl12xx_cmd_send(struct wl12xx *wl, u16 type, void *buf, size_t buf_len); |
| 31 | int wl12xx_cmd_test(struct wl12xx *wl, void *buf, size_t buf_len, u8 answer); |
| 32 | int wl12xx_cmd_interrogate(struct wl12xx *wl, u16 ie_id, u16 ie_len, |
| 33 | void *answer); |
| 34 | int wl12xx_cmd_configure(struct wl12xx *wl, void *ie, int ie_len); |
| 35 | int wl12xx_cmd_vbm(struct wl12xx *wl, u8 identity, |
| 36 | void *bitmap, u16 bitmap_len, u8 bitmap_control); |
| 37 | int wl12xx_cmd_data_path(struct wl12xx *wl, u8 channel, u8 enable); |
| 38 | int wl12xx_cmd_join(struct wl12xx *wl, u8 bss_type, u8 dtim_interval, |
| 39 | u16 beacon_interval, u8 wait); |
| 40 | int wl12xx_cmd_ps_mode(struct wl12xx *wl, u8 ps_mode); |
| 41 | int wl12xx_cmd_read_memory(struct wl12xx *wl, u32 addr, u32 len, void *answer); |
| 42 | int wl12xx_cmd_template_set(struct wl12xx *wl, u16 cmd_id, |
| 43 | void *buf, size_t buf_len); |
| 44 | |
| 45 | /* unit ms */ |
| 46 | #define WL12XX_COMMAND_TIMEOUT 2000 |
| 47 | |
| 48 | #define WL12XX_MAX_TEMPLATE_SIZE 300 |
| 49 | |
| 50 | struct wl12xx_cmd_packet_template { |
| 51 | __le16 size; |
| 52 | u8 template[WL12XX_MAX_TEMPLATE_SIZE]; |
| 53 | } __attribute__ ((packed)); |
| 54 | |
| 55 | enum wl12xx_commands { |
| 56 | CMD_RESET = 0, |
| 57 | CMD_INTERROGATE = 1, /*use this to read information elements*/ |
| 58 | CMD_CONFIGURE = 2, /*use this to write information elements*/ |
| 59 | CMD_ENABLE_RX = 3, |
| 60 | CMD_ENABLE_TX = 4, |
| 61 | CMD_DISABLE_RX = 5, |
| 62 | CMD_DISABLE_TX = 6, |
| 63 | CMD_SCAN = 8, |
| 64 | CMD_STOP_SCAN = 9, |
| 65 | CMD_VBM = 10, |
| 66 | CMD_START_JOIN = 11, |
| 67 | CMD_SET_KEYS = 12, |
| 68 | CMD_READ_MEMORY = 13, |
| 69 | CMD_WRITE_MEMORY = 14, |
| 70 | CMD_BEACON = 19, |
| 71 | CMD_PROBE_RESP = 20, |
| 72 | CMD_NULL_DATA = 21, |
| 73 | CMD_PROBE_REQ = 22, |
| 74 | CMD_TEST = 23, |
| 75 | CMD_RADIO_CALIBRATE = 25, /* OBSOLETE */ |
| 76 | CMD_ENABLE_RX_PATH = 27, /* OBSOLETE */ |
| 77 | CMD_NOISE_HIST = 28, |
| 78 | CMD_RX_RESET = 29, |
| 79 | CMD_PS_POLL = 30, |
| 80 | CMD_QOS_NULL_DATA = 31, |
| 81 | CMD_LNA_CONTROL = 32, |
| 82 | CMD_SET_BCN_MODE = 33, |
| 83 | CMD_MEASUREMENT = 34, |
| 84 | CMD_STOP_MEASUREMENT = 35, |
| 85 | CMD_DISCONNECT = 36, |
| 86 | CMD_SET_PS_MODE = 37, |
| 87 | CMD_CHANNEL_SWITCH = 38, |
| 88 | CMD_STOP_CHANNEL_SWICTH = 39, |
| 89 | CMD_AP_DISCOVERY = 40, |
| 90 | CMD_STOP_AP_DISCOVERY = 41, |
| 91 | CMD_SPS_SCAN = 42, |
| 92 | CMD_STOP_SPS_SCAN = 43, |
| 93 | CMD_HEALTH_CHECK = 45, |
| 94 | CMD_DEBUG = 46, |
| 95 | CMD_TRIGGER_SCAN_TO = 47, |
| 96 | |
| 97 | NUM_COMMANDS, |
| 98 | MAX_COMMAND_ID = 0xFFFF, |
| 99 | }; |
| 100 | |
| 101 | #define MAX_CMD_PARAMS 572 |
| 102 | |
| 103 | struct wl12xx_command { |
| 104 | u16 id; |
| 105 | u16 status; |
| 106 | u8 parameters[MAX_CMD_PARAMS]; |
| 107 | }; |
| 108 | |
| 109 | enum { |
| 110 | CMD_MAILBOX_IDLE = 0, |
| 111 | CMD_STATUS_SUCCESS = 1, |
| 112 | CMD_STATUS_UNKNOWN_CMD = 2, |
| 113 | CMD_STATUS_UNKNOWN_IE = 3, |
| 114 | CMD_STATUS_REJECT_MEAS_SG_ACTIVE = 11, |
| 115 | CMD_STATUS_RX_BUSY = 13, |
| 116 | CMD_STATUS_INVALID_PARAM = 14, |
| 117 | CMD_STATUS_TEMPLATE_TOO_LARGE = 15, |
| 118 | CMD_STATUS_OUT_OF_MEMORY = 16, |
| 119 | CMD_STATUS_STA_TABLE_FULL = 17, |
| 120 | CMD_STATUS_RADIO_ERROR = 18, |
| 121 | CMD_STATUS_WRONG_NESTING = 19, |
| 122 | CMD_STATUS_TIMEOUT = 21, /* Driver internal use.*/ |
| 123 | CMD_STATUS_FW_RESET = 22, /* Driver internal use.*/ |
| 124 | MAX_COMMAND_STATUS = 0xff |
| 125 | }; |
| 126 | |
| 127 | |
| 128 | /* |
| 129 | * CMD_READ_MEMORY |
| 130 | * |
| 131 | * The host issues this command to read the WiLink device memory/registers. |
| 132 | * |
| 133 | * Note: The Base Band address has special handling (16 bits registers and |
| 134 | * addresses). For more information, see the hardware specification. |
| 135 | */ |
| 136 | /* |
| 137 | * CMD_WRITE_MEMORY |
| 138 | * |
| 139 | * The host issues this command to write the WiLink device memory/registers. |
| 140 | * |
| 141 | * The Base Band address has special handling (16 bits registers and |
| 142 | * addresses). For more information, see the hardware specification. |
| 143 | */ |
| 144 | #define MAX_READ_SIZE 256 |
| 145 | |
| 146 | struct cmd_read_write_memory { |
| 147 | /* The address of the memory to read from or write to.*/ |
| 148 | u32 addr; |
| 149 | |
| 150 | /* The amount of data in bytes to read from or write to the WiLink |
| 151 | * device.*/ |
| 152 | u32 size; |
| 153 | |
| 154 | /* The actual value read from or written to the Wilink. The source |
| 155 | of this field is the Host in WRITE command or the Wilink in READ |
| 156 | command. */ |
| 157 | u8 value[MAX_READ_SIZE]; |
| 158 | }; |
| 159 | |
| 160 | #define CMDMBOX_HEADER_LEN 4 |
| 161 | #define CMDMBOX_INFO_ELEM_HEADER_LEN 4 |
| 162 | |
| 163 | |
| 164 | struct basic_scan_parameters { |
| 165 | u32 rx_config_options; |
| 166 | u32 rx_filter_options; |
| 167 | |
| 168 | /* |
| 169 | * Scan options: |
| 170 | * bit 0: When this bit is set, passive scan. |
| 171 | * bit 1: Band, when this bit is set we scan |
| 172 | * in the 5Ghz band. |
| 173 | * bit 2: voice mode, 0 for normal scan. |
| 174 | * bit 3: scan priority, 1 for high priority. |
| 175 | */ |
| 176 | u16 scan_options; |
| 177 | |
| 178 | /* Number of channels to scan */ |
| 179 | u8 num_channels; |
| 180 | |
| 181 | /* Number opf probe requests to send, per channel */ |
| 182 | u8 num_probe_requests; |
| 183 | |
| 184 | /* Rate and modulation for probe requests */ |
| 185 | u16 tx_rate; |
| 186 | |
| 187 | u8 tid_trigger; |
| 188 | u8 ssid_len; |
| 189 | u32 ssid[8]; |
| 190 | |
| 191 | } __attribute__ ((packed)); |
| 192 | |
| 193 | struct basic_scan_channel_parameters { |
| 194 | u32 min_duration; /* in TU */ |
| 195 | u32 max_duration; /* in TU */ |
| 196 | u32 bssid_lsb; |
| 197 | u16 bssid_msb; |
| 198 | |
| 199 | /* |
| 200 | * bits 0-3: Early termination count. |
| 201 | * bits 4-5: Early termination condition. |
| 202 | */ |
| 203 | u8 early_termination; |
| 204 | |
| 205 | u8 tx_power_att; |
| 206 | u8 channel; |
| 207 | u8 pad[3]; |
| 208 | } __attribute__ ((packed)); |
| 209 | |
| 210 | /* SCAN parameters */ |
| 211 | #define SCAN_MAX_NUM_OF_CHANNELS 16 |
| 212 | |
| 213 | struct cmd_scan { |
| 214 | struct basic_scan_parameters params; |
| 215 | struct basic_scan_channel_parameters channels[SCAN_MAX_NUM_OF_CHANNELS]; |
| 216 | } __attribute__ ((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 | u32 bssid_lsb; |
| 231 | u16 bssid_msb; |
| 232 | u16 beacon_interval; /* in TBTTs */ |
| 233 | u32 rx_config_options; |
| 234 | u32 rx_filter_options; |
| 235 | |
| 236 | /* |
| 237 | * The target uses this field to determine the rate at |
| 238 | * which to transmit control frame responses (such as |
| 239 | * ACK or CTS frames). |
| 240 | */ |
| 241 | u16 basic_rate_set; |
| 242 | u8 dtim_interval; |
| 243 | u8 tx_ctrl_frame_rate; /* OBSOLETE */ |
| 244 | u8 tx_ctrl_frame_mod; /* OBSOLETE */ |
| 245 | /* |
| 246 | * bits 0-2: This bitwise field specifies the type |
| 247 | * of BSS to start or join (BSS_TYPE_*). |
| 248 | * bit 4: Band - The radio band in which to join |
| 249 | * or start. |
| 250 | * 0 - 2.4GHz band |
| 251 | * 1 - 5GHz band |
| 252 | * bits 3, 5-7: Reserved |
| 253 | */ |
| 254 | u8 bss_type; |
| 255 | u8 channel; |
| 256 | u8 ssid_len; |
| 257 | u8 ssid[IW_ESSID_MAX_SIZE]; |
| 258 | u8 ctrl; /* JOIN_CMD_CTRL_* */ |
| 259 | u8 tx_mgt_frame_rate; /* OBSOLETE */ |
| 260 | u8 tx_mgt_frame_mod; /* OBSOLETE */ |
| 261 | u8 reserved; |
| 262 | } __attribute__ ((packed)); |
| 263 | |
| 264 | |
| 265 | #endif /* __WL12XX_CMD_H__ */ |