blob: f5d4971f13a0ab32808da68ef34f1adc38be3cc7 [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);
16
17static u16 commands_allowed_in_ps[] = {
Dan Williams0aef64d2007-08-02 11:31:18 -040018 CMD_802_11_RSSI,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020019};
20
21/**
22 * @brief This function checks if the commans is allowed
23 * in PS mode not.
24 *
25 * @param command the command ID
26 * @return TRUE or FALSE
27 */
David Woodhouse981f1872007-05-25 23:36:54 -040028static u8 is_command_allowed_in_ps(__le16 command)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020029{
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020030 int i;
31
David Woodhouse981f1872007-05-25 23:36:54 -040032 for (i = 0; i < ARRAY_SIZE(commands_allowed_in_ps); i++) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020033 if (command == cpu_to_le16(commands_allowed_in_ps[i]))
34 return 1;
35 }
36
37 return 0;
38}
39
40static int wlan_cmd_hw_spec(wlan_private * priv, struct cmd_ds_command *cmd)
41{
42 struct cmd_ds_get_hw_spec *hwspec = &cmd->params.hwspec;
43
Holger Schurig9012b282007-05-25 11:27:16 -040044 lbs_deb_enter(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020045
Dan Williams0aef64d2007-08-02 11:31:18 -040046 cmd->command = cpu_to_le16(CMD_GET_HW_SPEC);
David Woodhouse981f1872007-05-25 23:36:54 -040047 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_get_hw_spec) + S_DS_GEN);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020048 memcpy(hwspec->permanentaddr, priv->adapter->current_addr, ETH_ALEN);
49
Holger Schurig9012b282007-05-25 11:27:16 -040050 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020051 return 0;
52}
53
54static int wlan_cmd_802_11_ps_mode(wlan_private * priv,
55 struct cmd_ds_command *cmd,
56 u16 cmd_action)
57{
58 struct cmd_ds_802_11_ps_mode *psm = &cmd->params.psmode;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020059 wlan_adapter *adapter = priv->adapter;
60
Holger Schurig9012b282007-05-25 11:27:16 -040061 lbs_deb_enter(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020062
Dan Williams0aef64d2007-08-02 11:31:18 -040063 cmd->command = cpu_to_le16(CMD_802_11_PS_MODE);
David Woodhouse981f1872007-05-25 23:36:54 -040064 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_ps_mode) +
65 S_DS_GEN);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020066 psm->action = cpu_to_le16(cmd_action);
67 psm->multipledtim = 0;
David Woodhouse981f1872007-05-25 23:36:54 -040068 switch (cmd_action) {
Dan Williams0aef64d2007-08-02 11:31:18 -040069 case CMD_SUBCMD_ENTER_PS:
Holger Schurig9012b282007-05-25 11:27:16 -040070 lbs_deb_cmd("PS command:" "SubCode- Enter PS\n");
Holger Schurig8ff12da2007-08-02 11:54:31 -040071 lbs_deb_cmd("locallisteninterval %d\n",
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020072 adapter->locallisteninterval);
73
74 psm->locallisteninterval =
75 cpu_to_le16(adapter->locallisteninterval);
Holger Schurig97605c32007-08-02 13:09:15 -040076 psm->nullpktinterval = 0;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020077 psm->multipledtim =
78 cpu_to_le16(priv->adapter->multipledtim);
79 break;
80
Dan Williams0aef64d2007-08-02 11:31:18 -040081 case CMD_SUBCMD_EXIT_PS:
Holger Schurig9012b282007-05-25 11:27:16 -040082 lbs_deb_cmd("PS command:" "SubCode- Exit PS\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020083 break;
84
Dan Williams0aef64d2007-08-02 11:31:18 -040085 case CMD_SUBCMD_SLEEP_CONFIRMED:
Holger Schurig9012b282007-05-25 11:27:16 -040086 lbs_deb_cmd("PS command: SubCode- sleep confirm\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020087 break;
88
89 default:
90 break;
91 }
92
Holger Schurig9012b282007-05-25 11:27:16 -040093 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020094 return 0;
95}
96
97static int wlan_cmd_802_11_inactivity_timeout(wlan_private * priv,
98 struct cmd_ds_command *cmd,
99 u16 cmd_action, void *pdata_buf)
100{
101 u16 *timeout = pdata_buf;
102
Holger Schurig8ff12da2007-08-02 11:54:31 -0400103 lbs_deb_enter(LBS_DEB_CMD);
104
Dan Williams0aef64d2007-08-02 11:31:18 -0400105 cmd->command = cpu_to_le16(CMD_802_11_INACTIVITY_TIMEOUT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200106 cmd->size =
107 cpu_to_le16(sizeof(struct cmd_ds_802_11_inactivity_timeout)
108 + S_DS_GEN);
109
110 cmd->params.inactivity_timeout.action = cpu_to_le16(cmd_action);
111
112 if (cmd_action)
David Woodhouse981f1872007-05-25 23:36:54 -0400113 cmd->params.inactivity_timeout.timeout = cpu_to_le16(*timeout);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200114 else
115 cmd->params.inactivity_timeout.timeout = 0;
116
Holger Schurig8ff12da2007-08-02 11:54:31 -0400117 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200118 return 0;
119}
120
121static int wlan_cmd_802_11_sleep_params(wlan_private * priv,
122 struct cmd_ds_command *cmd,
123 u16 cmd_action)
124{
125 wlan_adapter *adapter = priv->adapter;
126 struct cmd_ds_802_11_sleep_params *sp = &cmd->params.sleep_params;
127
Holger Schurig9012b282007-05-25 11:27:16 -0400128 lbs_deb_enter(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200129
David Woodhouse981f1872007-05-25 23:36:54 -0400130 cmd->size = cpu_to_le16((sizeof(struct cmd_ds_802_11_sleep_params)) +
131 S_DS_GEN);
Dan Williams0aef64d2007-08-02 11:31:18 -0400132 cmd->command = cpu_to_le16(CMD_802_11_SLEEP_PARAMS);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200133
Dan Williams0aef64d2007-08-02 11:31:18 -0400134 if (cmd_action == CMD_ACT_GET) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200135 memset(&adapter->sp, 0, sizeof(struct sleep_params));
136 memset(sp, 0, sizeof(struct cmd_ds_802_11_sleep_params));
137 sp->action = cpu_to_le16(cmd_action);
Dan Williams0aef64d2007-08-02 11:31:18 -0400138 } else if (cmd_action == CMD_ACT_SET) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200139 sp->action = cpu_to_le16(cmd_action);
140 sp->error = cpu_to_le16(adapter->sp.sp_error);
141 sp->offset = cpu_to_le16(adapter->sp.sp_offset);
142 sp->stabletime = cpu_to_le16(adapter->sp.sp_stabletime);
143 sp->calcontrol = (u8) adapter->sp.sp_calcontrol;
144 sp->externalsleepclk = (u8) adapter->sp.sp_extsleepclk;
145 sp->reserved = cpu_to_le16(adapter->sp.sp_reserved);
146 }
147
Holger Schurig9012b282007-05-25 11:27:16 -0400148 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200149 return 0;
150}
151
152static int wlan_cmd_802_11_set_wep(wlan_private * priv,
153 struct cmd_ds_command *cmd,
154 u32 cmd_act,
155 void * pdata_buf)
156{
157 struct cmd_ds_802_11_set_wep *wep = &cmd->params.wep;
158 wlan_adapter *adapter = priv->adapter;
159 int ret = 0;
160 struct assoc_request * assoc_req = pdata_buf;
161
Holger Schurig9012b282007-05-25 11:27:16 -0400162 lbs_deb_enter(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200163
Dan Williams0aef64d2007-08-02 11:31:18 -0400164 cmd->command = cpu_to_le16(CMD_802_11_SET_WEP);
David Woodhouse981f1872007-05-25 23:36:54 -0400165 cmd->size = cpu_to_le16(sizeof(*wep) + S_DS_GEN);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200166
Dan Williams0aef64d2007-08-02 11:31:18 -0400167 if (cmd_act == CMD_ACT_ADD) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200168 int i;
169
170 if (!assoc_req) {
Holger Schurig9012b282007-05-25 11:27:16 -0400171 lbs_deb_cmd("Invalid association request!");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200172 ret = -1;
173 goto done;
174 }
175
Dan Williams0aef64d2007-08-02 11:31:18 -0400176 wep->action = cpu_to_le16(CMD_ACT_ADD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200177
178 /* default tx key index */
David Woodhouse981f1872007-05-25 23:36:54 -0400179 wep->keyindex = cpu_to_le16((u16)(assoc_req->wep_tx_keyidx &
Dan Williams0aef64d2007-08-02 11:31:18 -0400180 (u32)CMD_WEP_KEY_INDEX_MASK));
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200181
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200182 /* Copy key types and material to host command structure */
183 for (i = 0; i < 4; i++) {
Dan Williams1443b652007-08-02 10:45:55 -0400184 struct enc_key * pkey = &assoc_req->wep_keys[i];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200185
186 switch (pkey->len) {
187 case KEY_LEN_WEP_40:
David Woodhouse981f1872007-05-25 23:36:54 -0400188 wep->keytype[i] =
Dan Williams0aef64d2007-08-02 11:31:18 -0400189 cpu_to_le16(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:
David Woodhouse981f1872007-05-25 23:36:54 -0400195 wep->keytype[i] =
Dan Williams0aef64d2007-08-02 11:31:18 -0400196 cpu_to_le16(CMD_TYPE_WEP_104_BIT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200197 memmove(&wep->keymaterial[i], pkey->key,
198 pkey->len);
Holger Schurig8ff12da2007-08-02 11:54:31 -0400199 lbs_deb_cmd("SET_WEP: add key %d (104 bit)\n", i);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200200 break;
201 case 0:
202 break;
203 default:
Holger Schurig8ff12da2007-08-02 11:54:31 -0400204 lbs_deb_cmd("SET_WEP: invalid key %d, length %d\n",
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200205 i, pkey->len);
206 ret = -1;
207 goto done;
208 break;
209 }
210 }
Dan Williams0aef64d2007-08-02 11:31:18 -0400211 } else if (cmd_act == CMD_ACT_REMOVE) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200212 /* ACT_REMOVE clears _all_ WEP keys */
Dan Williams0aef64d2007-08-02 11:31:18 -0400213 wep->action = cpu_to_le16(CMD_ACT_REMOVE);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200214
215 /* default tx key index */
David Woodhouse981f1872007-05-25 23:36:54 -0400216 wep->keyindex = cpu_to_le16((u16)(adapter->wep_tx_keyidx &
Dan Williams0aef64d2007-08-02 11:31:18 -0400217 (u32)CMD_WEP_KEY_INDEX_MASK));
Holger Schurig8ff12da2007-08-02 11:54:31 -0400218 lbs_deb_cmd("SET_WEP: remove key %d\n", adapter->wep_tx_keyidx);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200219 }
220
221 ret = 0;
222
223done:
Holger Schurig9012b282007-05-25 11:27:16 -0400224 lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200225 return ret;
226}
227
228static int wlan_cmd_802_11_enable_rsn(wlan_private * priv,
229 struct cmd_ds_command *cmd,
Dan Williams90a42212007-05-25 23:01:24 -0400230 u16 cmd_action,
231 void * pdata_buf)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200232{
233 struct cmd_ds_802_11_enable_rsn *penableRSN = &cmd->params.enbrsn;
Dan Williams18c96c342007-06-18 12:01:12 -0400234 u32 * enable = pdata_buf;
Dan Williams90a42212007-05-25 23:01:24 -0400235
236 lbs_deb_enter(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200237
Dan Williams0aef64d2007-08-02 11:31:18 -0400238 cmd->command = cpu_to_le16(CMD_802_11_ENABLE_RSN);
David Woodhouse981f1872007-05-25 23:36:54 -0400239 cmd->size = cpu_to_le16(sizeof(*penableRSN) + S_DS_GEN);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200240 penableRSN->action = cpu_to_le16(cmd_action);
Dan Williams18c96c342007-06-18 12:01:12 -0400241
Dan Williams0aef64d2007-08-02 11:31:18 -0400242 if (cmd_action == CMD_ACT_SET) {
Dan Williams18c96c342007-06-18 12:01:12 -0400243 if (*enable)
Dan Williams0aef64d2007-08-02 11:31:18 -0400244 penableRSN->enable = cpu_to_le16(CMD_ENABLE_RSN);
Dan Williams18c96c342007-06-18 12:01:12 -0400245 else
Dan Williams0aef64d2007-08-02 11:31:18 -0400246 penableRSN->enable = cpu_to_le16(CMD_DISABLE_RSN);
Holger Schurig8ff12da2007-08-02 11:54:31 -0400247 lbs_deb_cmd("ENABLE_RSN: %d\n", *enable);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200248 }
249
Dan Williams90a42212007-05-25 23:01:24 -0400250 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200251 return 0;
252}
253
254
255static void set_one_wpa_key(struct MrvlIEtype_keyParamSet * pkeyparamset,
Dan Williams1443b652007-08-02 10:45:55 -0400256 struct enc_key * pkey)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200257{
Holger Schurig8ff12da2007-08-02 11:54:31 -0400258 lbs_deb_enter(LBS_DEB_CMD);
259
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200260 if (pkey->flags & KEY_INFO_WPA_ENABLED) {
Dan Williams90a42212007-05-25 23:01:24 -0400261 pkeyparamset->keyinfo |= cpu_to_le16(KEY_INFO_WPA_ENABLED);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200262 }
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200263 if (pkey->flags & KEY_INFO_WPA_UNICAST) {
264 pkeyparamset->keyinfo |= cpu_to_le16(KEY_INFO_WPA_UNICAST);
Dan Williams90a42212007-05-25 23:01:24 -0400265 }
266 if (pkey->flags & KEY_INFO_WPA_MCAST) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200267 pkeyparamset->keyinfo |= cpu_to_le16(KEY_INFO_WPA_MCAST);
268 }
269
270 pkeyparamset->type = cpu_to_le16(TLV_TYPE_KEY_MATERIAL);
Dan Williams1443b652007-08-02 10:45:55 -0400271 pkeyparamset->keytypeid = cpu_to_le16(pkey->type);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200272 pkeyparamset->keylen = cpu_to_le16(pkey->len);
273 memcpy(pkeyparamset->key, pkey->key, pkey->len);
274 pkeyparamset->length = cpu_to_le16( sizeof(pkeyparamset->keytypeid)
275 + sizeof(pkeyparamset->keyinfo)
276 + sizeof(pkeyparamset->keylen)
277 + sizeof(pkeyparamset->key));
Holger Schurig8ff12da2007-08-02 11:54:31 -0400278 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200279}
280
281static int wlan_cmd_802_11_key_material(wlan_private * priv,
282 struct cmd_ds_command *cmd,
283 u16 cmd_action,
284 u32 cmd_oid, void *pdata_buf)
285{
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200286 struct cmd_ds_802_11_key_material *pkeymaterial =
287 &cmd->params.keymaterial;
Dan Williams90a42212007-05-25 23:01:24 -0400288 struct assoc_request * assoc_req = pdata_buf;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200289 int ret = 0;
290 int index = 0;
291
Holger Schurig9012b282007-05-25 11:27:16 -0400292 lbs_deb_enter(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200293
Dan Williams0aef64d2007-08-02 11:31:18 -0400294 cmd->command = cpu_to_le16(CMD_802_11_KEY_MATERIAL);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200295 pkeymaterial->action = cpu_to_le16(cmd_action);
296
Dan Williams0aef64d2007-08-02 11:31:18 -0400297 if (cmd_action == CMD_ACT_GET) {
Dan Williams90a42212007-05-25 23:01:24 -0400298 cmd->size = cpu_to_le16(S_DS_GEN + sizeof (pkeymaterial->action));
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200299 ret = 0;
300 goto done;
301 }
302
303 memset(&pkeymaterial->keyParamSet, 0, sizeof(pkeymaterial->keyParamSet));
304
Dan Williams90a42212007-05-25 23:01:24 -0400305 if (test_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags)) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200306 set_one_wpa_key(&pkeymaterial->keyParamSet[index],
Dan Williams90a42212007-05-25 23:01:24 -0400307 &assoc_req->wpa_unicast_key);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200308 index++;
309 }
310
Dan Williams90a42212007-05-25 23:01:24 -0400311 if (test_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags)) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200312 set_one_wpa_key(&pkeymaterial->keyParamSet[index],
Dan Williams90a42212007-05-25 23:01:24 -0400313 &assoc_req->wpa_mcast_key);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200314 index++;
315 }
316
317 cmd->size = cpu_to_le16( S_DS_GEN
Dan Williams90a42212007-05-25 23:01:24 -0400318 + sizeof (pkeymaterial->action)
319 + (index * sizeof(struct MrvlIEtype_keyParamSet)));
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200320
321 ret = 0;
322
323done:
Holger Schurig9012b282007-05-25 11:27:16 -0400324 lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200325 return ret;
326}
327
328static int wlan_cmd_802_11_reset(wlan_private * priv,
329 struct cmd_ds_command *cmd, int cmd_action)
330{
331 struct cmd_ds_802_11_reset *reset = &cmd->params.reset;
332
Holger Schurig8ff12da2007-08-02 11:54:31 -0400333 lbs_deb_enter(LBS_DEB_CMD);
334
Dan Williams0aef64d2007-08-02 11:31:18 -0400335 cmd->command = cpu_to_le16(CMD_802_11_RESET);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200336 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_reset) + S_DS_GEN);
337 reset->action = cpu_to_le16(cmd_action);
338
Holger Schurig8ff12da2007-08-02 11:54:31 -0400339 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200340 return 0;
341}
342
343static int wlan_cmd_802_11_get_log(wlan_private * priv,
344 struct cmd_ds_command *cmd)
345{
Holger Schurig8ff12da2007-08-02 11:54:31 -0400346 lbs_deb_enter(LBS_DEB_CMD);
Dan Williams0aef64d2007-08-02 11:31:18 -0400347 cmd->command = cpu_to_le16(CMD_802_11_GET_LOG);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200348 cmd->size =
349 cpu_to_le16(sizeof(struct cmd_ds_802_11_get_log) + S_DS_GEN);
350
Holger Schurig8ff12da2007-08-02 11:54:31 -0400351 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200352 return 0;
353}
354
355static int wlan_cmd_802_11_get_stat(wlan_private * priv,
356 struct cmd_ds_command *cmd)
357{
Holger Schurig8ff12da2007-08-02 11:54:31 -0400358 lbs_deb_enter(LBS_DEB_CMD);
Dan Williams0aef64d2007-08-02 11:31:18 -0400359 cmd->command = cpu_to_le16(CMD_802_11_GET_STAT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200360 cmd->size =
David Woodhouse981f1872007-05-25 23:36:54 -0400361 cpu_to_le16(sizeof(struct cmd_ds_802_11_get_stat) + S_DS_GEN);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200362
Holger Schurig8ff12da2007-08-02 11:54:31 -0400363 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200364 return 0;
365}
366
367static int wlan_cmd_802_11_snmp_mib(wlan_private * priv,
368 struct cmd_ds_command *cmd,
369 int cmd_action,
370 int cmd_oid, void *pdata_buf)
371{
372 struct cmd_ds_802_11_snmp_mib *pSNMPMIB = &cmd->params.smib;
373 wlan_adapter *adapter = priv->adapter;
374 u8 ucTemp;
375
Holger Schurig9012b282007-05-25 11:27:16 -0400376 lbs_deb_enter(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200377
Holger Schurig9012b282007-05-25 11:27:16 -0400378 lbs_deb_cmd("SNMP_CMD: cmd_oid = 0x%x\n", cmd_oid);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200379
Dan Williams0aef64d2007-08-02 11:31:18 -0400380 cmd->command = cpu_to_le16(CMD_802_11_SNMP_MIB);
David Woodhouse981f1872007-05-25 23:36:54 -0400381 cmd->size = cpu_to_le16(sizeof(*pSNMPMIB) + S_DS_GEN);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200382
383 switch (cmd_oid) {
384 case OID_802_11_INFRASTRUCTURE_MODE:
385 {
Dan Williams0dc5a292007-05-10 22:58:02 -0400386 u8 mode = (u8) (size_t) pdata_buf;
Dan Williams0aef64d2007-08-02 11:31:18 -0400387 pSNMPMIB->querytype = cpu_to_le16(CMD_ACT_SET);
388 pSNMPMIB->oid = cpu_to_le16((u16) DESIRED_BSSTYPE_I);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200389 pSNMPMIB->bufsize = sizeof(u8);
Dan Williams0dc5a292007-05-10 22:58:02 -0400390 if (mode == IW_MODE_ADHOC) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200391 ucTemp = SNMP_MIB_VALUE_ADHOC;
Dan Williams0dc5a292007-05-10 22:58:02 -0400392 } else {
393 /* Infra and Auto modes */
394 ucTemp = SNMP_MIB_VALUE_INFRA;
395 }
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200396
397 memmove(pSNMPMIB->value, &ucTemp, sizeof(u8));
398
399 break;
400 }
401
402 case OID_802_11D_ENABLE:
403 {
404 u32 ulTemp;
405
Dan Williams0aef64d2007-08-02 11:31:18 -0400406 pSNMPMIB->oid = cpu_to_le16((u16) DOT11D_I);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200407
Dan Williams0aef64d2007-08-02 11:31:18 -0400408 if (cmd_action == CMD_ACT_SET) {
409 pSNMPMIB->querytype = CMD_ACT_SET;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200410 pSNMPMIB->bufsize = sizeof(u16);
411 ulTemp = *(u32 *)pdata_buf;
David Woodhouse981f1872007-05-25 23:36:54 -0400412 *((__le16 *)(pSNMPMIB->value)) =
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200413 cpu_to_le16((u16) ulTemp);
414 }
415 break;
416 }
417
418 case OID_802_11_FRAGMENTATION_THRESHOLD:
419 {
420 u32 ulTemp;
421
Dan Williams0aef64d2007-08-02 11:31:18 -0400422 pSNMPMIB->oid = cpu_to_le16((u16) FRAGTHRESH_I);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200423
Dan Williams0aef64d2007-08-02 11:31:18 -0400424 if (cmd_action == CMD_ACT_GET) {
425 pSNMPMIB->querytype = cpu_to_le16(CMD_ACT_GET);
426 } else if (cmd_action == CMD_ACT_SET) {
427 pSNMPMIB->querytype = cpu_to_le16(CMD_ACT_SET);
David Woodhouse981f1872007-05-25 23:36:54 -0400428 pSNMPMIB->bufsize = cpu_to_le16(sizeof(u16));
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200429 ulTemp = *((u32 *) pdata_buf);
David Woodhouse981f1872007-05-25 23:36:54 -0400430 *((__le16 *)(pSNMPMIB->value)) =
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200431 cpu_to_le16((u16) ulTemp);
432
433 }
434
435 break;
436 }
437
438 case OID_802_11_RTS_THRESHOLD:
439 {
440
441 u32 ulTemp;
Dan Williams0aef64d2007-08-02 11:31:18 -0400442 pSNMPMIB->oid = le16_to_cpu((u16) RTSTHRESH_I);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200443
Dan Williams0aef64d2007-08-02 11:31:18 -0400444 if (cmd_action == CMD_ACT_GET) {
445 pSNMPMIB->querytype = cpu_to_le16(CMD_ACT_GET);
446 } else if (cmd_action == CMD_ACT_SET) {
447 pSNMPMIB->querytype = cpu_to_le16(CMD_ACT_SET);
David Woodhouse981f1872007-05-25 23:36:54 -0400448 pSNMPMIB->bufsize = cpu_to_le16(sizeof(u16));
449 ulTemp = *((u32 *)pdata_buf);
450 *(__le16 *)(pSNMPMIB->value) =
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200451 cpu_to_le16((u16) ulTemp);
452
453 }
454 break;
455 }
456 case OID_802_11_TX_RETRYCOUNT:
Dan Williams0aef64d2007-08-02 11:31:18 -0400457 pSNMPMIB->oid = cpu_to_le16((u16) SHORT_RETRYLIM_I);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200458
Dan Williams0aef64d2007-08-02 11:31:18 -0400459 if (cmd_action == CMD_ACT_GET) {
460 pSNMPMIB->querytype = cpu_to_le16(CMD_ACT_GET);
461 } else if (cmd_action == CMD_ACT_SET) {
462 pSNMPMIB->querytype = cpu_to_le16(CMD_ACT_SET);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200463 pSNMPMIB->bufsize = cpu_to_le16(sizeof(u16));
David Woodhouse981f1872007-05-25 23:36:54 -0400464 *((__le16 *)(pSNMPMIB->value)) =
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200465 cpu_to_le16((u16) adapter->txretrycount);
466 }
467
468 break;
469 default:
470 break;
471 }
472
Holger Schurig9012b282007-05-25 11:27:16 -0400473 lbs_deb_cmd(
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200474 "SNMP_CMD: command=0x%x, size=0x%x, seqnum=0x%x, result=0x%x\n",
David Woodhouse981f1872007-05-25 23:36:54 -0400475 le16_to_cpu(cmd->command), le16_to_cpu(cmd->size),
476 le16_to_cpu(cmd->seqnum), le16_to_cpu(cmd->result));
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200477
Holger Schurig9012b282007-05-25 11:27:16 -0400478 lbs_deb_cmd(
Holger Schurig8ff12da2007-08-02 11:54:31 -0400479 "SNMP_CMD: action 0x%x, oid 0x%x, oidsize 0x%x, value 0x%x\n",
David Woodhouse981f1872007-05-25 23:36:54 -0400480 le16_to_cpu(pSNMPMIB->querytype), le16_to_cpu(pSNMPMIB->oid),
481 le16_to_cpu(pSNMPMIB->bufsize),
482 le16_to_cpu(*(__le16 *) pSNMPMIB->value));
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200483
Holger Schurig9012b282007-05-25 11:27:16 -0400484 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200485 return 0;
486}
487
488static int wlan_cmd_802_11_radio_control(wlan_private * priv,
489 struct cmd_ds_command *cmd,
490 int cmd_action)
491{
492 wlan_adapter *adapter = priv->adapter;
David Woodhouse981f1872007-05-25 23:36:54 -0400493 struct cmd_ds_802_11_radio_control *pradiocontrol = &cmd->params.radio;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200494
Holger Schurig9012b282007-05-25 11:27:16 -0400495 lbs_deb_enter(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200496
497 cmd->size =
498 cpu_to_le16((sizeof(struct cmd_ds_802_11_radio_control)) +
499 S_DS_GEN);
Dan Williams0aef64d2007-08-02 11:31:18 -0400500 cmd->command = cpu_to_le16(CMD_802_11_RADIO_CONTROL);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200501
502 pradiocontrol->action = cpu_to_le16(cmd_action);
503
504 switch (adapter->preamble) {
Dan Williams0aef64d2007-08-02 11:31:18 -0400505 case CMD_TYPE_SHORT_PREAMBLE:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200506 pradiocontrol->control = cpu_to_le16(SET_SHORT_PREAMBLE);
507 break;
508
Dan Williams0aef64d2007-08-02 11:31:18 -0400509 case CMD_TYPE_LONG_PREAMBLE:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200510 pradiocontrol->control = cpu_to_le16(SET_LONG_PREAMBLE);
511 break;
512
Dan Williams0aef64d2007-08-02 11:31:18 -0400513 case CMD_TYPE_AUTO_PREAMBLE:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200514 default:
515 pradiocontrol->control = cpu_to_le16(SET_AUTO_PREAMBLE);
516 break;
517 }
518
519 if (adapter->radioon)
520 pradiocontrol->control |= cpu_to_le16(TURN_ON_RF);
521 else
522 pradiocontrol->control &= cpu_to_le16(~TURN_ON_RF);
523
Holger Schurig9012b282007-05-25 11:27:16 -0400524 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200525 return 0;
526}
527
528static int wlan_cmd_802_11_rf_tx_power(wlan_private * priv,
529 struct cmd_ds_command *cmd,
530 u16 cmd_action, void *pdata_buf)
531{
532
533 struct cmd_ds_802_11_rf_tx_power *prtp = &cmd->params.txp;
534
Holger Schurig9012b282007-05-25 11:27:16 -0400535 lbs_deb_enter(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200536
537 cmd->size =
David Woodhouse981f1872007-05-25 23:36:54 -0400538 cpu_to_le16((sizeof(struct cmd_ds_802_11_rf_tx_power)) + S_DS_GEN);
Dan Williams0aef64d2007-08-02 11:31:18 -0400539 cmd->command = cpu_to_le16(CMD_802_11_RF_TX_POWER);
David Woodhouse981f1872007-05-25 23:36:54 -0400540 prtp->action = cpu_to_le16(cmd_action);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200541
David Woodhouse981f1872007-05-25 23:36:54 -0400542 lbs_deb_cmd("RF_TX_POWER_CMD: size:%d cmd:0x%x Act:%d\n",
543 le16_to_cpu(cmd->size), le16_to_cpu(cmd->command),
544 le16_to_cpu(prtp->action));
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200545
546 switch (cmd_action) {
Dan Williams0aef64d2007-08-02 11:31:18 -0400547 case CMD_ACT_TX_POWER_OPT_GET:
548 prtp->action = cpu_to_le16(CMD_ACT_GET);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200549 prtp->currentlevel = 0;
550 break;
551
Dan Williams0aef64d2007-08-02 11:31:18 -0400552 case CMD_ACT_TX_POWER_OPT_SET_HIGH:
553 prtp->action = cpu_to_le16(CMD_ACT_SET);
554 prtp->currentlevel = cpu_to_le16(CMD_ACT_TX_POWER_INDEX_HIGH);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200555 break;
556
Dan Williams0aef64d2007-08-02 11:31:18 -0400557 case CMD_ACT_TX_POWER_OPT_SET_MID:
558 prtp->action = cpu_to_le16(CMD_ACT_SET);
559 prtp->currentlevel = cpu_to_le16(CMD_ACT_TX_POWER_INDEX_MID);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200560 break;
561
Dan Williams0aef64d2007-08-02 11:31:18 -0400562 case CMD_ACT_TX_POWER_OPT_SET_LOW:
563 prtp->action = cpu_to_le16(CMD_ACT_SET);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200564 prtp->currentlevel = cpu_to_le16(*((u16 *) pdata_buf));
565 break;
566 }
Holger Schurig9012b282007-05-25 11:27:16 -0400567
568 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200569 return 0;
570}
571
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200572static int wlan_cmd_802_11_rate_adapt_rateset(wlan_private * priv,
573 struct cmd_ds_command *cmd,
574 u16 cmd_action)
575{
576 struct cmd_ds_802_11_rate_adapt_rateset
577 *rateadapt = &cmd->params.rateset;
578 wlan_adapter *adapter = priv->adapter;
579
Holger Schurig8ff12da2007-08-02 11:54:31 -0400580 lbs_deb_enter(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200581 cmd->size =
582 cpu_to_le16(sizeof(struct cmd_ds_802_11_rate_adapt_rateset)
583 + S_DS_GEN);
Dan Williams0aef64d2007-08-02 11:31:18 -0400584 cmd->command = cpu_to_le16(CMD_802_11_RATE_ADAPT_RATESET);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200585
David Woodhouse981f1872007-05-25 23:36:54 -0400586 rateadapt->action = cpu_to_le16(cmd_action);
587 rateadapt->enablehwauto = cpu_to_le16(adapter->enablehwauto);
588 rateadapt->bitmap = cpu_to_le16(adapter->ratebitmap);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200589
Holger Schurig9012b282007-05-25 11:27:16 -0400590 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200591 return 0;
592}
593
594static int wlan_cmd_802_11_data_rate(wlan_private * priv,
595 struct cmd_ds_command *cmd,
596 u16 cmd_action)
597{
598 struct cmd_ds_802_11_data_rate *pdatarate = &cmd->params.drate;
599 wlan_adapter *adapter = priv->adapter;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200600
Holger Schurig9012b282007-05-25 11:27:16 -0400601 lbs_deb_enter(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200602
David Woodhouse981f1872007-05-25 23:36:54 -0400603 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_data_rate) +
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200604 S_DS_GEN);
Dan Williams0aef64d2007-08-02 11:31:18 -0400605 cmd->command = cpu_to_le16(CMD_802_11_DATA_RATE);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200606 memset(pdatarate, 0, sizeof(struct cmd_ds_802_11_data_rate));
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200607 pdatarate->action = cpu_to_le16(cmd_action);
608
Dan Williamsffcae952007-08-02 11:35:46 -0400609 if (cmd_action == CMD_ACT_SET_TX_FIX_RATE) {
Dan Williams8c512762007-08-02 11:40:45 -0400610 pdatarate->rates[0] = libertas_data_rate_to_fw_index(adapter->cur_rate);
Holger Schurig8ff12da2007-08-02 11:54:31 -0400611 lbs_deb_cmd("DATA_RATE: set fixed 0x%02X\n",
Dan Williams8c512762007-08-02 11:40:45 -0400612 adapter->cur_rate);
Dan Williamsffcae952007-08-02 11:35:46 -0400613 } else if (cmd_action == CMD_ACT_SET_TX_AUTO) {
Holger Schurig8ff12da2007-08-02 11:54:31 -0400614 lbs_deb_cmd("DATA_RATE: setting auto\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200615 }
616
Holger Schurig9012b282007-05-25 11:27:16 -0400617 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200618 return 0;
619}
620
621static int wlan_cmd_mac_multicast_adr(wlan_private * priv,
622 struct cmd_ds_command *cmd,
623 u16 cmd_action)
624{
625 struct cmd_ds_mac_multicast_adr *pMCastAdr = &cmd->params.madr;
626 wlan_adapter *adapter = priv->adapter;
627
Holger Schurig8ff12da2007-08-02 11:54:31 -0400628 lbs_deb_enter(LBS_DEB_CMD);
David Woodhouse981f1872007-05-25 23:36:54 -0400629 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_mac_multicast_adr) +
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200630 S_DS_GEN);
Dan Williams0aef64d2007-08-02 11:31:18 -0400631 cmd->command = cpu_to_le16(CMD_MAC_MULTICAST_ADR);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200632
Holger Schurig8ff12da2007-08-02 11:54:31 -0400633 lbs_deb_cmd("MULTICAST_ADR: setting %d addresses\n", pMCastAdr->nr_of_adrs);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200634 pMCastAdr->action = cpu_to_le16(cmd_action);
635 pMCastAdr->nr_of_adrs =
636 cpu_to_le16((u16) adapter->nr_of_multicastmacaddr);
637 memcpy(pMCastAdr->maclist, adapter->multicastlist,
638 adapter->nr_of_multicastmacaddr * ETH_ALEN);
639
Holger Schurig8ff12da2007-08-02 11:54:31 -0400640 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200641 return 0;
642}
643
644static int wlan_cmd_802_11_rf_channel(wlan_private * priv,
645 struct cmd_ds_command *cmd,
646 int option, void *pdata_buf)
647{
648 struct cmd_ds_802_11_rf_channel *rfchan = &cmd->params.rfchannel;
649
Holger Schurig8ff12da2007-08-02 11:54:31 -0400650 lbs_deb_enter(LBS_DEB_CMD);
Dan Williams0aef64d2007-08-02 11:31:18 -0400651 cmd->command = cpu_to_le16(CMD_802_11_RF_CHANNEL);
David Woodhouse981f1872007-05-25 23:36:54 -0400652 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_rf_channel) +
653 S_DS_GEN);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200654
Dan Williams0aef64d2007-08-02 11:31:18 -0400655 if (option == CMD_OPT_802_11_RF_CHANNEL_SET) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200656 rfchan->currentchannel = cpu_to_le16(*((u16 *) pdata_buf));
657 }
658
659 rfchan->action = cpu_to_le16(option);
660
Holger Schurig8ff12da2007-08-02 11:54:31 -0400661 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200662 return 0;
663}
664
665static int wlan_cmd_802_11_rssi(wlan_private * priv,
666 struct cmd_ds_command *cmd)
667{
668 wlan_adapter *adapter = priv->adapter;
669
Holger Schurig8ff12da2007-08-02 11:54:31 -0400670 lbs_deb_enter(LBS_DEB_CMD);
Dan Williams0aef64d2007-08-02 11:31:18 -0400671 cmd->command = cpu_to_le16(CMD_802_11_RSSI);
David Woodhouse981f1872007-05-25 23:36:54 -0400672 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_rssi) + S_DS_GEN);
Holger Schuriga783f1e2007-08-02 13:08:24 -0400673 cmd->params.rssi.N = cpu_to_le16(DEFAULT_BCN_AVG_FACTOR);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200674
675 /* reset Beacon SNR/NF/RSSI values */
676 adapter->SNR[TYPE_BEACON][TYPE_NOAVG] = 0;
677 adapter->SNR[TYPE_BEACON][TYPE_AVG] = 0;
678 adapter->NF[TYPE_BEACON][TYPE_NOAVG] = 0;
679 adapter->NF[TYPE_BEACON][TYPE_AVG] = 0;
680 adapter->RSSI[TYPE_BEACON][TYPE_NOAVG] = 0;
681 adapter->RSSI[TYPE_BEACON][TYPE_AVG] = 0;
682
Holger Schurig8ff12da2007-08-02 11:54:31 -0400683 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200684 return 0;
685}
686
687static int wlan_cmd_reg_access(wlan_private * priv,
688 struct cmd_ds_command *cmdptr,
689 u8 cmd_action, void *pdata_buf)
690{
691 struct wlan_offset_value *offval;
692
Holger Schurig9012b282007-05-25 11:27:16 -0400693 lbs_deb_enter(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200694
695 offval = (struct wlan_offset_value *)pdata_buf;
696
697 switch (cmdptr->command) {
Dan Williams0aef64d2007-08-02 11:31:18 -0400698 case CMD_MAC_REG_ACCESS:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200699 {
700 struct cmd_ds_mac_reg_access *macreg;
701
702 cmdptr->size =
David Woodhouse981f1872007-05-25 23:36:54 -0400703 cpu_to_le16(sizeof (struct cmd_ds_mac_reg_access)
704 + S_DS_GEN);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200705 macreg =
706 (struct cmd_ds_mac_reg_access *)&cmdptr->params.
707 macreg;
708
709 macreg->action = cpu_to_le16(cmd_action);
710 macreg->offset = cpu_to_le16((u16) offval->offset);
711 macreg->value = cpu_to_le32(offval->value);
712
713 break;
714 }
715
Dan Williams0aef64d2007-08-02 11:31:18 -0400716 case CMD_BBP_REG_ACCESS:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200717 {
718 struct cmd_ds_bbp_reg_access *bbpreg;
719
720 cmdptr->size =
721 cpu_to_le16(sizeof
722 (struct cmd_ds_bbp_reg_access)
723 + S_DS_GEN);
724 bbpreg =
725 (struct cmd_ds_bbp_reg_access *)&cmdptr->params.
726 bbpreg;
727
728 bbpreg->action = cpu_to_le16(cmd_action);
729 bbpreg->offset = cpu_to_le16((u16) offval->offset);
730 bbpreg->value = (u8) offval->value;
731
732 break;
733 }
734
Dan Williams0aef64d2007-08-02 11:31:18 -0400735 case CMD_RF_REG_ACCESS:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200736 {
737 struct cmd_ds_rf_reg_access *rfreg;
738
739 cmdptr->size =
740 cpu_to_le16(sizeof
741 (struct cmd_ds_rf_reg_access) +
742 S_DS_GEN);
743 rfreg =
744 (struct cmd_ds_rf_reg_access *)&cmdptr->params.
745 rfreg;
746
747 rfreg->action = cpu_to_le16(cmd_action);
748 rfreg->offset = cpu_to_le16((u16) offval->offset);
749 rfreg->value = (u8) offval->value;
750
751 break;
752 }
753
754 default:
755 break;
756 }
757
Holger Schurig9012b282007-05-25 11:27:16 -0400758 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200759 return 0;
760}
761
762static int wlan_cmd_802_11_mac_address(wlan_private * priv,
763 struct cmd_ds_command *cmd,
764 u16 cmd_action)
765{
766 wlan_adapter *adapter = priv->adapter;
767
Holger Schurig8ff12da2007-08-02 11:54:31 -0400768 lbs_deb_enter(LBS_DEB_CMD);
Dan Williams0aef64d2007-08-02 11:31:18 -0400769 cmd->command = cpu_to_le16(CMD_802_11_MAC_ADDRESS);
David Woodhouse981f1872007-05-25 23:36:54 -0400770 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_mac_address) +
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200771 S_DS_GEN);
772 cmd->result = 0;
773
774 cmd->params.macadd.action = cpu_to_le16(cmd_action);
775
Dan Williams0aef64d2007-08-02 11:31:18 -0400776 if (cmd_action == CMD_ACT_SET) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200777 memcpy(cmd->params.macadd.macadd,
778 adapter->current_addr, ETH_ALEN);
Holger Schurigece56192007-08-02 11:53:06 -0400779 lbs_deb_hex(LBS_DEB_CMD, "SET_CMD: MAC addr", adapter->current_addr, 6);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200780 }
781
Holger Schurig8ff12da2007-08-02 11:54:31 -0400782 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200783 return 0;
784}
785
786static int wlan_cmd_802_11_eeprom_access(wlan_private * priv,
787 struct cmd_ds_command *cmd,
788 int cmd_action, void *pdata_buf)
789{
790 struct wlan_ioctl_regrdwr *ea = pdata_buf;
791
Holger Schurig9012b282007-05-25 11:27:16 -0400792 lbs_deb_enter(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200793
Dan Williams0aef64d2007-08-02 11:31:18 -0400794 cmd->command = cpu_to_le16(CMD_802_11_EEPROM_ACCESS);
David Woodhouse981f1872007-05-25 23:36:54 -0400795 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_eeprom_access) +
796 S_DS_GEN);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200797 cmd->result = 0;
798
799 cmd->params.rdeeprom.action = cpu_to_le16(ea->action);
800 cmd->params.rdeeprom.offset = cpu_to_le16(ea->offset);
801 cmd->params.rdeeprom.bytecount = cpu_to_le16(ea->NOB);
802 cmd->params.rdeeprom.value = 0;
803
Holger Schurig8ff12da2007-08-02 11:54:31 -0400804 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200805 return 0;
806}
807
808static int wlan_cmd_bt_access(wlan_private * priv,
809 struct cmd_ds_command *cmd,
810 u16 cmd_action, void *pdata_buf)
811{
812 struct cmd_ds_bt_access *bt_access = &cmd->params.bt;
Holger Schurig8ff12da2007-08-02 11:54:31 -0400813 lbs_deb_enter_args(LBS_DEB_CMD, "action %d", cmd_action);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200814
Dan Williams0aef64d2007-08-02 11:31:18 -0400815 cmd->command = cpu_to_le16(CMD_BT_ACCESS);
David Woodhouse981f1872007-05-25 23:36:54 -0400816 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_bt_access) + S_DS_GEN);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200817 cmd->result = 0;
818 bt_access->action = cpu_to_le16(cmd_action);
819
820 switch (cmd_action) {
Dan Williams0aef64d2007-08-02 11:31:18 -0400821 case CMD_ACT_BT_ACCESS_ADD:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200822 memcpy(bt_access->addr1, pdata_buf, 2 * ETH_ALEN);
Holger Schurigece56192007-08-02 11:53:06 -0400823 lbs_deb_hex(LBS_DEB_MESH, "BT_ADD: blinded MAC addr", bt_access->addr1, 6);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200824 break;
Dan Williams0aef64d2007-08-02 11:31:18 -0400825 case CMD_ACT_BT_ACCESS_DEL:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200826 memcpy(bt_access->addr1, pdata_buf, 1 * ETH_ALEN);
Holger Schurigece56192007-08-02 11:53:06 -0400827 lbs_deb_hex(LBS_DEB_MESH, "BT_DEL: blinded MAC addr", bt_access->addr1, 6);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200828 break;
Dan Williams0aef64d2007-08-02 11:31:18 -0400829 case CMD_ACT_BT_ACCESS_LIST:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200830 bt_access->id = cpu_to_le32(*(u32 *) pdata_buf);
831 break;
Dan Williams0aef64d2007-08-02 11:31:18 -0400832 case CMD_ACT_BT_ACCESS_RESET:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200833 break;
Dan Williams0aef64d2007-08-02 11:31:18 -0400834 case CMD_ACT_BT_ACCESS_SET_INVERT:
Luis Carlos Cobo90e8eaf2007-05-25 13:53:26 -0400835 bt_access->id = cpu_to_le32(*(u32 *) pdata_buf);
836 break;
Dan Williams0aef64d2007-08-02 11:31:18 -0400837 case CMD_ACT_BT_ACCESS_GET_INVERT:
Luis Carlos Cobo90e8eaf2007-05-25 13:53:26 -0400838 break;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200839 default:
840 break;
841 }
Holger Schurig8ff12da2007-08-02 11:54:31 -0400842 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200843 return 0;
844}
845
846static int wlan_cmd_fwt_access(wlan_private * priv,
847 struct cmd_ds_command *cmd,
848 u16 cmd_action, void *pdata_buf)
849{
850 struct cmd_ds_fwt_access *fwt_access = &cmd->params.fwt;
Holger Schurig8ff12da2007-08-02 11:54:31 -0400851 lbs_deb_enter_args(LBS_DEB_CMD, "action %d", cmd_action);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200852
Dan Williams0aef64d2007-08-02 11:31:18 -0400853 cmd->command = cpu_to_le16(CMD_FWT_ACCESS);
David Woodhouse981f1872007-05-25 23:36:54 -0400854 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_fwt_access) + S_DS_GEN);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200855 cmd->result = 0;
856
857 if (pdata_buf)
858 memcpy(fwt_access, pdata_buf, sizeof(*fwt_access));
859 else
860 memset(fwt_access, 0, sizeof(*fwt_access));
861
862 fwt_access->action = cpu_to_le16(cmd_action);
863
Holger Schurig8ff12da2007-08-02 11:54:31 -0400864 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200865 return 0;
866}
867
868static int wlan_cmd_mesh_access(wlan_private * priv,
869 struct cmd_ds_command *cmd,
870 u16 cmd_action, void *pdata_buf)
871{
872 struct cmd_ds_mesh_access *mesh_access = &cmd->params.mesh;
Holger Schurig8ff12da2007-08-02 11:54:31 -0400873 lbs_deb_enter_args(LBS_DEB_CMD, "action %d", cmd_action);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200874
Dan Williams0aef64d2007-08-02 11:31:18 -0400875 cmd->command = cpu_to_le16(CMD_MESH_ACCESS);
David Woodhouse981f1872007-05-25 23:36:54 -0400876 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_mesh_access) + S_DS_GEN);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200877 cmd->result = 0;
878
879 if (pdata_buf)
880 memcpy(mesh_access, pdata_buf, sizeof(*mesh_access));
881 else
882 memset(mesh_access, 0, sizeof(*mesh_access));
883
884 mesh_access->action = cpu_to_le16(cmd_action);
885
Holger Schurig8ff12da2007-08-02 11:54:31 -0400886 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200887 return 0;
888}
889
890void libertas_queue_cmd(wlan_adapter * adapter, struct cmd_ctrl_node *cmdnode, u8 addtail)
891{
892 unsigned long flags;
893 struct cmd_ds_command *cmdptr;
894
Holger Schurig8ff12da2007-08-02 11:54:31 -0400895 lbs_deb_enter(LBS_DEB_HOST);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200896
897 if (!cmdnode) {
Holger Schurig8ff12da2007-08-02 11:54:31 -0400898 lbs_deb_host("QUEUE_CMD: cmdnode is NULL\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200899 goto done;
900 }
901
902 cmdptr = (struct cmd_ds_command *)cmdnode->bufvirtualaddr;
903 if (!cmdptr) {
Holger Schurig8ff12da2007-08-02 11:54:31 -0400904 lbs_deb_host("QUEUE_CMD: cmdptr is NULL\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200905 goto done;
906 }
907
908 /* Exit_PS command needs to be queued in the header always. */
Dan Williams0aef64d2007-08-02 11:31:18 -0400909 if (cmdptr->command == CMD_802_11_PS_MODE) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200910 struct cmd_ds_802_11_ps_mode *psm = &cmdptr->params.psmode;
Dan Williams0aef64d2007-08-02 11:31:18 -0400911 if (psm->action == cpu_to_le16(CMD_SUBCMD_EXIT_PS)) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200912 if (adapter->psstate != PS_STATE_FULL_POWER)
913 addtail = 0;
914 }
915 }
916
917 spin_lock_irqsave(&adapter->driver_lock, flags);
918
919 if (addtail)
920 list_add_tail((struct list_head *)cmdnode,
921 &adapter->cmdpendingq);
922 else
923 list_add((struct list_head *)cmdnode, &adapter->cmdpendingq);
924
925 spin_unlock_irqrestore(&adapter->driver_lock, flags);
926
Holger Schurig8ff12da2007-08-02 11:54:31 -0400927 lbs_deb_host("QUEUE_CMD: inserted command 0x%04x into cmdpendingq\n",
David Woodhouse981f1872007-05-25 23:36:54 -0400928 le16_to_cpu(((struct cmd_ds_gen*)cmdnode->bufvirtualaddr)->command));
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200929
930done:
Holger Schurig8ff12da2007-08-02 11:54:31 -0400931 lbs_deb_leave(LBS_DEB_HOST);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200932}
933
934/*
935 * TODO: Fix the issue when DownloadcommandToStation is being called the
Holger Schurig8ff12da2007-08-02 11:54:31 -0400936 * second time when the command times out. All the cmdptr->xxx are in little
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200937 * endian and therefore all the comparissions will fail.
938 * For now - we are not performing the endian conversion the second time - but
939 * for PS and DEEP_SLEEP we need to worry
940 */
941static int DownloadcommandToStation(wlan_private * priv,
942 struct cmd_ctrl_node *cmdnode)
943{
944 unsigned long flags;
945 struct cmd_ds_command *cmdptr;
946 wlan_adapter *adapter = priv->adapter;
947 int ret = 0;
948 u16 cmdsize;
949 u16 command;
950
Holger Schurig8ff12da2007-08-02 11:54:31 -0400951 lbs_deb_enter(LBS_DEB_HOST);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200952
953 if (!adapter || !cmdnode) {
Holger Schurig8ff12da2007-08-02 11:54:31 -0400954 lbs_deb_host("DNLD_CMD: adapter or cmdmode is NULL\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200955 if (cmdnode) {
956 spin_lock_irqsave(&adapter->driver_lock, flags);
957 __libertas_cleanup_and_insert_cmd(priv, cmdnode);
958 spin_unlock_irqrestore(&adapter->driver_lock, flags);
959 }
960 ret = -1;
961 goto done;
962 }
963
964 cmdptr = (struct cmd_ds_command *)cmdnode->bufvirtualaddr;
965
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200966 spin_lock_irqsave(&adapter->driver_lock, flags);
967 if (!cmdptr || !cmdptr->size) {
Holger Schurig8ff12da2007-08-02 11:54:31 -0400968 lbs_deb_host("DNLD_CMD: cmdptr is NULL or zero\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200969 __libertas_cleanup_and_insert_cmd(priv, cmdnode);
970 spin_unlock_irqrestore(&adapter->driver_lock, flags);
971 ret = -1;
972 goto done;
973 }
974
975 adapter->cur_cmd = cmdnode;
976 adapter->cur_cmd_retcode = 0;
977 spin_unlock_irqrestore(&adapter->driver_lock, flags);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200978
979 cmdsize = cmdptr->size;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200980 command = cpu_to_le16(cmdptr->command);
981
Holger Schurig8ff12da2007-08-02 11:54:31 -0400982 lbs_deb_host("DNLD_CMD: command 0x%04x, size %d, jiffies %lu\n",
983 command, le16_to_cpu(cmdptr->size), jiffies);
984 lbs_deb_hex(LBS_DEB_HOST, "DNLD_CMD", cmdnode->bufvirtualaddr, cmdsize);
985
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200986 cmdnode->cmdwaitqwoken = 0;
987 cmdsize = cpu_to_le16(cmdsize);
988
Holger Schurig208fdd22007-05-25 12:17:06 -0400989 ret = priv->hw_host_to_card(priv, MVMS_CMD, (u8 *) cmdptr, cmdsize);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200990
991 if (ret != 0) {
Holger Schurig8ff12da2007-08-02 11:54:31 -0400992 lbs_deb_host("DNLD_CMD: hw_host_to_card failed\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200993 spin_lock_irqsave(&adapter->driver_lock, flags);
994 __libertas_cleanup_and_insert_cmd(priv, adapter->cur_cmd);
995 adapter->cur_cmd = NULL;
996 spin_unlock_irqrestore(&adapter->driver_lock, flags);
997 ret = -1;
998 goto done;
999 }
1000
Holger Schurig8ff12da2007-08-02 11:54:31 -04001001 lbs_deb_cmd("DNLD_CMD: sent command 0x%04x, jiffies %lu\n", command, jiffies);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001002
1003 /* Setup the timer after transmit command */
Dan Williams0aef64d2007-08-02 11:31:18 -04001004 if (command == CMD_802_11_SCAN || command == CMD_802_11_AUTHENTICATE
1005 || command == CMD_802_11_ASSOCIATE)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001006 mod_timer(&adapter->command_timer, jiffies + (10*HZ));
1007 else
1008 mod_timer(&adapter->command_timer, jiffies + (5*HZ));
1009
1010 ret = 0;
1011
Holger Schurig9012b282007-05-25 11:27:16 -04001012done:
Holger Schurig8ff12da2007-08-02 11:54:31 -04001013 lbs_deb_leave_args(LBS_DEB_HOST, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001014 return ret;
1015}
1016
1017static int wlan_cmd_mac_control(wlan_private * priv,
1018 struct cmd_ds_command *cmd)
1019{
1020 struct cmd_ds_mac_control *mac = &cmd->params.macctrl;
1021
Holger Schurig9012b282007-05-25 11:27:16 -04001022 lbs_deb_enter(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001023
Dan Williams0aef64d2007-08-02 11:31:18 -04001024 cmd->command = cpu_to_le16(CMD_MAC_CONTROL);
David Woodhouse981f1872007-05-25 23:36:54 -04001025 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_mac_control) + S_DS_GEN);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001026 mac->action = cpu_to_le16(priv->adapter->currentpacketfilter);
1027
Holger Schurig8ff12da2007-08-02 11:54:31 -04001028 lbs_deb_cmd("MAC_CONTROL: action 0x%x, size %d\n",
David Woodhouse981f1872007-05-25 23:36:54 -04001029 le16_to_cpu(mac->action), le16_to_cpu(cmd->size));
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001030
Holger Schurig9012b282007-05-25 11:27:16 -04001031 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001032 return 0;
1033}
1034
1035/**
1036 * This function inserts command node to cmdfreeq
1037 * after cleans it. Requires adapter->driver_lock held.
1038 */
1039void __libertas_cleanup_and_insert_cmd(wlan_private * priv, struct cmd_ctrl_node *ptempcmd)
1040{
1041 wlan_adapter *adapter = priv->adapter;
1042
1043 if (!ptempcmd)
Holger Schurig8ff12da2007-08-02 11:54:31 -04001044 return;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001045
1046 cleanup_cmdnode(ptempcmd);
1047 list_add_tail((struct list_head *)ptempcmd, &adapter->cmdfreeq);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001048}
1049
Holger Schurigac558ca2007-08-02 11:49:06 -04001050static void libertas_cleanup_and_insert_cmd(wlan_private * priv, struct cmd_ctrl_node *ptempcmd)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001051{
1052 unsigned long flags;
1053
1054 spin_lock_irqsave(&priv->adapter->driver_lock, flags);
1055 __libertas_cleanup_and_insert_cmd(priv, ptempcmd);
1056 spin_unlock_irqrestore(&priv->adapter->driver_lock, flags);
1057}
1058
1059int libertas_set_radio_control(wlan_private * priv)
1060{
1061 int ret = 0;
1062
Holger Schurig9012b282007-05-25 11:27:16 -04001063 lbs_deb_enter(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001064
1065 ret = libertas_prepare_and_send_command(priv,
Dan Williams0aef64d2007-08-02 11:31:18 -04001066 CMD_802_11_RADIO_CONTROL,
1067 CMD_ACT_SET,
1068 CMD_OPTION_WAITFORRSP, 0, NULL);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001069
Holger Schurig8ff12da2007-08-02 11:54:31 -04001070 lbs_deb_cmd("RADIO_SET: radio %d, preamble %d\n",
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001071 priv->adapter->radioon, priv->adapter->preamble);
1072
Holger Schurig9012b282007-05-25 11:27:16 -04001073 lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001074 return ret;
1075}
1076
1077int libertas_set_mac_packet_filter(wlan_private * priv)
1078{
1079 int ret = 0;
1080
Holger Schurig9012b282007-05-25 11:27:16 -04001081 lbs_deb_enter(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001082
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001083 /* Send MAC control command to station */
1084 ret = libertas_prepare_and_send_command(priv,
Dan Williams0aef64d2007-08-02 11:31:18 -04001085 CMD_MAC_CONTROL, 0, 0, 0, NULL);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001086
Holger Schurig9012b282007-05-25 11:27:16 -04001087 lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001088 return ret;
1089}
1090
1091/**
1092 * @brief This function prepare the command before send to firmware.
1093 *
1094 * @param priv A pointer to wlan_private structure
1095 * @param cmd_no command number
1096 * @param cmd_action command action: GET or SET
1097 * @param wait_option wait option: wait response or not
1098 * @param cmd_oid cmd oid: treated as sub command
1099 * @param pdata_buf A pointer to informaion buffer
1100 * @return 0 or -1
1101 */
1102int libertas_prepare_and_send_command(wlan_private * priv,
1103 u16 cmd_no,
1104 u16 cmd_action,
1105 u16 wait_option, u32 cmd_oid, void *pdata_buf)
1106{
1107 int ret = 0;
1108 wlan_adapter *adapter = priv->adapter;
1109 struct cmd_ctrl_node *cmdnode;
1110 struct cmd_ds_command *cmdptr;
1111 unsigned long flags;
1112
Holger Schurig8ff12da2007-08-02 11:54:31 -04001113 lbs_deb_enter(LBS_DEB_HOST);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001114
1115 if (!adapter) {
Holger Schurig8ff12da2007-08-02 11:54:31 -04001116 lbs_deb_host("PREP_CMD: adapter is NULL\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001117 ret = -1;
1118 goto done;
1119 }
1120
1121 if (adapter->surpriseremoved) {
Holger Schurig8ff12da2007-08-02 11:54:31 -04001122 lbs_deb_host("PREP_CMD: card removed\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001123 ret = -1;
1124 goto done;
1125 }
1126
1127 cmdnode = libertas_get_free_cmd_ctrl_node(priv);
1128
1129 if (cmdnode == NULL) {
Holger Schurig8ff12da2007-08-02 11:54:31 -04001130 lbs_deb_host("PREP_CMD: cmdnode is NULL\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001131
1132 /* Wake up main thread to execute next command */
Dan Williamsfe336152007-08-02 11:32:25 -04001133 wake_up_interruptible(&priv->waitq);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001134 ret = -1;
1135 goto done;
1136 }
1137
1138 libertas_set_cmd_ctrl_node(priv, cmdnode, cmd_oid, wait_option, pdata_buf);
1139
1140 cmdptr = (struct cmd_ds_command *)cmdnode->bufvirtualaddr;
1141
Holger Schurig8ff12da2007-08-02 11:54:31 -04001142 lbs_deb_host("PREP_CMD: command 0x%04x\n", cmd_no);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001143
1144 if (!cmdptr) {
Holger Schurig8ff12da2007-08-02 11:54:31 -04001145 lbs_deb_host("PREP_CMD: cmdptr is NULL\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001146 libertas_cleanup_and_insert_cmd(priv, cmdnode);
1147 ret = -1;
1148 goto done;
1149 }
1150
1151 /* Set sequence number, command and INT option */
1152 adapter->seqnum++;
1153 cmdptr->seqnum = cpu_to_le16(adapter->seqnum);
1154
David Woodhouse981f1872007-05-25 23:36:54 -04001155 cmdptr->command = cpu_to_le16(cmd_no);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001156 cmdptr->result = 0;
1157
1158 switch (cmd_no) {
Dan Williams0aef64d2007-08-02 11:31:18 -04001159 case CMD_GET_HW_SPEC:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001160 ret = wlan_cmd_hw_spec(priv, cmdptr);
1161 break;
Dan Williams0aef64d2007-08-02 11:31:18 -04001162 case CMD_802_11_PS_MODE:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001163 ret = wlan_cmd_802_11_ps_mode(priv, cmdptr, cmd_action);
1164 break;
1165
Dan Williams0aef64d2007-08-02 11:31:18 -04001166 case CMD_802_11_SCAN:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001167 ret = libertas_cmd_80211_scan(priv, cmdptr, pdata_buf);
1168 break;
1169
Dan Williams0aef64d2007-08-02 11:31:18 -04001170 case CMD_MAC_CONTROL:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001171 ret = wlan_cmd_mac_control(priv, cmdptr);
1172 break;
1173
Dan Williams0aef64d2007-08-02 11:31:18 -04001174 case CMD_802_11_ASSOCIATE:
1175 case CMD_802_11_REASSOCIATE:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001176 ret = libertas_cmd_80211_associate(priv, cmdptr, pdata_buf);
1177 break;
1178
Dan Williams0aef64d2007-08-02 11:31:18 -04001179 case CMD_802_11_DEAUTHENTICATE:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001180 ret = libertas_cmd_80211_deauthenticate(priv, cmdptr);
1181 break;
1182
Dan Williams0aef64d2007-08-02 11:31:18 -04001183 case CMD_802_11_SET_WEP:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001184 ret = wlan_cmd_802_11_set_wep(priv, cmdptr, cmd_action, pdata_buf);
1185 break;
1186
Dan Williams0aef64d2007-08-02 11:31:18 -04001187 case CMD_802_11_AD_HOC_START:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001188 ret = libertas_cmd_80211_ad_hoc_start(priv, cmdptr, pdata_buf);
1189 break;
Dan Williams0aef64d2007-08-02 11:31:18 -04001190 case CMD_CODE_DNLD:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001191 break;
1192
Dan Williams0aef64d2007-08-02 11:31:18 -04001193 case CMD_802_11_RESET:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001194 ret = wlan_cmd_802_11_reset(priv, cmdptr, cmd_action);
1195 break;
1196
Dan Williams0aef64d2007-08-02 11:31:18 -04001197 case CMD_802_11_GET_LOG:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001198 ret = wlan_cmd_802_11_get_log(priv, cmdptr);
1199 break;
1200
Dan Williams0aef64d2007-08-02 11:31:18 -04001201 case CMD_802_11_AUTHENTICATE:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001202 ret = libertas_cmd_80211_authenticate(priv, cmdptr, pdata_buf);
1203 break;
1204
Dan Williams0aef64d2007-08-02 11:31:18 -04001205 case CMD_802_11_GET_STAT:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001206 ret = wlan_cmd_802_11_get_stat(priv, cmdptr);
1207 break;
1208
Dan Williams0aef64d2007-08-02 11:31:18 -04001209 case CMD_802_11_SNMP_MIB:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001210 ret = wlan_cmd_802_11_snmp_mib(priv, cmdptr,
1211 cmd_action, cmd_oid, pdata_buf);
1212 break;
1213
Dan Williams0aef64d2007-08-02 11:31:18 -04001214 case CMD_MAC_REG_ACCESS:
1215 case CMD_BBP_REG_ACCESS:
1216 case CMD_RF_REG_ACCESS:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001217 ret = wlan_cmd_reg_access(priv, cmdptr, cmd_action, pdata_buf);
1218 break;
1219
Dan Williams0aef64d2007-08-02 11:31:18 -04001220 case CMD_802_11_RF_CHANNEL:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001221 ret = wlan_cmd_802_11_rf_channel(priv, cmdptr,
1222 cmd_action, pdata_buf);
1223 break;
1224
Dan Williams0aef64d2007-08-02 11:31:18 -04001225 case CMD_802_11_RF_TX_POWER:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001226 ret = wlan_cmd_802_11_rf_tx_power(priv, cmdptr,
1227 cmd_action, pdata_buf);
1228 break;
1229
Dan Williams0aef64d2007-08-02 11:31:18 -04001230 case CMD_802_11_RADIO_CONTROL:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001231 ret = wlan_cmd_802_11_radio_control(priv, cmdptr, cmd_action);
1232 break;
1233
Dan Williams0aef64d2007-08-02 11:31:18 -04001234 case CMD_802_11_DATA_RATE:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001235 ret = wlan_cmd_802_11_data_rate(priv, cmdptr, cmd_action);
1236 break;
Dan Williams0aef64d2007-08-02 11:31:18 -04001237 case CMD_802_11_RATE_ADAPT_RATESET:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001238 ret = wlan_cmd_802_11_rate_adapt_rateset(priv,
1239 cmdptr, cmd_action);
1240 break;
1241
Dan Williams0aef64d2007-08-02 11:31:18 -04001242 case CMD_MAC_MULTICAST_ADR:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001243 ret = wlan_cmd_mac_multicast_adr(priv, cmdptr, cmd_action);
1244 break;
1245
Dan Williams0aef64d2007-08-02 11:31:18 -04001246 case CMD_802_11_AD_HOC_JOIN:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001247 ret = libertas_cmd_80211_ad_hoc_join(priv, cmdptr, pdata_buf);
1248 break;
1249
Dan Williams0aef64d2007-08-02 11:31:18 -04001250 case CMD_802_11_RSSI:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001251 ret = wlan_cmd_802_11_rssi(priv, cmdptr);
1252 break;
1253
Dan Williams0aef64d2007-08-02 11:31:18 -04001254 case CMD_802_11_AD_HOC_STOP:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001255 ret = libertas_cmd_80211_ad_hoc_stop(priv, cmdptr);
1256 break;
1257
Dan Williams0aef64d2007-08-02 11:31:18 -04001258 case CMD_802_11_ENABLE_RSN:
Dan Williams90a42212007-05-25 23:01:24 -04001259 ret = wlan_cmd_802_11_enable_rsn(priv, cmdptr, cmd_action,
1260 pdata_buf);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001261 break;
1262
Dan Williams0aef64d2007-08-02 11:31:18 -04001263 case CMD_802_11_KEY_MATERIAL:
Dan Williams90a42212007-05-25 23:01:24 -04001264 ret = wlan_cmd_802_11_key_material(priv, cmdptr, cmd_action,
1265 cmd_oid, pdata_buf);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001266 break;
1267
Dan Williams0aef64d2007-08-02 11:31:18 -04001268 case CMD_802_11_PAIRWISE_TSC:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001269 break;
Dan Williams0aef64d2007-08-02 11:31:18 -04001270 case CMD_802_11_GROUP_TSC:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001271 break;
1272
Dan Williams0aef64d2007-08-02 11:31:18 -04001273 case CMD_802_11_MAC_ADDRESS:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001274 ret = wlan_cmd_802_11_mac_address(priv, cmdptr, cmd_action);
1275 break;
1276
Dan Williams0aef64d2007-08-02 11:31:18 -04001277 case CMD_802_11_EEPROM_ACCESS:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001278 ret = wlan_cmd_802_11_eeprom_access(priv, cmdptr,
1279 cmd_action, pdata_buf);
1280 break;
1281
Dan Williams0aef64d2007-08-02 11:31:18 -04001282 case CMD_802_11_SET_AFC:
1283 case CMD_802_11_GET_AFC:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001284
1285 cmdptr->command = cpu_to_le16(cmd_no);
David Woodhouse981f1872007-05-25 23:36:54 -04001286 cmdptr->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_afc) +
1287 S_DS_GEN);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001288
1289 memmove(&cmdptr->params.afc,
1290 pdata_buf, sizeof(struct cmd_ds_802_11_afc));
1291
1292 ret = 0;
1293 goto done;
1294
Dan Williams0aef64d2007-08-02 11:31:18 -04001295 case CMD_802_11D_DOMAIN_INFO:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001296 ret = libertas_cmd_802_11d_domain_info(priv, cmdptr,
1297 cmd_no, cmd_action);
1298 break;
1299
Dan Williams0aef64d2007-08-02 11:31:18 -04001300 case CMD_802_11_SLEEP_PARAMS:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001301 ret = wlan_cmd_802_11_sleep_params(priv, cmdptr, cmd_action);
1302 break;
Dan Williams0aef64d2007-08-02 11:31:18 -04001303 case CMD_802_11_INACTIVITY_TIMEOUT:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001304 ret = wlan_cmd_802_11_inactivity_timeout(priv, cmdptr,
1305 cmd_action, pdata_buf);
1306 libertas_set_cmd_ctrl_node(priv, cmdnode, 0, 0, pdata_buf);
1307 break;
1308
Dan Williams0aef64d2007-08-02 11:31:18 -04001309 case CMD_802_11_TPC_CFG:
1310 cmdptr->command = cpu_to_le16(CMD_802_11_TPC_CFG);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001311 cmdptr->size =
1312 cpu_to_le16(sizeof(struct cmd_ds_802_11_tpc_cfg) +
1313 S_DS_GEN);
1314
1315 memmove(&cmdptr->params.tpccfg,
1316 pdata_buf, sizeof(struct cmd_ds_802_11_tpc_cfg));
1317
1318 ret = 0;
1319 break;
Dan Williams0aef64d2007-08-02 11:31:18 -04001320 case CMD_802_11_LED_GPIO_CTRL:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001321 {
1322 struct mrvlietypes_ledgpio *gpio =
1323 (struct mrvlietypes_ledgpio*)
1324 cmdptr->params.ledgpio.data;
1325
1326 memmove(&cmdptr->params.ledgpio,
1327 pdata_buf,
1328 sizeof(struct cmd_ds_802_11_led_ctrl));
1329
1330 cmdptr->command =
Dan Williams0aef64d2007-08-02 11:31:18 -04001331 cpu_to_le16(CMD_802_11_LED_GPIO_CTRL);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001332
1333#define ACTION_NUMLED_TLVTYPE_LEN_FIELDS_LEN 8
1334 cmdptr->size =
1335 cpu_to_le16(gpio->header.len + S_DS_GEN +
1336 ACTION_NUMLED_TLVTYPE_LEN_FIELDS_LEN);
1337 gpio->header.len = cpu_to_le16(gpio->header.len);
1338
1339 ret = 0;
1340 break;
1341 }
Dan Williams0aef64d2007-08-02 11:31:18 -04001342 case CMD_802_11_PWR_CFG:
1343 cmdptr->command = cpu_to_le16(CMD_802_11_PWR_CFG);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001344 cmdptr->size =
1345 cpu_to_le16(sizeof(struct cmd_ds_802_11_pwr_cfg) +
1346 S_DS_GEN);
1347 memmove(&cmdptr->params.pwrcfg, pdata_buf,
1348 sizeof(struct cmd_ds_802_11_pwr_cfg));
1349
1350 ret = 0;
1351 break;
Dan Williams0aef64d2007-08-02 11:31:18 -04001352 case CMD_BT_ACCESS:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001353 ret = wlan_cmd_bt_access(priv, cmdptr, cmd_action, pdata_buf);
1354 break;
1355
Dan Williams0aef64d2007-08-02 11:31:18 -04001356 case CMD_FWT_ACCESS:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001357 ret = wlan_cmd_fwt_access(priv, cmdptr, cmd_action, pdata_buf);
1358 break;
1359
Dan Williams0aef64d2007-08-02 11:31:18 -04001360 case CMD_MESH_ACCESS:
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001361 ret = wlan_cmd_mesh_access(priv, cmdptr, cmd_action, pdata_buf);
1362 break;
1363
Dan Williams0aef64d2007-08-02 11:31:18 -04001364 case CMD_GET_TSF:
1365 cmdptr->command = cpu_to_le16(CMD_GET_TSF);
David Woodhouse981f1872007-05-25 23:36:54 -04001366 cmdptr->size = cpu_to_le16(sizeof(struct cmd_ds_get_tsf) +
1367 S_DS_GEN);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001368 ret = 0;
1369 break;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001370 default:
Holger Schurig8ff12da2007-08-02 11:54:31 -04001371 lbs_deb_host("PREP_CMD: unknown command 0x%04x\n", cmd_no);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001372 ret = -1;
1373 break;
1374 }
1375
1376 /* return error, since the command preparation failed */
1377 if (ret != 0) {
Holger Schurig8ff12da2007-08-02 11:54:31 -04001378 lbs_deb_host("PREP_CMD: command preparation failed\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001379 libertas_cleanup_and_insert_cmd(priv, cmdnode);
1380 ret = -1;
1381 goto done;
1382 }
1383
1384 cmdnode->cmdwaitqwoken = 0;
1385
1386 libertas_queue_cmd(adapter, cmdnode, 1);
1387 adapter->nr_cmd_pending++;
Dan Williamsfe336152007-08-02 11:32:25 -04001388 wake_up_interruptible(&priv->waitq);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001389
Dan Williams0aef64d2007-08-02 11:31:18 -04001390 if (wait_option & CMD_OPTION_WAITFORRSP) {
Holger Schurig8ff12da2007-08-02 11:54:31 -04001391 lbs_deb_host("PREP_CMD: wait for response\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001392 might_sleep();
1393 wait_event_interruptible(cmdnode->cmdwait_q,
1394 cmdnode->cmdwaitqwoken);
1395 }
1396
1397 spin_lock_irqsave(&adapter->driver_lock, flags);
1398 if (adapter->cur_cmd_retcode) {
Holger Schurig8ff12da2007-08-02 11:54:31 -04001399 lbs_deb_host("PREP_CMD: command failed with return code %d\n",
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001400 adapter->cur_cmd_retcode);
1401 adapter->cur_cmd_retcode = 0;
1402 ret = -1;
1403 }
1404 spin_unlock_irqrestore(&adapter->driver_lock, flags);
1405
1406done:
Holger Schurig8ff12da2007-08-02 11:54:31 -04001407 lbs_deb_leave_args(LBS_DEB_HOST, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001408 return ret;
1409}
Holger Schurig084708b2007-05-25 12:37:58 -04001410EXPORT_SYMBOL_GPL(libertas_prepare_and_send_command);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001411
1412/**
1413 * @brief This function allocates the command buffer and link
1414 * it to command free queue.
1415 *
1416 * @param priv A pointer to wlan_private structure
1417 * @return 0 or -1
1418 */
1419int libertas_allocate_cmd_buffer(wlan_private * priv)
1420{
1421 int ret = 0;
1422 u32 ulbufsize;
1423 u32 i;
1424 struct cmd_ctrl_node *tempcmd_array;
1425 u8 *ptempvirtualaddr;
1426 wlan_adapter *adapter = priv->adapter;
1427
Holger Schurig8ff12da2007-08-02 11:54:31 -04001428 lbs_deb_enter(LBS_DEB_HOST);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001429
1430 /* Allocate and initialize cmdCtrlNode */
1431 ulbufsize = sizeof(struct cmd_ctrl_node) * MRVDRV_NUM_OF_CMD_BUFFER;
1432
Holger Schurigfb3dddf2007-05-25 11:58:22 -04001433 if (!(tempcmd_array = kzalloc(ulbufsize, GFP_KERNEL))) {
Holger Schurig8ff12da2007-08-02 11:54:31 -04001434 lbs_deb_host("ALLOC_CMD_BUF: tempcmd_array is NULL\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001435 ret = -1;
1436 goto done;
1437 }
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001438 adapter->cmd_array = tempcmd_array;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001439
1440 /* Allocate and initialize command buffers */
1441 ulbufsize = MRVDRV_SIZE_OF_CMD_BUFFER;
1442 for (i = 0; i < MRVDRV_NUM_OF_CMD_BUFFER; i++) {
Holger Schurigfb3dddf2007-05-25 11:58:22 -04001443 if (!(ptempvirtualaddr = kzalloc(ulbufsize, GFP_KERNEL))) {
Holger Schurig8ff12da2007-08-02 11:54:31 -04001444 lbs_deb_host("ALLOC_CMD_BUF: ptempvirtualaddr is NULL\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001445 ret = -1;
1446 goto done;
1447 }
1448
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001449 /* Update command buffer virtual */
1450 tempcmd_array[i].bufvirtualaddr = ptempvirtualaddr;
1451 }
1452
1453 for (i = 0; i < MRVDRV_NUM_OF_CMD_BUFFER; i++) {
1454 init_waitqueue_head(&tempcmd_array[i].cmdwait_q);
1455 libertas_cleanup_and_insert_cmd(priv, &tempcmd_array[i]);
1456 }
1457
1458 ret = 0;
Holger Schurig9012b282007-05-25 11:27:16 -04001459
1460done:
Holger Schurig8ff12da2007-08-02 11:54:31 -04001461 lbs_deb_leave_args(LBS_DEB_HOST, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001462 return ret;
1463}
1464
1465/**
1466 * @brief This function frees the command buffer.
1467 *
1468 * @param priv A pointer to wlan_private structure
1469 * @return 0 or -1
1470 */
1471int libertas_free_cmd_buffer(wlan_private * priv)
1472{
David Woodhouse981f1872007-05-25 23:36:54 -04001473 u32 ulbufsize; /* Someone needs to die for this. Slowly and painfully */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001474 unsigned int i;
1475 struct cmd_ctrl_node *tempcmd_array;
1476 wlan_adapter *adapter = priv->adapter;
1477
Holger Schurig8ff12da2007-08-02 11:54:31 -04001478 lbs_deb_enter(LBS_DEB_HOST);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001479
1480 /* need to check if cmd array is allocated or not */
1481 if (adapter->cmd_array == NULL) {
Holger Schurig8ff12da2007-08-02 11:54:31 -04001482 lbs_deb_host("FREE_CMD_BUF: cmd_array is NULL\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001483 goto done;
1484 }
1485
1486 tempcmd_array = adapter->cmd_array;
1487
1488 /* Release shared memory buffers */
1489 ulbufsize = MRVDRV_SIZE_OF_CMD_BUFFER;
1490 for (i = 0; i < MRVDRV_NUM_OF_CMD_BUFFER; i++) {
1491 if (tempcmd_array[i].bufvirtualaddr) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001492 kfree(tempcmd_array[i].bufvirtualaddr);
1493 tempcmd_array[i].bufvirtualaddr = NULL;
1494 }
1495 }
1496
1497 /* Release cmd_ctrl_node */
1498 if (adapter->cmd_array) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001499 kfree(adapter->cmd_array);
1500 adapter->cmd_array = NULL;
1501 }
1502
1503done:
Holger Schurig8ff12da2007-08-02 11:54:31 -04001504 lbs_deb_leave(LBS_DEB_HOST);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001505 return 0;
1506}
1507
1508/**
1509 * @brief This function gets a free command node if available in
1510 * command free queue.
1511 *
1512 * @param priv A pointer to wlan_private structure
1513 * @return cmd_ctrl_node A pointer to cmd_ctrl_node structure or NULL
1514 */
1515struct cmd_ctrl_node *libertas_get_free_cmd_ctrl_node(wlan_private * priv)
1516{
1517 struct cmd_ctrl_node *tempnode;
1518 wlan_adapter *adapter = priv->adapter;
1519 unsigned long flags;
1520
Holger Schurig8ff12da2007-08-02 11:54:31 -04001521 lbs_deb_enter(LBS_DEB_HOST);
1522
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001523 if (!adapter)
1524 return NULL;
1525
1526 spin_lock_irqsave(&adapter->driver_lock, flags);
1527
1528 if (!list_empty(&adapter->cmdfreeq)) {
1529 tempnode = (struct cmd_ctrl_node *)adapter->cmdfreeq.next;
1530 list_del((struct list_head *)tempnode);
1531 } else {
Holger Schurig8ff12da2007-08-02 11:54:31 -04001532 lbs_deb_host("GET_CMD_NODE: cmd_ctrl_node is not available\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001533 tempnode = NULL;
1534 }
1535
1536 spin_unlock_irqrestore(&adapter->driver_lock, flags);
1537
Holger Schurig8ff12da2007-08-02 11:54:31 -04001538 if (tempnode)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001539 cleanup_cmdnode(tempnode);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001540
Holger Schurig8ff12da2007-08-02 11:54:31 -04001541 lbs_deb_leave(LBS_DEB_HOST);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001542 return tempnode;
1543}
1544
1545/**
1546 * @brief This function cleans command node.
1547 *
1548 * @param ptempnode A pointer to cmdCtrlNode structure
1549 * @return n/a
1550 */
1551static void cleanup_cmdnode(struct cmd_ctrl_node *ptempnode)
1552{
Holger Schurig8ff12da2007-08-02 11:54:31 -04001553 lbs_deb_enter(LBS_DEB_HOST);
1554
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001555 if (!ptempnode)
1556 return;
1557 ptempnode->cmdwaitqwoken = 1;
1558 wake_up_interruptible(&ptempnode->cmdwait_q);
1559 ptempnode->status = 0;
1560 ptempnode->cmd_oid = (u32) 0;
1561 ptempnode->wait_option = 0;
1562 ptempnode->pdata_buf = NULL;
1563
1564 if (ptempnode->bufvirtualaddr != NULL)
1565 memset(ptempnode->bufvirtualaddr, 0, MRVDRV_SIZE_OF_CMD_BUFFER);
Holger Schurig8ff12da2007-08-02 11:54:31 -04001566
1567 lbs_deb_leave(LBS_DEB_HOST);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001568}
1569
1570/**
1571 * @brief This function initializes the command node.
1572 *
1573 * @param priv A pointer to wlan_private structure
1574 * @param ptempnode A pointer to cmd_ctrl_node structure
1575 * @param cmd_oid cmd oid: treated as sub command
1576 * @param wait_option wait option: wait response or not
1577 * @param pdata_buf A pointer to informaion buffer
1578 * @return 0 or -1
1579 */
1580void libertas_set_cmd_ctrl_node(wlan_private * priv,
1581 struct cmd_ctrl_node *ptempnode,
1582 u32 cmd_oid, u16 wait_option, void *pdata_buf)
1583{
Holger Schurig8ff12da2007-08-02 11:54:31 -04001584 lbs_deb_enter(LBS_DEB_HOST);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001585
1586 if (!ptempnode)
1587 return;
1588
1589 ptempnode->cmd_oid = cmd_oid;
1590 ptempnode->wait_option = wait_option;
1591 ptempnode->pdata_buf = pdata_buf;
1592
Holger Schurig8ff12da2007-08-02 11:54:31 -04001593 lbs_deb_leave(LBS_DEB_HOST);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001594}
1595
1596/**
1597 * @brief This function executes next command in command
1598 * pending queue. It will put fimware back to PS mode
1599 * if applicable.
1600 *
1601 * @param priv A pointer to wlan_private structure
1602 * @return 0 or -1
1603 */
1604int libertas_execute_next_command(wlan_private * priv)
1605{
1606 wlan_adapter *adapter = priv->adapter;
1607 struct cmd_ctrl_node *cmdnode = NULL;
1608 struct cmd_ds_command *cmdptr;
1609 unsigned long flags;
1610 int ret = 0;
1611
Holger Schurig8ff12da2007-08-02 11:54:31 -04001612 // Debug group is LBS_DEB_THREAD and not LBS_DEB_HOST, because the
1613 // only caller to us is libertas_thread() and we get even when a
1614 // data packet is received
1615 lbs_deb_enter(LBS_DEB_THREAD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001616
1617 spin_lock_irqsave(&adapter->driver_lock, flags);
1618
1619 if (adapter->cur_cmd) {
Holger Schurig8ff12da2007-08-02 11:54:31 -04001620 lbs_pr_alert( "EXEC_NEXT_CMD: already processing command!\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001621 spin_unlock_irqrestore(&adapter->driver_lock, flags);
1622 ret = -1;
1623 goto done;
1624 }
1625
1626 if (!list_empty(&adapter->cmdpendingq)) {
1627 cmdnode = (struct cmd_ctrl_node *)
1628 adapter->cmdpendingq.next;
1629 }
1630
1631 spin_unlock_irqrestore(&adapter->driver_lock, flags);
1632
1633 if (cmdnode) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001634 cmdptr = (struct cmd_ds_command *)cmdnode->bufvirtualaddr;
1635
1636 if (is_command_allowed_in_ps(cmdptr->command)) {
David Woodhouse981f1872007-05-25 23:36:54 -04001637 if ((adapter->psstate == PS_STATE_SLEEP) ||
1638 (adapter->psstate == PS_STATE_PRE_SLEEP)) {
Holger Schurig8ff12da2007-08-02 11:54:31 -04001639 lbs_deb_host(
1640 "EXEC_NEXT_CMD: cannot send cmd 0x%04x in psstate %d\n",
David Woodhouse981f1872007-05-25 23:36:54 -04001641 le16_to_cpu(cmdptr->command),
1642 adapter->psstate);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001643 ret = -1;
1644 goto done;
1645 }
Holger Schurig8ff12da2007-08-02 11:54:31 -04001646 lbs_deb_host("EXEC_NEXT_CMD: OK to send command "
1647 "0x%04x in psstate %d\n",
David Woodhouse981f1872007-05-25 23:36:54 -04001648 le16_to_cpu(cmdptr->command),
1649 adapter->psstate);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001650 } else if (adapter->psstate != PS_STATE_FULL_POWER) {
1651 /*
1652 * 1. Non-PS command:
1653 * Queue it. set needtowakeup to TRUE if current state
1654 * is SLEEP, otherwise call libertas_ps_wakeup to send Exit_PS.
1655 * 2. PS command but not Exit_PS:
1656 * Ignore it.
1657 * 3. PS command Exit_PS:
1658 * Set needtowakeup to TRUE if current state is SLEEP,
1659 * otherwise send this command down to firmware
1660 * immediately.
1661 */
1662 if (cmdptr->command !=
Dan Williams0aef64d2007-08-02 11:31:18 -04001663 cpu_to_le16(CMD_802_11_PS_MODE)) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001664 /* Prepare to send Exit PS,
1665 * this non PS command will be sent later */
1666 if ((adapter->psstate == PS_STATE_SLEEP)
1667 || (adapter->psstate == PS_STATE_PRE_SLEEP)
1668 ) {
1669 /* w/ new scheme, it will not reach here.
1670 since it is blocked in main_thread. */
1671 adapter->needtowakeup = 1;
1672 } else
1673 libertas_ps_wakeup(priv, 0);
1674
1675 ret = 0;
1676 goto done;
1677 } else {
1678 /*
1679 * PS command. Ignore it if it is not Exit_PS.
1680 * otherwise send it down immediately.
1681 */
1682 struct cmd_ds_802_11_ps_mode *psm =
1683 &cmdptr->params.psmode;
1684
Holger Schurig8ff12da2007-08-02 11:54:31 -04001685 lbs_deb_host(
1686 "EXEC_NEXT_CMD: PS cmd, action 0x%02x\n",
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001687 psm->action);
1688 if (psm->action !=
Dan Williams0aef64d2007-08-02 11:31:18 -04001689 cpu_to_le16(CMD_SUBCMD_EXIT_PS)) {
Holger Schurig8ff12da2007-08-02 11:54:31 -04001690 lbs_deb_host(
1691 "EXEC_NEXT_CMD: ignore ENTER_PS cmd\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001692 list_del((struct list_head *)cmdnode);
1693 libertas_cleanup_and_insert_cmd(priv, cmdnode);
1694
1695 ret = 0;
1696 goto done;
1697 }
1698
David Woodhouse981f1872007-05-25 23:36:54 -04001699 if ((adapter->psstate == PS_STATE_SLEEP) ||
1700 (adapter->psstate == PS_STATE_PRE_SLEEP)) {
Holger Schurig8ff12da2007-08-02 11:54:31 -04001701 lbs_deb_host(
1702 "EXEC_NEXT_CMD: ignore EXIT_PS cmd in sleep\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001703 list_del((struct list_head *)cmdnode);
1704 libertas_cleanup_and_insert_cmd(priv, cmdnode);
1705 adapter->needtowakeup = 1;
1706
1707 ret = 0;
1708 goto done;
1709 }
1710
Holger Schurig8ff12da2007-08-02 11:54:31 -04001711 lbs_deb_host(
1712 "EXEC_NEXT_CMD: sending EXIT_PS\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001713 }
1714 }
1715 list_del((struct list_head *)cmdnode);
Holger Schurig8ff12da2007-08-02 11:54:31 -04001716 lbs_deb_host("EXEC_NEXT_CMD: sending command 0x%04x\n",
David Woodhouse981f1872007-05-25 23:36:54 -04001717 le16_to_cpu(cmdptr->command));
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001718 DownloadcommandToStation(priv, cmdnode);
1719 } else {
1720 /*
1721 * check if in power save mode, if yes, put the device back
1722 * to PS mode
1723 */
Dan Williams0aef64d2007-08-02 11:31:18 -04001724 if ((adapter->psmode != WLAN802_11POWERMODECAM) &&
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001725 (adapter->psstate == PS_STATE_FULL_POWER) &&
Dan Williams0aef64d2007-08-02 11:31:18 -04001726 (adapter->connect_status == LIBERTAS_CONNECTED)) {
David Woodhouse981f1872007-05-25 23:36:54 -04001727 if (adapter->secinfo.WPAenabled ||
1728 adapter->secinfo.WPA2enabled) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001729 /* check for valid WPA group keys */
David Woodhouse981f1872007-05-25 23:36:54 -04001730 if (adapter->wpa_mcast_key.len ||
1731 adapter->wpa_unicast_key.len) {
Holger Schurig8ff12da2007-08-02 11:54:31 -04001732 lbs_deb_host(
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001733 "EXEC_NEXT_CMD: WPA enabled and GTK_SET"
1734 " go back to PS_SLEEP");
1735 libertas_ps_sleep(priv, 0);
1736 }
1737 } else {
Holger Schurig8ff12da2007-08-02 11:54:31 -04001738 lbs_deb_host(
1739 "EXEC_NEXT_CMD: cmdpendingq empty, "
1740 "go back to PS_SLEEP");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001741 libertas_ps_sleep(priv, 0);
1742 }
1743 }
1744 }
1745
1746 ret = 0;
1747done:
Holger Schurig8ff12da2007-08-02 11:54:31 -04001748 lbs_deb_leave(LBS_DEB_THREAD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001749 return ret;
1750}
1751
1752void libertas_send_iwevcustom_event(wlan_private * priv, s8 * str)
1753{
1754 union iwreq_data iwrq;
1755 u8 buf[50];
1756
Holger Schurig8ff12da2007-08-02 11:54:31 -04001757 lbs_deb_enter(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001758
1759 memset(&iwrq, 0, sizeof(union iwreq_data));
1760 memset(buf, 0, sizeof(buf));
1761
1762 snprintf(buf, sizeof(buf) - 1, "%s", str);
1763
1764 iwrq.data.length = strlen(buf) + 1 + IW_EV_LCP_LEN;
1765
1766 /* Send Event to upper layer */
Holger Schurig8ff12da2007-08-02 11:54:31 -04001767 lbs_deb_wext("event indication string %s\n", (char *)buf);
1768 lbs_deb_wext("event indication length %d\n", iwrq.data.length);
1769 lbs_deb_wext("sending wireless event IWEVCUSTOM for %s\n", str);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001770
Holger Schurig634b8f42007-05-25 13:05:16 -04001771 wireless_send_event(priv->dev, IWEVCUSTOM, &iwrq, buf);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001772
Holger Schurig8ff12da2007-08-02 11:54:31 -04001773 lbs_deb_leave(LBS_DEB_WEXT);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001774}
1775
1776static int sendconfirmsleep(wlan_private * priv, u8 * cmdptr, u16 size)
1777{
1778 unsigned long flags;
1779 wlan_adapter *adapter = priv->adapter;
1780 int ret = 0;
1781
Holger Schurig8ff12da2007-08-02 11:54:31 -04001782 lbs_deb_enter(LBS_DEB_HOST);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001783
Holger Schurig8ff12da2007-08-02 11:54:31 -04001784 lbs_deb_host("SEND_SLEEPC_CMD: before download, cmd size %d\n",
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001785 size);
1786
Holger Schurig8ff12da2007-08-02 11:54:31 -04001787 lbs_deb_hex(LBS_DEB_HOST, "sleep confirm command", cmdptr, size);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001788
Holger Schurig208fdd22007-05-25 12:17:06 -04001789 ret = priv->hw_host_to_card(priv, MVMS_CMD, cmdptr, size);
Holger Schurig634b8f42007-05-25 13:05:16 -04001790 priv->dnld_sent = DNLD_RES_RECEIVED;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001791
1792 spin_lock_irqsave(&adapter->driver_lock, flags);
1793 if (adapter->intcounter || adapter->currenttxskb)
Holger Schurig8ff12da2007-08-02 11:54:31 -04001794 lbs_deb_host("SEND_SLEEPC_CMD: intcounter %d, currenttxskb %p\n",
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001795 adapter->intcounter, adapter->currenttxskb);
1796 spin_unlock_irqrestore(&adapter->driver_lock, flags);
1797
1798 if (ret) {
1799 lbs_pr_alert(
1800 "SEND_SLEEPC_CMD: Host to Card failed for Confirm Sleep\n");
1801 } else {
1802 spin_lock_irqsave(&adapter->driver_lock, flags);
1803 if (!adapter->intcounter) {
1804 adapter->psstate = PS_STATE_SLEEP;
1805 } else {
Holger Schurig8ff12da2007-08-02 11:54:31 -04001806 lbs_deb_host("SEND_SLEEPC_CMD: after sent, intcounter %d\n",
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001807 adapter->intcounter);
1808 }
1809 spin_unlock_irqrestore(&adapter->driver_lock, flags);
1810
Holger Schurig8ff12da2007-08-02 11:54:31 -04001811 lbs_deb_host("SEND_SLEEPC_CMD: sent confirm sleep\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001812 }
1813
Holger Schurig8ff12da2007-08-02 11:54:31 -04001814 lbs_deb_leave_args(LBS_DEB_HOST, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001815 return ret;
1816}
1817
1818void libertas_ps_sleep(wlan_private * priv, int wait_option)
1819{
Holger Schurig8ff12da2007-08-02 11:54:31 -04001820 lbs_deb_enter(LBS_DEB_HOST);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001821
1822 /*
1823 * PS is currently supported only in Infrastructure mode
1824 * Remove this check if it is to be supported in IBSS mode also
1825 */
1826
Dan Williams0aef64d2007-08-02 11:31:18 -04001827 libertas_prepare_and_send_command(priv, CMD_802_11_PS_MODE,
1828 CMD_SUBCMD_ENTER_PS, wait_option, 0, NULL);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001829
Holger Schurig8ff12da2007-08-02 11:54:31 -04001830 lbs_deb_leave(LBS_DEB_HOST);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001831}
1832
1833/**
Holger Schurig8ff12da2007-08-02 11:54:31 -04001834 * @brief This function sends Exit_PS command to firmware.
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001835 *
1836 * @param priv A pointer to wlan_private structure
1837 * @param wait_option wait response or not
1838 * @return n/a
1839 */
1840void libertas_ps_wakeup(wlan_private * priv, int wait_option)
1841{
David Woodhouse981f1872007-05-25 23:36:54 -04001842 __le32 Localpsmode;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001843
Holger Schurig8ff12da2007-08-02 11:54:31 -04001844 lbs_deb_enter(LBS_DEB_HOST);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001845
Dan Williams0aef64d2007-08-02 11:31:18 -04001846 Localpsmode = cpu_to_le32(WLAN802_11POWERMODECAM);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001847
Dan Williams0aef64d2007-08-02 11:31:18 -04001848 libertas_prepare_and_send_command(priv, CMD_802_11_PS_MODE,
1849 CMD_SUBCMD_EXIT_PS,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001850 wait_option, 0, &Localpsmode);
1851
Holger Schurig8ff12da2007-08-02 11:54:31 -04001852 lbs_deb_leave(LBS_DEB_HOST);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001853}
1854
1855/**
1856 * @brief This function checks condition and prepares to
1857 * send sleep confirm command to firmware if ok.
1858 *
1859 * @param priv A pointer to wlan_private structure
1860 * @param psmode Power Saving mode
1861 * @return n/a
1862 */
1863void libertas_ps_confirm_sleep(wlan_private * priv, u16 psmode)
1864{
1865 unsigned long flags =0;
1866 wlan_adapter *adapter = priv->adapter;
1867 u8 allowed = 1;
1868
Holger Schurig8ff12da2007-08-02 11:54:31 -04001869 lbs_deb_enter(LBS_DEB_HOST);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001870
Holger Schurig634b8f42007-05-25 13:05:16 -04001871 if (priv->dnld_sent) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001872 allowed = 0;
Holger Schurig8ff12da2007-08-02 11:54:31 -04001873 lbs_deb_host("dnld_sent was set");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001874 }
1875
1876 spin_lock_irqsave(&adapter->driver_lock, flags);
1877 if (adapter->cur_cmd) {
1878 allowed = 0;
Holger Schurig8ff12da2007-08-02 11:54:31 -04001879 lbs_deb_host("cur_cmd was set");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001880 }
1881 if (adapter->intcounter > 0) {
1882 allowed = 0;
Holger Schurig8ff12da2007-08-02 11:54:31 -04001883 lbs_deb_host("intcounter %d", adapter->intcounter);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001884 }
1885 spin_unlock_irqrestore(&adapter->driver_lock, flags);
1886
1887 if (allowed) {
Holger Schurig8ff12da2007-08-02 11:54:31 -04001888 lbs_deb_host("sending libertas_ps_confirm_sleep\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001889 sendconfirmsleep(priv, (u8 *) & adapter->libertas_ps_confirm_sleep,
1890 sizeof(struct PS_CMD_ConfirmSleep));
1891 } else {
Holger Schurig8ff12da2007-08-02 11:54:31 -04001892 lbs_deb_host("sleep confirm has been delayed\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001893 }
1894
Holger Schurig8ff12da2007-08-02 11:54:31 -04001895 lbs_deb_leave(LBS_DEB_HOST);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001896}