blob: 23c75988f082b878b4ee513769d00d0bdecdcd1d [file] [log] [blame]
Luciano Coelhof5fc0f82009-08-06 16:25:28 +03001/*
2 * This file is part of wl1271
3 *
Luciano Coelho2f826f52010-03-26 12:53:21 +02004 * Copyright (C) 2009-2010 Nokia Corporation
Luciano Coelhof5fc0f82009-08-06 16:25:28 +03005 *
6 * Contact: Luciano Coelho <luciano.coelho@nokia.com>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA
21 *
22 */
23
24#include <linux/module.h>
25#include <linux/platform_device.h>
26#include <linux/crc7.h>
27#include <linux/spi/spi.h>
28#include <linux/etherdevice.h>
Kalle Valo023e0822010-03-18 12:26:36 +020029#include <linux/ieee80211.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090030#include <linux/slab.h>
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030031
32#include "wl1271.h"
33#include "wl1271_reg.h"
Teemu Paasikivi7b048c52010-02-18 13:25:55 +020034#include "wl1271_io.h"
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030035#include "wl1271_acx.h"
36#include "wl12xx_80211.h"
37#include "wl1271_cmd.h"
Luciano Coelho99d84c12010-03-26 12:53:20 +020038#include "wl1271_event.h"
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030039
Juuso Oikarinen16092b52010-04-28 09:49:59 +030040#define WL1271_CMD_FAST_POLL_COUNT 50
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030041
42/*
43 * send command to firmware
44 *
45 * @wl: wl struct
46 * @id: command id
47 * @buf: buffer containing the command, must work with dma
48 * @len: length of the buffer
49 */
Juuso Oikarinenfa867e72009-11-02 20:22:13 +020050int wl1271_cmd_send(struct wl1271 *wl, u16 id, void *buf, size_t len,
51 size_t res_len)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030052{
53 struct wl1271_cmd_header *cmd;
54 unsigned long timeout;
55 u32 intr;
56 int ret = 0;
Juuso Oikarinenad150e92009-11-02 20:22:12 +020057 u16 status;
Saravanan Dhanabalbc0f03e2010-03-26 12:53:33 +020058 u16 poll_count = 0;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030059
60 cmd = buf;
Luciano Coelhod0f63b22009-10-15 10:33:29 +030061 cmd->id = cpu_to_le16(id);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030062 cmd->status = 0;
63
64 WARN_ON(len % 4 != 0);
65
Teemu Paasikivi7b048c52010-02-18 13:25:55 +020066 wl1271_write(wl, wl->cmd_box_addr, buf, len, false);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030067
Teemu Paasikivi7b048c52010-02-18 13:25:55 +020068 wl1271_write32(wl, ACX_REG_INTERRUPT_TRIG, INTR_TRIG_CMD);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030069
70 timeout = jiffies + msecs_to_jiffies(WL1271_COMMAND_TIMEOUT);
71
Teemu Paasikivi7b048c52010-02-18 13:25:55 +020072 intr = wl1271_read32(wl, ACX_REG_INTERRUPT_NO_CLEAR);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030073 while (!(intr & WL1271_ACX_INTR_CMD_COMPLETE)) {
74 if (time_after(jiffies, timeout)) {
75 wl1271_error("command complete timeout");
76 ret = -ETIMEDOUT;
77 goto out;
78 }
79
Saravanan Dhanabalbc0f03e2010-03-26 12:53:33 +020080 poll_count++;
Juuso Oikarinen16092b52010-04-28 09:49:59 +030081 if (poll_count < WL1271_CMD_FAST_POLL_COUNT)
82 udelay(10);
83 else
84 msleep(1);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030085
Teemu Paasikivi7b048c52010-02-18 13:25:55 +020086 intr = wl1271_read32(wl, ACX_REG_INTERRUPT_NO_CLEAR);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030087 }
88
Juuso Oikarinen3b775b42009-11-02 20:22:10 +020089 /* read back the status code of the command */
Juuso Oikarinenfa867e72009-11-02 20:22:13 +020090 if (res_len == 0)
91 res_len = sizeof(struct wl1271_cmd_header);
Teemu Paasikivi7b048c52010-02-18 13:25:55 +020092 wl1271_read(wl, wl->cmd_box_addr, cmd, res_len, false);
Juuso Oikarinen3b775b42009-11-02 20:22:10 +020093
Juuso Oikarinenad150e92009-11-02 20:22:12 +020094 status = le16_to_cpu(cmd->status);
95 if (status != CMD_STATUS_SUCCESS) {
96 wl1271_error("command execute failure %d", status);
Juuso Oikarinen3b775b42009-11-02 20:22:10 +020097 ret = -EIO;
98 }
99
Teemu Paasikivi7b048c52010-02-18 13:25:55 +0200100 wl1271_write32(wl, ACX_REG_INTERRUPT_ACK,
101 WL1271_ACX_INTR_CMD_COMPLETE);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300102
103out:
104 return ret;
105}
106
Luciano Coelho98b5dd52009-11-23 23:22:17 +0200107int wl1271_cmd_general_parms(struct wl1271 *wl)
108{
109 struct wl1271_general_parms_cmd *gen_parms;
Luciano Coelho98b5dd52009-11-23 23:22:17 +0200110 int ret;
111
Juuso Oikarinen152ee6e2010-02-18 13:25:42 +0200112 if (!wl->nvs)
113 return -ENODEV;
114
Luciano Coelho98b5dd52009-11-23 23:22:17 +0200115 gen_parms = kzalloc(sizeof(*gen_parms), GFP_KERNEL);
116 if (!gen_parms)
117 return -ENOMEM;
118
119 gen_parms->test.id = TEST_CMD_INI_FILE_GENERAL_PARAM;
120
Juuso Oikarineneb70eb72010-05-14 10:46:22 +0300121 memcpy(&gen_parms->general_params, &wl->nvs->general_params,
122 sizeof(struct wl1271_ini_general_params));
Luciano Coelho76c0f8d2009-12-11 15:40:41 +0200123
Luciano Coelho98b5dd52009-11-23 23:22:17 +0200124 ret = wl1271_cmd_test(wl, gen_parms, sizeof(*gen_parms), 0);
125 if (ret < 0)
126 wl1271_warning("CMD_INI_FILE_GENERAL_PARAM failed");
127
128 kfree(gen_parms);
129 return ret;
130}
131
132int wl1271_cmd_radio_parms(struct wl1271 *wl)
133{
134 struct wl1271_radio_parms_cmd *radio_parms;
Luciano Coelhoe6b190f2010-07-08 17:50:01 +0300135 struct wl1271_ini_general_params *gp = &wl->nvs->general_params;
Juuso Oikarinen152ee6e2010-02-18 13:25:42 +0200136 int ret;
137
138 if (!wl->nvs)
139 return -ENODEV;
Luciano Coelho98b5dd52009-11-23 23:22:17 +0200140
141 radio_parms = kzalloc(sizeof(*radio_parms), GFP_KERNEL);
142 if (!radio_parms)
143 return -ENOMEM;
144
145 radio_parms->test.id = TEST_CMD_INI_FILE_RADIO_PARAM;
146
Juuso Oikarinena7da74f2010-05-14 10:46:23 +0300147 /* 2.4GHz parameters */
Juuso Oikarineneb70eb72010-05-14 10:46:22 +0300148 memcpy(&radio_parms->static_params_2, &wl->nvs->stat_radio_params_2,
149 sizeof(struct wl1271_ini_band_params_2));
150 memcpy(&radio_parms->dyn_params_2,
Luciano Coelhoe6b190f2010-07-08 17:50:01 +0300151 &wl->nvs->dyn_radio_params_2[gp->tx_bip_fem_manufacturer].params,
Juuso Oikarineneb70eb72010-05-14 10:46:22 +0300152 sizeof(struct wl1271_ini_fem_params_2));
Luciano Coelho98b5dd52009-11-23 23:22:17 +0200153
Juuso Oikarinena7da74f2010-05-14 10:46:23 +0300154 /* 5GHz parameters */
155 memcpy(&radio_parms->static_params_5,
156 &wl->nvs->stat_radio_params_5,
157 sizeof(struct wl1271_ini_band_params_5));
158 memcpy(&radio_parms->dyn_params_5,
Luciano Coelhoe6b190f2010-07-08 17:50:01 +0300159 &wl->nvs->dyn_radio_params_5[gp->tx_bip_fem_manufacturer].params,
Juuso Oikarinena7da74f2010-05-14 10:46:23 +0300160 sizeof(struct wl1271_ini_fem_params_5));
Luciano Coelho98b5dd52009-11-23 23:22:17 +0200161
162 wl1271_dump(DEBUG_CMD, "TEST_CMD_INI_FILE_RADIO_PARAM: ",
163 radio_parms, sizeof(*radio_parms));
164
165 ret = wl1271_cmd_test(wl, radio_parms, sizeof(*radio_parms), 0);
166 if (ret < 0)
167 wl1271_warning("CMD_INI_FILE_RADIO_PARAM failed");
168
169 kfree(radio_parms);
170 return ret;
171}
172
Luciano Coelho99d84c12010-03-26 12:53:20 +0200173/*
174 * Poll the mailbox event field until any of the bits in the mask is set or a
175 * timeout occurs (WL1271_EVENT_TIMEOUT in msecs)
176 */
177static int wl1271_cmd_wait_for_event(struct wl1271 *wl, u32 mask)
178{
179 u32 events_vector, event;
180 unsigned long timeout;
181
182 timeout = jiffies + msecs_to_jiffies(WL1271_EVENT_TIMEOUT);
183
184 do {
185 if (time_after(jiffies, timeout))
186 return -ETIMEDOUT;
187
188 msleep(1);
189
190 /* read from both event fields */
191 wl1271_read(wl, wl->mbox_ptr[0], &events_vector,
192 sizeof(events_vector), false);
193 event = events_vector & mask;
194 wl1271_read(wl, wl->mbox_ptr[1], &events_vector,
195 sizeof(events_vector), false);
196 event |= events_vector & mask;
197 } while (!event);
198
199 return 0;
200}
201
Juuso Oikarinen15305492010-02-22 08:38:32 +0200202int wl1271_cmd_join(struct wl1271 *wl, u8 bss_type)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300203{
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300204 struct wl1271_cmd_join *join;
205 int ret, i;
206 u8 *bssid;
207
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300208 join = kzalloc(sizeof(*join), GFP_KERNEL);
209 if (!join) {
210 ret = -ENOMEM;
211 goto out;
212 }
213
214 wl1271_debug(DEBUG_CMD, "cmd join");
215
216 /* Reverse order BSSID */
217 bssid = (u8 *) &join->bssid_lsb;
218 for (i = 0; i < ETH_ALEN; i++)
219 bssid[i] = wl->bssid[ETH_ALEN - i - 1];
220
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300221 join->rx_config_options = cpu_to_le32(wl->rx_config);
222 join->rx_filter_options = cpu_to_le32(wl->rx_filter);
Juuso Oikarinen15305492010-02-22 08:38:32 +0200223 join->bss_type = bss_type;
Luciano Coelho23a7a512010-04-28 09:50:02 +0300224 join->basic_rate_set = cpu_to_le32(wl->basic_rate_set);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300225
Juuso Oikarinenebba60c2010-04-01 11:38:20 +0300226 if (wl->band == IEEE80211_BAND_5GHZ)
Teemu Paasikivia4102642009-10-13 12:47:51 +0300227 join->bss_type |= WL1271_JOIN_CMD_BSS_TYPE_5GHZ;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300228
Juuso Oikarinen60e84c22010-03-26 12:53:25 +0200229 join->beacon_interval = cpu_to_le16(wl->beacon_int);
Luciano Coelhoae751ba2009-10-12 15:08:57 +0300230 join->dtim_interval = WL1271_DEFAULT_DTIM_PERIOD;
Teemu Paasikivia4102642009-10-13 12:47:51 +0300231
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300232 join->channel = wl->channel;
233 join->ssid_len = wl->ssid_len;
234 memcpy(join->ssid, wl->ssid, wl->ssid_len);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300235
236 join->ctrl |= wl->session_counter << WL1271_JOIN_CMD_TX_SESSION_OFFSET;
237
Juuso Oikarinenac4e4ce2009-10-08 21:56:19 +0300238 /* reset TX security counters */
239 wl->tx_security_last_seq = 0;
Juuso Oikarinen04e36fc2010-02-22 08:38:40 +0200240 wl->tx_security_seq = 0;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300241
Juuso Oikarinenfa867e72009-11-02 20:22:13 +0200242 ret = wl1271_cmd_send(wl, CMD_START_JOIN, join, sizeof(*join), 0);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300243 if (ret < 0) {
244 wl1271_error("failed to initiate cmd join");
245 goto out_free;
246 }
247
Luciano Coelho99d84c12010-03-26 12:53:20 +0200248 ret = wl1271_cmd_wait_for_event(wl, JOIN_EVENT_COMPLETE_ID);
249 if (ret < 0)
250 wl1271_error("cmd join event completion error");
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300251
252out_free:
253 kfree(join);
254
255out:
256 return ret;
257}
258
259/**
260 * send test command to firmware
261 *
262 * @wl: wl struct
263 * @buf: buffer containing the command, with all headers, must work with dma
264 * @len: length of the buffer
265 * @answer: is answer needed
266 */
267int wl1271_cmd_test(struct wl1271 *wl, void *buf, size_t buf_len, u8 answer)
268{
269 int ret;
Juuso Oikarinenfa867e72009-11-02 20:22:13 +0200270 size_t res_len = 0;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300271
272 wl1271_debug(DEBUG_CMD, "cmd test");
273
Juuso Oikarinenfa867e72009-11-02 20:22:13 +0200274 if (answer)
275 res_len = buf_len;
276
277 ret = wl1271_cmd_send(wl, CMD_TEST, buf, buf_len, res_len);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300278
279 if (ret < 0) {
280 wl1271_warning("TEST command failed");
281 return ret;
282 }
283
Juuso Oikarinenfa867e72009-11-02 20:22:13 +0200284 return ret;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300285}
286
287/**
288 * read acx from firmware
289 *
290 * @wl: wl struct
291 * @id: acx id
292 * @buf: buffer for the response, including all headers, must work with dma
293 * @len: lenght of buf
294 */
295int wl1271_cmd_interrogate(struct wl1271 *wl, u16 id, void *buf, size_t len)
296{
297 struct acx_header *acx = buf;
298 int ret;
299
300 wl1271_debug(DEBUG_CMD, "cmd interrogate");
301
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300302 acx->id = cpu_to_le16(id);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300303
304 /* payload length, does not include any headers */
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300305 acx->len = cpu_to_le16(len - sizeof(*acx));
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300306
Juuso Oikarinenfa867e72009-11-02 20:22:13 +0200307 ret = wl1271_cmd_send(wl, CMD_INTERROGATE, acx, sizeof(*acx), len);
308 if (ret < 0)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300309 wl1271_error("INTERROGATE command failed");
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300310
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300311 return ret;
312}
313
314/**
315 * write acx value to firmware
316 *
317 * @wl: wl struct
318 * @id: acx id
319 * @buf: buffer containing acx, including all headers, must work with dma
320 * @len: length of buf
321 */
322int wl1271_cmd_configure(struct wl1271 *wl, u16 id, void *buf, size_t len)
323{
324 struct acx_header *acx = buf;
325 int ret;
326
327 wl1271_debug(DEBUG_CMD, "cmd configure");
328
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300329 acx->id = cpu_to_le16(id);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300330
331 /* payload length, does not include any headers */
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300332 acx->len = cpu_to_le16(len - sizeof(*acx));
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300333
Juuso Oikarinenfa867e72009-11-02 20:22:13 +0200334 ret = wl1271_cmd_send(wl, CMD_CONFIGURE, acx, len, 0);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300335 if (ret < 0) {
336 wl1271_warning("CONFIGURE command NOK");
337 return ret;
338 }
339
340 return 0;
341}
342
Luciano Coelho94210892009-12-11 15:40:55 +0200343int wl1271_cmd_data_path(struct wl1271 *wl, bool enable)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300344{
345 struct cmd_enabledisable_path *cmd;
346 int ret;
347 u16 cmd_rx, cmd_tx;
348
349 wl1271_debug(DEBUG_CMD, "cmd data path");
350
351 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
352 if (!cmd) {
353 ret = -ENOMEM;
354 goto out;
355 }
356
Luciano Coelho94210892009-12-11 15:40:55 +0200357 /* the channel here is only used for calibration, so hardcoded to 1 */
358 cmd->channel = 1;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300359
360 if (enable) {
361 cmd_rx = CMD_ENABLE_RX;
362 cmd_tx = CMD_ENABLE_TX;
363 } else {
364 cmd_rx = CMD_DISABLE_RX;
365 cmd_tx = CMD_DISABLE_TX;
366 }
367
Juuso Oikarinenfa867e72009-11-02 20:22:13 +0200368 ret = wl1271_cmd_send(wl, cmd_rx, cmd, sizeof(*cmd), 0);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300369 if (ret < 0) {
370 wl1271_error("rx %s cmd for channel %d failed",
Luciano Coelho94210892009-12-11 15:40:55 +0200371 enable ? "start" : "stop", cmd->channel);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300372 goto out;
373 }
374
375 wl1271_debug(DEBUG_BOOT, "rx %s cmd channel %d",
Luciano Coelho94210892009-12-11 15:40:55 +0200376 enable ? "start" : "stop", cmd->channel);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300377
Juuso Oikarinenfa867e72009-11-02 20:22:13 +0200378 ret = wl1271_cmd_send(wl, cmd_tx, cmd, sizeof(*cmd), 0);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300379 if (ret < 0) {
380 wl1271_error("tx %s cmd for channel %d failed",
Luciano Coelho94210892009-12-11 15:40:55 +0200381 enable ? "start" : "stop", cmd->channel);
Juuso Oikarinen1b00f2b2010-03-26 12:53:17 +0200382 goto out;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300383 }
384
385 wl1271_debug(DEBUG_BOOT, "tx %s cmd channel %d",
Luciano Coelho94210892009-12-11 15:40:55 +0200386 enable ? "start" : "stop", cmd->channel);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300387
388out:
389 kfree(cmd);
390 return ret;
391}
392
Juuso Oikarinend8c42c02010-02-18 13:25:36 +0200393int wl1271_cmd_ps_mode(struct wl1271 *wl, u8 ps_mode, bool send)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300394{
395 struct wl1271_cmd_ps_params *ps_params = NULL;
396 int ret = 0;
397
398 /* FIXME: this should be in ps.c */
Juuso Oikarinen51f2be22009-10-13 12:47:42 +0300399 ret = wl1271_acx_wake_up_conditions(wl);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300400 if (ret < 0) {
401 wl1271_error("couldn't set wake up conditions");
402 goto out;
403 }
404
405 wl1271_debug(DEBUG_CMD, "cmd set ps mode");
406
407 ps_params = kzalloc(sizeof(*ps_params), GFP_KERNEL);
408 if (!ps_params) {
409 ret = -ENOMEM;
410 goto out;
411 }
412
413 ps_params->ps_mode = ps_mode;
Juuso Oikarinend8c42c02010-02-18 13:25:36 +0200414 ps_params->send_null_data = send;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300415 ps_params->retries = 5;
Juuso Oikarinencbd1ea82010-05-07 11:39:02 +0300416 ps_params->hang_over_period = 1;
Juuso Oikarinen5da54f92010-05-24 11:18:19 +0300417 ps_params->null_data_rate = cpu_to_le32(wl->basic_rate_set);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300418
419 ret = wl1271_cmd_send(wl, CMD_SET_PS_MODE, ps_params,
Juuso Oikarinenfa867e72009-11-02 20:22:13 +0200420 sizeof(*ps_params), 0);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300421 if (ret < 0) {
422 wl1271_error("cmd set_ps_mode failed");
423 goto out;
424 }
425
426out:
427 kfree(ps_params);
428 return ret;
429}
430
431int wl1271_cmd_read_memory(struct wl1271 *wl, u32 addr, void *answer,
432 size_t len)
433{
434 struct cmd_read_write_memory *cmd;
435 int ret = 0;
436
437 wl1271_debug(DEBUG_CMD, "cmd read memory");
438
439 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
440 if (!cmd) {
441 ret = -ENOMEM;
442 goto out;
443 }
444
445 WARN_ON(len > MAX_READ_SIZE);
446 len = min_t(size_t, len, MAX_READ_SIZE);
447
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300448 cmd->addr = cpu_to_le32(addr);
449 cmd->size = cpu_to_le32(len);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300450
Juuso Oikarinenfa867e72009-11-02 20:22:13 +0200451 ret = wl1271_cmd_send(wl, CMD_READ_MEMORY, cmd, sizeof(*cmd),
452 sizeof(*cmd));
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300453 if (ret < 0) {
454 wl1271_error("read memory command failed: %d", ret);
455 goto out;
456 }
457
Juuso Oikarinenfa867e72009-11-02 20:22:13 +0200458 /* the read command got in */
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300459 memcpy(answer, cmd->value, len);
460
461out:
462 kfree(cmd);
463 return ret;
464}
465
Kalle Valo818e3062010-03-18 12:26:35 +0200466int wl1271_cmd_scan(struct wl1271 *wl, const u8 *ssid, size_t ssid_len,
Juuso Oikarinen4fb26fa2010-05-24 11:18:20 +0300467 struct cfg80211_scan_request *req, u8 active_scan,
Kalle Valo818e3062010-03-18 12:26:35 +0200468 u8 high_prio, u8 band, u8 probe_requests)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300469{
470
471 struct wl1271_cmd_trigger_scan_to *trigger = NULL;
472 struct wl1271_cmd_scan *params = NULL;
Teemu Paasikivi311494c2009-10-13 12:47:49 +0300473 struct ieee80211_channel *channels;
Juuso Oikarinenebba60c2010-04-01 11:38:20 +0300474 u32 rate;
Teemu Paasikivi311494c2009-10-13 12:47:49 +0300475 int i, j, n_ch, ret;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300476 u16 scan_options = 0;
Teemu Paasikiviabb0b3b2009-10-13 12:47:50 +0300477 u8 ieee_band;
478
Juuso Oikarinenebba60c2010-04-01 11:38:20 +0300479 if (band == WL1271_SCAN_BAND_2_4_GHZ) {
Teemu Paasikiviabb0b3b2009-10-13 12:47:50 +0300480 ieee_band = IEEE80211_BAND_2GHZ;
Juuso Oikarinenebba60c2010-04-01 11:38:20 +0300481 rate = wl->conf.tx.basic_rate;
482 } else if (band == WL1271_SCAN_BAND_DUAL && wl1271_11a_enabled()) {
Teemu Paasikiviabb0b3b2009-10-13 12:47:50 +0300483 ieee_band = IEEE80211_BAND_2GHZ;
Juuso Oikarinenebba60c2010-04-01 11:38:20 +0300484 rate = wl->conf.tx.basic_rate;
485 } else if (band == WL1271_SCAN_BAND_5_GHZ && wl1271_11a_enabled()) {
Teemu Paasikiviabb0b3b2009-10-13 12:47:50 +0300486 ieee_band = IEEE80211_BAND_5GHZ;
Juuso Oikarinenebba60c2010-04-01 11:38:20 +0300487 rate = wl->conf.tx.basic_rate_5;
488 } else
Teemu Paasikiviabb0b3b2009-10-13 12:47:50 +0300489 return -EINVAL;
490
491 if (wl->hw->wiphy->bands[ieee_band]->channels == NULL)
492 return -EINVAL;
493
494 channels = wl->hw->wiphy->bands[ieee_band]->channels;
495 n_ch = wl->hw->wiphy->bands[ieee_band]->n_channels;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300496
Juuso Oikarinen71449f82009-12-11 15:41:07 +0200497 if (test_bit(WL1271_FLAG_SCANNING, &wl->flags))
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300498 return -EINVAL;
499
500 params = kzalloc(sizeof(*params), GFP_KERNEL);
501 if (!params)
502 return -ENOMEM;
503
504 params->params.rx_config_options = cpu_to_le32(CFG_RX_ALL_GOOD);
505 params->params.rx_filter_options =
506 cpu_to_le32(CFG_RX_PRSP_EN | CFG_RX_MGMT_EN | CFG_RX_BCN_EN);
507
508 if (!active_scan)
509 scan_options |= WL1271_SCAN_OPT_PASSIVE;
510 if (high_prio)
511 scan_options |= WL1271_SCAN_OPT_PRIORITY_HIGH;
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300512 params->params.scan_options = cpu_to_le16(scan_options);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300513
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300514 params->params.num_probe_requests = probe_requests;
Luciano Coelho23a7a512010-04-28 09:50:02 +0300515 params->params.tx_rate = cpu_to_le32(rate);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300516 params->params.tid_trigger = 0;
517 params->params.scan_tag = WL1271_SCAN_DEFAULT_TAG;
518
Teemu Paasikiviabb0b3b2009-10-13 12:47:50 +0300519 if (band == WL1271_SCAN_BAND_DUAL)
520 params->params.band = WL1271_SCAN_BAND_2_4_GHZ;
521 else
522 params->params.band = band;
523
Teemu Paasikivi311494c2009-10-13 12:47:49 +0300524 for (i = 0, j = 0; i < n_ch && i < WL1271_SCAN_MAX_CHANNELS; i++) {
525 if (!(channels[i].flags & IEEE80211_CHAN_DISABLED)) {
526 params->channels[j].min_duration =
527 cpu_to_le32(WL1271_SCAN_CHAN_MIN_DURATION);
528 params->channels[j].max_duration =
529 cpu_to_le32(WL1271_SCAN_CHAN_MAX_DURATION);
530 memset(&params->channels[j].bssid_lsb, 0xff, 4);
531 memset(&params->channels[j].bssid_msb, 0xff, 2);
532 params->channels[j].early_termination = 0;
533 params->channels[j].tx_power_att =
534 WL1271_SCAN_CURRENT_TX_PWR;
535 params->channels[j].channel = channels[i].hw_value;
536 j++;
537 }
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300538 }
539
Teemu Paasikivi311494c2009-10-13 12:47:49 +0300540 params->params.num_channels = j;
541
Kalle Valo818e3062010-03-18 12:26:35 +0200542 if (ssid_len && ssid) {
543 params->params.ssid_len = ssid_len;
544 memcpy(params->params.ssid, ssid, ssid_len);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300545 }
546
Kalle Valo818e3062010-03-18 12:26:35 +0200547 ret = wl1271_cmd_build_probe_req(wl, ssid, ssid_len,
Juuso Oikarinen4fb26fa2010-05-24 11:18:20 +0300548 req->ie, req->ie_len, ieee_band);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300549 if (ret < 0) {
550 wl1271_error("PROBE request template failed");
551 goto out;
552 }
553
554 trigger = kzalloc(sizeof(*trigger), GFP_KERNEL);
555 if (!trigger) {
556 ret = -ENOMEM;
557 goto out;
558 }
559
560 /* disable the timeout */
561 trigger->timeout = 0;
562
563 ret = wl1271_cmd_send(wl, CMD_TRIGGER_SCAN_TO, trigger,
Juuso Oikarinenfa867e72009-11-02 20:22:13 +0200564 sizeof(*trigger), 0);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300565 if (ret < 0) {
566 wl1271_error("trigger scan to failed for hw scan");
567 goto out;
568 }
569
570 wl1271_dump(DEBUG_SCAN, "SCAN: ", params, sizeof(*params));
571
Juuso Oikarinen71449f82009-12-11 15:41:07 +0200572 set_bit(WL1271_FLAG_SCANNING, &wl->flags);
Teemu Paasikiviabb0b3b2009-10-13 12:47:50 +0300573 if (wl1271_11a_enabled()) {
574 wl->scan.state = band;
575 if (band == WL1271_SCAN_BAND_DUAL) {
576 wl->scan.active = active_scan;
577 wl->scan.high_prio = high_prio;
578 wl->scan.probe_requests = probe_requests;
Kalle Valo818e3062010-03-18 12:26:35 +0200579 if (ssid_len && ssid) {
580 wl->scan.ssid_len = ssid_len;
581 memcpy(wl->scan.ssid, ssid, ssid_len);
Teemu Paasikiviabb0b3b2009-10-13 12:47:50 +0300582 } else
583 wl->scan.ssid_len = 0;
Juuso Oikarinen4fb26fa2010-05-24 11:18:20 +0300584 wl->scan.req = req;
585 } else
586 wl->scan.req = NULL;
Teemu Paasikiviabb0b3b2009-10-13 12:47:50 +0300587 }
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300588
Juuso Oikarinenfa867e72009-11-02 20:22:13 +0200589 ret = wl1271_cmd_send(wl, CMD_SCAN, params, sizeof(*params), 0);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300590 if (ret < 0) {
591 wl1271_error("SCAN failed");
Juuso Oikarinen71449f82009-12-11 15:41:07 +0200592 clear_bit(WL1271_FLAG_SCANNING, &wl->flags);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300593 goto out;
594 }
595
596out:
597 kfree(params);
Juuso Oikarinen9cea4612010-03-26 12:53:14 +0200598 kfree(trigger);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300599 return ret;
600}
601
602int wl1271_cmd_template_set(struct wl1271 *wl, u16 template_id,
Juuso Oikarinen606c1482010-04-01 11:38:21 +0300603 void *buf, size_t buf_len, int index, u32 rates)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300604{
605 struct wl1271_cmd_template_set *cmd;
606 int ret = 0;
607
608 wl1271_debug(DEBUG_CMD, "cmd template_set %d", template_id);
609
610 WARN_ON(buf_len > WL1271_CMD_TEMPL_MAX_SIZE);
611 buf_len = min_t(size_t, buf_len, WL1271_CMD_TEMPL_MAX_SIZE);
612
613 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
614 if (!cmd) {
615 ret = -ENOMEM;
616 goto out;
617 }
618
619 cmd->len = cpu_to_le16(buf_len);
620 cmd->template_type = template_id;
Juuso Oikarinen606c1482010-04-01 11:38:21 +0300621 cmd->enabled_rates = cpu_to_le32(rates);
Juuso Oikarinen45b531a2009-10-13 12:47:41 +0300622 cmd->short_retry_limit = wl->conf.tx.rc_conf.short_retry_limit;
623 cmd->long_retry_limit = wl->conf.tx.rc_conf.long_retry_limit;
Juuso Oikarinenbfb24c92010-03-26 12:53:31 +0200624 cmd->index = index;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300625
626 if (buf)
627 memcpy(cmd->template_data, buf, buf_len);
628
Juuso Oikarinenfa867e72009-11-02 20:22:13 +0200629 ret = wl1271_cmd_send(wl, CMD_SET_TEMPLATE, cmd, sizeof(*cmd), 0);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300630 if (ret < 0) {
631 wl1271_warning("cmd set_template failed: %d", ret);
632 goto out_free;
633 }
634
635out_free:
636 kfree(cmd);
637
638out:
639 return ret;
640}
641
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300642int wl1271_cmd_build_null_data(struct wl1271 *wl)
643{
Juuso Oikarinena0cb7be2010-03-18 12:26:44 +0200644 struct sk_buff *skb = NULL;
645 int size;
646 void *ptr;
647 int ret = -ENOMEM;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300648
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300649
Juuso Oikarinena0cb7be2010-03-18 12:26:44 +0200650 if (wl->bss_type == BSS_TYPE_IBSS) {
651 size = sizeof(struct wl12xx_null_data_template);
652 ptr = NULL;
653 } else {
654 skb = ieee80211_nullfunc_get(wl->hw, wl->vif);
655 if (!skb)
656 goto out;
657 size = skb->len;
658 ptr = skb->data;
659 }
660
Juuso Oikarinen606c1482010-04-01 11:38:21 +0300661 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_NULL_DATA, ptr, size, 0,
662 WL1271_RATE_AUTOMATIC);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300663
Kalle Valo899e6e62010-03-18 12:26:34 +0200664out:
665 dev_kfree_skb(skb);
Juuso Oikarinena0cb7be2010-03-18 12:26:44 +0200666 if (ret)
667 wl1271_warning("cmd buld null data failed %d", ret);
668
Kalle Valo899e6e62010-03-18 12:26:34 +0200669 return ret;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300670
671}
672
Juuso Oikarinenbfb24c92010-03-26 12:53:31 +0200673int wl1271_cmd_build_klv_null_data(struct wl1271 *wl)
674{
675 struct sk_buff *skb = NULL;
676 int ret = -ENOMEM;
677
678 skb = ieee80211_nullfunc_get(wl->hw, wl->vif);
679 if (!skb)
680 goto out;
681
682 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_KLV,
683 skb->data, skb->len,
Juuso Oikarinen606c1482010-04-01 11:38:21 +0300684 CMD_TEMPL_KLV_IDX_NULL_DATA,
685 WL1271_RATE_AUTOMATIC);
Juuso Oikarinenbfb24c92010-03-26 12:53:31 +0200686
687out:
688 dev_kfree_skb(skb);
689 if (ret)
690 wl1271_warning("cmd build klv null data failed %d", ret);
691
692 return ret;
693
694}
695
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300696int wl1271_cmd_build_ps_poll(struct wl1271 *wl, u16 aid)
697{
Kalle Valo899e6e62010-03-18 12:26:34 +0200698 struct sk_buff *skb;
699 int ret = 0;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300700
Kalle Valo899e6e62010-03-18 12:26:34 +0200701 skb = ieee80211_pspoll_get(wl->hw, wl->vif);
702 if (!skb)
703 goto out;
Juuso Oikarinenc3fea192009-10-08 21:56:22 +0300704
Kalle Valo899e6e62010-03-18 12:26:34 +0200705 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_PS_POLL, skb->data,
Juuso Oikarinen849923f2010-07-08 17:49:59 +0300706 skb->len, 0, wl->basic_rate_set);
Juuso Oikarinenc3fea192009-10-08 21:56:22 +0300707
Kalle Valo899e6e62010-03-18 12:26:34 +0200708out:
709 dev_kfree_skb(skb);
710 return ret;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300711}
712
Kalle Valo818e3062010-03-18 12:26:35 +0200713int wl1271_cmd_build_probe_req(struct wl1271 *wl,
714 const u8 *ssid, size_t ssid_len,
715 const u8 *ie, size_t ie_len, u8 band)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300716{
Kalle Valo818e3062010-03-18 12:26:35 +0200717 struct sk_buff *skb;
Teemu Paasikiviabb0b3b2009-10-13 12:47:50 +0300718 int ret;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300719
Kalle Valo818e3062010-03-18 12:26:35 +0200720 skb = ieee80211_probereq_get(wl->hw, wl->vif, ssid, ssid_len,
721 ie, ie_len);
722 if (!skb) {
723 ret = -ENOMEM;
724 goto out;
725 }
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300726
Kalle Valo818e3062010-03-18 12:26:35 +0200727 wl1271_dump(DEBUG_SCAN, "PROBE REQ: ", skb->data, skb->len);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300728
Teemu Paasikiviabb0b3b2009-10-13 12:47:50 +0300729 if (band == IEEE80211_BAND_2GHZ)
730 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_CFG_PROBE_REQ_2_4,
Juuso Oikarinen606c1482010-04-01 11:38:21 +0300731 skb->data, skb->len, 0,
732 wl->conf.tx.basic_rate);
Teemu Paasikiviabb0b3b2009-10-13 12:47:50 +0300733 else
734 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_CFG_PROBE_REQ_5,
Juuso Oikarinen606c1482010-04-01 11:38:21 +0300735 skb->data, skb->len, 0,
736 wl->conf.tx.basic_rate_5);
Kalle Valo818e3062010-03-18 12:26:35 +0200737
738out:
739 dev_kfree_skb(skb);
Teemu Paasikiviabb0b3b2009-10-13 12:47:50 +0300740 return ret;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300741}
742
Kalle Valo023e0822010-03-18 12:26:36 +0200743int wl1271_build_qos_null_data(struct wl1271 *wl)
744{
745 struct ieee80211_qos_hdr template;
746
747 memset(&template, 0, sizeof(template));
748
749 memcpy(template.addr1, wl->bssid, ETH_ALEN);
750 memcpy(template.addr2, wl->mac_addr, ETH_ALEN);
751 memcpy(template.addr3, wl->bssid, ETH_ALEN);
752
753 template.frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA |
754 IEEE80211_STYPE_QOS_NULLFUNC |
755 IEEE80211_FCTL_TODS);
756
757 /* FIXME: not sure what priority to use here */
758 template.qos_ctrl = cpu_to_le16(0);
759
760 return wl1271_cmd_template_set(wl, CMD_TEMPL_QOS_NULL_DATA, &template,
Juuso Oikarinen606c1482010-04-01 11:38:21 +0300761 sizeof(template), 0,
762 WL1271_RATE_AUTOMATIC);
Kalle Valo023e0822010-03-18 12:26:36 +0200763}
764
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300765int wl1271_cmd_set_default_wep_key(struct wl1271 *wl, u8 id)
766{
767 struct wl1271_cmd_set_keys *cmd;
768 int ret = 0;
769
770 wl1271_debug(DEBUG_CMD, "cmd set_default_wep_key %d", id);
771
772 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
773 if (!cmd) {
774 ret = -ENOMEM;
775 goto out;
776 }
777
778 cmd->id = id;
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300779 cmd->key_action = cpu_to_le16(KEY_SET_ID);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300780 cmd->key_type = KEY_WEP;
781
Juuso Oikarinenfa867e72009-11-02 20:22:13 +0200782 ret = wl1271_cmd_send(wl, CMD_SET_KEYS, cmd, sizeof(*cmd), 0);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300783 if (ret < 0) {
784 wl1271_warning("cmd set_default_wep_key failed: %d", ret);
785 goto out;
786 }
787
788out:
789 kfree(cmd);
790
791 return ret;
792}
793
794int wl1271_cmd_set_key(struct wl1271 *wl, u16 action, u8 id, u8 key_type,
Juuso Oikarinenac4e4ce2009-10-08 21:56:19 +0300795 u8 key_size, const u8 *key, const u8 *addr,
796 u32 tx_seq_32, u16 tx_seq_16)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300797{
798 struct wl1271_cmd_set_keys *cmd;
799 int ret = 0;
800
801 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
802 if (!cmd) {
803 ret = -ENOMEM;
804 goto out;
805 }
806
807 if (key_type != KEY_WEP)
808 memcpy(cmd->addr, addr, ETH_ALEN);
809
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300810 cmd->key_action = cpu_to_le16(action);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300811 cmd->key_size = key_size;
812 cmd->key_type = key_type;
813
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300814 cmd->ac_seq_num16[0] = cpu_to_le16(tx_seq_16);
815 cmd->ac_seq_num32[0] = cpu_to_le32(tx_seq_32);
Juuso Oikarinenac4e4ce2009-10-08 21:56:19 +0300816
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300817 /* we have only one SSID profile */
818 cmd->ssid_profile = 0;
819
820 cmd->id = id;
821
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300822 if (key_type == KEY_TKIP) {
823 /*
824 * We get the key in the following form:
825 * TKIP (16 bytes) - TX MIC (8 bytes) - RX MIC (8 bytes)
826 * but the target is expecting:
827 * TKIP - RX MIC - TX MIC
828 */
829 memcpy(cmd->key, key, 16);
830 memcpy(cmd->key + 16, key + 24, 8);
831 memcpy(cmd->key + 24, key + 16, 8);
832
833 } else {
834 memcpy(cmd->key, key, key_size);
835 }
836
837 wl1271_dump(DEBUG_CRYPT, "TARGET KEY: ", cmd, sizeof(*cmd));
838
Juuso Oikarinenfa867e72009-11-02 20:22:13 +0200839 ret = wl1271_cmd_send(wl, CMD_SET_KEYS, cmd, sizeof(*cmd), 0);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300840 if (ret < 0) {
841 wl1271_warning("could not set keys");
Juuso Oikarinen152ee6e2010-02-18 13:25:42 +0200842 goto out;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300843 }
844
845out:
846 kfree(cmd);
847
848 return ret;
849}
Luciano Coelho25a7dc62009-10-12 15:08:42 +0300850
851int wl1271_cmd_disconnect(struct wl1271 *wl)
852{
853 struct wl1271_cmd_disconnect *cmd;
854 int ret = 0;
855
856 wl1271_debug(DEBUG_CMD, "cmd disconnect");
857
858 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
859 if (!cmd) {
860 ret = -ENOMEM;
861 goto out;
862 }
863
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300864 cmd->rx_config_options = cpu_to_le32(wl->rx_config);
865 cmd->rx_filter_options = cpu_to_le32(wl->rx_filter);
Luciano Coelho25a7dc62009-10-12 15:08:42 +0300866 /* disconnect reason is not used in immediate disconnections */
867 cmd->type = DISCONNECT_IMMEDIATE;
868
Juuso Oikarinenfa867e72009-11-02 20:22:13 +0200869 ret = wl1271_cmd_send(wl, CMD_DISCONNECT, cmd, sizeof(*cmd), 0);
Luciano Coelho25a7dc62009-10-12 15:08:42 +0300870 if (ret < 0) {
871 wl1271_error("failed to send disconnect command");
872 goto out_free;
873 }
874
Luciano Coelho2f826f52010-03-26 12:53:21 +0200875 ret = wl1271_cmd_wait_for_event(wl, DISCONNECT_EVENT_COMPLETE_ID);
876 if (ret < 0)
877 wl1271_error("cmd disconnect event completion error");
878
Luciano Coelho25a7dc62009-10-12 15:08:42 +0300879out_free:
880 kfree(cmd);
881
882out:
883 return ret;
884}