blob: 7c9ffc511b58e2a736e3477cf0482f03c71ef36c [file] [log] [blame]
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02001/**
2 * This file contains the handling of command
3 * responses as well as events generated by firmware.
4 */
5#include <linux/delay.h>
6#include <linux/if_arp.h>
7#include <linux/netdevice.h>
8
9#include <net/iw_handler.h>
10
11#include "host.h"
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020012#include "decl.h"
13#include "defs.h"
14#include "dev.h"
15#include "join.h"
16#include "wext.h"
17
18/**
19 * @brief This function handles disconnect event. it
20 * reports disconnect to upper layer, clean tx/rx packets,
21 * reset link state etc.
22 *
Holger Schurig69f90322007-11-23 15:43:44 +010023 * @param priv A pointer to struct lbs_private structure
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020024 * @return n/a
25 */
Holger Schurig69f90322007-11-23 15:43:44 +010026void lbs_mac_event_disconnected(struct lbs_private *priv)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020027{
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020028 union iwreq_data wrqu;
29
David Woodhouseaa21c002007-12-08 20:04:36 +000030 if (priv->connect_status != LBS_CONNECTED)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020031 return;
32
Holger Schurig91843462007-11-28 14:05:02 +010033 lbs_deb_enter(LBS_DEB_ASSOC);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020034
35 memset(wrqu.ap_addr.sa_data, 0x00, ETH_ALEN);
36 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
37
38 /*
39 * Cisco AP sends EAP failure and de-auth in less than 0.5 ms.
40 * It causes problem in the Supplicant
41 */
42
43 msleep_interruptible(1000);
Holger Schurig634b8f42007-05-25 13:05:16 -040044 wireless_send_event(priv->dev, SIOCGIWAP, &wrqu, NULL);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020045
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020046 /* report disconnect to upper layer */
Holger Schurig634b8f42007-05-25 13:05:16 -040047 netif_stop_queue(priv->dev);
48 netif_carrier_off(priv->dev);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020049
David Woodhousea27b9f92007-12-12 00:41:51 -050050 /* Free Tx and Rx packets */
51 kfree_skb(priv->currenttxskb);
52 priv->currenttxskb = NULL;
53 priv->tx_pending_len = 0;
54
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020055 /* reset SNR/NF/RSSI values */
David Woodhouseaa21c002007-12-08 20:04:36 +000056 memset(priv->SNR, 0x00, sizeof(priv->SNR));
57 memset(priv->NF, 0x00, sizeof(priv->NF));
58 memset(priv->RSSI, 0x00, sizeof(priv->RSSI));
59 memset(priv->rawSNR, 0x00, sizeof(priv->rawSNR));
60 memset(priv->rawNF, 0x00, sizeof(priv->rawNF));
61 priv->nextSNRNF = 0;
62 priv->numSNRNF = 0;
63 priv->connect_status = LBS_DISCONNECTED;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020064
Dan Williamse76850d2007-05-25 17:09:41 -040065 /* Clear out associated SSID and BSSID since connection is
66 * no longer valid.
67 */
David Woodhouseaa21c002007-12-08 20:04:36 +000068 memset(&priv->curbssparams.bssid, 0, ETH_ALEN);
69 memset(&priv->curbssparams.ssid, 0, IW_ESSID_MAX_SIZE);
70 priv->curbssparams.ssid_len = 0;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020071
David Woodhouseaa21c002007-12-08 20:04:36 +000072 if (priv->psstate != PS_STATE_FULL_POWER) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020073 /* make firmware to exit PS mode */
Holger Schuriga6c87002007-08-02 11:54:10 -040074 lbs_deb_cmd("disconnected, so exit PS mode\n");
Holger Schurig10078322007-11-15 18:05:47 -050075 lbs_ps_wakeup(priv, 0);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020076 }
Holger Schuriga6c87002007-08-02 11:54:10 -040077 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020078}
79
80/**
81 * @brief This function handles MIC failure event.
82 *
Holger Schurig69f90322007-11-23 15:43:44 +010083 * @param priv A pointer to struct lbs_private structure
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020084 * @para event the event id
85 * @return n/a
86 */
Holger Schurig69f90322007-11-23 15:43:44 +010087static void handle_mic_failureevent(struct lbs_private *priv, u32 event)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020088{
89 char buf[50];
90
Holger Schuriga6c87002007-08-02 11:54:10 -040091 lbs_deb_enter(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020092 memset(buf, 0, sizeof(buf));
93
94 sprintf(buf, "%s", "MLME-MICHAELMICFAILURE.indication ");
95
96 if (event == MACREG_INT_CODE_MIC_ERR_UNICAST) {
97 strcat(buf, "unicast ");
98 } else {
99 strcat(buf, "multicast ");
100 }
101
Holger Schurig10078322007-11-15 18:05:47 -0500102 lbs_send_iwevcustom_event(priv, buf);
Holger Schuriga6c87002007-08-02 11:54:10 -0400103 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200104}
105
Holger Schurig69f90322007-11-23 15:43:44 +0100106static int lbs_ret_reg_access(struct lbs_private *priv,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200107 u16 type, struct cmd_ds_command *resp)
108{
Holger Schurig9012b282007-05-25 11:27:16 -0400109 int ret = 0;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200110
Holger Schurig9012b282007-05-25 11:27:16 -0400111 lbs_deb_enter(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200112
113 switch (type) {
Holger Schurig6b63cd02007-08-02 11:53:36 -0400114 case CMD_RET(CMD_MAC_REG_ACCESS):
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200115 {
David Woodhouse981f1872007-05-25 23:36:54 -0400116 struct cmd_ds_mac_reg_access *reg = &resp->params.macreg;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200117
David Woodhouseaa21c002007-12-08 20:04:36 +0000118 priv->offsetvalue.offset = (u32)le16_to_cpu(reg->offset);
119 priv->offsetvalue.value = le32_to_cpu(reg->value);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200120 break;
121 }
122
Holger Schurig6b63cd02007-08-02 11:53:36 -0400123 case CMD_RET(CMD_BBP_REG_ACCESS):
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200124 {
David Woodhouse981f1872007-05-25 23:36:54 -0400125 struct cmd_ds_bbp_reg_access *reg = &resp->params.bbpreg;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200126
David Woodhouseaa21c002007-12-08 20:04:36 +0000127 priv->offsetvalue.offset = (u32)le16_to_cpu(reg->offset);
128 priv->offsetvalue.value = reg->value;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200129 break;
130 }
131
Holger Schurig6b63cd02007-08-02 11:53:36 -0400132 case CMD_RET(CMD_RF_REG_ACCESS):
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200133 {
David Woodhouse981f1872007-05-25 23:36:54 -0400134 struct cmd_ds_rf_reg_access *reg = &resp->params.rfreg;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200135
David Woodhouseaa21c002007-12-08 20:04:36 +0000136 priv->offsetvalue.offset = (u32)le16_to_cpu(reg->offset);
137 priv->offsetvalue.value = reg->value;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200138 break;
139 }
140
141 default:
Holger Schurig9012b282007-05-25 11:27:16 -0400142 ret = -1;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200143 }
144
Holger Schurig8b17d722007-10-08 11:09:30 +0200145 lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret);
Holger Schurig9012b282007-05-25 11:27:16 -0400146 return ret;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200147}
148
Holger Schurig69f90322007-11-23 15:43:44 +0100149static int lbs_ret_802_11_sleep_params(struct lbs_private *priv,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200150 struct cmd_ds_command *resp)
151{
152 struct cmd_ds_802_11_sleep_params *sp = &resp->params.sleep_params;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200153
Holger Schurig9012b282007-05-25 11:27:16 -0400154 lbs_deb_enter(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200155
Holger Schuriga6c87002007-08-02 11:54:10 -0400156 lbs_deb_cmd("error 0x%x, offset 0x%x, stabletime 0x%x, calcontrol 0x%x "
157 "extsleepclk 0x%x\n", le16_to_cpu(sp->error),
David Woodhouse981f1872007-05-25 23:36:54 -0400158 le16_to_cpu(sp->offset), le16_to_cpu(sp->stabletime),
159 sp->calcontrol, sp->externalsleepclk);
160
David Woodhouseaa21c002007-12-08 20:04:36 +0000161 priv->sp.sp_error = le16_to_cpu(sp->error);
162 priv->sp.sp_offset = le16_to_cpu(sp->offset);
163 priv->sp.sp_stabletime = le16_to_cpu(sp->stabletime);
164 priv->sp.sp_calcontrol = sp->calcontrol;
165 priv->sp.sp_extsleepclk = sp->externalsleepclk;
166 priv->sp.sp_reserved = le16_to_cpu(sp->reserved);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200167
Holger Schurig9012b282007-05-25 11:27:16 -0400168 lbs_deb_enter(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200169 return 0;
170}
171
Holger Schurig69f90322007-11-23 15:43:44 +0100172static int lbs_ret_802_11_stat(struct lbs_private *priv,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200173 struct cmd_ds_command *resp)
174{
Holger Schuriga6c87002007-08-02 11:54:10 -0400175 lbs_deb_enter(LBS_DEB_CMD);
David Woodhouseaa21c002007-12-08 20:04:36 +0000176/* currently priv->wlan802_11Stat is unused
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200177
178 struct cmd_ds_802_11_get_stat *p11Stat = &resp->params.gstat;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200179
180 // TODO Convert it to Big endian befor copy
David Woodhouseaa21c002007-12-08 20:04:36 +0000181 memcpy(&priv->wlan802_11Stat,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200182 p11Stat, sizeof(struct cmd_ds_802_11_get_stat));
183*/
Holger Schuriga6c87002007-08-02 11:54:10 -0400184 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200185 return 0;
186}
187
Holger Schurig69f90322007-11-23 15:43:44 +0100188static int lbs_ret_802_11_snmp_mib(struct lbs_private *priv,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200189 struct cmd_ds_command *resp)
190{
191 struct cmd_ds_802_11_snmp_mib *smib = &resp->params.smib;
192 u16 oid = le16_to_cpu(smib->oid);
193 u16 querytype = le16_to_cpu(smib->querytype);
194
Holger Schurig9012b282007-05-25 11:27:16 -0400195 lbs_deb_enter(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200196
Holger Schuriga6c87002007-08-02 11:54:10 -0400197 lbs_deb_cmd("SNMP_RESP: oid 0x%x, querytype 0x%x\n", oid,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200198 querytype);
Holger Schuriga6c87002007-08-02 11:54:10 -0400199 lbs_deb_cmd("SNMP_RESP: Buf size %d\n", le16_to_cpu(smib->bufsize));
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200200
Dan Williams0aef64d2007-08-02 11:31:18 -0400201 if (querytype == CMD_ACT_GET) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200202 switch (oid) {
Dan Williams0aef64d2007-08-02 11:31:18 -0400203 case FRAGTHRESH_I:
David Woodhouseaa21c002007-12-08 20:04:36 +0000204 priv->fragthsd =
David Woodhouse981f1872007-05-25 23:36:54 -0400205 le16_to_cpu(*((__le16 *)(smib->value)));
Holger Schuriga6c87002007-08-02 11:54:10 -0400206 lbs_deb_cmd("SNMP_RESP: frag threshold %u\n",
David Woodhouseaa21c002007-12-08 20:04:36 +0000207 priv->fragthsd);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200208 break;
Dan Williams0aef64d2007-08-02 11:31:18 -0400209 case RTSTHRESH_I:
David Woodhouseaa21c002007-12-08 20:04:36 +0000210 priv->rtsthsd =
David Woodhouse981f1872007-05-25 23:36:54 -0400211 le16_to_cpu(*((__le16 *)(smib->value)));
Holger Schuriga6c87002007-08-02 11:54:10 -0400212 lbs_deb_cmd("SNMP_RESP: rts threshold %u\n",
David Woodhouseaa21c002007-12-08 20:04:36 +0000213 priv->rtsthsd);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200214 break;
Dan Williams0aef64d2007-08-02 11:31:18 -0400215 case SHORT_RETRYLIM_I:
David Woodhouseaa21c002007-12-08 20:04:36 +0000216 priv->txretrycount =
David Woodhouse981f1872007-05-25 23:36:54 -0400217 le16_to_cpu(*((__le16 *)(smib->value)));
Holger Schuriga6c87002007-08-02 11:54:10 -0400218 lbs_deb_cmd("SNMP_RESP: tx retry count %u\n",
David Woodhouseaa21c002007-12-08 20:04:36 +0000219 priv->rtsthsd);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200220 break;
221 default:
222 break;
223 }
224 }
225
Holger Schurig9012b282007-05-25 11:27:16 -0400226 lbs_deb_enter(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200227 return 0;
228}
229
Holger Schurig69f90322007-11-23 15:43:44 +0100230static int lbs_ret_802_11_key_material(struct lbs_private *priv,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200231 struct cmd_ds_command *resp)
232{
233 struct cmd_ds_802_11_key_material *pkeymaterial =
234 &resp->params.keymaterial;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200235 u16 action = le16_to_cpu(pkeymaterial->action);
236
Holger Schurig9012b282007-05-25 11:27:16 -0400237 lbs_deb_enter(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200238
239 /* Copy the returned key to driver private data */
Dan Williams0aef64d2007-08-02 11:31:18 -0400240 if (action == CMD_ACT_GET) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200241 u8 * buf_ptr = (u8 *) &pkeymaterial->keyParamSet;
242 u8 * resp_end = (u8 *) (resp + le16_to_cpu(resp->size));
243
244 while (buf_ptr < resp_end) {
245 struct MrvlIEtype_keyParamSet * pkeyparamset =
246 (struct MrvlIEtype_keyParamSet *) buf_ptr;
Dan Williams1443b652007-08-02 10:45:55 -0400247 struct enc_key * pkey;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200248 u16 param_set_len = le16_to_cpu(pkeyparamset->length);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200249 u16 key_len = le16_to_cpu(pkeyparamset->keylen);
Dan Williams1443b652007-08-02 10:45:55 -0400250 u16 key_flags = le16_to_cpu(pkeyparamset->keyinfo);
251 u16 key_type = le16_to_cpu(pkeyparamset->keytypeid);
252 u8 * end;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200253
254 end = (u8 *) pkeyparamset + sizeof (pkeyparamset->type)
255 + sizeof (pkeyparamset->length)
256 + param_set_len;
257 /* Make sure we don't access past the end of the IEs */
258 if (end > resp_end)
259 break;
260
Dan Williams1443b652007-08-02 10:45:55 -0400261 if (key_flags & KEY_INFO_WPA_UNICAST)
David Woodhouseaa21c002007-12-08 20:04:36 +0000262 pkey = &priv->wpa_unicast_key;
Dan Williams1443b652007-08-02 10:45:55 -0400263 else if (key_flags & KEY_INFO_WPA_MCAST)
David Woodhouseaa21c002007-12-08 20:04:36 +0000264 pkey = &priv->wpa_mcast_key;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200265 else
266 break;
267
268 /* Copy returned key into driver */
Dan Williams1443b652007-08-02 10:45:55 -0400269 memset(pkey, 0, sizeof(struct enc_key));
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200270 if (key_len > sizeof(pkey->key))
271 break;
Dan Williams1443b652007-08-02 10:45:55 -0400272 pkey->type = key_type;
273 pkey->flags = key_flags;
274 pkey->len = key_len;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200275 memcpy(pkey->key, pkeyparamset->key, pkey->len);
276
277 buf_ptr = end + 1;
278 }
279 }
280
Holger Schurig9012b282007-05-25 11:27:16 -0400281 lbs_deb_enter(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200282 return 0;
283}
284
Holger Schurig69f90322007-11-23 15:43:44 +0100285static int lbs_ret_802_11_mac_address(struct lbs_private *priv,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200286 struct cmd_ds_command *resp)
287{
288 struct cmd_ds_802_11_mac_address *macadd = &resp->params.macadd;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200289
Holger Schurig9012b282007-05-25 11:27:16 -0400290 lbs_deb_enter(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200291
David Woodhouseaa21c002007-12-08 20:04:36 +0000292 memcpy(priv->current_addr, macadd->macadd, ETH_ALEN);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200293
Holger Schurig9012b282007-05-25 11:27:16 -0400294 lbs_deb_enter(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200295 return 0;
296}
297
Holger Schurig69f90322007-11-23 15:43:44 +0100298static int lbs_ret_802_11_rf_tx_power(struct lbs_private *priv,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200299 struct cmd_ds_command *resp)
300{
301 struct cmd_ds_802_11_rf_tx_power *rtp = &resp->params.txp;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200302
Holger Schurig9012b282007-05-25 11:27:16 -0400303 lbs_deb_enter(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200304
David Woodhouseaa21c002007-12-08 20:04:36 +0000305 priv->txpowerlevel = le16_to_cpu(rtp->currentlevel);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200306
David Woodhouseaa21c002007-12-08 20:04:36 +0000307 lbs_deb_cmd("TX power currently %d\n", priv->txpowerlevel);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200308
Holger Schuriga6c87002007-08-02 11:54:10 -0400309 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200310 return 0;
311}
312
Holger Schurig69f90322007-11-23 15:43:44 +0100313static int lbs_ret_802_11_rate_adapt_rateset(struct lbs_private *priv,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200314 struct cmd_ds_command *resp)
315{
David Woodhouse981f1872007-05-25 23:36:54 -0400316 struct cmd_ds_802_11_rate_adapt_rateset *rates = &resp->params.rateset;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200317
Holger Schurig9012b282007-05-25 11:27:16 -0400318 lbs_deb_enter(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200319
Dan Williams0aef64d2007-08-02 11:31:18 -0400320 if (rates->action == CMD_ACT_GET) {
David Woodhouseaa21c002007-12-08 20:04:36 +0000321 priv->enablehwauto = le16_to_cpu(rates->enablehwauto);
322 priv->ratebitmap = le16_to_cpu(rates->bitmap);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200323 }
324
Holger Schuriga6c87002007-08-02 11:54:10 -0400325 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200326 return 0;
327}
328
Holger Schurig69f90322007-11-23 15:43:44 +0100329static int lbs_ret_802_11_rssi(struct lbs_private *priv,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200330 struct cmd_ds_command *resp)
331{
332 struct cmd_ds_802_11_rssi_rsp *rssirsp = &resp->params.rssirsp;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200333
Holger Schuriga6c87002007-08-02 11:54:10 -0400334 lbs_deb_enter(LBS_DEB_CMD);
335
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200336 /* store the non average value */
David Woodhouseaa21c002007-12-08 20:04:36 +0000337 priv->SNR[TYPE_BEACON][TYPE_NOAVG] = le16_to_cpu(rssirsp->SNR);
338 priv->NF[TYPE_BEACON][TYPE_NOAVG] = le16_to_cpu(rssirsp->noisefloor);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200339
David Woodhouseaa21c002007-12-08 20:04:36 +0000340 priv->SNR[TYPE_BEACON][TYPE_AVG] = le16_to_cpu(rssirsp->avgSNR);
341 priv->NF[TYPE_BEACON][TYPE_AVG] = le16_to_cpu(rssirsp->avgnoisefloor);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200342
David Woodhouseaa21c002007-12-08 20:04:36 +0000343 priv->RSSI[TYPE_BEACON][TYPE_NOAVG] =
344 CAL_RSSI(priv->SNR[TYPE_BEACON][TYPE_NOAVG],
345 priv->NF[TYPE_BEACON][TYPE_NOAVG]);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200346
David Woodhouseaa21c002007-12-08 20:04:36 +0000347 priv->RSSI[TYPE_BEACON][TYPE_AVG] =
348 CAL_RSSI(priv->SNR[TYPE_BEACON][TYPE_AVG] / AVG_SCALE,
349 priv->NF[TYPE_BEACON][TYPE_AVG] / AVG_SCALE);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200350
Holger Schuriga6c87002007-08-02 11:54:10 -0400351 lbs_deb_cmd("RSSI: beacon %d, avg %d\n",
David Woodhouseaa21c002007-12-08 20:04:36 +0000352 priv->RSSI[TYPE_BEACON][TYPE_NOAVG],
353 priv->RSSI[TYPE_BEACON][TYPE_AVG]);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200354
Holger Schuriga6c87002007-08-02 11:54:10 -0400355 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200356 return 0;
357}
358
Holger Schurig69f90322007-11-23 15:43:44 +0100359static int lbs_ret_802_11_eeprom_access(struct lbs_private *priv,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200360 struct cmd_ds_command *resp)
361{
Holger Schurig10078322007-11-15 18:05:47 -0500362 struct lbs_ioctl_regrdwr *pbuf;
David Woodhouseaa21c002007-12-08 20:04:36 +0000363 pbuf = (struct lbs_ioctl_regrdwr *) priv->prdeeprom;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200364
Holger Schuriga6c87002007-08-02 11:54:10 -0400365 lbs_deb_enter_args(LBS_DEB_CMD, "len %d",
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200366 le16_to_cpu(resp->params.rdeeprom.bytecount));
367 if (pbuf->NOB < le16_to_cpu(resp->params.rdeeprom.bytecount)) {
368 pbuf->NOB = 0;
Holger Schuriga6c87002007-08-02 11:54:10 -0400369 lbs_deb_cmd("EEPROM read length too big\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200370 return -1;
371 }
372 pbuf->NOB = le16_to_cpu(resp->params.rdeeprom.bytecount);
373 if (pbuf->NOB > 0) {
374
375 memcpy(&pbuf->value, (u8 *) & resp->params.rdeeprom.value,
376 le16_to_cpu(resp->params.rdeeprom.bytecount));
Holger Schuriga6c87002007-08-02 11:54:10 -0400377 lbs_deb_hex(LBS_DEB_CMD, "EEPROM", (char *)&pbuf->value,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200378 le16_to_cpu(resp->params.rdeeprom.bytecount));
379 }
Holger Schuriga6c87002007-08-02 11:54:10 -0400380 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200381 return 0;
382}
383
Holger Schurig69f90322007-11-23 15:43:44 +0100384static int lbs_ret_get_log(struct lbs_private *priv,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200385 struct cmd_ds_command *resp)
386{
David Woodhouse981f1872007-05-25 23:36:54 -0400387 struct cmd_ds_802_11_get_log *logmessage = &resp->params.glog;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200388
Holger Schurig9012b282007-05-25 11:27:16 -0400389 lbs_deb_enter(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200390
David Woodhouse981f1872007-05-25 23:36:54 -0400391 /* Stored little-endian */
David Woodhouseaa21c002007-12-08 20:04:36 +0000392 memcpy(&priv->logmsg, logmessage, sizeof(struct cmd_ds_802_11_get_log));
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200393
Holger Schuriga6c87002007-08-02 11:54:10 -0400394 lbs_deb_leave(LBS_DEB_CMD);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200395 return 0;
396}
397
Holger Schurig69f90322007-11-23 15:43:44 +0100398static int lbs_ret_802_11_enable_rsn(struct lbs_private *priv,
Dan Williams18c96c342007-06-18 12:01:12 -0400399 struct cmd_ds_command *resp)
400{
401 struct cmd_ds_802_11_enable_rsn *enable_rsn = &resp->params.enbrsn;
David Woodhouse75567672007-12-15 02:38:17 -0500402 uint32_t * pdata_buf = (uint32_t *)priv->cur_cmd->callback_arg;
Dan Williams18c96c342007-06-18 12:01:12 -0400403
404 lbs_deb_enter(LBS_DEB_CMD);
405
Dan Williams0aef64d2007-08-02 11:31:18 -0400406 if (enable_rsn->action == cpu_to_le16(CMD_ACT_GET)) {
Dan Williams18c96c342007-06-18 12:01:12 -0400407 if (pdata_buf)
David Woodhouse75567672007-12-15 02:38:17 -0500408 *pdata_buf = (uint32_t) le16_to_cpu(enable_rsn->enable);
Dan Williams18c96c342007-06-18 12:01:12 -0400409 }
410
Holger Schuriga6c87002007-08-02 11:54:10 -0400411 lbs_deb_leave(LBS_DEB_CMD);
Dan Williams18c96c342007-06-18 12:01:12 -0400412 return 0;
413}
414
Brajesh Dave96287ac2007-11-20 17:44:28 -0500415static int lbs_ret_802_11_bcn_ctrl(struct lbs_private * priv,
416 struct cmd_ds_command *resp)
417{
418 struct cmd_ds_802_11_beacon_control *bcn_ctrl =
419 &resp->params.bcn_ctrl;
Brajesh Dave96287ac2007-11-20 17:44:28 -0500420
421 lbs_deb_enter(LBS_DEB_CMD);
422
423 if (bcn_ctrl->action == CMD_ACT_GET) {
David Woodhouseaa21c002007-12-08 20:04:36 +0000424 priv->beacon_enable = (u8) le16_to_cpu(bcn_ctrl->beacon_enable);
425 priv->beacon_period = le16_to_cpu(bcn_ctrl->beacon_period);
Brajesh Dave96287ac2007-11-20 17:44:28 -0500426 }
427
428 lbs_deb_enter(LBS_DEB_CMD);
429 return 0;
430}
431
Holger Schurig3a188642007-11-26 10:07:14 +0100432static int lbs_ret_802_11_subscribe_event(struct lbs_private *priv,
433 struct cmd_ds_command *resp)
434{
Holger Schurig3a188642007-11-26 10:07:14 +0100435 struct cmd_ds_802_11_subscribe_event *cmd_event =
436 &resp->params.subscribe_event;
437 struct cmd_ds_802_11_subscribe_event *dst_event =
David Woodhouse75567672007-12-15 02:38:17 -0500438 (void *)priv->cur_cmd->callback_arg;
Holger Schurig3a188642007-11-26 10:07:14 +0100439
440 lbs_deb_enter(LBS_DEB_CMD);
441
442 if (dst_event->action == cpu_to_le16(CMD_ACT_GET)) {
Holger Schurigc2df2ef2007-12-07 15:30:44 +0000443 dst_event->events = cmd_event->events;
Holger Schurig3a188642007-11-26 10:07:14 +0100444 memcpy(dst_event->tlv, cmd_event->tlv, sizeof(dst_event->tlv));
445 }
446
447 lbs_deb_leave(LBS_DEB_CMD);
448 return 0;
449}
450
David Woodhouse1309b552007-12-10 13:36:10 -0500451static inline int handle_cmd_response(struct lbs_private *priv,
452 unsigned long dummy,
Dan Williamsddac4522007-12-11 13:49:39 -0500453 struct cmd_header *cmd_response)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200454{
Dan Williamsddac4522007-12-11 13:49:39 -0500455 struct cmd_ds_command *resp = (struct cmd_ds_command *) cmd_response;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200456 int ret = 0;
457 unsigned long flags;
David Woodhouse1309b552007-12-10 13:36:10 -0500458 uint16_t respcmd = le16_to_cpu(resp->command);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200459
Holger Schuriga6c87002007-08-02 11:54:10 -0400460 lbs_deb_enter(LBS_DEB_HOST);
461
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200462 switch (respcmd) {
Holger Schurig6b63cd02007-08-02 11:53:36 -0400463 case CMD_RET(CMD_MAC_REG_ACCESS):
464 case CMD_RET(CMD_BBP_REG_ACCESS):
465 case CMD_RET(CMD_RF_REG_ACCESS):
Holger Schurig10078322007-11-15 18:05:47 -0500466 ret = lbs_ret_reg_access(priv, respcmd, resp);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200467 break;
468
Holger Schurig6b63cd02007-08-02 11:53:36 -0400469 case CMD_RET(CMD_802_11_SCAN):
Holger Schurig10078322007-11-15 18:05:47 -0500470 ret = lbs_ret_80211_scan(priv, resp);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200471 break;
472
Holger Schurig6b63cd02007-08-02 11:53:36 -0400473 case CMD_RET(CMD_802_11_GET_LOG):
Holger Schurig10078322007-11-15 18:05:47 -0500474 ret = lbs_ret_get_log(priv, resp);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200475 break;
476
Dan Williams0aef64d2007-08-02 11:31:18 -0400477 case CMD_RET_802_11_ASSOCIATE:
Holger Schurig6b63cd02007-08-02 11:53:36 -0400478 case CMD_RET(CMD_802_11_ASSOCIATE):
479 case CMD_RET(CMD_802_11_REASSOCIATE):
Holger Schurig10078322007-11-15 18:05:47 -0500480 ret = lbs_ret_80211_associate(priv, resp);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200481 break;
482
Holger Schurig6b63cd02007-08-02 11:53:36 -0400483 case CMD_RET(CMD_802_11_DISASSOCIATE):
484 case CMD_RET(CMD_802_11_DEAUTHENTICATE):
Holger Schurig10078322007-11-15 18:05:47 -0500485 ret = lbs_ret_80211_disassociate(priv, resp);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200486 break;
487
Holger Schurig6b63cd02007-08-02 11:53:36 -0400488 case CMD_RET(CMD_802_11_AD_HOC_START):
489 case CMD_RET(CMD_802_11_AD_HOC_JOIN):
Holger Schurig10078322007-11-15 18:05:47 -0500490 ret = lbs_ret_80211_ad_hoc_start(priv, resp);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200491 break;
492
Holger Schurig6b63cd02007-08-02 11:53:36 -0400493 case CMD_RET(CMD_802_11_GET_STAT):
Holger Schurig10078322007-11-15 18:05:47 -0500494 ret = lbs_ret_802_11_stat(priv, resp);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200495 break;
496
Holger Schurig6b63cd02007-08-02 11:53:36 -0400497 case CMD_RET(CMD_802_11_SNMP_MIB):
Holger Schurig10078322007-11-15 18:05:47 -0500498 ret = lbs_ret_802_11_snmp_mib(priv, resp);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200499 break;
500
Holger Schurig6b63cd02007-08-02 11:53:36 -0400501 case CMD_RET(CMD_802_11_RF_TX_POWER):
Holger Schurig10078322007-11-15 18:05:47 -0500502 ret = lbs_ret_802_11_rf_tx_power(priv, resp);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200503 break;
504
Holger Schurig6b63cd02007-08-02 11:53:36 -0400505 case CMD_RET(CMD_802_11_SET_AFC):
506 case CMD_RET(CMD_802_11_GET_AFC):
David Woodhouseaa21c002007-12-08 20:04:36 +0000507 spin_lock_irqsave(&priv->driver_lock, flags);
David Woodhouse75567672007-12-15 02:38:17 -0500508 memmove((void *)priv->cur_cmd->callback_arg, &resp->params.afc,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200509 sizeof(struct cmd_ds_802_11_afc));
David Woodhouseaa21c002007-12-08 20:04:36 +0000510 spin_unlock_irqrestore(&priv->driver_lock, flags);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200511
512 break;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200513
Holger Schurig6b63cd02007-08-02 11:53:36 -0400514 case CMD_RET(CMD_MAC_MULTICAST_ADR):
515 case CMD_RET(CMD_MAC_CONTROL):
516 case CMD_RET(CMD_802_11_SET_WEP):
517 case CMD_RET(CMD_802_11_RESET):
518 case CMD_RET(CMD_802_11_AUTHENTICATE):
Holger Schurig6b63cd02007-08-02 11:53:36 -0400519 case CMD_RET(CMD_802_11_BEACON_STOP):
Dan Williams18c96c342007-06-18 12:01:12 -0400520 break;
521
Holger Schurig6b63cd02007-08-02 11:53:36 -0400522 case CMD_RET(CMD_802_11_ENABLE_RSN):
Holger Schurig10078322007-11-15 18:05:47 -0500523 ret = lbs_ret_802_11_enable_rsn(priv, resp);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200524 break;
525
Holger Schurig6b63cd02007-08-02 11:53:36 -0400526 case CMD_RET(CMD_802_11_RATE_ADAPT_RATESET):
Holger Schurig10078322007-11-15 18:05:47 -0500527 ret = lbs_ret_802_11_rate_adapt_rateset(priv, resp);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200528 break;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200529
Holger Schurig6b63cd02007-08-02 11:53:36 -0400530 case CMD_RET(CMD_802_11_RSSI):
Holger Schurig10078322007-11-15 18:05:47 -0500531 ret = lbs_ret_802_11_rssi(priv, resp);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200532 break;
533
Holger Schurig6b63cd02007-08-02 11:53:36 -0400534 case CMD_RET(CMD_802_11_MAC_ADDRESS):
Holger Schurig10078322007-11-15 18:05:47 -0500535 ret = lbs_ret_802_11_mac_address(priv, resp);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200536 break;
537
Holger Schurig6b63cd02007-08-02 11:53:36 -0400538 case CMD_RET(CMD_802_11_AD_HOC_STOP):
Holger Schurig10078322007-11-15 18:05:47 -0500539 ret = lbs_ret_80211_ad_hoc_stop(priv, resp);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200540 break;
541
Holger Schurig6b63cd02007-08-02 11:53:36 -0400542 case CMD_RET(CMD_802_11_KEY_MATERIAL):
Holger Schurig10078322007-11-15 18:05:47 -0500543 ret = lbs_ret_802_11_key_material(priv, resp);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200544 break;
545
Holger Schurig6b63cd02007-08-02 11:53:36 -0400546 case CMD_RET(CMD_802_11_EEPROM_ACCESS):
Holger Schurig10078322007-11-15 18:05:47 -0500547 ret = lbs_ret_802_11_eeprom_access(priv, resp);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200548 break;
549
Holger Schurig6b63cd02007-08-02 11:53:36 -0400550 case CMD_RET(CMD_802_11D_DOMAIN_INFO):
Holger Schurig10078322007-11-15 18:05:47 -0500551 ret = lbs_ret_802_11d_domain_info(priv, resp);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200552 break;
553
Holger Schurig6b63cd02007-08-02 11:53:36 -0400554 case CMD_RET(CMD_802_11_SLEEP_PARAMS):
Holger Schurig10078322007-11-15 18:05:47 -0500555 ret = lbs_ret_802_11_sleep_params(priv, resp);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200556 break;
Holger Schurig6b63cd02007-08-02 11:53:36 -0400557 case CMD_RET(CMD_802_11_INACTIVITY_TIMEOUT):
David Woodhouseaa21c002007-12-08 20:04:36 +0000558 spin_lock_irqsave(&priv->driver_lock, flags);
David Woodhouse75567672007-12-15 02:38:17 -0500559 *((uint16_t *) priv->cur_cmd->callback_arg) =
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200560 le16_to_cpu(resp->params.inactivity_timeout.timeout);
David Woodhouseaa21c002007-12-08 20:04:36 +0000561 spin_unlock_irqrestore(&priv->driver_lock, flags);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200562 break;
563
Holger Schurig6b63cd02007-08-02 11:53:36 -0400564 case CMD_RET(CMD_802_11_TPC_CFG):
David Woodhouseaa21c002007-12-08 20:04:36 +0000565 spin_lock_irqsave(&priv->driver_lock, flags);
David Woodhouse75567672007-12-15 02:38:17 -0500566 memmove((void *)priv->cur_cmd->callback_arg, &resp->params.tpccfg,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200567 sizeof(struct cmd_ds_802_11_tpc_cfg));
David Woodhouseaa21c002007-12-08 20:04:36 +0000568 spin_unlock_irqrestore(&priv->driver_lock, flags);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200569 break;
Holger Schurig6b63cd02007-08-02 11:53:36 -0400570 case CMD_RET(CMD_802_11_LED_GPIO_CTRL):
David Woodhouseaa21c002007-12-08 20:04:36 +0000571 spin_lock_irqsave(&priv->driver_lock, flags);
David Woodhouse75567672007-12-15 02:38:17 -0500572 memmove((void *)priv->cur_cmd->callback_arg, &resp->params.ledgpio,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200573 sizeof(struct cmd_ds_802_11_led_ctrl));
David Woodhouseaa21c002007-12-08 20:04:36 +0000574 spin_unlock_irqrestore(&priv->driver_lock, flags);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200575 break;
Holger Schurig3a188642007-11-26 10:07:14 +0100576 case CMD_RET(CMD_802_11_SUBSCRIBE_EVENT):
577 ret = lbs_ret_802_11_subscribe_event(priv, resp);
578 break;
579
Holger Schurig6b63cd02007-08-02 11:53:36 -0400580 case CMD_RET(CMD_802_11_PWR_CFG):
David Woodhouseaa21c002007-12-08 20:04:36 +0000581 spin_lock_irqsave(&priv->driver_lock, flags);
David Woodhouse75567672007-12-15 02:38:17 -0500582 memmove((void *)priv->cur_cmd->callback_arg, &resp->params.pwrcfg,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200583 sizeof(struct cmd_ds_802_11_pwr_cfg));
David Woodhouseaa21c002007-12-08 20:04:36 +0000584 spin_unlock_irqrestore(&priv->driver_lock, flags);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200585
586 break;
587
Holger Schurig6b63cd02007-08-02 11:53:36 -0400588 case CMD_RET(CMD_GET_TSF):
David Woodhouseaa21c002007-12-08 20:04:36 +0000589 spin_lock_irqsave(&priv->driver_lock, flags);
David Woodhouse75567672007-12-15 02:38:17 -0500590 memcpy((void *)priv->cur_cmd->callback_arg,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200591 &resp->params.gettsf.tsfvalue, sizeof(u64));
David Woodhouseaa21c002007-12-08 20:04:36 +0000592 spin_unlock_irqrestore(&priv->driver_lock, flags);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200593 break;
Holger Schurig6b63cd02007-08-02 11:53:36 -0400594 case CMD_RET(CMD_BT_ACCESS):
David Woodhouseaa21c002007-12-08 20:04:36 +0000595 spin_lock_irqsave(&priv->driver_lock, flags);
David Woodhouse75567672007-12-15 02:38:17 -0500596 if (priv->cur_cmd->callback_arg)
597 memcpy((void *)priv->cur_cmd->callback_arg,
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200598 &resp->params.bt.addr1, 2 * ETH_ALEN);
David Woodhouseaa21c002007-12-08 20:04:36 +0000599 spin_unlock_irqrestore(&priv->driver_lock, flags);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200600 break;
Holger Schurig6b63cd02007-08-02 11:53:36 -0400601 case CMD_RET(CMD_FWT_ACCESS):
David Woodhouseaa21c002007-12-08 20:04:36 +0000602 spin_lock_irqsave(&priv->driver_lock, flags);
David Woodhouse75567672007-12-15 02:38:17 -0500603 if (priv->cur_cmd->callback_arg)
604 memcpy((void *)priv->cur_cmd->callback_arg, &resp->params.fwt,
David Woodhouse981f1872007-05-25 23:36:54 -0400605 sizeof(resp->params.fwt));
David Woodhouseaa21c002007-12-08 20:04:36 +0000606 spin_unlock_irqrestore(&priv->driver_lock, flags);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200607 break;
Brajesh Dave96287ac2007-11-20 17:44:28 -0500608 case CMD_RET(CMD_802_11_BEACON_CTRL):
609 ret = lbs_ret_802_11_bcn_ctrl(priv, resp);
610 break;
611
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200612 default:
Holger Schuriga6c87002007-08-02 11:54:10 -0400613 lbs_deb_host("CMD_RESP: unknown cmd response 0x%04x\n",
David Woodhousee1258172007-12-11 23:42:49 -0500614 le16_to_cpu(resp->command));
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200615 break;
616 }
Holger Schuriga6c87002007-08-02 11:54:10 -0400617 lbs_deb_leave(LBS_DEB_HOST);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200618 return ret;
619}
620
Holger Schurig69f90322007-11-23 15:43:44 +0100621int lbs_process_rx_command(struct lbs_private *priv)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200622{
David Woodhousee1258172007-12-11 23:42:49 -0500623 uint16_t respcmd, curcmd;
Dan Williamsddac4522007-12-11 13:49:39 -0500624 struct cmd_header *resp;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200625 int ret = 0;
David Woodhousee1258172007-12-11 23:42:49 -0500626 unsigned long flags;
627 uint16_t result;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200628
Holger Schuriga6c87002007-08-02 11:54:10 -0400629 lbs_deb_enter(LBS_DEB_HOST);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200630
David Woodhouseaa21c002007-12-08 20:04:36 +0000631 mutex_lock(&priv->lock);
632 spin_lock_irqsave(&priv->driver_lock, flags);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200633
David Woodhouseaa21c002007-12-08 20:04:36 +0000634 if (!priv->cur_cmd) {
Holger Schuriga6c87002007-08-02 11:54:10 -0400635 lbs_deb_host("CMD_RESP: cur_cmd is NULL\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200636 ret = -1;
David Woodhouseaa21c002007-12-08 20:04:36 +0000637 spin_unlock_irqrestore(&priv->driver_lock, flags);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200638 goto done;
639 }
David Woodhousee1258172007-12-11 23:42:49 -0500640
David Woodhouse7003b072007-12-17 15:22:43 -0500641 resp = (void *)priv->upld_buf;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200642
David Woodhouseac4cced2007-12-17 15:12:49 -0500643 curcmd = le16_to_cpu(resp->command);
644
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200645 respcmd = le16_to_cpu(resp->command);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200646 result = le16_to_cpu(resp->result);
647
David Woodhousee1258172007-12-11 23:42:49 -0500648 lbs_deb_host("CMD_RESP: response 0x%04x, seq %d, size %d, jiffies %lu\n",
649 respcmd, le16_to_cpu(resp->seqnum), priv->upld_len, jiffies);
Dan Williamsddac4522007-12-11 13:49:39 -0500650 lbs_deb_hex(LBS_DEB_HOST, "CMD_RESP", (void *) resp, priv->upld_len);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200651
David Woodhouseac4cced2007-12-17 15:12:49 -0500652 if (resp->seqnum != resp->seqnum) {
David Woodhousee1258172007-12-11 23:42:49 -0500653 lbs_pr_info("Received CMD_RESP with invalid sequence %d (expected %d)\n",
David Woodhouseac4cced2007-12-17 15:12:49 -0500654 le16_to_cpu(resp->seqnum), le16_to_cpu(resp->seqnum));
David Woodhouseaa21c002007-12-08 20:04:36 +0000655 spin_unlock_irqrestore(&priv->driver_lock, flags);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200656 ret = -1;
657 goto done;
658 }
David Woodhousee1258172007-12-11 23:42:49 -0500659 if (respcmd != CMD_RET(curcmd) &&
660 respcmd != CMD_802_11_ASSOCIATE && curcmd != CMD_RET_802_11_ASSOCIATE) {
661 lbs_pr_info("Invalid CMD_RESP %x to command %x!\n", respcmd, curcmd);
662 spin_unlock_irqrestore(&priv->driver_lock, flags);
663 ret = -1;
664 goto done;
665 }
666
David Woodhouse85388232007-12-17 15:41:30 -0500667 if (resp->result == cpu_to_le16(0x0004)) {
668 /* 0x0004 means -EAGAIN. Drop the response, let it time out
669 and be resubmitted */
670 lbs_pr_info("Firmware returns DEFER to command %x. Will let it time out...\n",
671 le16_to_cpu(resp->command));
672 spin_unlock_irqrestore(&priv->driver_lock, flags);
673 ret = -1;
674 goto done;
675 }
676
David Woodhousee1258172007-12-11 23:42:49 -0500677 /* Now we got response from FW, cancel the command timer */
678 del_timer(&priv->command_timer);
David Woodhouse2a345092007-12-15 19:33:43 -0500679 priv->cmd_timed_out = 0;
680 if (priv->nr_retries) {
681 lbs_pr_info("Received result %x to command %x after %d retries\n",
682 result, curcmd, priv->nr_retries);
683 priv->nr_retries = 0;
684 }
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200685
686 /* Store the response code to cur_cmd_retcode. */
David Woodhouseaa21c002007-12-08 20:04:36 +0000687 priv->cur_cmd_retcode = result;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200688
Holger Schurig6b63cd02007-08-02 11:53:36 -0400689 if (respcmd == CMD_RET(CMD_802_11_PS_MODE)) {
David Woodhouse38bfab12007-12-16 23:26:54 -0500690 struct cmd_ds_802_11_ps_mode *psmode = (void *) &resp[1];
David Woodhouse981f1872007-05-25 23:36:54 -0400691 u16 action = le16_to_cpu(psmode->action);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200692
Holger Schuriga6c87002007-08-02 11:54:10 -0400693 lbs_deb_host(
694 "CMD_RESP: PS_MODE cmd reply result 0x%x, action 0x%x\n",
David Woodhouse981f1872007-05-25 23:36:54 -0400695 result, action);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200696
697 if (result) {
Holger Schuriga6c87002007-08-02 11:54:10 -0400698 lbs_deb_host("CMD_RESP: PS command failed with 0x%x\n",
David Woodhouse981f1872007-05-25 23:36:54 -0400699 result);
700 /*
701 * We should not re-try enter-ps command in
702 * ad-hoc mode. It takes place in
Holger Schurig10078322007-11-15 18:05:47 -0500703 * lbs_execute_next_command().
David Woodhouse981f1872007-05-25 23:36:54 -0400704 */
David Woodhouseaa21c002007-12-08 20:04:36 +0000705 if (priv->mode == IW_MODE_ADHOC &&
Dan Williams0aef64d2007-08-02 11:31:18 -0400706 action == CMD_SUBCMD_ENTER_PS)
David Woodhouseaa21c002007-12-08 20:04:36 +0000707 priv->psmode = LBS802_11POWERMODECAM;
Dan Williams0aef64d2007-08-02 11:31:18 -0400708 } else if (action == CMD_SUBCMD_ENTER_PS) {
David Woodhouseaa21c002007-12-08 20:04:36 +0000709 priv->needtowakeup = 0;
710 priv->psstate = PS_STATE_AWAKE;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200711
Holger Schuriga6c87002007-08-02 11:54:10 -0400712 lbs_deb_host("CMD_RESP: ENTER_PS command response\n");
David Woodhouseaa21c002007-12-08 20:04:36 +0000713 if (priv->connect_status != LBS_CONNECTED) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200714 /*
715 * When Deauth Event received before Enter_PS command
716 * response, We need to wake up the firmware.
717 */
Holger Schuriga6c87002007-08-02 11:54:10 -0400718 lbs_deb_host(
Holger Schurig10078322007-11-15 18:05:47 -0500719 "disconnected, invoking lbs_ps_wakeup\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200720
David Woodhouseaa21c002007-12-08 20:04:36 +0000721 spin_unlock_irqrestore(&priv->driver_lock, flags);
722 mutex_unlock(&priv->lock);
Holger Schurig10078322007-11-15 18:05:47 -0500723 lbs_ps_wakeup(priv, 0);
David Woodhouseaa21c002007-12-08 20:04:36 +0000724 mutex_lock(&priv->lock);
725 spin_lock_irqsave(&priv->driver_lock, flags);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200726 }
Dan Williams0aef64d2007-08-02 11:31:18 -0400727 } else if (action == CMD_SUBCMD_EXIT_PS) {
David Woodhouseaa21c002007-12-08 20:04:36 +0000728 priv->needtowakeup = 0;
729 priv->psstate = PS_STATE_FULL_POWER;
Holger Schuriga6c87002007-08-02 11:54:10 -0400730 lbs_deb_host("CMD_RESP: EXIT_PS command response\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200731 } else {
Holger Schuriga6c87002007-08-02 11:54:10 -0400732 lbs_deb_host("CMD_RESP: PS action 0x%X\n", action);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200733 }
734
David Woodhouse183aeac2007-12-15 01:52:54 -0500735 lbs_complete_command(priv, priv->cur_cmd, result);
David Woodhouseaa21c002007-12-08 20:04:36 +0000736 spin_unlock_irqrestore(&priv->driver_lock, flags);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200737
738 ret = 0;
739 goto done;
740 }
741
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200742 /* If the command is not successful, cleanup and return failure */
743 if ((result != 0 || !(respcmd & 0x8000))) {
Holger Schuriga6c87002007-08-02 11:54:10 -0400744 lbs_deb_host("CMD_RESP: error 0x%04x in command reply 0x%04x\n",
745 result, respcmd);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200746 /*
747 * Handling errors here
748 */
749 switch (respcmd) {
Holger Schurig6b63cd02007-08-02 11:53:36 -0400750 case CMD_RET(CMD_GET_HW_SPEC):
751 case CMD_RET(CMD_802_11_RESET):
Holger Schuriga6c87002007-08-02 11:54:10 -0400752 lbs_deb_host("CMD_RESP: reset failed\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200753 break;
754
755 }
David Woodhouse183aeac2007-12-15 01:52:54 -0500756 lbs_complete_command(priv, priv->cur_cmd, result);
David Woodhouseaa21c002007-12-08 20:04:36 +0000757 spin_unlock_irqrestore(&priv->driver_lock, flags);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200758
759 ret = -1;
760 goto done;
761 }
762
David Woodhouseaa21c002007-12-08 20:04:36 +0000763 spin_unlock_irqrestore(&priv->driver_lock, flags);
David Woodhouse17230472007-12-07 15:13:05 +0000764
Dan Williams7ad994d2007-12-11 12:33:30 -0500765 if (priv->cur_cmd && priv->cur_cmd->callback) {
766 ret = priv->cur_cmd->callback(priv, priv->cur_cmd->callback_arg,
Dan Williamsddac4522007-12-11 13:49:39 -0500767 resp);
Dan Williams7ad994d2007-12-11 12:33:30 -0500768 } else
David Woodhouse1309b552007-12-10 13:36:10 -0500769 ret = handle_cmd_response(priv, 0, resp);
David Woodhouse17230472007-12-07 15:13:05 +0000770
David Woodhouseaa21c002007-12-08 20:04:36 +0000771 spin_lock_irqsave(&priv->driver_lock, flags);
David Woodhouse17230472007-12-07 15:13:05 +0000772
David Woodhouseaa21c002007-12-08 20:04:36 +0000773 if (priv->cur_cmd) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200774 /* Clean up and Put current command back to cmdfreeq */
David Woodhouse183aeac2007-12-15 01:52:54 -0500775 lbs_complete_command(priv, priv->cur_cmd, result);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200776 }
David Woodhouseaa21c002007-12-08 20:04:36 +0000777 spin_unlock_irqrestore(&priv->driver_lock, flags);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200778
779done:
David Woodhouseaa21c002007-12-08 20:04:36 +0000780 mutex_unlock(&priv->lock);
Holger Schuriga6c87002007-08-02 11:54:10 -0400781 lbs_deb_leave_args(LBS_DEB_HOST, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200782 return ret;
783}
784
David Woodhouseb47ef242007-12-17 13:26:42 -0500785static int lbs_send_confirmwake(struct lbs_private *priv)
786{
787 struct cmd_header *cmd = &priv->lbs_ps_confirm_wake;
788 int ret = 0;
789
790 lbs_deb_enter(LBS_DEB_HOST);
791
792 cmd->command = cpu_to_le16(CMD_802_11_WAKEUP_CONFIRM);
793 cmd->size = cpu_to_le16(sizeof(*cmd));
794 cmd->seqnum = cpu_to_le16(++priv->seqnum);
795 cmd->result = 0;
796
797 lbs_deb_host("SEND_WAKEC_CMD: before download\n");
798
799 lbs_deb_hex(LBS_DEB_HOST, "wake confirm command", (void *)cmd, sizeof(*cmd));
800
801 ret = priv->hw_host_to_card(priv, MVMS_CMD, (void *)cmd, sizeof(*cmd));
802 if (ret)
803 lbs_pr_alert("SEND_WAKEC_CMD: Host to Card failed for Confirm Wake\n");
804
805 lbs_deb_leave_args(LBS_DEB_HOST, "ret %d", ret);
806 return ret;
807}
808
Holger Schurig69f90322007-11-23 15:43:44 +0100809int lbs_process_event(struct lbs_private *priv)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200810{
811 int ret = 0;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200812 u32 eventcause;
813
Holger Schurig9556d212007-08-02 13:14:07 -0400814 lbs_deb_enter(LBS_DEB_CMD);
815
David Woodhouseaa21c002007-12-08 20:04:36 +0000816 spin_lock_irq(&priv->driver_lock);
817 eventcause = priv->eventcause >> SBI_EVENT_CAUSE_SHIFT;
818 spin_unlock_irq(&priv->driver_lock);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200819
Holger Schurig0b3c07f2007-11-28 09:15:11 +0100820 lbs_deb_cmd("event cause %d\n", eventcause);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200821
Holger Schurig0b3c07f2007-11-28 09:15:11 +0100822 switch (eventcause) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200823 case MACREG_INT_CODE_LINK_SENSED:
Holger Schurig9012b282007-05-25 11:27:16 -0400824 lbs_deb_cmd("EVENT: MACREG_INT_CODE_LINK_SENSED\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200825 break;
826
827 case MACREG_INT_CODE_DEAUTHENTICATED:
Holger Schuriga6c87002007-08-02 11:54:10 -0400828 lbs_deb_cmd("EVENT: deauthenticated\n");
Holger Schurig10078322007-11-15 18:05:47 -0500829 lbs_mac_event_disconnected(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200830 break;
831
832 case MACREG_INT_CODE_DISASSOCIATED:
Holger Schuriga6c87002007-08-02 11:54:10 -0400833 lbs_deb_cmd("EVENT: disassociated\n");
Holger Schurig10078322007-11-15 18:05:47 -0500834 lbs_mac_event_disconnected(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200835 break;
836
Holger Schurig0b3c07f2007-11-28 09:15:11 +0100837 case MACREG_INT_CODE_LINK_LOST_NO_SCAN:
Holger Schuriga6c87002007-08-02 11:54:10 -0400838 lbs_deb_cmd("EVENT: link lost\n");
Holger Schurig10078322007-11-15 18:05:47 -0500839 lbs_mac_event_disconnected(priv);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200840 break;
841
842 case MACREG_INT_CODE_PS_SLEEP:
Holger Schuriga6c87002007-08-02 11:54:10 -0400843 lbs_deb_cmd("EVENT: sleep\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200844
845 /* handle unexpected PS SLEEP event */
David Woodhouseaa21c002007-12-08 20:04:36 +0000846 if (priv->psstate == PS_STATE_FULL_POWER) {
Holger Schurig9012b282007-05-25 11:27:16 -0400847 lbs_deb_cmd(
Holger Schuriga6c87002007-08-02 11:54:10 -0400848 "EVENT: in FULL POWER mode, ignoreing PS_SLEEP\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200849 break;
850 }
David Woodhouseaa21c002007-12-08 20:04:36 +0000851 priv->psstate = PS_STATE_PRE_SLEEP;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200852
David Woodhouseaa21c002007-12-08 20:04:36 +0000853 lbs_ps_confirm_sleep(priv, (u16) priv->psmode);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200854
855 break;
856
David Woodhouseb47ef242007-12-17 13:26:42 -0500857 case MACREG_INT_CODE_HOST_AWAKE:
858 lbs_deb_cmd("EVENT: HOST_AWAKE\n");
859 lbs_send_confirmwake(priv);
860 break;
861
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200862 case MACREG_INT_CODE_PS_AWAKE:
Holger Schuriga6c87002007-08-02 11:54:10 -0400863 lbs_deb_cmd("EVENT: awake\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200864 /* handle unexpected PS AWAKE event */
David Woodhouseaa21c002007-12-08 20:04:36 +0000865 if (priv->psstate == PS_STATE_FULL_POWER) {
Holger Schurig9012b282007-05-25 11:27:16 -0400866 lbs_deb_cmd(
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200867 "EVENT: In FULL POWER mode - ignore PS AWAKE\n");
868 break;
869 }
870
David Woodhouseaa21c002007-12-08 20:04:36 +0000871 priv->psstate = PS_STATE_AWAKE;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200872
David Woodhouseaa21c002007-12-08 20:04:36 +0000873 if (priv->needtowakeup) {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200874 /*
875 * wait for the command processing to finish
876 * before resuming sending
David Woodhouseaa21c002007-12-08 20:04:36 +0000877 * priv->needtowakeup will be set to FALSE
Holger Schurig10078322007-11-15 18:05:47 -0500878 * in lbs_ps_wakeup()
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200879 */
Holger Schuriga6c87002007-08-02 11:54:10 -0400880 lbs_deb_cmd("waking up ...\n");
Holger Schurig10078322007-11-15 18:05:47 -0500881 lbs_ps_wakeup(priv, 0);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200882 }
883 break;
884
885 case MACREG_INT_CODE_MIC_ERR_UNICAST:
Holger Schurig9012b282007-05-25 11:27:16 -0400886 lbs_deb_cmd("EVENT: UNICAST MIC ERROR\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200887 handle_mic_failureevent(priv, MACREG_INT_CODE_MIC_ERR_UNICAST);
888 break;
889
890 case MACREG_INT_CODE_MIC_ERR_MULTICAST:
Holger Schurig9012b282007-05-25 11:27:16 -0400891 lbs_deb_cmd("EVENT: MULTICAST MIC ERROR\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200892 handle_mic_failureevent(priv, MACREG_INT_CODE_MIC_ERR_MULTICAST);
893 break;
894 case MACREG_INT_CODE_MIB_CHANGED:
895 case MACREG_INT_CODE_INIT_DONE:
896 break;
897
898 case MACREG_INT_CODE_ADHOC_BCN_LOST:
Holger Schuriga6c87002007-08-02 11:54:10 -0400899 lbs_deb_cmd("EVENT: ADHOC beacon lost\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200900 break;
901
902 case MACREG_INT_CODE_RSSI_LOW:
Holger Schuriga6c87002007-08-02 11:54:10 -0400903 lbs_pr_alert("EVENT: rssi low\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200904 break;
905 case MACREG_INT_CODE_SNR_LOW:
Holger Schuriga6c87002007-08-02 11:54:10 -0400906 lbs_pr_alert("EVENT: snr low\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200907 break;
908 case MACREG_INT_CODE_MAX_FAIL:
Holger Schuriga6c87002007-08-02 11:54:10 -0400909 lbs_pr_alert("EVENT: max fail\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200910 break;
911 case MACREG_INT_CODE_RSSI_HIGH:
Holger Schuriga6c87002007-08-02 11:54:10 -0400912 lbs_pr_alert("EVENT: rssi high\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200913 break;
914 case MACREG_INT_CODE_SNR_HIGH:
Holger Schuriga6c87002007-08-02 11:54:10 -0400915 lbs_pr_alert("EVENT: snr high\n");
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200916 break;
917
Luis Carlos Cobo Rus7d8d28b2007-05-25 23:12:19 -0400918 case MACREG_INT_CODE_MESH_AUTO_STARTED:
Dan Williams5612c012007-08-02 13:20:12 -0400919 /* Ignore spurious autostart events if autostart is disabled */
920 if (!priv->mesh_autostart_enabled) {
921 lbs_pr_info("EVENT: MESH_AUTO_STARTED (ignoring)\n");
922 break;
923 }
Luis Carlos Cobo9cdc6d22007-08-02 11:55:22 -0400924 lbs_pr_info("EVENT: MESH_AUTO_STARTED\n");
David Woodhouseaa21c002007-12-08 20:04:36 +0000925 priv->mesh_connect_status = LBS_CONNECTED;
David Woodhousea27b9f92007-12-12 00:41:51 -0500926 if (priv->mesh_open) {
Luis Carlos Cobo9cdc6d22007-08-02 11:55:22 -0400927 netif_carrier_on(priv->mesh_dev);
David Woodhousea27b9f92007-12-12 00:41:51 -0500928 if (!priv->tx_pending_len)
929 netif_wake_queue(priv->mesh_dev);
Luis Carlos Cobo Rus7d8d28b2007-05-25 23:12:19 -0400930 }
David Woodhouseaa21c002007-12-08 20:04:36 +0000931 priv->mode = IW_MODE_ADHOC;
Luis Carlos Cobo Rusb8bedef2007-05-30 12:14:34 -0400932 schedule_work(&priv->sync_channel);
Luis Carlos Cobo Rus7d8d28b2007-05-25 23:12:19 -0400933 break;
934
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200935 default:
Holger Schurig0b3c07f2007-11-28 09:15:11 +0100936 lbs_pr_alert("EVENT: unknown event id %d\n", eventcause);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200937 break;
938 }
939
David Woodhouseaa21c002007-12-08 20:04:36 +0000940 spin_lock_irq(&priv->driver_lock);
941 priv->eventcause = 0;
942 spin_unlock_irq(&priv->driver_lock);
Holger Schurig9012b282007-05-25 11:27:16 -0400943
Holger Schurig9556d212007-08-02 13:14:07 -0400944 lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret);
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200945 return ret;
946}