blob: 9064513aea0d22a1bc94e84e41bf6b95a11ee412 [file] [log] [blame]
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001/**
2 * This file contains the handling of command.
3 * It prepares command and sends it to firmware when it is ready.
4 */
5
6#include <net/iw_handler.h>
7#include "host.h"
8#include "hostcmd.h"
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02009#include "decl.h"
10#include "defs.h"
11#include "dev.h"
12#include "join.h"
13#include "wext.h"
14
15static void cleanup_cmdnode(struct cmd_ctrl_node *ptempnode);
Holger Schurig0d61d042007-12-05 17:58:06 +010016struct cmd_ctrl_node *lbs_get_cmd_ctrl_node(struct lbs_private *priv);
17void lbs_set_cmd_ctrl_node(struct lbs_private *priv,
18 struct cmd_ctrl_node *ptempnode,
19 u16 wait_option, void *pdata_buf);
20
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020021
22static u16 commands_allowed_in_ps[] = {
Dan Williams0aef64d2007-08-02 11:31:18 -040023 CMD_802_11_RSSI,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020024};
25
26/**
27 * @brief This function checks if the commans is allowed
28 * in PS mode not.
29 *
30 * @param command the command ID
31 * @return TRUE or FALSE
32 */
David Woodhouse981f1872007-05-25 23:36:54 -040033static u8 is_command_allowed_in_ps(__le16 command)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020034{
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020035 int i;
36
David Woodhouse981f1872007-05-25 23:36:54 -040037 for (i = 0; i < ARRAY_SIZE(commands_allowed_in_ps); i++) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020038 if (command == cpu_to_le16(commands_allowed_in_ps[i]))
39 return 1;
40 }
41
42 return 0;
43}
44
Holger Schurig69f90322007-11-23 15:43:44 +010045static int lbs_cmd_hw_spec(struct lbs_private *priv, struct cmd_ds_command *cmd)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020046{
47 struct cmd_ds_get_hw_spec *hwspec = &cmd->params.hwspec;
48
Holger Schurig9012b282007-05-25 11:27:16 -040049 lbs_deb_enter(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020050
Dan Williams0aef64d2007-08-02 11:31:18 -040051 cmd->command = cpu_to_le16(CMD_GET_HW_SPEC);
David Woodhouse981f1872007-05-25 23:36:54 -040052 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_get_hw_spec) + S_DS_GEN);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020053 memcpy(hwspec->permanentaddr, priv->adapter->current_addr, ETH_ALEN);
54
Holger Schurig9012b282007-05-25 11:27:16 -040055 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020056 return 0;
57}
58
Holger Schurig69f90322007-11-23 15:43:44 +010059static int lbs_cmd_802_11_ps_mode(struct lbs_private *priv,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020060 struct cmd_ds_command *cmd,
61 u16 cmd_action)
62{
63 struct cmd_ds_802_11_ps_mode *psm = &cmd->params.psmode;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020064
Holger Schurig9012b282007-05-25 11:27:16 -040065 lbs_deb_enter(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020066
Dan Williams0aef64d2007-08-02 11:31:18 -040067 cmd->command = cpu_to_le16(CMD_802_11_PS_MODE);
David Woodhouse981f1872007-05-25 23:36:54 -040068 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_ps_mode) +
69 S_DS_GEN);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020070 psm->action = cpu_to_le16(cmd_action);
71 psm->multipledtim = 0;
David Woodhouse981f1872007-05-25 23:36:54 -040072 switch (cmd_action) {
Dan Williams0aef64d2007-08-02 11:31:18 -040073 case CMD_SUBCMD_ENTER_PS:
Holger Schurig9012b282007-05-25 11:27:16 -040074 lbs_deb_cmd("PS command:" "SubCode- Enter PS\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020075
Holger Schurig252cf0d2007-08-02 13:09:34 -040076 psm->locallisteninterval = 0;
Holger Schurig97605c32007-08-02 13:09:15 -040077 psm->nullpktinterval = 0;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020078 psm->multipledtim =
Holger Schurig56c46562007-08-02 13:09:49 -040079 cpu_to_le16(MRVDRV_DEFAULT_MULTIPLE_DTIM);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020080 break;
81
Dan Williams0aef64d2007-08-02 11:31:18 -040082 case CMD_SUBCMD_EXIT_PS:
Holger Schurig9012b282007-05-25 11:27:16 -040083 lbs_deb_cmd("PS command:" "SubCode- Exit PS\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020084 break;
85
Dan Williams0aef64d2007-08-02 11:31:18 -040086 case CMD_SUBCMD_SLEEP_CONFIRMED:
Holger Schurig9012b282007-05-25 11:27:16 -040087 lbs_deb_cmd("PS command: SubCode- sleep confirm\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020088 break;
89
90 default:
91 break;
92 }
93
Holger Schurig9012b282007-05-25 11:27:16 -040094 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020095 return 0;
96}
97
Holger Schurig69f90322007-11-23 15:43:44 +010098static int lbs_cmd_802_11_inactivity_timeout(struct lbs_private *priv,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020099 struct cmd_ds_command *cmd,
100 u16 cmd_action, void *pdata_buf)
101{
102 u16 *timeout = pdata_buf;
103
Holger Schurig8ff12da2007-08-02 11:54:31 -0400104 lbs_deb_enter(LBS_DEB_CMD);
105
Dan Williams0aef64d2007-08-02 11:31:18 -0400106 cmd->command = cpu_to_le16(CMD_802_11_INACTIVITY_TIMEOUT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200107 cmd->size =
108 cpu_to_le16(sizeof(struct cmd_ds_802_11_inactivity_timeout)
109 + S_DS_GEN);
110
111 cmd->params.inactivity_timeout.action = cpu_to_le16(cmd_action);
112
113 if (cmd_action)
David Woodhouse981f1872007-05-25 23:36:54 -0400114 cmd->params.inactivity_timeout.timeout = cpu_to_le16(*timeout);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200115 else
116 cmd->params.inactivity_timeout.timeout = 0;
117
Holger Schurig8ff12da2007-08-02 11:54:31 -0400118 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200119 return 0;
120}
121
Holger Schurig69f90322007-11-23 15:43:44 +0100122static int lbs_cmd_802_11_sleep_params(struct lbs_private *priv,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200123 struct cmd_ds_command *cmd,
124 u16 cmd_action)
125{
Holger Schurig69f90322007-11-23 15:43:44 +0100126 struct lbs_adapter *adapter = priv->adapter;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200127 struct cmd_ds_802_11_sleep_params *sp = &cmd->params.sleep_params;
128
Holger Schurig9012b282007-05-25 11:27:16 -0400129 lbs_deb_enter(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200130
David Woodhouse981f1872007-05-25 23:36:54 -0400131 cmd->size = cpu_to_le16((sizeof(struct cmd_ds_802_11_sleep_params)) +
132 S_DS_GEN);
Dan Williams0aef64d2007-08-02 11:31:18 -0400133 cmd->command = cpu_to_le16(CMD_802_11_SLEEP_PARAMS);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200134
Dan Williams0aef64d2007-08-02 11:31:18 -0400135 if (cmd_action == CMD_ACT_GET) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200136 memset(&adapter->sp, 0, sizeof(struct sleep_params));
137 memset(sp, 0, sizeof(struct cmd_ds_802_11_sleep_params));
138 sp->action = cpu_to_le16(cmd_action);
Dan Williams0aef64d2007-08-02 11:31:18 -0400139 } else if (cmd_action == CMD_ACT_SET) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200140 sp->action = cpu_to_le16(cmd_action);
141 sp->error = cpu_to_le16(adapter->sp.sp_error);
142 sp->offset = cpu_to_le16(adapter->sp.sp_offset);
143 sp->stabletime = cpu_to_le16(adapter->sp.sp_stabletime);
144 sp->calcontrol = (u8) adapter->sp.sp_calcontrol;
145 sp->externalsleepclk = (u8) adapter->sp.sp_extsleepclk;
146 sp->reserved = cpu_to_le16(adapter->sp.sp_reserved);
147 }
148
Holger Schurig9012b282007-05-25 11:27:16 -0400149 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200150 return 0;
151}
152
Holger Schurig69f90322007-11-23 15:43:44 +0100153static int lbs_cmd_802_11_set_wep(struct lbs_private *priv,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200154 struct cmd_ds_command *cmd,
155 u32 cmd_act,
156 void * pdata_buf)
157{
158 struct cmd_ds_802_11_set_wep *wep = &cmd->params.wep;
Holger Schurig69f90322007-11-23 15:43:44 +0100159 struct lbs_adapter *adapter = priv->adapter;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200160 int ret = 0;
161 struct assoc_request * assoc_req = pdata_buf;
162
Holger Schurig9012b282007-05-25 11:27:16 -0400163 lbs_deb_enter(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200164
Dan Williams0aef64d2007-08-02 11:31:18 -0400165 cmd->command = cpu_to_le16(CMD_802_11_SET_WEP);
David Woodhouse981f1872007-05-25 23:36:54 -0400166 cmd->size = cpu_to_le16(sizeof(*wep) + S_DS_GEN);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200167
Dan Williams0aef64d2007-08-02 11:31:18 -0400168 if (cmd_act == CMD_ACT_ADD) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200169 int i;
170
171 if (!assoc_req) {
Holger Schurig9012b282007-05-25 11:27:16 -0400172 lbs_deb_cmd("Invalid association request!");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200173 ret = -1;
174 goto done;
175 }
176
Dan Williams0aef64d2007-08-02 11:31:18 -0400177 wep->action = cpu_to_le16(CMD_ACT_ADD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200178
179 /* default tx key index */
David Woodhouse981f1872007-05-25 23:36:54 -0400180 wep->keyindex = cpu_to_le16((u16)(assoc_req->wep_tx_keyidx &
Dan Williams0aef64d2007-08-02 11:31:18 -0400181 (u32)CMD_WEP_KEY_INDEX_MASK));
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200182
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200183 /* Copy key types and material to host command structure */
184 for (i = 0; i < 4; i++) {
Dan Williams1443b652007-08-02 10:45:55 -0400185 struct enc_key * pkey = &assoc_req->wep_keys[i];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200186
187 switch (pkey->len) {
188 case KEY_LEN_WEP_40:
Holger Schurig6470a892007-10-08 11:07:27 +0200189 wep->keytype[i] = CMD_TYPE_WEP_40_BIT;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200190 memmove(&wep->keymaterial[i], pkey->key,
191 pkey->len);
Holger Schurig8ff12da2007-08-02 11:54:31 -0400192 lbs_deb_cmd("SET_WEP: add key %d (40 bit)\n", i);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200193 break;
194 case KEY_LEN_WEP_104:
Holger Schurig6470a892007-10-08 11:07:27 +0200195 wep->keytype[i] = CMD_TYPE_WEP_104_BIT;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200196 memmove(&wep->keymaterial[i], pkey->key,
197 pkey->len);
Holger Schurig8ff12da2007-08-02 11:54:31 -0400198 lbs_deb_cmd("SET_WEP: add key %d (104 bit)\n", i);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200199 break;
200 case 0:
201 break;
202 default:
Holger Schurig8ff12da2007-08-02 11:54:31 -0400203 lbs_deb_cmd("SET_WEP: invalid key %d, length %d\n",
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200204 i, pkey->len);
205 ret = -1;
206 goto done;
207 break;
208 }
209 }
Dan Williams0aef64d2007-08-02 11:31:18 -0400210 } else if (cmd_act == CMD_ACT_REMOVE) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200211 /* ACT_REMOVE clears _all_ WEP keys */
Dan Williams0aef64d2007-08-02 11:31:18 -0400212 wep->action = cpu_to_le16(CMD_ACT_REMOVE);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200213
214 /* default tx key index */
David Woodhouse981f1872007-05-25 23:36:54 -0400215 wep->keyindex = cpu_to_le16((u16)(adapter->wep_tx_keyidx &
Dan Williams0aef64d2007-08-02 11:31:18 -0400216 (u32)CMD_WEP_KEY_INDEX_MASK));
Holger Schurig8ff12da2007-08-02 11:54:31 -0400217 lbs_deb_cmd("SET_WEP: remove key %d\n", adapter->wep_tx_keyidx);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200218 }
219
220 ret = 0;
221
222done:
Holger Schurig9012b282007-05-25 11:27:16 -0400223 lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200224 return ret;
225}
226
Holger Schurig69f90322007-11-23 15:43:44 +0100227static int lbs_cmd_802_11_enable_rsn(struct lbs_private *priv,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200228 struct cmd_ds_command *cmd,
Dan Williams90a42212007-05-25 23:01:24 -0400229 u16 cmd_action,
230 void * pdata_buf)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200231{
232 struct cmd_ds_802_11_enable_rsn *penableRSN = &cmd->params.enbrsn;
Dan Williams18c96c342007-06-18 12:01:12 -0400233 u32 * enable = pdata_buf;
Dan Williams90a42212007-05-25 23:01:24 -0400234
235 lbs_deb_enter(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200236
Dan Williams0aef64d2007-08-02 11:31:18 -0400237 cmd->command = cpu_to_le16(CMD_802_11_ENABLE_RSN);
David Woodhouse981f1872007-05-25 23:36:54 -0400238 cmd->size = cpu_to_le16(sizeof(*penableRSN) + S_DS_GEN);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200239 penableRSN->action = cpu_to_le16(cmd_action);
Dan Williams18c96c342007-06-18 12:01:12 -0400240
Dan Williams0aef64d2007-08-02 11:31:18 -0400241 if (cmd_action == CMD_ACT_SET) {
Dan Williams18c96c342007-06-18 12:01:12 -0400242 if (*enable)
Dan Williams0aef64d2007-08-02 11:31:18 -0400243 penableRSN->enable = cpu_to_le16(CMD_ENABLE_RSN);
Dan Williams18c96c342007-06-18 12:01:12 -0400244 else
Dan Williams0aef64d2007-08-02 11:31:18 -0400245 penableRSN->enable = cpu_to_le16(CMD_DISABLE_RSN);
Holger Schurig8ff12da2007-08-02 11:54:31 -0400246 lbs_deb_cmd("ENABLE_RSN: %d\n", *enable);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200247 }
248
Dan Williams90a42212007-05-25 23:01:24 -0400249 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200250 return 0;
251}
252
253
Holger Schurig3a188642007-11-26 10:07:14 +0100254static ssize_t lbs_tlv_size(const u8 *tlv, u16 size)
255{
256 ssize_t pos = 0;
257 struct mrvlietypesheader *tlv_h;
258 while (pos < size) {
259 u16 length;
260 tlv_h = (struct mrvlietypesheader *) tlv;
261 if (tlv_h->len == 0)
262 return pos;
263 length = le16_to_cpu(tlv_h->len) +
264 sizeof(struct mrvlietypesheader);
265 pos += length;
266 tlv += length;
267 }
268 return pos;
269}
270
271
272static void lbs_cmd_802_11_subscribe_event(struct lbs_private *priv,
273 struct cmd_ds_command *cmd, u16 cmd_action,
274 void *pdata_buf)
275{
276 struct cmd_ds_802_11_subscribe_event *events =
277 (struct cmd_ds_802_11_subscribe_event *) pdata_buf;
278
279 /* pdata_buf points to a struct cmd_ds_802_11_subscribe_event and room
280 * for various Marvell TLVs */
281
282 lbs_deb_enter(LBS_DEB_CMD);
283
284 cmd->size = cpu_to_le16(sizeof(*events)
285 - sizeof(events->tlv)
286 + S_DS_GEN);
287 cmd->params.subscribe_event.action = cpu_to_le16(cmd_action);
288 if (cmd_action == CMD_ACT_GET) {
289 cmd->params.subscribe_event.events = 0;
290 } else {
291 ssize_t sz = lbs_tlv_size(events->tlv, sizeof(events->tlv));
292 cmd->size = cpu_to_le16(le16_to_cpu(cmd->size) + sz);
293 cmd->params.subscribe_event.events = events->events;
294 memcpy(cmd->params.subscribe_event.tlv, events->tlv, sz);
295 }
296
297 lbs_deb_leave(LBS_DEB_CMD);
298}
299
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200300static void set_one_wpa_key(struct MrvlIEtype_keyParamSet * pkeyparamset,
Dan Williams1443b652007-08-02 10:45:55 -0400301 struct enc_key * pkey)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200302{
Holger Schurig8ff12da2007-08-02 11:54:31 -0400303 lbs_deb_enter(LBS_DEB_CMD);
304
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200305 if (pkey->flags & KEY_INFO_WPA_ENABLED) {
Dan Williams90a42212007-05-25 23:01:24 -0400306 pkeyparamset->keyinfo |= cpu_to_le16(KEY_INFO_WPA_ENABLED);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200307 }
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200308 if (pkey->flags & KEY_INFO_WPA_UNICAST) {
309 pkeyparamset->keyinfo |= cpu_to_le16(KEY_INFO_WPA_UNICAST);
Dan Williams90a42212007-05-25 23:01:24 -0400310 }
311 if (pkey->flags & KEY_INFO_WPA_MCAST) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200312 pkeyparamset->keyinfo |= cpu_to_le16(KEY_INFO_WPA_MCAST);
313 }
314
315 pkeyparamset->type = cpu_to_le16(TLV_TYPE_KEY_MATERIAL);
Dan Williams1443b652007-08-02 10:45:55 -0400316 pkeyparamset->keytypeid = cpu_to_le16(pkey->type);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200317 pkeyparamset->keylen = cpu_to_le16(pkey->len);
318 memcpy(pkeyparamset->key, pkey->key, pkey->len);
319 pkeyparamset->length = cpu_to_le16( sizeof(pkeyparamset->keytypeid)
320 + sizeof(pkeyparamset->keyinfo)
321 + sizeof(pkeyparamset->keylen)
322 + sizeof(pkeyparamset->key));
Holger Schurig8ff12da2007-08-02 11:54:31 -0400323 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200324}
325
Holger Schurig69f90322007-11-23 15:43:44 +0100326static int lbs_cmd_802_11_key_material(struct lbs_private *priv,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200327 struct cmd_ds_command *cmd,
328 u16 cmd_action,
329 u32 cmd_oid, void *pdata_buf)
330{
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200331 struct cmd_ds_802_11_key_material *pkeymaterial =
332 &cmd->params.keymaterial;
Dan Williams90a42212007-05-25 23:01:24 -0400333 struct assoc_request * assoc_req = pdata_buf;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200334 int ret = 0;
335 int index = 0;
336
Holger Schurig9012b282007-05-25 11:27:16 -0400337 lbs_deb_enter(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200338
Dan Williams0aef64d2007-08-02 11:31:18 -0400339 cmd->command = cpu_to_le16(CMD_802_11_KEY_MATERIAL);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200340 pkeymaterial->action = cpu_to_le16(cmd_action);
341
Dan Williams0aef64d2007-08-02 11:31:18 -0400342 if (cmd_action == CMD_ACT_GET) {
Dan Williams90a42212007-05-25 23:01:24 -0400343 cmd->size = cpu_to_le16(S_DS_GEN + sizeof (pkeymaterial->action));
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200344 ret = 0;
345 goto done;
346 }
347
348 memset(&pkeymaterial->keyParamSet, 0, sizeof(pkeymaterial->keyParamSet));
349
Dan Williams90a42212007-05-25 23:01:24 -0400350 if (test_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags)) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200351 set_one_wpa_key(&pkeymaterial->keyParamSet[index],
Dan Williams90a42212007-05-25 23:01:24 -0400352 &assoc_req->wpa_unicast_key);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200353 index++;
354 }
355
Dan Williams90a42212007-05-25 23:01:24 -0400356 if (test_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags)) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200357 set_one_wpa_key(&pkeymaterial->keyParamSet[index],
Dan Williams90a42212007-05-25 23:01:24 -0400358 &assoc_req->wpa_mcast_key);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200359 index++;
360 }
361
362 cmd->size = cpu_to_le16( S_DS_GEN
Dan Williams90a42212007-05-25 23:01:24 -0400363 + sizeof (pkeymaterial->action)
364 + (index * sizeof(struct MrvlIEtype_keyParamSet)));
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200365
366 ret = 0;
367
368done:
Holger Schurig9012b282007-05-25 11:27:16 -0400369 lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200370 return ret;
371}
372
Holger Schurig69f90322007-11-23 15:43:44 +0100373static int lbs_cmd_802_11_reset(struct lbs_private *priv,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200374 struct cmd_ds_command *cmd, int cmd_action)
375{
376 struct cmd_ds_802_11_reset *reset = &cmd->params.reset;
377
Holger Schurig8ff12da2007-08-02 11:54:31 -0400378 lbs_deb_enter(LBS_DEB_CMD);
379
Dan Williams0aef64d2007-08-02 11:31:18 -0400380 cmd->command = cpu_to_le16(CMD_802_11_RESET);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200381 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_reset) + S_DS_GEN);
382 reset->action = cpu_to_le16(cmd_action);
383
Holger Schurig8ff12da2007-08-02 11:54:31 -0400384 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200385 return 0;
386}
387
Holger Schurig69f90322007-11-23 15:43:44 +0100388static int lbs_cmd_802_11_get_log(struct lbs_private *priv,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200389 struct cmd_ds_command *cmd)
390{
Holger Schurig8ff12da2007-08-02 11:54:31 -0400391 lbs_deb_enter(LBS_DEB_CMD);
Dan Williams0aef64d2007-08-02 11:31:18 -0400392 cmd->command = cpu_to_le16(CMD_802_11_GET_LOG);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200393 cmd->size =
394 cpu_to_le16(sizeof(struct cmd_ds_802_11_get_log) + S_DS_GEN);
395
Holger Schurig8ff12da2007-08-02 11:54:31 -0400396 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200397 return 0;
398}
399
Holger Schurig69f90322007-11-23 15:43:44 +0100400static int lbs_cmd_802_11_get_stat(struct lbs_private *priv,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200401 struct cmd_ds_command *cmd)
402{
Holger Schurig8ff12da2007-08-02 11:54:31 -0400403 lbs_deb_enter(LBS_DEB_CMD);
Dan Williams0aef64d2007-08-02 11:31:18 -0400404 cmd->command = cpu_to_le16(CMD_802_11_GET_STAT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200405 cmd->size =
David Woodhouse981f1872007-05-25 23:36:54 -0400406 cpu_to_le16(sizeof(struct cmd_ds_802_11_get_stat) + S_DS_GEN);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200407
Holger Schurig8ff12da2007-08-02 11:54:31 -0400408 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200409 return 0;
410}
411
Holger Schurig69f90322007-11-23 15:43:44 +0100412static int lbs_cmd_802_11_snmp_mib(struct lbs_private *priv,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200413 struct cmd_ds_command *cmd,
414 int cmd_action,
415 int cmd_oid, void *pdata_buf)
416{
417 struct cmd_ds_802_11_snmp_mib *pSNMPMIB = &cmd->params.smib;
Holger Schurig69f90322007-11-23 15:43:44 +0100418 struct lbs_adapter *adapter = priv->adapter;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200419 u8 ucTemp;
420
Holger Schurig9012b282007-05-25 11:27:16 -0400421 lbs_deb_enter(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200422
Holger Schurig9012b282007-05-25 11:27:16 -0400423 lbs_deb_cmd("SNMP_CMD: cmd_oid = 0x%x\n", cmd_oid);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200424
Dan Williams0aef64d2007-08-02 11:31:18 -0400425 cmd->command = cpu_to_le16(CMD_802_11_SNMP_MIB);
David Woodhouse981f1872007-05-25 23:36:54 -0400426 cmd->size = cpu_to_le16(sizeof(*pSNMPMIB) + S_DS_GEN);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200427
428 switch (cmd_oid) {
429 case OID_802_11_INFRASTRUCTURE_MODE:
430 {
Dan Williams0dc5a292007-05-10 22:58:02 -0400431 u8 mode = (u8) (size_t) pdata_buf;
Dan Williams0aef64d2007-08-02 11:31:18 -0400432 pSNMPMIB->querytype = cpu_to_le16(CMD_ACT_SET);
433 pSNMPMIB->oid = cpu_to_le16((u16) DESIRED_BSSTYPE_I);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200434 pSNMPMIB->bufsize = sizeof(u8);
Dan Williams0dc5a292007-05-10 22:58:02 -0400435 if (mode == IW_MODE_ADHOC) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200436 ucTemp = SNMP_MIB_VALUE_ADHOC;
Dan Williams0dc5a292007-05-10 22:58:02 -0400437 } else {
438 /* Infra and Auto modes */
439 ucTemp = SNMP_MIB_VALUE_INFRA;
440 }
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200441
442 memmove(pSNMPMIB->value, &ucTemp, sizeof(u8));
443
444 break;
445 }
446
447 case OID_802_11D_ENABLE:
448 {
449 u32 ulTemp;
450
Dan Williams0aef64d2007-08-02 11:31:18 -0400451 pSNMPMIB->oid = cpu_to_le16((u16) DOT11D_I);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200452
Dan Williams0aef64d2007-08-02 11:31:18 -0400453 if (cmd_action == CMD_ACT_SET) {
454 pSNMPMIB->querytype = CMD_ACT_SET;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200455 pSNMPMIB->bufsize = sizeof(u16);
456 ulTemp = *(u32 *)pdata_buf;
David Woodhouse981f1872007-05-25 23:36:54 -0400457 *((__le16 *)(pSNMPMIB->value)) =
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200458 cpu_to_le16((u16) ulTemp);
459 }
460 break;
461 }
462
463 case OID_802_11_FRAGMENTATION_THRESHOLD:
464 {
465 u32 ulTemp;
466
Dan Williams0aef64d2007-08-02 11:31:18 -0400467 pSNMPMIB->oid = cpu_to_le16((u16) FRAGTHRESH_I);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200468
Dan Williams0aef64d2007-08-02 11:31:18 -0400469 if (cmd_action == CMD_ACT_GET) {
470 pSNMPMIB->querytype = cpu_to_le16(CMD_ACT_GET);
471 } else if (cmd_action == CMD_ACT_SET) {
472 pSNMPMIB->querytype = cpu_to_le16(CMD_ACT_SET);
David Woodhouse981f1872007-05-25 23:36:54 -0400473 pSNMPMIB->bufsize = cpu_to_le16(sizeof(u16));
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200474 ulTemp = *((u32 *) pdata_buf);
David Woodhouse981f1872007-05-25 23:36:54 -0400475 *((__le16 *)(pSNMPMIB->value)) =
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200476 cpu_to_le16((u16) ulTemp);
477
478 }
479
480 break;
481 }
482
483 case OID_802_11_RTS_THRESHOLD:
484 {
485
486 u32 ulTemp;
Dan Williams0aef64d2007-08-02 11:31:18 -0400487 pSNMPMIB->oid = le16_to_cpu((u16) RTSTHRESH_I);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200488
Dan Williams0aef64d2007-08-02 11:31:18 -0400489 if (cmd_action == CMD_ACT_GET) {
490 pSNMPMIB->querytype = cpu_to_le16(CMD_ACT_GET);
491 } else if (cmd_action == CMD_ACT_SET) {
492 pSNMPMIB->querytype = cpu_to_le16(CMD_ACT_SET);
David Woodhouse981f1872007-05-25 23:36:54 -0400493 pSNMPMIB->bufsize = cpu_to_le16(sizeof(u16));
494 ulTemp = *((u32 *)pdata_buf);
495 *(__le16 *)(pSNMPMIB->value) =
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200496 cpu_to_le16((u16) ulTemp);
497
498 }
499 break;
500 }
501 case OID_802_11_TX_RETRYCOUNT:
Dan Williams0aef64d2007-08-02 11:31:18 -0400502 pSNMPMIB->oid = cpu_to_le16((u16) SHORT_RETRYLIM_I);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200503
Dan Williams0aef64d2007-08-02 11:31:18 -0400504 if (cmd_action == CMD_ACT_GET) {
505 pSNMPMIB->querytype = cpu_to_le16(CMD_ACT_GET);
506 } else if (cmd_action == CMD_ACT_SET) {
507 pSNMPMIB->querytype = cpu_to_le16(CMD_ACT_SET);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200508 pSNMPMIB->bufsize = cpu_to_le16(sizeof(u16));
David Woodhouse981f1872007-05-25 23:36:54 -0400509 *((__le16 *)(pSNMPMIB->value)) =
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200510 cpu_to_le16((u16) adapter->txretrycount);
511 }
512
513 break;
514 default:
515 break;
516 }
517
Holger Schurig9012b282007-05-25 11:27:16 -0400518 lbs_deb_cmd(
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200519 "SNMP_CMD: command=0x%x, size=0x%x, seqnum=0x%x, result=0x%x\n",
David Woodhouse981f1872007-05-25 23:36:54 -0400520 le16_to_cpu(cmd->command), le16_to_cpu(cmd->size),
521 le16_to_cpu(cmd->seqnum), le16_to_cpu(cmd->result));
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200522
Holger Schurig9012b282007-05-25 11:27:16 -0400523 lbs_deb_cmd(
Holger Schurig8ff12da2007-08-02 11:54:31 -0400524 "SNMP_CMD: action 0x%x, oid 0x%x, oidsize 0x%x, value 0x%x\n",
David Woodhouse981f1872007-05-25 23:36:54 -0400525 le16_to_cpu(pSNMPMIB->querytype), le16_to_cpu(pSNMPMIB->oid),
526 le16_to_cpu(pSNMPMIB->bufsize),
527 le16_to_cpu(*(__le16 *) pSNMPMIB->value));
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200528
Holger Schurig9012b282007-05-25 11:27:16 -0400529 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200530 return 0;
531}
532
Holger Schurig69f90322007-11-23 15:43:44 +0100533static int lbs_cmd_802_11_radio_control(struct lbs_private *priv,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200534 struct cmd_ds_command *cmd,
535 int cmd_action)
536{
Holger Schurig69f90322007-11-23 15:43:44 +0100537 struct lbs_adapter *adapter = priv->adapter;
David Woodhouse981f1872007-05-25 23:36:54 -0400538 struct cmd_ds_802_11_radio_control *pradiocontrol = &cmd->params.radio;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200539
Holger Schurig9012b282007-05-25 11:27:16 -0400540 lbs_deb_enter(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200541
542 cmd->size =
543 cpu_to_le16((sizeof(struct cmd_ds_802_11_radio_control)) +
544 S_DS_GEN);
Dan Williams0aef64d2007-08-02 11:31:18 -0400545 cmd->command = cpu_to_le16(CMD_802_11_RADIO_CONTROL);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200546
547 pradiocontrol->action = cpu_to_le16(cmd_action);
548
549 switch (adapter->preamble) {
Dan Williams0aef64d2007-08-02 11:31:18 -0400550 case CMD_TYPE_SHORT_PREAMBLE:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200551 pradiocontrol->control = cpu_to_le16(SET_SHORT_PREAMBLE);
552 break;
553
Dan Williams0aef64d2007-08-02 11:31:18 -0400554 case CMD_TYPE_LONG_PREAMBLE:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200555 pradiocontrol->control = cpu_to_le16(SET_LONG_PREAMBLE);
556 break;
557
Dan Williams0aef64d2007-08-02 11:31:18 -0400558 case CMD_TYPE_AUTO_PREAMBLE:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200559 default:
560 pradiocontrol->control = cpu_to_le16(SET_AUTO_PREAMBLE);
561 break;
562 }
563
564 if (adapter->radioon)
565 pradiocontrol->control |= cpu_to_le16(TURN_ON_RF);
566 else
567 pradiocontrol->control &= cpu_to_le16(~TURN_ON_RF);
568
Holger Schurig9012b282007-05-25 11:27:16 -0400569 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200570 return 0;
571}
572
Holger Schurig69f90322007-11-23 15:43:44 +0100573static int lbs_cmd_802_11_rf_tx_power(struct lbs_private *priv,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200574 struct cmd_ds_command *cmd,
575 u16 cmd_action, void *pdata_buf)
576{
577
578 struct cmd_ds_802_11_rf_tx_power *prtp = &cmd->params.txp;
579
Holger Schurig9012b282007-05-25 11:27:16 -0400580 lbs_deb_enter(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200581
582 cmd->size =
David Woodhouse981f1872007-05-25 23:36:54 -0400583 cpu_to_le16((sizeof(struct cmd_ds_802_11_rf_tx_power)) + S_DS_GEN);
Dan Williams0aef64d2007-08-02 11:31:18 -0400584 cmd->command = cpu_to_le16(CMD_802_11_RF_TX_POWER);
David Woodhouse981f1872007-05-25 23:36:54 -0400585 prtp->action = cpu_to_le16(cmd_action);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200586
David Woodhouse981f1872007-05-25 23:36:54 -0400587 lbs_deb_cmd("RF_TX_POWER_CMD: size:%d cmd:0x%x Act:%d\n",
588 le16_to_cpu(cmd->size), le16_to_cpu(cmd->command),
589 le16_to_cpu(prtp->action));
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200590
591 switch (cmd_action) {
Dan Williams0aef64d2007-08-02 11:31:18 -0400592 case CMD_ACT_TX_POWER_OPT_GET:
593 prtp->action = cpu_to_le16(CMD_ACT_GET);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200594 prtp->currentlevel = 0;
595 break;
596
Dan Williams0aef64d2007-08-02 11:31:18 -0400597 case CMD_ACT_TX_POWER_OPT_SET_HIGH:
598 prtp->action = cpu_to_le16(CMD_ACT_SET);
599 prtp->currentlevel = cpu_to_le16(CMD_ACT_TX_POWER_INDEX_HIGH);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200600 break;
601
Dan Williams0aef64d2007-08-02 11:31:18 -0400602 case CMD_ACT_TX_POWER_OPT_SET_MID:
603 prtp->action = cpu_to_le16(CMD_ACT_SET);
604 prtp->currentlevel = cpu_to_le16(CMD_ACT_TX_POWER_INDEX_MID);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200605 break;
606
Dan Williams0aef64d2007-08-02 11:31:18 -0400607 case CMD_ACT_TX_POWER_OPT_SET_LOW:
608 prtp->action = cpu_to_le16(CMD_ACT_SET);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200609 prtp->currentlevel = cpu_to_le16(*((u16 *) pdata_buf));
610 break;
611 }
Holger Schurig9012b282007-05-25 11:27:16 -0400612
613 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200614 return 0;
615}
616
Holger Schurig69f90322007-11-23 15:43:44 +0100617static int lbs_cmd_802_11_monitor_mode(struct lbs_private *priv,
Luis Carlos Cobo965f8bbc2007-08-02 13:16:55 -0400618 struct cmd_ds_command *cmd,
619 u16 cmd_action, void *pdata_buf)
620{
621 struct cmd_ds_802_11_monitor_mode *monitor = &cmd->params.monitor;
622
623 cmd->command = cpu_to_le16(CMD_802_11_MONITOR_MODE);
624 cmd->size =
625 cpu_to_le16(sizeof(struct cmd_ds_802_11_monitor_mode) +
626 S_DS_GEN);
627
628 monitor->action = cpu_to_le16(cmd_action);
629 if (cmd_action == CMD_ACT_SET) {
630 monitor->mode =
631 cpu_to_le16((u16) (*(u32 *) pdata_buf));
632 }
633
634 return 0;
635}
636
Holger Schurig69f90322007-11-23 15:43:44 +0100637static int lbs_cmd_802_11_rate_adapt_rateset(struct lbs_private *priv,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200638 struct cmd_ds_command *cmd,
639 u16 cmd_action)
640{
641 struct cmd_ds_802_11_rate_adapt_rateset
642 *rateadapt = &cmd->params.rateset;
Holger Schurig69f90322007-11-23 15:43:44 +0100643 struct lbs_adapter *adapter = priv->adapter;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200644
Holger Schurig8ff12da2007-08-02 11:54:31 -0400645 lbs_deb_enter(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200646 cmd->size =
647 cpu_to_le16(sizeof(struct cmd_ds_802_11_rate_adapt_rateset)
648 + S_DS_GEN);
Dan Williams0aef64d2007-08-02 11:31:18 -0400649 cmd->command = cpu_to_le16(CMD_802_11_RATE_ADAPT_RATESET);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200650
David Woodhouse981f1872007-05-25 23:36:54 -0400651 rateadapt->action = cpu_to_le16(cmd_action);
652 rateadapt->enablehwauto = cpu_to_le16(adapter->enablehwauto);
653 rateadapt->bitmap = cpu_to_le16(adapter->ratebitmap);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200654
Holger Schurig9012b282007-05-25 11:27:16 -0400655 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200656 return 0;
657}
658
Holger Schurig69f90322007-11-23 15:43:44 +0100659static int lbs_cmd_802_11_data_rate(struct lbs_private *priv,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200660 struct cmd_ds_command *cmd,
661 u16 cmd_action)
662{
663 struct cmd_ds_802_11_data_rate *pdatarate = &cmd->params.drate;
Holger Schurig69f90322007-11-23 15:43:44 +0100664 struct lbs_adapter *adapter = priv->adapter;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200665
Holger Schurig9012b282007-05-25 11:27:16 -0400666 lbs_deb_enter(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200667
David Woodhouse981f1872007-05-25 23:36:54 -0400668 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_data_rate) +
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200669 S_DS_GEN);
Dan Williams0aef64d2007-08-02 11:31:18 -0400670 cmd->command = cpu_to_le16(CMD_802_11_DATA_RATE);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200671 memset(pdatarate, 0, sizeof(struct cmd_ds_802_11_data_rate));
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200672 pdatarate->action = cpu_to_le16(cmd_action);
673
Dan Williamsffcae952007-08-02 11:35:46 -0400674 if (cmd_action == CMD_ACT_SET_TX_FIX_RATE) {
Holger Schurig10078322007-11-15 18:05:47 -0500675 pdatarate->rates[0] = lbs_data_rate_to_fw_index(adapter->cur_rate);
Holger Schurig8ff12da2007-08-02 11:54:31 -0400676 lbs_deb_cmd("DATA_RATE: set fixed 0x%02X\n",
Dan Williams8c512762007-08-02 11:40:45 -0400677 adapter->cur_rate);
Dan Williamsffcae952007-08-02 11:35:46 -0400678 } else if (cmd_action == CMD_ACT_SET_TX_AUTO) {
Holger Schurig8ff12da2007-08-02 11:54:31 -0400679 lbs_deb_cmd("DATA_RATE: setting auto\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200680 }
681
Holger Schurig9012b282007-05-25 11:27:16 -0400682 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200683 return 0;
684}
685
Holger Schurig69f90322007-11-23 15:43:44 +0100686static int lbs_cmd_mac_multicast_adr(struct lbs_private *priv,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200687 struct cmd_ds_command *cmd,
688 u16 cmd_action)
689{
690 struct cmd_ds_mac_multicast_adr *pMCastAdr = &cmd->params.madr;
Holger Schurig69f90322007-11-23 15:43:44 +0100691 struct lbs_adapter *adapter = priv->adapter;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200692
Holger Schurig8ff12da2007-08-02 11:54:31 -0400693 lbs_deb_enter(LBS_DEB_CMD);
David Woodhouse981f1872007-05-25 23:36:54 -0400694 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_mac_multicast_adr) +
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200695 S_DS_GEN);
Dan Williams0aef64d2007-08-02 11:31:18 -0400696 cmd->command = cpu_to_le16(CMD_MAC_MULTICAST_ADR);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200697
Holger Schurig8ff12da2007-08-02 11:54:31 -0400698 lbs_deb_cmd("MULTICAST_ADR: setting %d addresses\n", pMCastAdr->nr_of_adrs);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200699 pMCastAdr->action = cpu_to_le16(cmd_action);
700 pMCastAdr->nr_of_adrs =
701 cpu_to_le16((u16) adapter->nr_of_multicastmacaddr);
702 memcpy(pMCastAdr->maclist, adapter->multicastlist,
703 adapter->nr_of_multicastmacaddr * ETH_ALEN);
704
Holger Schurig8ff12da2007-08-02 11:54:31 -0400705 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200706 return 0;
707}
708
Holger Schurig69f90322007-11-23 15:43:44 +0100709static int lbs_cmd_802_11_rf_channel(struct lbs_private *priv,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200710 struct cmd_ds_command *cmd,
711 int option, void *pdata_buf)
712{
713 struct cmd_ds_802_11_rf_channel *rfchan = &cmd->params.rfchannel;
714
Holger Schurig8ff12da2007-08-02 11:54:31 -0400715 lbs_deb_enter(LBS_DEB_CMD);
Dan Williams0aef64d2007-08-02 11:31:18 -0400716 cmd->command = cpu_to_le16(CMD_802_11_RF_CHANNEL);
David Woodhouse981f1872007-05-25 23:36:54 -0400717 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_rf_channel) +
718 S_DS_GEN);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200719
Dan Williams0aef64d2007-08-02 11:31:18 -0400720 if (option == CMD_OPT_802_11_RF_CHANNEL_SET) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200721 rfchan->currentchannel = cpu_to_le16(*((u16 *) pdata_buf));
722 }
723
724 rfchan->action = cpu_to_le16(option);
725
Holger Schurig8ff12da2007-08-02 11:54:31 -0400726 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200727 return 0;
728}
729
Holger Schurig69f90322007-11-23 15:43:44 +0100730static int lbs_cmd_802_11_rssi(struct lbs_private *priv,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200731 struct cmd_ds_command *cmd)
732{
Holger Schurig69f90322007-11-23 15:43:44 +0100733 struct lbs_adapter *adapter = priv->adapter;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200734
Holger Schurig8ff12da2007-08-02 11:54:31 -0400735 lbs_deb_enter(LBS_DEB_CMD);
Dan Williams0aef64d2007-08-02 11:31:18 -0400736 cmd->command = cpu_to_le16(CMD_802_11_RSSI);
David Woodhouse981f1872007-05-25 23:36:54 -0400737 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_rssi) + S_DS_GEN);
Holger Schuriga783f1e2007-08-02 13:08:24 -0400738 cmd->params.rssi.N = cpu_to_le16(DEFAULT_BCN_AVG_FACTOR);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200739
740 /* reset Beacon SNR/NF/RSSI values */
741 adapter->SNR[TYPE_BEACON][TYPE_NOAVG] = 0;
742 adapter->SNR[TYPE_BEACON][TYPE_AVG] = 0;
743 adapter->NF[TYPE_BEACON][TYPE_NOAVG] = 0;
744 adapter->NF[TYPE_BEACON][TYPE_AVG] = 0;
745 adapter->RSSI[TYPE_BEACON][TYPE_NOAVG] = 0;
746 adapter->RSSI[TYPE_BEACON][TYPE_AVG] = 0;
747
Holger Schurig8ff12da2007-08-02 11:54:31 -0400748 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200749 return 0;
750}
751
Holger Schurig69f90322007-11-23 15:43:44 +0100752static int lbs_cmd_reg_access(struct lbs_private *priv,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200753 struct cmd_ds_command *cmdptr,
754 u8 cmd_action, void *pdata_buf)
755{
Holger Schurig10078322007-11-15 18:05:47 -0500756 struct lbs_offset_value *offval;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200757
Holger Schurig9012b282007-05-25 11:27:16 -0400758 lbs_deb_enter(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200759
Holger Schurig10078322007-11-15 18:05:47 -0500760 offval = (struct lbs_offset_value *)pdata_buf;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200761
762 switch (cmdptr->command) {
Dan Williams0aef64d2007-08-02 11:31:18 -0400763 case CMD_MAC_REG_ACCESS:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200764 {
765 struct cmd_ds_mac_reg_access *macreg;
766
767 cmdptr->size =
David Woodhouse981f1872007-05-25 23:36:54 -0400768 cpu_to_le16(sizeof (struct cmd_ds_mac_reg_access)
769 + S_DS_GEN);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200770 macreg =
771 (struct cmd_ds_mac_reg_access *)&cmdptr->params.
772 macreg;
773
774 macreg->action = cpu_to_le16(cmd_action);
775 macreg->offset = cpu_to_le16((u16) offval->offset);
776 macreg->value = cpu_to_le32(offval->value);
777
778 break;
779 }
780
Dan Williams0aef64d2007-08-02 11:31:18 -0400781 case CMD_BBP_REG_ACCESS:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200782 {
783 struct cmd_ds_bbp_reg_access *bbpreg;
784
785 cmdptr->size =
786 cpu_to_le16(sizeof
787 (struct cmd_ds_bbp_reg_access)
788 + S_DS_GEN);
789 bbpreg =
790 (struct cmd_ds_bbp_reg_access *)&cmdptr->params.
791 bbpreg;
792
793 bbpreg->action = cpu_to_le16(cmd_action);
794 bbpreg->offset = cpu_to_le16((u16) offval->offset);
795 bbpreg->value = (u8) offval->value;
796
797 break;
798 }
799
Dan Williams0aef64d2007-08-02 11:31:18 -0400800 case CMD_RF_REG_ACCESS:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200801 {
802 struct cmd_ds_rf_reg_access *rfreg;
803
804 cmdptr->size =
805 cpu_to_le16(sizeof
806 (struct cmd_ds_rf_reg_access) +
807 S_DS_GEN);
808 rfreg =
809 (struct cmd_ds_rf_reg_access *)&cmdptr->params.
810 rfreg;
811
812 rfreg->action = cpu_to_le16(cmd_action);
813 rfreg->offset = cpu_to_le16((u16) offval->offset);
814 rfreg->value = (u8) offval->value;
815
816 break;
817 }
818
819 default:
820 break;
821 }
822
Holger Schurig9012b282007-05-25 11:27:16 -0400823 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200824 return 0;
825}
826
Holger Schurig69f90322007-11-23 15:43:44 +0100827static int lbs_cmd_802_11_mac_address(struct lbs_private *priv,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200828 struct cmd_ds_command *cmd,
829 u16 cmd_action)
830{
Holger Schurig69f90322007-11-23 15:43:44 +0100831 struct lbs_adapter *adapter = priv->adapter;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200832
Holger Schurig8ff12da2007-08-02 11:54:31 -0400833 lbs_deb_enter(LBS_DEB_CMD);
Dan Williams0aef64d2007-08-02 11:31:18 -0400834 cmd->command = cpu_to_le16(CMD_802_11_MAC_ADDRESS);
David Woodhouse981f1872007-05-25 23:36:54 -0400835 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_mac_address) +
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200836 S_DS_GEN);
837 cmd->result = 0;
838
839 cmd->params.macadd.action = cpu_to_le16(cmd_action);
840
Dan Williams0aef64d2007-08-02 11:31:18 -0400841 if (cmd_action == CMD_ACT_SET) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200842 memcpy(cmd->params.macadd.macadd,
843 adapter->current_addr, ETH_ALEN);
Holger Schurigece56192007-08-02 11:53:06 -0400844 lbs_deb_hex(LBS_DEB_CMD, "SET_CMD: MAC addr", adapter->current_addr, 6);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200845 }
846
Holger Schurig8ff12da2007-08-02 11:54:31 -0400847 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200848 return 0;
849}
850
Holger Schurig69f90322007-11-23 15:43:44 +0100851static int lbs_cmd_802_11_eeprom_access(struct lbs_private *priv,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200852 struct cmd_ds_command *cmd,
853 int cmd_action, void *pdata_buf)
854{
Holger Schurig10078322007-11-15 18:05:47 -0500855 struct lbs_ioctl_regrdwr *ea = pdata_buf;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200856
Holger Schurig9012b282007-05-25 11:27:16 -0400857 lbs_deb_enter(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200858
Dan Williams0aef64d2007-08-02 11:31:18 -0400859 cmd->command = cpu_to_le16(CMD_802_11_EEPROM_ACCESS);
David Woodhouse981f1872007-05-25 23:36:54 -0400860 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_eeprom_access) +
861 S_DS_GEN);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200862 cmd->result = 0;
863
864 cmd->params.rdeeprom.action = cpu_to_le16(ea->action);
865 cmd->params.rdeeprom.offset = cpu_to_le16(ea->offset);
866 cmd->params.rdeeprom.bytecount = cpu_to_le16(ea->NOB);
867 cmd->params.rdeeprom.value = 0;
868
Holger Schurig8ff12da2007-08-02 11:54:31 -0400869 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200870 return 0;
871}
872
Holger Schurig69f90322007-11-23 15:43:44 +0100873static int lbs_cmd_bt_access(struct lbs_private *priv,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200874 struct cmd_ds_command *cmd,
875 u16 cmd_action, void *pdata_buf)
876{
877 struct cmd_ds_bt_access *bt_access = &cmd->params.bt;
Holger Schurig8ff12da2007-08-02 11:54:31 -0400878 lbs_deb_enter_args(LBS_DEB_CMD, "action %d", cmd_action);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200879
Dan Williams0aef64d2007-08-02 11:31:18 -0400880 cmd->command = cpu_to_le16(CMD_BT_ACCESS);
David Woodhouse981f1872007-05-25 23:36:54 -0400881 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_bt_access) + S_DS_GEN);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200882 cmd->result = 0;
883 bt_access->action = cpu_to_le16(cmd_action);
884
885 switch (cmd_action) {
Dan Williams0aef64d2007-08-02 11:31:18 -0400886 case CMD_ACT_BT_ACCESS_ADD:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200887 memcpy(bt_access->addr1, pdata_buf, 2 * ETH_ALEN);
Holger Schurigece56192007-08-02 11:53:06 -0400888 lbs_deb_hex(LBS_DEB_MESH, "BT_ADD: blinded MAC addr", bt_access->addr1, 6);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200889 break;
Dan Williams0aef64d2007-08-02 11:31:18 -0400890 case CMD_ACT_BT_ACCESS_DEL:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200891 memcpy(bt_access->addr1, pdata_buf, 1 * ETH_ALEN);
Holger Schurigece56192007-08-02 11:53:06 -0400892 lbs_deb_hex(LBS_DEB_MESH, "BT_DEL: blinded MAC addr", bt_access->addr1, 6);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200893 break;
Dan Williams0aef64d2007-08-02 11:31:18 -0400894 case CMD_ACT_BT_ACCESS_LIST:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200895 bt_access->id = cpu_to_le32(*(u32 *) pdata_buf);
896 break;
Dan Williams0aef64d2007-08-02 11:31:18 -0400897 case CMD_ACT_BT_ACCESS_RESET:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200898 break;
Dan Williams0aef64d2007-08-02 11:31:18 -0400899 case CMD_ACT_BT_ACCESS_SET_INVERT:
Luis Carlos Cobo90e8eaf2007-05-25 13:53:26 -0400900 bt_access->id = cpu_to_le32(*(u32 *) pdata_buf);
901 break;
Dan Williams0aef64d2007-08-02 11:31:18 -0400902 case CMD_ACT_BT_ACCESS_GET_INVERT:
Luis Carlos Cobo90e8eaf2007-05-25 13:53:26 -0400903 break;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200904 default:
905 break;
906 }
Holger Schurig8ff12da2007-08-02 11:54:31 -0400907 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200908 return 0;
909}
910
Holger Schurig69f90322007-11-23 15:43:44 +0100911static int lbs_cmd_fwt_access(struct lbs_private *priv,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200912 struct cmd_ds_command *cmd,
913 u16 cmd_action, void *pdata_buf)
914{
915 struct cmd_ds_fwt_access *fwt_access = &cmd->params.fwt;
Holger Schurig8ff12da2007-08-02 11:54:31 -0400916 lbs_deb_enter_args(LBS_DEB_CMD, "action %d", cmd_action);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200917
Dan Williams0aef64d2007-08-02 11:31:18 -0400918 cmd->command = cpu_to_le16(CMD_FWT_ACCESS);
David Woodhouse981f1872007-05-25 23:36:54 -0400919 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_fwt_access) + S_DS_GEN);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200920 cmd->result = 0;
921
922 if (pdata_buf)
923 memcpy(fwt_access, pdata_buf, sizeof(*fwt_access));
924 else
925 memset(fwt_access, 0, sizeof(*fwt_access));
926
927 fwt_access->action = cpu_to_le16(cmd_action);
928
Holger Schurig8ff12da2007-08-02 11:54:31 -0400929 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200930 return 0;
931}
932
Holger Schurig69f90322007-11-23 15:43:44 +0100933static int lbs_cmd_mesh_access(struct lbs_private *priv,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200934 struct cmd_ds_command *cmd,
935 u16 cmd_action, void *pdata_buf)
936{
937 struct cmd_ds_mesh_access *mesh_access = &cmd->params.mesh;
Holger Schurig8ff12da2007-08-02 11:54:31 -0400938 lbs_deb_enter_args(LBS_DEB_CMD, "action %d", cmd_action);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200939
Dan Williams0aef64d2007-08-02 11:31:18 -0400940 cmd->command = cpu_to_le16(CMD_MESH_ACCESS);
David Woodhouse981f1872007-05-25 23:36:54 -0400941 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_mesh_access) + S_DS_GEN);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200942 cmd->result = 0;
943
944 if (pdata_buf)
945 memcpy(mesh_access, pdata_buf, sizeof(*mesh_access));
946 else
947 memset(mesh_access, 0, sizeof(*mesh_access));
948
949 mesh_access->action = cpu_to_le16(cmd_action);
950
Holger Schurig8ff12da2007-08-02 11:54:31 -0400951 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200952 return 0;
953}
954
Brajesh Dave96287ac2007-11-20 17:44:28 -0500955static int lbs_cmd_bcn_ctrl(struct lbs_private * priv,
956 struct cmd_ds_command *cmd,
957 u16 cmd_action)
958{
959 struct cmd_ds_802_11_beacon_control
960 *bcn_ctrl = &cmd->params.bcn_ctrl;
961 struct lbs_adapter *adapter = priv->adapter;
962
963 lbs_deb_enter(LBS_DEB_CMD);
964 cmd->size =
965 cpu_to_le16(sizeof(struct cmd_ds_802_11_beacon_control)
966 + S_DS_GEN);
967 cmd->command = cpu_to_le16(CMD_802_11_BEACON_CTRL);
968
969 bcn_ctrl->action = cpu_to_le16(cmd_action);
970 bcn_ctrl->beacon_enable = cpu_to_le16(adapter->beacon_enable);
971 bcn_ctrl->beacon_period = cpu_to_le16(adapter->beacon_period);
972
973 lbs_deb_leave(LBS_DEB_CMD);
974 return 0;
975}
976
Holger Schurig69f90322007-11-23 15:43:44 +0100977static int lbs_cmd_set_boot2_ver(struct lbs_private *priv,
Luis Carlos Cobo63f00232007-08-02 13:19:24 -0400978 struct cmd_ds_command *cmd,
979 u16 cmd_action, void *pdata_buf)
980{
981 struct cmd_ds_set_boot2_ver *boot2_ver = &cmd->params.boot2_ver;
982 cmd->command = cpu_to_le16(CMD_SET_BOOT2_VER);
983 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_set_boot2_ver) + S_DS_GEN);
984 boot2_ver->version = priv->boot2_version;
985 return 0;
986}
987
Marcelo Tosatti29f5f2a2007-10-30 10:52:46 -0400988/*
Holger Schurig10078322007-11-15 18:05:47 -0500989 * Note: NEVER use lbs_queue_cmd() with addtail==0 other than for
Marcelo Tosatti29f5f2a2007-10-30 10:52:46 -0400990 * the command timer, because it does not account for queued commands.
991 */
Holger Schurig69f90322007-11-23 15:43:44 +0100992void lbs_queue_cmd(struct lbs_adapter *adapter,
993 struct cmd_ctrl_node *cmdnode,
994 u8 addtail)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200995{
996 unsigned long flags;
997 struct cmd_ds_command *cmdptr;
998
Holger Schurig8ff12da2007-08-02 11:54:31 -0400999 lbs_deb_enter(LBS_DEB_HOST);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001000
1001 if (!cmdnode) {
Holger Schurig8ff12da2007-08-02 11:54:31 -04001002 lbs_deb_host("QUEUE_CMD: cmdnode is NULL\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001003 goto done;
1004 }
1005
1006 cmdptr = (struct cmd_ds_command *)cmdnode->bufvirtualaddr;
1007 if (!cmdptr) {
Holger Schurig8ff12da2007-08-02 11:54:31 -04001008 lbs_deb_host("QUEUE_CMD: cmdptr is NULL\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001009 goto done;
1010 }
1011
1012 /* Exit_PS command needs to be queued in the header always. */
Dan Williams0aef64d2007-08-02 11:31:18 -04001013 if (cmdptr->command == CMD_802_11_PS_MODE) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001014 struct cmd_ds_802_11_ps_mode *psm = &cmdptr->params.psmode;
Dan Williams0aef64d2007-08-02 11:31:18 -04001015 if (psm->action == cpu_to_le16(CMD_SUBCMD_EXIT_PS)) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001016 if (adapter->psstate != PS_STATE_FULL_POWER)
1017 addtail = 0;
1018 }
1019 }
1020
1021 spin_lock_irqsave(&adapter->driver_lock, flags);
1022
Marcelo Tosatti29f5f2a2007-10-30 10:52:46 -04001023 if (addtail) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001024 list_add_tail((struct list_head *)cmdnode,
1025 &adapter->cmdpendingq);
Marcelo Tosatti29f5f2a2007-10-30 10:52:46 -04001026 adapter->nr_cmd_pending++;
1027 } else
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001028 list_add((struct list_head *)cmdnode, &adapter->cmdpendingq);
1029
1030 spin_unlock_irqrestore(&adapter->driver_lock, flags);
1031
Holger Schurig8ff12da2007-08-02 11:54:31 -04001032 lbs_deb_host("QUEUE_CMD: inserted command 0x%04x into cmdpendingq\n",
David Woodhouse981f1872007-05-25 23:36:54 -04001033 le16_to_cpu(((struct cmd_ds_gen*)cmdnode->bufvirtualaddr)->command));
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001034
1035done:
Holger Schurig8ff12da2007-08-02 11:54:31 -04001036 lbs_deb_leave(LBS_DEB_HOST);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001037}
1038
1039/*
1040 * TODO: Fix the issue when DownloadcommandToStation is being called the
Holger Schurig8ff12da2007-08-02 11:54:31 -04001041 * second time when the command times out. All the cmdptr->xxx are in little
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001042 * endian and therefore all the comparissions will fail.
1043 * For now - we are not performing the endian conversion the second time - but
1044 * for PS and DEEP_SLEEP we need to worry
1045 */
Holger Schurig69f90322007-11-23 15:43:44 +01001046static int DownloadcommandToStation(struct lbs_private *priv,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001047 struct cmd_ctrl_node *cmdnode)
1048{
1049 unsigned long flags;
1050 struct cmd_ds_command *cmdptr;
Holger Schurig69f90322007-11-23 15:43:44 +01001051 struct lbs_adapter *adapter = priv->adapter;
Eugene Teob031ac12007-08-02 13:18:07 -04001052 int ret = -1;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001053 u16 cmdsize;
1054 u16 command;
1055
Holger Schurig8ff12da2007-08-02 11:54:31 -04001056 lbs_deb_enter(LBS_DEB_HOST);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001057
1058 if (!adapter || !cmdnode) {
Holger Schurig8ff12da2007-08-02 11:54:31 -04001059 lbs_deb_host("DNLD_CMD: adapter or cmdmode is NULL\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001060 goto done;
1061 }
1062
1063 cmdptr = (struct cmd_ds_command *)cmdnode->bufvirtualaddr;
1064
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001065 spin_lock_irqsave(&adapter->driver_lock, flags);
1066 if (!cmdptr || !cmdptr->size) {
Holger Schurig8ff12da2007-08-02 11:54:31 -04001067 lbs_deb_host("DNLD_CMD: cmdptr is NULL or zero\n");
Holger Schurig10078322007-11-15 18:05:47 -05001068 __lbs_cleanup_and_insert_cmd(priv, cmdnode);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001069 spin_unlock_irqrestore(&adapter->driver_lock, flags);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001070 goto done;
1071 }
1072
1073 adapter->cur_cmd = cmdnode;
1074 adapter->cur_cmd_retcode = 0;
1075 spin_unlock_irqrestore(&adapter->driver_lock, flags);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001076
1077 cmdsize = cmdptr->size;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001078 command = cpu_to_le16(cmdptr->command);
1079
Holger Schurig8ff12da2007-08-02 11:54:31 -04001080 lbs_deb_host("DNLD_CMD: command 0x%04x, size %d, jiffies %lu\n",
1081 command, le16_to_cpu(cmdptr->size), jiffies);
1082 lbs_deb_hex(LBS_DEB_HOST, "DNLD_CMD", cmdnode->bufvirtualaddr, cmdsize);
1083
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001084 cmdnode->cmdwaitqwoken = 0;
1085 cmdsize = cpu_to_le16(cmdsize);
1086
Holger Schurig208fdd22007-05-25 12:17:06 -04001087 ret = priv->hw_host_to_card(priv, MVMS_CMD, (u8 *) cmdptr, cmdsize);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001088
1089 if (ret != 0) {
Holger Schurig8ff12da2007-08-02 11:54:31 -04001090 lbs_deb_host("DNLD_CMD: hw_host_to_card failed\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001091 spin_lock_irqsave(&adapter->driver_lock, flags);
Pierre Ossman794760f2007-08-20 12:24:42 -04001092 adapter->cur_cmd_retcode = ret;
Holger Schurig10078322007-11-15 18:05:47 -05001093 __lbs_cleanup_and_insert_cmd(priv, adapter->cur_cmd);
Pierre Ossman794760f2007-08-20 12:24:42 -04001094 adapter->nr_cmd_pending--;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001095 adapter->cur_cmd = NULL;
1096 spin_unlock_irqrestore(&adapter->driver_lock, flags);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001097 goto done;
1098 }
1099
Holger Schurig8ff12da2007-08-02 11:54:31 -04001100 lbs_deb_cmd("DNLD_CMD: sent command 0x%04x, jiffies %lu\n", command, jiffies);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001101
1102 /* Setup the timer after transmit command */
Dan Williams0aef64d2007-08-02 11:31:18 -04001103 if (command == CMD_802_11_SCAN || command == CMD_802_11_AUTHENTICATE
1104 || command == CMD_802_11_ASSOCIATE)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001105 mod_timer(&adapter->command_timer, jiffies + (10*HZ));
1106 else
1107 mod_timer(&adapter->command_timer, jiffies + (5*HZ));
1108
1109 ret = 0;
1110
Holger Schurig9012b282007-05-25 11:27:16 -04001111done:
Holger Schurig8ff12da2007-08-02 11:54:31 -04001112 lbs_deb_leave_args(LBS_DEB_HOST, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001113 return ret;
1114}
1115
Holger Schurig69f90322007-11-23 15:43:44 +01001116static int lbs_cmd_mac_control(struct lbs_private *priv,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001117 struct cmd_ds_command *cmd)
1118{
1119 struct cmd_ds_mac_control *mac = &cmd->params.macctrl;
1120
Holger Schurig9012b282007-05-25 11:27:16 -04001121 lbs_deb_enter(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001122
Dan Williams0aef64d2007-08-02 11:31:18 -04001123 cmd->command = cpu_to_le16(CMD_MAC_CONTROL);
David Woodhouse981f1872007-05-25 23:36:54 -04001124 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_mac_control) + S_DS_GEN);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001125 mac->action = cpu_to_le16(priv->adapter->currentpacketfilter);
1126
Holger Schurig8ff12da2007-08-02 11:54:31 -04001127 lbs_deb_cmd("MAC_CONTROL: action 0x%x, size %d\n",
David Woodhouse981f1872007-05-25 23:36:54 -04001128 le16_to_cpu(mac->action), le16_to_cpu(cmd->size));
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001129
Holger Schurig9012b282007-05-25 11:27:16 -04001130 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001131 return 0;
1132}
1133
1134/**
1135 * This function inserts command node to cmdfreeq
1136 * after cleans it. Requires adapter->driver_lock held.
1137 */
Holger Schurig69f90322007-11-23 15:43:44 +01001138void __lbs_cleanup_and_insert_cmd(struct lbs_private *priv,
1139 struct cmd_ctrl_node *ptempcmd)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001140{
Holger Schurig69f90322007-11-23 15:43:44 +01001141 struct lbs_adapter *adapter = priv->adapter;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001142
1143 if (!ptempcmd)
Holger Schurig8ff12da2007-08-02 11:54:31 -04001144 return;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001145
1146 cleanup_cmdnode(ptempcmd);
1147 list_add_tail((struct list_head *)ptempcmd, &adapter->cmdfreeq);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001148}
1149
Holger Schurig69f90322007-11-23 15:43:44 +01001150static void lbs_cleanup_and_insert_cmd(struct lbs_private *priv,
1151 struct cmd_ctrl_node *ptempcmd)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001152{
1153 unsigned long flags;
1154
1155 spin_lock_irqsave(&priv->adapter->driver_lock, flags);
Holger Schurig10078322007-11-15 18:05:47 -05001156 __lbs_cleanup_and_insert_cmd(priv, ptempcmd);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001157 spin_unlock_irqrestore(&priv->adapter->driver_lock, flags);
1158}
1159
Holger Schurig69f90322007-11-23 15:43:44 +01001160int lbs_set_radio_control(struct lbs_private *priv)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001161{
1162 int ret = 0;
1163
Holger Schurig9012b282007-05-25 11:27:16 -04001164 lbs_deb_enter(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001165
Holger Schurig10078322007-11-15 18:05:47 -05001166 ret = lbs_prepare_and_send_command(priv,
Dan Williams0aef64d2007-08-02 11:31:18 -04001167 CMD_802_11_RADIO_CONTROL,
1168 CMD_ACT_SET,
1169 CMD_OPTION_WAITFORRSP, 0, NULL);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001170
Holger Schurig8ff12da2007-08-02 11:54:31 -04001171 lbs_deb_cmd("RADIO_SET: radio %d, preamble %d\n",
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001172 priv->adapter->radioon, priv->adapter->preamble);
1173
Holger Schurig9012b282007-05-25 11:27:16 -04001174 lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001175 return ret;
1176}
1177
Holger Schurig69f90322007-11-23 15:43:44 +01001178int lbs_set_mac_packet_filter(struct lbs_private *priv)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001179{
1180 int ret = 0;
1181
Holger Schurig9012b282007-05-25 11:27:16 -04001182 lbs_deb_enter(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001183
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001184 /* Send MAC control command to station */
Holger Schurig10078322007-11-15 18:05:47 -05001185 ret = lbs_prepare_and_send_command(priv,
Dan Williams0aef64d2007-08-02 11:31:18 -04001186 CMD_MAC_CONTROL, 0, 0, 0, NULL);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001187
Holger Schurig9012b282007-05-25 11:27:16 -04001188 lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001189 return ret;
1190}
1191
1192/**
1193 * @brief This function prepare the command before send to firmware.
1194 *
Holger Schurig69f90322007-11-23 15:43:44 +01001195 * @param priv A pointer to struct lbs_private structure
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001196 * @param cmd_no command number
1197 * @param cmd_action command action: GET or SET
1198 * @param wait_option wait option: wait response or not
1199 * @param cmd_oid cmd oid: treated as sub command
1200 * @param pdata_buf A pointer to informaion buffer
1201 * @return 0 or -1
1202 */
Holger Schurig69f90322007-11-23 15:43:44 +01001203int lbs_prepare_and_send_command(struct lbs_private *priv,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001204 u16 cmd_no,
1205 u16 cmd_action,
1206 u16 wait_option, u32 cmd_oid, void *pdata_buf)
1207{
1208 int ret = 0;
Holger Schurig69f90322007-11-23 15:43:44 +01001209 struct lbs_adapter *adapter = priv->adapter;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001210 struct cmd_ctrl_node *cmdnode;
1211 struct cmd_ds_command *cmdptr;
1212 unsigned long flags;
1213
Holger Schurig8ff12da2007-08-02 11:54:31 -04001214 lbs_deb_enter(LBS_DEB_HOST);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001215
1216 if (!adapter) {
Holger Schurig8ff12da2007-08-02 11:54:31 -04001217 lbs_deb_host("PREP_CMD: adapter is NULL\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001218 ret = -1;
1219 goto done;
1220 }
1221
1222 if (adapter->surpriseremoved) {
Holger Schurig8ff12da2007-08-02 11:54:31 -04001223 lbs_deb_host("PREP_CMD: card removed\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001224 ret = -1;
1225 goto done;
1226 }
1227
Holger Schurig0d61d042007-12-05 17:58:06 +01001228 cmdnode = lbs_get_cmd_ctrl_node(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001229
1230 if (cmdnode == NULL) {
Holger Schurig8ff12da2007-08-02 11:54:31 -04001231 lbs_deb_host("PREP_CMD: cmdnode is NULL\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001232
1233 /* Wake up main thread to execute next command */
Dan Williamsfe336152007-08-02 11:32:25 -04001234 wake_up_interruptible(&priv->waitq);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001235 ret = -1;
1236 goto done;
1237 }
1238
David Woodhousef5ece8f2007-12-01 15:15:41 +00001239 lbs_set_cmd_ctrl_node(priv, cmdnode, wait_option, pdata_buf);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001240
1241 cmdptr = (struct cmd_ds_command *)cmdnode->bufvirtualaddr;
1242
Holger Schurig8ff12da2007-08-02 11:54:31 -04001243 lbs_deb_host("PREP_CMD: command 0x%04x\n", cmd_no);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001244
1245 if (!cmdptr) {
Holger Schurig8ff12da2007-08-02 11:54:31 -04001246 lbs_deb_host("PREP_CMD: cmdptr is NULL\n");
Holger Schurig10078322007-11-15 18:05:47 -05001247 lbs_cleanup_and_insert_cmd(priv, cmdnode);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001248 ret = -1;
1249 goto done;
1250 }
1251
1252 /* Set sequence number, command and INT option */
1253 adapter->seqnum++;
1254 cmdptr->seqnum = cpu_to_le16(adapter->seqnum);
1255
David Woodhouse981f1872007-05-25 23:36:54 -04001256 cmdptr->command = cpu_to_le16(cmd_no);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001257 cmdptr->result = 0;
1258
1259 switch (cmd_no) {
Dan Williams0aef64d2007-08-02 11:31:18 -04001260 case CMD_GET_HW_SPEC:
Holger Schurig10078322007-11-15 18:05:47 -05001261 ret = lbs_cmd_hw_spec(priv, cmdptr);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001262 break;
Dan Williams0aef64d2007-08-02 11:31:18 -04001263 case CMD_802_11_PS_MODE:
Holger Schurig10078322007-11-15 18:05:47 -05001264 ret = lbs_cmd_802_11_ps_mode(priv, cmdptr, cmd_action);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001265 break;
1266
Dan Williams0aef64d2007-08-02 11:31:18 -04001267 case CMD_802_11_SCAN:
Holger Schurig10078322007-11-15 18:05:47 -05001268 ret = lbs_cmd_80211_scan(priv, cmdptr, pdata_buf);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001269 break;
1270
Dan Williams0aef64d2007-08-02 11:31:18 -04001271 case CMD_MAC_CONTROL:
Holger Schurig10078322007-11-15 18:05:47 -05001272 ret = lbs_cmd_mac_control(priv, cmdptr);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001273 break;
1274
Dan Williams0aef64d2007-08-02 11:31:18 -04001275 case CMD_802_11_ASSOCIATE:
1276 case CMD_802_11_REASSOCIATE:
Holger Schurig10078322007-11-15 18:05:47 -05001277 ret = lbs_cmd_80211_associate(priv, cmdptr, pdata_buf);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001278 break;
1279
Dan Williams0aef64d2007-08-02 11:31:18 -04001280 case CMD_802_11_DEAUTHENTICATE:
Holger Schurig10078322007-11-15 18:05:47 -05001281 ret = lbs_cmd_80211_deauthenticate(priv, cmdptr);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001282 break;
1283
Dan Williams0aef64d2007-08-02 11:31:18 -04001284 case CMD_802_11_SET_WEP:
Holger Schurig10078322007-11-15 18:05:47 -05001285 ret = lbs_cmd_802_11_set_wep(priv, cmdptr, cmd_action, pdata_buf);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001286 break;
1287
Dan Williams0aef64d2007-08-02 11:31:18 -04001288 case CMD_802_11_AD_HOC_START:
Holger Schurig10078322007-11-15 18:05:47 -05001289 ret = lbs_cmd_80211_ad_hoc_start(priv, cmdptr, pdata_buf);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001290 break;
Dan Williams0aef64d2007-08-02 11:31:18 -04001291 case CMD_CODE_DNLD:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001292 break;
1293
Dan Williams0aef64d2007-08-02 11:31:18 -04001294 case CMD_802_11_RESET:
Holger Schurig10078322007-11-15 18:05:47 -05001295 ret = lbs_cmd_802_11_reset(priv, cmdptr, cmd_action);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001296 break;
1297
Dan Williams0aef64d2007-08-02 11:31:18 -04001298 case CMD_802_11_GET_LOG:
Holger Schurig10078322007-11-15 18:05:47 -05001299 ret = lbs_cmd_802_11_get_log(priv, cmdptr);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001300 break;
1301
Dan Williams0aef64d2007-08-02 11:31:18 -04001302 case CMD_802_11_AUTHENTICATE:
Holger Schurig10078322007-11-15 18:05:47 -05001303 ret = lbs_cmd_80211_authenticate(priv, cmdptr, pdata_buf);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001304 break;
1305
Dan Williams0aef64d2007-08-02 11:31:18 -04001306 case CMD_802_11_GET_STAT:
Holger Schurig10078322007-11-15 18:05:47 -05001307 ret = lbs_cmd_802_11_get_stat(priv, cmdptr);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001308 break;
1309
Dan Williams0aef64d2007-08-02 11:31:18 -04001310 case CMD_802_11_SNMP_MIB:
Holger Schurig10078322007-11-15 18:05:47 -05001311 ret = lbs_cmd_802_11_snmp_mib(priv, cmdptr,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001312 cmd_action, cmd_oid, pdata_buf);
1313 break;
1314
Dan Williams0aef64d2007-08-02 11:31:18 -04001315 case CMD_MAC_REG_ACCESS:
1316 case CMD_BBP_REG_ACCESS:
1317 case CMD_RF_REG_ACCESS:
Holger Schurig10078322007-11-15 18:05:47 -05001318 ret = lbs_cmd_reg_access(priv, cmdptr, cmd_action, pdata_buf);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001319 break;
1320
Dan Williams0aef64d2007-08-02 11:31:18 -04001321 case CMD_802_11_RF_CHANNEL:
Holger Schurig10078322007-11-15 18:05:47 -05001322 ret = lbs_cmd_802_11_rf_channel(priv, cmdptr,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001323 cmd_action, pdata_buf);
1324 break;
1325
Dan Williams0aef64d2007-08-02 11:31:18 -04001326 case CMD_802_11_RF_TX_POWER:
Holger Schurig10078322007-11-15 18:05:47 -05001327 ret = lbs_cmd_802_11_rf_tx_power(priv, cmdptr,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001328 cmd_action, pdata_buf);
1329 break;
1330
Dan Williams0aef64d2007-08-02 11:31:18 -04001331 case CMD_802_11_RADIO_CONTROL:
Holger Schurig10078322007-11-15 18:05:47 -05001332 ret = lbs_cmd_802_11_radio_control(priv, cmdptr, cmd_action);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001333 break;
1334
Dan Williams0aef64d2007-08-02 11:31:18 -04001335 case CMD_802_11_DATA_RATE:
Holger Schurig10078322007-11-15 18:05:47 -05001336 ret = lbs_cmd_802_11_data_rate(priv, cmdptr, cmd_action);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001337 break;
Dan Williams0aef64d2007-08-02 11:31:18 -04001338 case CMD_802_11_RATE_ADAPT_RATESET:
Holger Schurig10078322007-11-15 18:05:47 -05001339 ret = lbs_cmd_802_11_rate_adapt_rateset(priv,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001340 cmdptr, cmd_action);
1341 break;
1342
Dan Williams0aef64d2007-08-02 11:31:18 -04001343 case CMD_MAC_MULTICAST_ADR:
Holger Schurig10078322007-11-15 18:05:47 -05001344 ret = lbs_cmd_mac_multicast_adr(priv, cmdptr, cmd_action);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001345 break;
1346
Luis Carlos Cobo965f8bbc2007-08-02 13:16:55 -04001347 case CMD_802_11_MONITOR_MODE:
Holger Schurig10078322007-11-15 18:05:47 -05001348 ret = lbs_cmd_802_11_monitor_mode(priv, cmdptr,
Luis Carlos Cobo965f8bbc2007-08-02 13:16:55 -04001349 cmd_action, pdata_buf);
1350 break;
1351
Dan Williams0aef64d2007-08-02 11:31:18 -04001352 case CMD_802_11_AD_HOC_JOIN:
Holger Schurig10078322007-11-15 18:05:47 -05001353 ret = lbs_cmd_80211_ad_hoc_join(priv, cmdptr, pdata_buf);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001354 break;
1355
Dan Williams0aef64d2007-08-02 11:31:18 -04001356 case CMD_802_11_RSSI:
Holger Schurig10078322007-11-15 18:05:47 -05001357 ret = lbs_cmd_802_11_rssi(priv, cmdptr);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001358 break;
1359
Dan Williams0aef64d2007-08-02 11:31:18 -04001360 case CMD_802_11_AD_HOC_STOP:
Holger Schurig10078322007-11-15 18:05:47 -05001361 ret = lbs_cmd_80211_ad_hoc_stop(priv, cmdptr);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001362 break;
1363
Dan Williams0aef64d2007-08-02 11:31:18 -04001364 case CMD_802_11_ENABLE_RSN:
Holger Schurig10078322007-11-15 18:05:47 -05001365 ret = lbs_cmd_802_11_enable_rsn(priv, cmdptr, cmd_action,
Dan Williams90a42212007-05-25 23:01:24 -04001366 pdata_buf);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001367 break;
1368
Dan Williams0aef64d2007-08-02 11:31:18 -04001369 case CMD_802_11_KEY_MATERIAL:
Holger Schurig10078322007-11-15 18:05:47 -05001370 ret = lbs_cmd_802_11_key_material(priv, cmdptr, cmd_action,
Dan Williams90a42212007-05-25 23:01:24 -04001371 cmd_oid, pdata_buf);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001372 break;
1373
Dan Williams0aef64d2007-08-02 11:31:18 -04001374 case CMD_802_11_PAIRWISE_TSC:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001375 break;
Dan Williams0aef64d2007-08-02 11:31:18 -04001376 case CMD_802_11_GROUP_TSC:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001377 break;
1378
Dan Williams0aef64d2007-08-02 11:31:18 -04001379 case CMD_802_11_MAC_ADDRESS:
Holger Schurig10078322007-11-15 18:05:47 -05001380 ret = lbs_cmd_802_11_mac_address(priv, cmdptr, cmd_action);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001381 break;
1382
Dan Williams0aef64d2007-08-02 11:31:18 -04001383 case CMD_802_11_EEPROM_ACCESS:
Holger Schurig10078322007-11-15 18:05:47 -05001384 ret = lbs_cmd_802_11_eeprom_access(priv, cmdptr,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001385 cmd_action, pdata_buf);
1386 break;
1387
Dan Williams0aef64d2007-08-02 11:31:18 -04001388 case CMD_802_11_SET_AFC:
1389 case CMD_802_11_GET_AFC:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001390
1391 cmdptr->command = cpu_to_le16(cmd_no);
David Woodhouse981f1872007-05-25 23:36:54 -04001392 cmdptr->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_afc) +
1393 S_DS_GEN);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001394
1395 memmove(&cmdptr->params.afc,
1396 pdata_buf, sizeof(struct cmd_ds_802_11_afc));
1397
1398 ret = 0;
1399 goto done;
1400
Dan Williams0aef64d2007-08-02 11:31:18 -04001401 case CMD_802_11D_DOMAIN_INFO:
Holger Schurig10078322007-11-15 18:05:47 -05001402 ret = lbs_cmd_802_11d_domain_info(priv, cmdptr,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001403 cmd_no, cmd_action);
1404 break;
1405
Dan Williams0aef64d2007-08-02 11:31:18 -04001406 case CMD_802_11_SLEEP_PARAMS:
Holger Schurig10078322007-11-15 18:05:47 -05001407 ret = lbs_cmd_802_11_sleep_params(priv, cmdptr, cmd_action);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001408 break;
Dan Williams0aef64d2007-08-02 11:31:18 -04001409 case CMD_802_11_INACTIVITY_TIMEOUT:
Holger Schurig10078322007-11-15 18:05:47 -05001410 ret = lbs_cmd_802_11_inactivity_timeout(priv, cmdptr,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001411 cmd_action, pdata_buf);
David Woodhousef5ece8f2007-12-01 15:15:41 +00001412 lbs_set_cmd_ctrl_node(priv, cmdnode, 0, pdata_buf);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001413 break;
1414
Dan Williams0aef64d2007-08-02 11:31:18 -04001415 case CMD_802_11_TPC_CFG:
1416 cmdptr->command = cpu_to_le16(CMD_802_11_TPC_CFG);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001417 cmdptr->size =
1418 cpu_to_le16(sizeof(struct cmd_ds_802_11_tpc_cfg) +
1419 S_DS_GEN);
1420
1421 memmove(&cmdptr->params.tpccfg,
1422 pdata_buf, sizeof(struct cmd_ds_802_11_tpc_cfg));
1423
1424 ret = 0;
1425 break;
Dan Williams0aef64d2007-08-02 11:31:18 -04001426 case CMD_802_11_LED_GPIO_CTRL:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001427 {
1428 struct mrvlietypes_ledgpio *gpio =
1429 (struct mrvlietypes_ledgpio*)
1430 cmdptr->params.ledgpio.data;
1431
1432 memmove(&cmdptr->params.ledgpio,
1433 pdata_buf,
1434 sizeof(struct cmd_ds_802_11_led_ctrl));
1435
1436 cmdptr->command =
Dan Williams0aef64d2007-08-02 11:31:18 -04001437 cpu_to_le16(CMD_802_11_LED_GPIO_CTRL);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001438
1439#define ACTION_NUMLED_TLVTYPE_LEN_FIELDS_LEN 8
1440 cmdptr->size =
1441 cpu_to_le16(gpio->header.len + S_DS_GEN +
1442 ACTION_NUMLED_TLVTYPE_LEN_FIELDS_LEN);
1443 gpio->header.len = cpu_to_le16(gpio->header.len);
1444
1445 ret = 0;
1446 break;
1447 }
Holger Schurig3a188642007-11-26 10:07:14 +01001448 case CMD_802_11_SUBSCRIBE_EVENT:
1449 lbs_cmd_802_11_subscribe_event(priv, cmdptr,
1450 cmd_action, pdata_buf);
1451 break;
Dan Williams0aef64d2007-08-02 11:31:18 -04001452 case CMD_802_11_PWR_CFG:
1453 cmdptr->command = cpu_to_le16(CMD_802_11_PWR_CFG);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001454 cmdptr->size =
1455 cpu_to_le16(sizeof(struct cmd_ds_802_11_pwr_cfg) +
1456 S_DS_GEN);
1457 memmove(&cmdptr->params.pwrcfg, pdata_buf,
1458 sizeof(struct cmd_ds_802_11_pwr_cfg));
1459
1460 ret = 0;
1461 break;
Dan Williams0aef64d2007-08-02 11:31:18 -04001462 case CMD_BT_ACCESS:
Holger Schurig10078322007-11-15 18:05:47 -05001463 ret = lbs_cmd_bt_access(priv, cmdptr, cmd_action, pdata_buf);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001464 break;
1465
Dan Williams0aef64d2007-08-02 11:31:18 -04001466 case CMD_FWT_ACCESS:
Holger Schurig10078322007-11-15 18:05:47 -05001467 ret = lbs_cmd_fwt_access(priv, cmdptr, cmd_action, pdata_buf);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001468 break;
1469
Dan Williams0aef64d2007-08-02 11:31:18 -04001470 case CMD_MESH_ACCESS:
Holger Schurig10078322007-11-15 18:05:47 -05001471 ret = lbs_cmd_mesh_access(priv, cmdptr, cmd_action, pdata_buf);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001472 break;
1473
Luis Carlos Cobo63f00232007-08-02 13:19:24 -04001474 case CMD_SET_BOOT2_VER:
Holger Schurig10078322007-11-15 18:05:47 -05001475 ret = lbs_cmd_set_boot2_ver(priv, cmdptr, cmd_action, pdata_buf);
Luis Carlos Cobo63f00232007-08-02 13:19:24 -04001476 break;
1477
Dan Williams0aef64d2007-08-02 11:31:18 -04001478 case CMD_GET_TSF:
1479 cmdptr->command = cpu_to_le16(CMD_GET_TSF);
David Woodhouse981f1872007-05-25 23:36:54 -04001480 cmdptr->size = cpu_to_le16(sizeof(struct cmd_ds_get_tsf) +
1481 S_DS_GEN);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001482 ret = 0;
1483 break;
Brajesh Dave96287ac2007-11-20 17:44:28 -05001484 case CMD_802_11_BEACON_CTRL:
1485 ret = lbs_cmd_bcn_ctrl(priv, cmdptr, cmd_action);
1486 break;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001487 default:
Holger Schurig8ff12da2007-08-02 11:54:31 -04001488 lbs_deb_host("PREP_CMD: unknown command 0x%04x\n", cmd_no);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001489 ret = -1;
1490 break;
1491 }
1492
1493 /* return error, since the command preparation failed */
1494 if (ret != 0) {
Holger Schurig8ff12da2007-08-02 11:54:31 -04001495 lbs_deb_host("PREP_CMD: command preparation failed\n");
Holger Schurig10078322007-11-15 18:05:47 -05001496 lbs_cleanup_and_insert_cmd(priv, cmdnode);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001497 ret = -1;
1498 goto done;
1499 }
1500
1501 cmdnode->cmdwaitqwoken = 0;
1502
Holger Schurig10078322007-11-15 18:05:47 -05001503 lbs_queue_cmd(adapter, cmdnode, 1);
Dan Williamsfe336152007-08-02 11:32:25 -04001504 wake_up_interruptible(&priv->waitq);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001505
Dan Williams0aef64d2007-08-02 11:31:18 -04001506 if (wait_option & CMD_OPTION_WAITFORRSP) {
Holger Schurig8ff12da2007-08-02 11:54:31 -04001507 lbs_deb_host("PREP_CMD: wait for response\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001508 might_sleep();
1509 wait_event_interruptible(cmdnode->cmdwait_q,
1510 cmdnode->cmdwaitqwoken);
1511 }
1512
1513 spin_lock_irqsave(&adapter->driver_lock, flags);
1514 if (adapter->cur_cmd_retcode) {
Holger Schurig8ff12da2007-08-02 11:54:31 -04001515 lbs_deb_host("PREP_CMD: command failed with return code %d\n",
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001516 adapter->cur_cmd_retcode);
1517 adapter->cur_cmd_retcode = 0;
1518 ret = -1;
1519 }
1520 spin_unlock_irqrestore(&adapter->driver_lock, flags);
1521
1522done:
Holger Schurig8ff12da2007-08-02 11:54:31 -04001523 lbs_deb_leave_args(LBS_DEB_HOST, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001524 return ret;
1525}
Holger Schurig10078322007-11-15 18:05:47 -05001526EXPORT_SYMBOL_GPL(lbs_prepare_and_send_command);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001527
1528/**
1529 * @brief This function allocates the command buffer and link
1530 * it to command free queue.
1531 *
Holger Schurig69f90322007-11-23 15:43:44 +01001532 * @param priv A pointer to struct lbs_private structure
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001533 * @return 0 or -1
1534 */
Holger Schurig69f90322007-11-23 15:43:44 +01001535int lbs_allocate_cmd_buffer(struct lbs_private *priv)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001536{
1537 int ret = 0;
1538 u32 ulbufsize;
1539 u32 i;
1540 struct cmd_ctrl_node *tempcmd_array;
1541 u8 *ptempvirtualaddr;
Holger Schurig69f90322007-11-23 15:43:44 +01001542 struct lbs_adapter *adapter = priv->adapter;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001543
Holger Schurig8ff12da2007-08-02 11:54:31 -04001544 lbs_deb_enter(LBS_DEB_HOST);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001545
1546 /* Allocate and initialize cmdCtrlNode */
1547 ulbufsize = sizeof(struct cmd_ctrl_node) * MRVDRV_NUM_OF_CMD_BUFFER;
1548
Holger Schurigfb3dddf2007-05-25 11:58:22 -04001549 if (!(tempcmd_array = kzalloc(ulbufsize, GFP_KERNEL))) {
Holger Schurig8ff12da2007-08-02 11:54:31 -04001550 lbs_deb_host("ALLOC_CMD_BUF: tempcmd_array is NULL\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001551 ret = -1;
1552 goto done;
1553 }
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001554 adapter->cmd_array = tempcmd_array;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001555
1556 /* Allocate and initialize command buffers */
1557 ulbufsize = MRVDRV_SIZE_OF_CMD_BUFFER;
1558 for (i = 0; i < MRVDRV_NUM_OF_CMD_BUFFER; i++) {
Holger Schurigfb3dddf2007-05-25 11:58:22 -04001559 if (!(ptempvirtualaddr = kzalloc(ulbufsize, GFP_KERNEL))) {
Holger Schurig8ff12da2007-08-02 11:54:31 -04001560 lbs_deb_host("ALLOC_CMD_BUF: ptempvirtualaddr is NULL\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001561 ret = -1;
1562 goto done;
1563 }
1564
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001565 /* Update command buffer virtual */
1566 tempcmd_array[i].bufvirtualaddr = ptempvirtualaddr;
1567 }
1568
1569 for (i = 0; i < MRVDRV_NUM_OF_CMD_BUFFER; i++) {
1570 init_waitqueue_head(&tempcmd_array[i].cmdwait_q);
Holger Schurig10078322007-11-15 18:05:47 -05001571 lbs_cleanup_and_insert_cmd(priv, &tempcmd_array[i]);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001572 }
1573
1574 ret = 0;
Holger Schurig9012b282007-05-25 11:27:16 -04001575
1576done:
Holger Schurig8ff12da2007-08-02 11:54:31 -04001577 lbs_deb_leave_args(LBS_DEB_HOST, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001578 return ret;
1579}
1580
1581/**
1582 * @brief This function frees the command buffer.
1583 *
Holger Schurig69f90322007-11-23 15:43:44 +01001584 * @param priv A pointer to struct lbs_private structure
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001585 * @return 0 or -1
1586 */
Holger Schurig69f90322007-11-23 15:43:44 +01001587int lbs_free_cmd_buffer(struct lbs_private *priv)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001588{
David Woodhouse981f1872007-05-25 23:36:54 -04001589 u32 ulbufsize; /* Someone needs to die for this. Slowly and painfully */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001590 unsigned int i;
1591 struct cmd_ctrl_node *tempcmd_array;
Holger Schurig69f90322007-11-23 15:43:44 +01001592 struct lbs_adapter *adapter = priv->adapter;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001593
Holger Schurig8ff12da2007-08-02 11:54:31 -04001594 lbs_deb_enter(LBS_DEB_HOST);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001595
1596 /* need to check if cmd array is allocated or not */
1597 if (adapter->cmd_array == NULL) {
Holger Schurig8ff12da2007-08-02 11:54:31 -04001598 lbs_deb_host("FREE_CMD_BUF: cmd_array is NULL\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001599 goto done;
1600 }
1601
1602 tempcmd_array = adapter->cmd_array;
1603
1604 /* Release shared memory buffers */
1605 ulbufsize = MRVDRV_SIZE_OF_CMD_BUFFER;
1606 for (i = 0; i < MRVDRV_NUM_OF_CMD_BUFFER; i++) {
1607 if (tempcmd_array[i].bufvirtualaddr) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001608 kfree(tempcmd_array[i].bufvirtualaddr);
1609 tempcmd_array[i].bufvirtualaddr = NULL;
1610 }
1611 }
1612
1613 /* Release cmd_ctrl_node */
1614 if (adapter->cmd_array) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001615 kfree(adapter->cmd_array);
1616 adapter->cmd_array = NULL;
1617 }
1618
1619done:
Holger Schurig8ff12da2007-08-02 11:54:31 -04001620 lbs_deb_leave(LBS_DEB_HOST);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001621 return 0;
1622}
1623
1624/**
1625 * @brief This function gets a free command node if available in
1626 * command free queue.
1627 *
Holger Schurig69f90322007-11-23 15:43:44 +01001628 * @param priv A pointer to struct lbs_private structure
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001629 * @return cmd_ctrl_node A pointer to cmd_ctrl_node structure or NULL
1630 */
Holger Schurig0d61d042007-12-05 17:58:06 +01001631struct cmd_ctrl_node *lbs_get_cmd_ctrl_node(struct lbs_private *priv)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001632{
1633 struct cmd_ctrl_node *tempnode;
Holger Schurig69f90322007-11-23 15:43:44 +01001634 struct lbs_adapter *adapter = priv->adapter;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001635 unsigned long flags;
1636
Holger Schurig8ff12da2007-08-02 11:54:31 -04001637 lbs_deb_enter(LBS_DEB_HOST);
1638
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001639 if (!adapter)
1640 return NULL;
1641
1642 spin_lock_irqsave(&adapter->driver_lock, flags);
1643
1644 if (!list_empty(&adapter->cmdfreeq)) {
1645 tempnode = (struct cmd_ctrl_node *)adapter->cmdfreeq.next;
1646 list_del((struct list_head *)tempnode);
1647 } else {
Holger Schurig8ff12da2007-08-02 11:54:31 -04001648 lbs_deb_host("GET_CMD_NODE: cmd_ctrl_node is not available\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001649 tempnode = NULL;
1650 }
1651
1652 spin_unlock_irqrestore(&adapter->driver_lock, flags);
1653
Holger Schurig8ff12da2007-08-02 11:54:31 -04001654 if (tempnode)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001655 cleanup_cmdnode(tempnode);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001656
Holger Schurig8ff12da2007-08-02 11:54:31 -04001657 lbs_deb_leave(LBS_DEB_HOST);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001658 return tempnode;
1659}
1660
1661/**
1662 * @brief This function cleans command node.
1663 *
1664 * @param ptempnode A pointer to cmdCtrlNode structure
1665 * @return n/a
1666 */
1667static void cleanup_cmdnode(struct cmd_ctrl_node *ptempnode)
1668{
Holger Schurig8ff12da2007-08-02 11:54:31 -04001669 lbs_deb_enter(LBS_DEB_HOST);
1670
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001671 if (!ptempnode)
1672 return;
1673 ptempnode->cmdwaitqwoken = 1;
1674 wake_up_interruptible(&ptempnode->cmdwait_q);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001675 ptempnode->wait_option = 0;
1676 ptempnode->pdata_buf = NULL;
1677
1678 if (ptempnode->bufvirtualaddr != NULL)
1679 memset(ptempnode->bufvirtualaddr, 0, MRVDRV_SIZE_OF_CMD_BUFFER);
Holger Schurig8ff12da2007-08-02 11:54:31 -04001680
1681 lbs_deb_leave(LBS_DEB_HOST);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001682}
1683
1684/**
1685 * @brief This function initializes the command node.
1686 *
Holger Schurig69f90322007-11-23 15:43:44 +01001687 * @param priv A pointer to struct lbs_private structure
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001688 * @param ptempnode A pointer to cmd_ctrl_node structure
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001689 * @param wait_option wait option: wait response or not
1690 * @param pdata_buf A pointer to informaion buffer
1691 * @return 0 or -1
1692 */
Holger Schurig69f90322007-11-23 15:43:44 +01001693void lbs_set_cmd_ctrl_node(struct lbs_private *priv,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001694 struct cmd_ctrl_node *ptempnode,
David Woodhousef5ece8f2007-12-01 15:15:41 +00001695 u16 wait_option, void *pdata_buf)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001696{
Holger Schurig8ff12da2007-08-02 11:54:31 -04001697 lbs_deb_enter(LBS_DEB_HOST);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001698
1699 if (!ptempnode)
1700 return;
1701
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001702 ptempnode->wait_option = wait_option;
1703 ptempnode->pdata_buf = pdata_buf;
1704
Holger Schurig8ff12da2007-08-02 11:54:31 -04001705 lbs_deb_leave(LBS_DEB_HOST);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001706}
1707
1708/**
1709 * @brief This function executes next command in command
1710 * pending queue. It will put fimware back to PS mode
1711 * if applicable.
1712 *
Holger Schurig69f90322007-11-23 15:43:44 +01001713 * @param priv A pointer to struct lbs_private structure
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001714 * @return 0 or -1
1715 */
Holger Schurig69f90322007-11-23 15:43:44 +01001716int lbs_execute_next_command(struct lbs_private *priv)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001717{
Holger Schurig69f90322007-11-23 15:43:44 +01001718 struct lbs_adapter *adapter = priv->adapter;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001719 struct cmd_ctrl_node *cmdnode = NULL;
1720 struct cmd_ds_command *cmdptr;
1721 unsigned long flags;
1722 int ret = 0;
1723
Holger Schurig8ff12da2007-08-02 11:54:31 -04001724 // Debug group is LBS_DEB_THREAD and not LBS_DEB_HOST, because the
Holger Schurig10078322007-11-15 18:05:47 -05001725 // only caller to us is lbs_thread() and we get even when a
Holger Schurig8ff12da2007-08-02 11:54:31 -04001726 // data packet is received
1727 lbs_deb_enter(LBS_DEB_THREAD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001728
1729 spin_lock_irqsave(&adapter->driver_lock, flags);
1730
1731 if (adapter->cur_cmd) {
Holger Schurig8ff12da2007-08-02 11:54:31 -04001732 lbs_pr_alert( "EXEC_NEXT_CMD: already processing command!\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001733 spin_unlock_irqrestore(&adapter->driver_lock, flags);
1734 ret = -1;
1735 goto done;
1736 }
1737
1738 if (!list_empty(&adapter->cmdpendingq)) {
1739 cmdnode = (struct cmd_ctrl_node *)
1740 adapter->cmdpendingq.next;
1741 }
1742
1743 spin_unlock_irqrestore(&adapter->driver_lock, flags);
1744
1745 if (cmdnode) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001746 cmdptr = (struct cmd_ds_command *)cmdnode->bufvirtualaddr;
1747
1748 if (is_command_allowed_in_ps(cmdptr->command)) {
David Woodhouse981f1872007-05-25 23:36:54 -04001749 if ((adapter->psstate == PS_STATE_SLEEP) ||
1750 (adapter->psstate == PS_STATE_PRE_SLEEP)) {
Holger Schurig8ff12da2007-08-02 11:54:31 -04001751 lbs_deb_host(
1752 "EXEC_NEXT_CMD: cannot send cmd 0x%04x in psstate %d\n",
David Woodhouse981f1872007-05-25 23:36:54 -04001753 le16_to_cpu(cmdptr->command),
1754 adapter->psstate);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001755 ret = -1;
1756 goto done;
1757 }
Holger Schurig8ff12da2007-08-02 11:54:31 -04001758 lbs_deb_host("EXEC_NEXT_CMD: OK to send command "
1759 "0x%04x in psstate %d\n",
David Woodhouse981f1872007-05-25 23:36:54 -04001760 le16_to_cpu(cmdptr->command),
1761 adapter->psstate);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001762 } else if (adapter->psstate != PS_STATE_FULL_POWER) {
1763 /*
1764 * 1. Non-PS command:
1765 * Queue it. set needtowakeup to TRUE if current state
Holger Schurig10078322007-11-15 18:05:47 -05001766 * is SLEEP, otherwise call lbs_ps_wakeup to send Exit_PS.
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001767 * 2. PS command but not Exit_PS:
1768 * Ignore it.
1769 * 3. PS command Exit_PS:
1770 * Set needtowakeup to TRUE if current state is SLEEP,
1771 * otherwise send this command down to firmware
1772 * immediately.
1773 */
1774 if (cmdptr->command !=
Dan Williams0aef64d2007-08-02 11:31:18 -04001775 cpu_to_le16(CMD_802_11_PS_MODE)) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001776 /* Prepare to send Exit PS,
1777 * this non PS command will be sent later */
1778 if ((adapter->psstate == PS_STATE_SLEEP)
1779 || (adapter->psstate == PS_STATE_PRE_SLEEP)
1780 ) {
1781 /* w/ new scheme, it will not reach here.
1782 since it is blocked in main_thread. */
1783 adapter->needtowakeup = 1;
1784 } else
Holger Schurig10078322007-11-15 18:05:47 -05001785 lbs_ps_wakeup(priv, 0);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001786
1787 ret = 0;
1788 goto done;
1789 } else {
1790 /*
1791 * PS command. Ignore it if it is not Exit_PS.
1792 * otherwise send it down immediately.
1793 */
1794 struct cmd_ds_802_11_ps_mode *psm =
1795 &cmdptr->params.psmode;
1796
Holger Schurig8ff12da2007-08-02 11:54:31 -04001797 lbs_deb_host(
1798 "EXEC_NEXT_CMD: PS cmd, action 0x%02x\n",
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001799 psm->action);
1800 if (psm->action !=
Dan Williams0aef64d2007-08-02 11:31:18 -04001801 cpu_to_le16(CMD_SUBCMD_EXIT_PS)) {
Holger Schurig8ff12da2007-08-02 11:54:31 -04001802 lbs_deb_host(
1803 "EXEC_NEXT_CMD: ignore ENTER_PS cmd\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001804 list_del((struct list_head *)cmdnode);
Holger Schurig10078322007-11-15 18:05:47 -05001805 lbs_cleanup_and_insert_cmd(priv, cmdnode);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001806
1807 ret = 0;
1808 goto done;
1809 }
1810
David Woodhouse981f1872007-05-25 23:36:54 -04001811 if ((adapter->psstate == PS_STATE_SLEEP) ||
1812 (adapter->psstate == PS_STATE_PRE_SLEEP)) {
Holger Schurig8ff12da2007-08-02 11:54:31 -04001813 lbs_deb_host(
1814 "EXEC_NEXT_CMD: ignore EXIT_PS cmd in sleep\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001815 list_del((struct list_head *)cmdnode);
Holger Schurig10078322007-11-15 18:05:47 -05001816 lbs_cleanup_and_insert_cmd(priv, cmdnode);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001817 adapter->needtowakeup = 1;
1818
1819 ret = 0;
1820 goto done;
1821 }
1822
Holger Schurig8ff12da2007-08-02 11:54:31 -04001823 lbs_deb_host(
1824 "EXEC_NEXT_CMD: sending EXIT_PS\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001825 }
1826 }
1827 list_del((struct list_head *)cmdnode);
Holger Schurig8ff12da2007-08-02 11:54:31 -04001828 lbs_deb_host("EXEC_NEXT_CMD: sending command 0x%04x\n",
David Woodhouse981f1872007-05-25 23:36:54 -04001829 le16_to_cpu(cmdptr->command));
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001830 DownloadcommandToStation(priv, cmdnode);
1831 } else {
1832 /*
1833 * check if in power save mode, if yes, put the device back
1834 * to PS mode
1835 */
Holger Schurig10078322007-11-15 18:05:47 -05001836 if ((adapter->psmode != LBS802_11POWERMODECAM) &&
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001837 (adapter->psstate == PS_STATE_FULL_POWER) &&
Brajesh Dave01d77d82007-11-20 17:44:14 -05001838 ((adapter->connect_status == LBS_CONNECTED) ||
1839 (adapter->mesh_connect_status == LBS_CONNECTED))) {
David Woodhouse981f1872007-05-25 23:36:54 -04001840 if (adapter->secinfo.WPAenabled ||
1841 adapter->secinfo.WPA2enabled) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001842 /* check for valid WPA group keys */
David Woodhouse981f1872007-05-25 23:36:54 -04001843 if (adapter->wpa_mcast_key.len ||
1844 adapter->wpa_unicast_key.len) {
Holger Schurig8ff12da2007-08-02 11:54:31 -04001845 lbs_deb_host(
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001846 "EXEC_NEXT_CMD: WPA enabled and GTK_SET"
1847 " go back to PS_SLEEP");
Holger Schurig10078322007-11-15 18:05:47 -05001848 lbs_ps_sleep(priv, 0);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001849 }
1850 } else {
Holger Schurig8ff12da2007-08-02 11:54:31 -04001851 lbs_deb_host(
1852 "EXEC_NEXT_CMD: cmdpendingq empty, "
1853 "go back to PS_SLEEP");
Holger Schurig10078322007-11-15 18:05:47 -05001854 lbs_ps_sleep(priv, 0);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001855 }
1856 }
1857 }
1858
1859 ret = 0;
1860done:
Holger Schurig8ff12da2007-08-02 11:54:31 -04001861 lbs_deb_leave(LBS_DEB_THREAD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001862 return ret;
1863}
1864
Holger Schurig69f90322007-11-23 15:43:44 +01001865void lbs_send_iwevcustom_event(struct lbs_private *priv, s8 *str)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001866{
1867 union iwreq_data iwrq;
1868 u8 buf[50];
1869
Holger Schurig8ff12da2007-08-02 11:54:31 -04001870 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001871
1872 memset(&iwrq, 0, sizeof(union iwreq_data));
1873 memset(buf, 0, sizeof(buf));
1874
1875 snprintf(buf, sizeof(buf) - 1, "%s", str);
1876
1877 iwrq.data.length = strlen(buf) + 1 + IW_EV_LCP_LEN;
1878
1879 /* Send Event to upper layer */
Holger Schurig8ff12da2007-08-02 11:54:31 -04001880 lbs_deb_wext("event indication string %s\n", (char *)buf);
1881 lbs_deb_wext("event indication length %d\n", iwrq.data.length);
1882 lbs_deb_wext("sending wireless event IWEVCUSTOM for %s\n", str);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001883
Holger Schurig634b8f42007-05-25 13:05:16 -04001884 wireless_send_event(priv->dev, IWEVCUSTOM, &iwrq, buf);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001885
Holger Schurig8ff12da2007-08-02 11:54:31 -04001886 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001887}
1888
Holger Schurig69f90322007-11-23 15:43:44 +01001889static int sendconfirmsleep(struct lbs_private *priv, u8 *cmdptr, u16 size)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001890{
1891 unsigned long flags;
Holger Schurig69f90322007-11-23 15:43:44 +01001892 struct lbs_adapter *adapter = priv->adapter;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001893 int ret = 0;
1894
Holger Schurig8ff12da2007-08-02 11:54:31 -04001895 lbs_deb_enter(LBS_DEB_HOST);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001896
Holger Schurig8ff12da2007-08-02 11:54:31 -04001897 lbs_deb_host("SEND_SLEEPC_CMD: before download, cmd size %d\n",
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001898 size);
1899
Holger Schurig8ff12da2007-08-02 11:54:31 -04001900 lbs_deb_hex(LBS_DEB_HOST, "sleep confirm command", cmdptr, size);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001901
Holger Schurig208fdd22007-05-25 12:17:06 -04001902 ret = priv->hw_host_to_card(priv, MVMS_CMD, cmdptr, size);
Holger Schurig634b8f42007-05-25 13:05:16 -04001903 priv->dnld_sent = DNLD_RES_RECEIVED;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001904
1905 spin_lock_irqsave(&adapter->driver_lock, flags);
1906 if (adapter->intcounter || adapter->currenttxskb)
Holger Schurig8ff12da2007-08-02 11:54:31 -04001907 lbs_deb_host("SEND_SLEEPC_CMD: intcounter %d, currenttxskb %p\n",
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001908 adapter->intcounter, adapter->currenttxskb);
1909 spin_unlock_irqrestore(&adapter->driver_lock, flags);
1910
1911 if (ret) {
1912 lbs_pr_alert(
1913 "SEND_SLEEPC_CMD: Host to Card failed for Confirm Sleep\n");
1914 } else {
1915 spin_lock_irqsave(&adapter->driver_lock, flags);
1916 if (!adapter->intcounter) {
1917 adapter->psstate = PS_STATE_SLEEP;
1918 } else {
Holger Schurig8ff12da2007-08-02 11:54:31 -04001919 lbs_deb_host("SEND_SLEEPC_CMD: after sent, intcounter %d\n",
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001920 adapter->intcounter);
1921 }
1922 spin_unlock_irqrestore(&adapter->driver_lock, flags);
1923
Holger Schurig8ff12da2007-08-02 11:54:31 -04001924 lbs_deb_host("SEND_SLEEPC_CMD: sent confirm sleep\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001925 }
1926
Holger Schurig8ff12da2007-08-02 11:54:31 -04001927 lbs_deb_leave_args(LBS_DEB_HOST, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001928 return ret;
1929}
1930
Holger Schurig69f90322007-11-23 15:43:44 +01001931void lbs_ps_sleep(struct lbs_private *priv, int wait_option)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001932{
Holger Schurig8ff12da2007-08-02 11:54:31 -04001933 lbs_deb_enter(LBS_DEB_HOST);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001934
1935 /*
1936 * PS is currently supported only in Infrastructure mode
1937 * Remove this check if it is to be supported in IBSS mode also
1938 */
1939
Holger Schurig10078322007-11-15 18:05:47 -05001940 lbs_prepare_and_send_command(priv, CMD_802_11_PS_MODE,
Dan Williams0aef64d2007-08-02 11:31:18 -04001941 CMD_SUBCMD_ENTER_PS, wait_option, 0, NULL);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001942
Holger Schurig8ff12da2007-08-02 11:54:31 -04001943 lbs_deb_leave(LBS_DEB_HOST);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001944}
1945
1946/**
Holger Schurig8ff12da2007-08-02 11:54:31 -04001947 * @brief This function sends Exit_PS command to firmware.
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001948 *
Holger Schurig69f90322007-11-23 15:43:44 +01001949 * @param priv A pointer to struct lbs_private structure
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001950 * @param wait_option wait response or not
1951 * @return n/a
1952 */
Holger Schurig69f90322007-11-23 15:43:44 +01001953void lbs_ps_wakeup(struct lbs_private *priv, int wait_option)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001954{
David Woodhouse981f1872007-05-25 23:36:54 -04001955 __le32 Localpsmode;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001956
Holger Schurig8ff12da2007-08-02 11:54:31 -04001957 lbs_deb_enter(LBS_DEB_HOST);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001958
Holger Schurig10078322007-11-15 18:05:47 -05001959 Localpsmode = cpu_to_le32(LBS802_11POWERMODECAM);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001960
Holger Schurig10078322007-11-15 18:05:47 -05001961 lbs_prepare_and_send_command(priv, CMD_802_11_PS_MODE,
Dan Williams0aef64d2007-08-02 11:31:18 -04001962 CMD_SUBCMD_EXIT_PS,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001963 wait_option, 0, &Localpsmode);
1964
Holger Schurig8ff12da2007-08-02 11:54:31 -04001965 lbs_deb_leave(LBS_DEB_HOST);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001966}
1967
1968/**
1969 * @brief This function checks condition and prepares to
1970 * send sleep confirm command to firmware if ok.
1971 *
Holger Schurig69f90322007-11-23 15:43:44 +01001972 * @param priv A pointer to struct lbs_private structure
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001973 * @param psmode Power Saving mode
1974 * @return n/a
1975 */
Holger Schurig69f90322007-11-23 15:43:44 +01001976void lbs_ps_confirm_sleep(struct lbs_private *priv, u16 psmode)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001977{
1978 unsigned long flags =0;
Holger Schurig69f90322007-11-23 15:43:44 +01001979 struct lbs_adapter *adapter = priv->adapter;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001980 u8 allowed = 1;
1981
Holger Schurig8ff12da2007-08-02 11:54:31 -04001982 lbs_deb_enter(LBS_DEB_HOST);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001983
Holger Schurig634b8f42007-05-25 13:05:16 -04001984 if (priv->dnld_sent) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001985 allowed = 0;
Holger Schurig8ff12da2007-08-02 11:54:31 -04001986 lbs_deb_host("dnld_sent was set");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001987 }
1988
1989 spin_lock_irqsave(&adapter->driver_lock, flags);
1990 if (adapter->cur_cmd) {
1991 allowed = 0;
Holger Schurig8ff12da2007-08-02 11:54:31 -04001992 lbs_deb_host("cur_cmd was set");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001993 }
1994 if (adapter->intcounter > 0) {
1995 allowed = 0;
Holger Schurig8ff12da2007-08-02 11:54:31 -04001996 lbs_deb_host("intcounter %d", adapter->intcounter);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001997 }
1998 spin_unlock_irqrestore(&adapter->driver_lock, flags);
1999
2000 if (allowed) {
Holger Schurig10078322007-11-15 18:05:47 -05002001 lbs_deb_host("sending lbs_ps_confirm_sleep\n");
2002 sendconfirmsleep(priv, (u8 *) & adapter->lbs_ps_confirm_sleep,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002003 sizeof(struct PS_CMD_ConfirmSleep));
2004 } else {
Holger Schurig8ff12da2007-08-02 11:54:31 -04002005 lbs_deb_host("sleep confirm has been delayed\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002006 }
2007
Holger Schurig8ff12da2007-08-02 11:54:31 -04002008 lbs_deb_leave(LBS_DEB_HOST);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02002009}
Holger Schurig675787e2007-12-05 17:58:11 +01002010
2011
2012/**
2013 * @brief Simple way to call firmware functions
2014 *
2015 * @param priv A pointer to struct lbs_private structure
2016 * @param psmode one of the many CMD_802_11_xxxx
2017 * @param cmd pointer to the parameters structure for above command
2018 * (this should not include the command, size, sequence
2019 * and result fields from struct cmd_ds_gen)
2020 * @param cmd_size size structure pointed to by cmd
2021 * @param rsp pointer to an area where the result should be placed
2022 * @param rsp_size pointer to the size of the rsp area. If the firmware
2023 * returns fewer bytes, then this *rsp_size will be
2024 * changed to the actual size.
2025 * @return -1 in case of a higher level error, otherwise
2026 * the result code from the firmware
2027 */
2028int lbs_cmd(struct lbs_private *priv,
2029 u16 command,
2030 void *cmd, int cmd_size,
2031 void *rsp, int *rsp_size)
2032{
2033 struct lbs_adapter *adapter = priv->adapter;
2034 struct cmd_ctrl_node *cmdnode;
2035 struct cmd_ds_gen *cmdptr;
2036 unsigned long flags;
2037 int ret = 0;
2038
2039 lbs_deb_enter(LBS_DEB_HOST);
2040 lbs_deb_host("rsp at %p, rsp_size at %p\n", rsp, rsp_size);
2041
2042 if (!adapter || !rsp_size) {
2043 lbs_deb_host("PREP_CMD: adapter is NULL\n");
2044 ret = -1;
2045 goto done;
2046 }
2047
2048 if (adapter->surpriseremoved) {
2049 lbs_deb_host("PREP_CMD: card removed\n");
2050 ret = -1;
2051 goto done;
2052 }
2053
2054 cmdnode = lbs_get_cmd_ctrl_node(priv);
2055
2056 if (cmdnode == NULL) {
2057 lbs_deb_host("PREP_CMD: cmdnode is NULL\n");
2058
2059 /* Wake up main thread to execute next command */
2060 wake_up_interruptible(&priv->waitq);
2061 ret = -1;
2062 goto done;
2063 }
2064
2065 cmdptr = (struct cmd_ds_gen *)cmdnode->bufvirtualaddr;
2066 cmdnode->wait_option = CMD_OPTION_WAITFORRSP;
2067 cmdnode->pdata_buf = rsp;
2068 cmdnode->pdata_size = rsp_size;
2069
2070 /* Set sequence number, clean result, move to buffer */
2071 adapter->seqnum++;
2072 cmdptr->command = cpu_to_le16(command);
2073 cmdptr->size = cmd_size + S_DS_GEN;
2074 cmdptr->seqnum = cpu_to_le16(adapter->seqnum);
2075 cmdptr->result = 0;
2076 memcpy(cmdptr->cmdresp, cmd, cmd_size);
2077
2078 lbs_deb_host("PREP_CMD: command 0x%04x\n", command);
2079
2080 /* here was the big old switch() statement, which is now obsolete,
2081 * because the caller of lbs_cmd() sets up all of *cmd for us. */
2082
2083 cmdnode->cmdwaitqwoken = 0;
2084 lbs_queue_cmd(adapter, cmdnode, 1);
2085 wake_up_interruptible(&priv->waitq);
2086
2087 might_sleep();
2088 wait_event_interruptible(cmdnode->cmdwait_q, cmdnode->cmdwaitqwoken);
2089
2090 spin_lock_irqsave(&adapter->driver_lock, flags);
2091 if (adapter->cur_cmd_retcode) {
2092 lbs_deb_host("PREP_CMD: command failed with return code %d\n",
2093 adapter->cur_cmd_retcode);
2094 adapter->cur_cmd_retcode = 0;
2095 ret = -1;
2096 }
2097 spin_unlock_irqrestore(&adapter->driver_lock, flags);
2098
2099done:
2100 lbs_deb_leave_args(LBS_DEB_HOST, "ret %d", ret);
2101 return ret;
2102}
2103EXPORT_SYMBOL_GPL(lbs_cmd);
2104
2105