Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1 | /** |
| 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 Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 12 | #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 Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 23 | * @param priv A pointer to struct lbs_private structure |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 24 | * @return n/a |
| 25 | */ |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 26 | void lbs_mac_event_disconnected(struct lbs_private *priv) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 27 | { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 28 | union iwreq_data wrqu; |
| 29 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 30 | if (priv->connect_status != LBS_CONNECTED) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 31 | return; |
| 32 | |
Holger Schurig | 9184346 | 2007-11-28 14:05:02 +0100 | [diff] [blame] | 33 | lbs_deb_enter(LBS_DEB_ASSOC); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 34 | |
| 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 Schurig | 634b8f4 | 2007-05-25 13:05:16 -0400 | [diff] [blame] | 44 | wireless_send_event(priv->dev, SIOCGIWAP, &wrqu, NULL); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 45 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 46 | /* report disconnect to upper layer */ |
Holger Schurig | 634b8f4 | 2007-05-25 13:05:16 -0400 | [diff] [blame] | 47 | netif_stop_queue(priv->dev); |
| 48 | netif_carrier_off(priv->dev); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 49 | |
David Woodhouse | a27b9f9 | 2007-12-12 00:41:51 -0500 | [diff] [blame] | 50 | /* Free Tx and Rx packets */ |
| 51 | kfree_skb(priv->currenttxskb); |
| 52 | priv->currenttxskb = NULL; |
| 53 | priv->tx_pending_len = 0; |
| 54 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 55 | /* reset SNR/NF/RSSI values */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 56 | 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 Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 64 | |
Dan Williams | e76850d | 2007-05-25 17:09:41 -0400 | [diff] [blame] | 65 | /* Clear out associated SSID and BSSID since connection is |
| 66 | * no longer valid. |
| 67 | */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 68 | memset(&priv->curbssparams.bssid, 0, ETH_ALEN); |
| 69 | memset(&priv->curbssparams.ssid, 0, IW_ESSID_MAX_SIZE); |
| 70 | priv->curbssparams.ssid_len = 0; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 71 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 72 | if (priv->psstate != PS_STATE_FULL_POWER) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 73 | /* make firmware to exit PS mode */ |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 74 | lbs_deb_cmd("disconnected, so exit PS mode\n"); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 75 | lbs_ps_wakeup(priv, 0); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 76 | } |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 77 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | /** |
| 81 | * @brief This function handles MIC failure event. |
| 82 | * |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 83 | * @param priv A pointer to struct lbs_private structure |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 84 | * @para event the event id |
| 85 | * @return n/a |
| 86 | */ |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 87 | static void handle_mic_failureevent(struct lbs_private *priv, u32 event) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 88 | { |
| 89 | char buf[50]; |
| 90 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 91 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 92 | 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 Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 102 | lbs_send_iwevcustom_event(priv, buf); |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 103 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 104 | } |
| 105 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 106 | static int lbs_ret_reg_access(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 107 | u16 type, struct cmd_ds_command *resp) |
| 108 | { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 109 | int ret = 0; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 110 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 111 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 112 | |
| 113 | switch (type) { |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 114 | case CMD_RET(CMD_MAC_REG_ACCESS): |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 115 | { |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 116 | struct cmd_ds_mac_reg_access *reg = &resp->params.macreg; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 117 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 118 | priv->offsetvalue.offset = (u32)le16_to_cpu(reg->offset); |
| 119 | priv->offsetvalue.value = le32_to_cpu(reg->value); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 120 | break; |
| 121 | } |
| 122 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 123 | case CMD_RET(CMD_BBP_REG_ACCESS): |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 124 | { |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 125 | struct cmd_ds_bbp_reg_access *reg = &resp->params.bbpreg; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 126 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 127 | priv->offsetvalue.offset = (u32)le16_to_cpu(reg->offset); |
| 128 | priv->offsetvalue.value = reg->value; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 129 | break; |
| 130 | } |
| 131 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 132 | case CMD_RET(CMD_RF_REG_ACCESS): |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 133 | { |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 134 | struct cmd_ds_rf_reg_access *reg = &resp->params.rfreg; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 135 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 136 | priv->offsetvalue.offset = (u32)le16_to_cpu(reg->offset); |
| 137 | priv->offsetvalue.value = reg->value; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 138 | break; |
| 139 | } |
| 140 | |
| 141 | default: |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 142 | ret = -1; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 143 | } |
| 144 | |
Holger Schurig | 8b17d72 | 2007-10-08 11:09:30 +0200 | [diff] [blame] | 145 | lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret); |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 146 | return ret; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 147 | } |
| 148 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 149 | static int lbs_ret_802_11_sleep_params(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 150 | struct cmd_ds_command *resp) |
| 151 | { |
| 152 | struct cmd_ds_802_11_sleep_params *sp = &resp->params.sleep_params; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 153 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 154 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 155 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 156 | 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 Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 158 | le16_to_cpu(sp->offset), le16_to_cpu(sp->stabletime), |
| 159 | sp->calcontrol, sp->externalsleepclk); |
| 160 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 161 | 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 Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 167 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 168 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 169 | return 0; |
| 170 | } |
| 171 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 172 | static int lbs_ret_802_11_stat(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 173 | struct cmd_ds_command *resp) |
| 174 | { |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 175 | lbs_deb_enter(LBS_DEB_CMD); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 176 | /* currently priv->wlan802_11Stat is unused |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 177 | |
| 178 | struct cmd_ds_802_11_get_stat *p11Stat = &resp->params.gstat; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 179 | |
| 180 | // TODO Convert it to Big endian befor copy |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 181 | memcpy(&priv->wlan802_11Stat, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 182 | p11Stat, sizeof(struct cmd_ds_802_11_get_stat)); |
| 183 | */ |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 184 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 185 | return 0; |
| 186 | } |
| 187 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 188 | static int lbs_ret_802_11_snmp_mib(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 189 | 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 Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 195 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 196 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 197 | lbs_deb_cmd("SNMP_RESP: oid 0x%x, querytype 0x%x\n", oid, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 198 | querytype); |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 199 | lbs_deb_cmd("SNMP_RESP: Buf size %d\n", le16_to_cpu(smib->bufsize)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 200 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 201 | if (querytype == CMD_ACT_GET) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 202 | switch (oid) { |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 203 | case FRAGTHRESH_I: |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 204 | priv->fragthsd = |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 205 | le16_to_cpu(*((__le16 *)(smib->value))); |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 206 | lbs_deb_cmd("SNMP_RESP: frag threshold %u\n", |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 207 | priv->fragthsd); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 208 | break; |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 209 | case RTSTHRESH_I: |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 210 | priv->rtsthsd = |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 211 | le16_to_cpu(*((__le16 *)(smib->value))); |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 212 | lbs_deb_cmd("SNMP_RESP: rts threshold %u\n", |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 213 | priv->rtsthsd); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 214 | break; |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 215 | case SHORT_RETRYLIM_I: |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 216 | priv->txretrycount = |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 217 | le16_to_cpu(*((__le16 *)(smib->value))); |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 218 | lbs_deb_cmd("SNMP_RESP: tx retry count %u\n", |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 219 | priv->rtsthsd); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 220 | break; |
| 221 | default: |
| 222 | break; |
| 223 | } |
| 224 | } |
| 225 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 226 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 227 | return 0; |
| 228 | } |
| 229 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 230 | static int lbs_ret_802_11_key_material(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 231 | struct cmd_ds_command *resp) |
| 232 | { |
| 233 | struct cmd_ds_802_11_key_material *pkeymaterial = |
| 234 | &resp->params.keymaterial; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 235 | u16 action = le16_to_cpu(pkeymaterial->action); |
| 236 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 237 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 238 | |
| 239 | /* Copy the returned key to driver private data */ |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 240 | if (action == CMD_ACT_GET) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 241 | 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 Williams | 1443b65 | 2007-08-02 10:45:55 -0400 | [diff] [blame] | 247 | struct enc_key * pkey; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 248 | u16 param_set_len = le16_to_cpu(pkeyparamset->length); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 249 | u16 key_len = le16_to_cpu(pkeyparamset->keylen); |
Dan Williams | 1443b65 | 2007-08-02 10:45:55 -0400 | [diff] [blame] | 250 | u16 key_flags = le16_to_cpu(pkeyparamset->keyinfo); |
| 251 | u16 key_type = le16_to_cpu(pkeyparamset->keytypeid); |
| 252 | u8 * end; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 253 | |
| 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 Williams | 1443b65 | 2007-08-02 10:45:55 -0400 | [diff] [blame] | 261 | if (key_flags & KEY_INFO_WPA_UNICAST) |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 262 | pkey = &priv->wpa_unicast_key; |
Dan Williams | 1443b65 | 2007-08-02 10:45:55 -0400 | [diff] [blame] | 263 | else if (key_flags & KEY_INFO_WPA_MCAST) |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 264 | pkey = &priv->wpa_mcast_key; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 265 | else |
| 266 | break; |
| 267 | |
| 268 | /* Copy returned key into driver */ |
Dan Williams | 1443b65 | 2007-08-02 10:45:55 -0400 | [diff] [blame] | 269 | memset(pkey, 0, sizeof(struct enc_key)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 270 | if (key_len > sizeof(pkey->key)) |
| 271 | break; |
Dan Williams | 1443b65 | 2007-08-02 10:45:55 -0400 | [diff] [blame] | 272 | pkey->type = key_type; |
| 273 | pkey->flags = key_flags; |
| 274 | pkey->len = key_len; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 275 | memcpy(pkey->key, pkeyparamset->key, pkey->len); |
| 276 | |
| 277 | buf_ptr = end + 1; |
| 278 | } |
| 279 | } |
| 280 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 281 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 282 | return 0; |
| 283 | } |
| 284 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 285 | static int lbs_ret_802_11_mac_address(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 286 | struct cmd_ds_command *resp) |
| 287 | { |
| 288 | struct cmd_ds_802_11_mac_address *macadd = &resp->params.macadd; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 289 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 290 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 291 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 292 | memcpy(priv->current_addr, macadd->macadd, ETH_ALEN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 293 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 294 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 295 | return 0; |
| 296 | } |
| 297 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 298 | static int lbs_ret_802_11_rf_tx_power(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 299 | struct cmd_ds_command *resp) |
| 300 | { |
| 301 | struct cmd_ds_802_11_rf_tx_power *rtp = &resp->params.txp; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 302 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 303 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 304 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 305 | priv->txpowerlevel = le16_to_cpu(rtp->currentlevel); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 306 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 307 | lbs_deb_cmd("TX power currently %d\n", priv->txpowerlevel); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 308 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 309 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 310 | return 0; |
| 311 | } |
| 312 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 313 | static int lbs_ret_802_11_rate_adapt_rateset(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 314 | struct cmd_ds_command *resp) |
| 315 | { |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 316 | struct cmd_ds_802_11_rate_adapt_rateset *rates = &resp->params.rateset; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 317 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 318 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 319 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 320 | if (rates->action == CMD_ACT_GET) { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 321 | priv->enablehwauto = le16_to_cpu(rates->enablehwauto); |
| 322 | priv->ratebitmap = le16_to_cpu(rates->bitmap); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 323 | } |
| 324 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 325 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 326 | return 0; |
| 327 | } |
| 328 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 329 | static int lbs_ret_802_11_rssi(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 330 | struct cmd_ds_command *resp) |
| 331 | { |
| 332 | struct cmd_ds_802_11_rssi_rsp *rssirsp = &resp->params.rssirsp; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 333 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 334 | lbs_deb_enter(LBS_DEB_CMD); |
| 335 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 336 | /* store the non average value */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 337 | priv->SNR[TYPE_BEACON][TYPE_NOAVG] = le16_to_cpu(rssirsp->SNR); |
| 338 | priv->NF[TYPE_BEACON][TYPE_NOAVG] = le16_to_cpu(rssirsp->noisefloor); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 339 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 340 | priv->SNR[TYPE_BEACON][TYPE_AVG] = le16_to_cpu(rssirsp->avgSNR); |
| 341 | priv->NF[TYPE_BEACON][TYPE_AVG] = le16_to_cpu(rssirsp->avgnoisefloor); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 342 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 343 | priv->RSSI[TYPE_BEACON][TYPE_NOAVG] = |
| 344 | CAL_RSSI(priv->SNR[TYPE_BEACON][TYPE_NOAVG], |
| 345 | priv->NF[TYPE_BEACON][TYPE_NOAVG]); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 346 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 347 | 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 Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 350 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 351 | lbs_deb_cmd("RSSI: beacon %d, avg %d\n", |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 352 | priv->RSSI[TYPE_BEACON][TYPE_NOAVG], |
| 353 | priv->RSSI[TYPE_BEACON][TYPE_AVG]); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 354 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 355 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 356 | return 0; |
| 357 | } |
| 358 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 359 | static int lbs_ret_802_11_eeprom_access(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 360 | struct cmd_ds_command *resp) |
| 361 | { |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 362 | struct lbs_ioctl_regrdwr *pbuf; |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 363 | pbuf = (struct lbs_ioctl_regrdwr *) priv->prdeeprom; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 364 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 365 | lbs_deb_enter_args(LBS_DEB_CMD, "len %d", |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 366 | le16_to_cpu(resp->params.rdeeprom.bytecount)); |
| 367 | if (pbuf->NOB < le16_to_cpu(resp->params.rdeeprom.bytecount)) { |
| 368 | pbuf->NOB = 0; |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 369 | lbs_deb_cmd("EEPROM read length too big\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 370 | 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 Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 377 | lbs_deb_hex(LBS_DEB_CMD, "EEPROM", (char *)&pbuf->value, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 378 | le16_to_cpu(resp->params.rdeeprom.bytecount)); |
| 379 | } |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 380 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 381 | return 0; |
| 382 | } |
| 383 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 384 | static int lbs_ret_get_log(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 385 | struct cmd_ds_command *resp) |
| 386 | { |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 387 | struct cmd_ds_802_11_get_log *logmessage = &resp->params.glog; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 388 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 389 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 390 | |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 391 | /* Stored little-endian */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 392 | memcpy(&priv->logmsg, logmessage, sizeof(struct cmd_ds_802_11_get_log)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 393 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 394 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 395 | return 0; |
| 396 | } |
| 397 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 398 | static int lbs_ret_802_11_enable_rsn(struct lbs_private *priv, |
Dan Williams | 18c96c34 | 2007-06-18 12:01:12 -0400 | [diff] [blame] | 399 | struct cmd_ds_command *resp) |
| 400 | { |
| 401 | struct cmd_ds_802_11_enable_rsn *enable_rsn = &resp->params.enbrsn; |
David Woodhouse | 7556767 | 2007-12-15 02:38:17 -0500 | [diff] [blame] | 402 | uint32_t * pdata_buf = (uint32_t *)priv->cur_cmd->callback_arg; |
Dan Williams | 18c96c34 | 2007-06-18 12:01:12 -0400 | [diff] [blame] | 403 | |
| 404 | lbs_deb_enter(LBS_DEB_CMD); |
| 405 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 406 | if (enable_rsn->action == cpu_to_le16(CMD_ACT_GET)) { |
Dan Williams | 18c96c34 | 2007-06-18 12:01:12 -0400 | [diff] [blame] | 407 | if (pdata_buf) |
David Woodhouse | 7556767 | 2007-12-15 02:38:17 -0500 | [diff] [blame] | 408 | *pdata_buf = (uint32_t) le16_to_cpu(enable_rsn->enable); |
Dan Williams | 18c96c34 | 2007-06-18 12:01:12 -0400 | [diff] [blame] | 409 | } |
| 410 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 411 | lbs_deb_leave(LBS_DEB_CMD); |
Dan Williams | 18c96c34 | 2007-06-18 12:01:12 -0400 | [diff] [blame] | 412 | return 0; |
| 413 | } |
| 414 | |
Brajesh Dave | 96287ac | 2007-11-20 17:44:28 -0500 | [diff] [blame] | 415 | static 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 Dave | 96287ac | 2007-11-20 17:44:28 -0500 | [diff] [blame] | 420 | |
| 421 | lbs_deb_enter(LBS_DEB_CMD); |
| 422 | |
| 423 | if (bcn_ctrl->action == CMD_ACT_GET) { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 424 | priv->beacon_enable = (u8) le16_to_cpu(bcn_ctrl->beacon_enable); |
| 425 | priv->beacon_period = le16_to_cpu(bcn_ctrl->beacon_period); |
Brajesh Dave | 96287ac | 2007-11-20 17:44:28 -0500 | [diff] [blame] | 426 | } |
| 427 | |
| 428 | lbs_deb_enter(LBS_DEB_CMD); |
| 429 | return 0; |
| 430 | } |
| 431 | |
Holger Schurig | 3a18864 | 2007-11-26 10:07:14 +0100 | [diff] [blame] | 432 | static int lbs_ret_802_11_subscribe_event(struct lbs_private *priv, |
| 433 | struct cmd_ds_command *resp) |
| 434 | { |
Holger Schurig | 3a18864 | 2007-11-26 10:07:14 +0100 | [diff] [blame] | 435 | 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 Woodhouse | 7556767 | 2007-12-15 02:38:17 -0500 | [diff] [blame] | 438 | (void *)priv->cur_cmd->callback_arg; |
Holger Schurig | 3a18864 | 2007-11-26 10:07:14 +0100 | [diff] [blame] | 439 | |
| 440 | lbs_deb_enter(LBS_DEB_CMD); |
| 441 | |
| 442 | if (dst_event->action == cpu_to_le16(CMD_ACT_GET)) { |
Holger Schurig | c2df2ef | 2007-12-07 15:30:44 +0000 | [diff] [blame] | 443 | dst_event->events = cmd_event->events; |
Holger Schurig | 3a18864 | 2007-11-26 10:07:14 +0100 | [diff] [blame] | 444 | 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 Woodhouse | 1309b55 | 2007-12-10 13:36:10 -0500 | [diff] [blame] | 451 | static inline int handle_cmd_response(struct lbs_private *priv, |
| 452 | unsigned long dummy, |
Dan Williams | ddac452 | 2007-12-11 13:49:39 -0500 | [diff] [blame] | 453 | struct cmd_header *cmd_response) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 454 | { |
Dan Williams | ddac452 | 2007-12-11 13:49:39 -0500 | [diff] [blame] | 455 | struct cmd_ds_command *resp = (struct cmd_ds_command *) cmd_response; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 456 | int ret = 0; |
| 457 | unsigned long flags; |
David Woodhouse | 1309b55 | 2007-12-10 13:36:10 -0500 | [diff] [blame] | 458 | uint16_t respcmd = le16_to_cpu(resp->command); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 459 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 460 | lbs_deb_enter(LBS_DEB_HOST); |
| 461 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 462 | switch (respcmd) { |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 463 | case CMD_RET(CMD_MAC_REG_ACCESS): |
| 464 | case CMD_RET(CMD_BBP_REG_ACCESS): |
| 465 | case CMD_RET(CMD_RF_REG_ACCESS): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 466 | ret = lbs_ret_reg_access(priv, respcmd, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 467 | break; |
| 468 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 469 | case CMD_RET(CMD_802_11_SCAN): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 470 | ret = lbs_ret_80211_scan(priv, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 471 | break; |
| 472 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 473 | case CMD_RET(CMD_802_11_GET_LOG): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 474 | ret = lbs_ret_get_log(priv, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 475 | break; |
| 476 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 477 | case CMD_RET_802_11_ASSOCIATE: |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 478 | case CMD_RET(CMD_802_11_ASSOCIATE): |
| 479 | case CMD_RET(CMD_802_11_REASSOCIATE): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 480 | ret = lbs_ret_80211_associate(priv, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 481 | break; |
| 482 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 483 | case CMD_RET(CMD_802_11_DISASSOCIATE): |
| 484 | case CMD_RET(CMD_802_11_DEAUTHENTICATE): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 485 | ret = lbs_ret_80211_disassociate(priv, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 486 | break; |
| 487 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 488 | case CMD_RET(CMD_802_11_AD_HOC_START): |
| 489 | case CMD_RET(CMD_802_11_AD_HOC_JOIN): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 490 | ret = lbs_ret_80211_ad_hoc_start(priv, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 491 | break; |
| 492 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 493 | case CMD_RET(CMD_802_11_GET_STAT): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 494 | ret = lbs_ret_802_11_stat(priv, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 495 | break; |
| 496 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 497 | case CMD_RET(CMD_802_11_SNMP_MIB): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 498 | ret = lbs_ret_802_11_snmp_mib(priv, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 499 | break; |
| 500 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 501 | case CMD_RET(CMD_802_11_RF_TX_POWER): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 502 | ret = lbs_ret_802_11_rf_tx_power(priv, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 503 | break; |
| 504 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 505 | case CMD_RET(CMD_802_11_SET_AFC): |
| 506 | case CMD_RET(CMD_802_11_GET_AFC): |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 507 | spin_lock_irqsave(&priv->driver_lock, flags); |
David Woodhouse | 7556767 | 2007-12-15 02:38:17 -0500 | [diff] [blame] | 508 | memmove((void *)priv->cur_cmd->callback_arg, &resp->params.afc, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 509 | sizeof(struct cmd_ds_802_11_afc)); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 510 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 511 | |
| 512 | break; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 513 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 514 | 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 Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 519 | case CMD_RET(CMD_802_11_BEACON_STOP): |
Dan Williams | 18c96c34 | 2007-06-18 12:01:12 -0400 | [diff] [blame] | 520 | break; |
| 521 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 522 | case CMD_RET(CMD_802_11_ENABLE_RSN): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 523 | ret = lbs_ret_802_11_enable_rsn(priv, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 524 | break; |
| 525 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 526 | case CMD_RET(CMD_802_11_RATE_ADAPT_RATESET): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 527 | ret = lbs_ret_802_11_rate_adapt_rateset(priv, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 528 | break; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 529 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 530 | case CMD_RET(CMD_802_11_RSSI): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 531 | ret = lbs_ret_802_11_rssi(priv, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 532 | break; |
| 533 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 534 | case CMD_RET(CMD_802_11_MAC_ADDRESS): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 535 | ret = lbs_ret_802_11_mac_address(priv, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 536 | break; |
| 537 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 538 | case CMD_RET(CMD_802_11_AD_HOC_STOP): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 539 | ret = lbs_ret_80211_ad_hoc_stop(priv, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 540 | break; |
| 541 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 542 | case CMD_RET(CMD_802_11_KEY_MATERIAL): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 543 | ret = lbs_ret_802_11_key_material(priv, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 544 | break; |
| 545 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 546 | case CMD_RET(CMD_802_11_EEPROM_ACCESS): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 547 | ret = lbs_ret_802_11_eeprom_access(priv, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 548 | break; |
| 549 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 550 | case CMD_RET(CMD_802_11D_DOMAIN_INFO): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 551 | ret = lbs_ret_802_11d_domain_info(priv, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 552 | break; |
| 553 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 554 | case CMD_RET(CMD_802_11_SLEEP_PARAMS): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 555 | ret = lbs_ret_802_11_sleep_params(priv, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 556 | break; |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 557 | case CMD_RET(CMD_802_11_INACTIVITY_TIMEOUT): |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 558 | spin_lock_irqsave(&priv->driver_lock, flags); |
David Woodhouse | 7556767 | 2007-12-15 02:38:17 -0500 | [diff] [blame] | 559 | *((uint16_t *) priv->cur_cmd->callback_arg) = |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 560 | le16_to_cpu(resp->params.inactivity_timeout.timeout); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 561 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 562 | break; |
| 563 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 564 | case CMD_RET(CMD_802_11_TPC_CFG): |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 565 | spin_lock_irqsave(&priv->driver_lock, flags); |
David Woodhouse | 7556767 | 2007-12-15 02:38:17 -0500 | [diff] [blame] | 566 | memmove((void *)priv->cur_cmd->callback_arg, &resp->params.tpccfg, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 567 | sizeof(struct cmd_ds_802_11_tpc_cfg)); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 568 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 569 | break; |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 570 | case CMD_RET(CMD_802_11_LED_GPIO_CTRL): |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 571 | spin_lock_irqsave(&priv->driver_lock, flags); |
David Woodhouse | 7556767 | 2007-12-15 02:38:17 -0500 | [diff] [blame] | 572 | memmove((void *)priv->cur_cmd->callback_arg, &resp->params.ledgpio, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 573 | sizeof(struct cmd_ds_802_11_led_ctrl)); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 574 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 575 | break; |
Holger Schurig | 3a18864 | 2007-11-26 10:07:14 +0100 | [diff] [blame] | 576 | case CMD_RET(CMD_802_11_SUBSCRIBE_EVENT): |
| 577 | ret = lbs_ret_802_11_subscribe_event(priv, resp); |
| 578 | break; |
| 579 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 580 | case CMD_RET(CMD_802_11_PWR_CFG): |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 581 | spin_lock_irqsave(&priv->driver_lock, flags); |
David Woodhouse | 7556767 | 2007-12-15 02:38:17 -0500 | [diff] [blame] | 582 | memmove((void *)priv->cur_cmd->callback_arg, &resp->params.pwrcfg, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 583 | sizeof(struct cmd_ds_802_11_pwr_cfg)); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 584 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 585 | |
| 586 | break; |
| 587 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 588 | case CMD_RET(CMD_GET_TSF): |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 589 | spin_lock_irqsave(&priv->driver_lock, flags); |
David Woodhouse | 7556767 | 2007-12-15 02:38:17 -0500 | [diff] [blame] | 590 | memcpy((void *)priv->cur_cmd->callback_arg, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 591 | &resp->params.gettsf.tsfvalue, sizeof(u64)); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 592 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 593 | break; |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 594 | case CMD_RET(CMD_BT_ACCESS): |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 595 | spin_lock_irqsave(&priv->driver_lock, flags); |
David Woodhouse | 7556767 | 2007-12-15 02:38:17 -0500 | [diff] [blame] | 596 | if (priv->cur_cmd->callback_arg) |
| 597 | memcpy((void *)priv->cur_cmd->callback_arg, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 598 | &resp->params.bt.addr1, 2 * ETH_ALEN); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 599 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 600 | break; |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 601 | case CMD_RET(CMD_FWT_ACCESS): |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 602 | spin_lock_irqsave(&priv->driver_lock, flags); |
David Woodhouse | 7556767 | 2007-12-15 02:38:17 -0500 | [diff] [blame] | 603 | if (priv->cur_cmd->callback_arg) |
| 604 | memcpy((void *)priv->cur_cmd->callback_arg, &resp->params.fwt, |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 605 | sizeof(resp->params.fwt)); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 606 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 607 | break; |
Brajesh Dave | 96287ac | 2007-11-20 17:44:28 -0500 | [diff] [blame] | 608 | case CMD_RET(CMD_802_11_BEACON_CTRL): |
| 609 | ret = lbs_ret_802_11_bcn_ctrl(priv, resp); |
| 610 | break; |
| 611 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 612 | default: |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 613 | lbs_deb_host("CMD_RESP: unknown cmd response 0x%04x\n", |
David Woodhouse | e125817 | 2007-12-11 23:42:49 -0500 | [diff] [blame] | 614 | le16_to_cpu(resp->command)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 615 | break; |
| 616 | } |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 617 | lbs_deb_leave(LBS_DEB_HOST); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 618 | return ret; |
| 619 | } |
| 620 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 621 | int lbs_process_rx_command(struct lbs_private *priv) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 622 | { |
David Woodhouse | e125817 | 2007-12-11 23:42:49 -0500 | [diff] [blame] | 623 | uint16_t respcmd, curcmd; |
Dan Williams | ddac452 | 2007-12-11 13:49:39 -0500 | [diff] [blame] | 624 | struct cmd_header *resp; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 625 | int ret = 0; |
David Woodhouse | e125817 | 2007-12-11 23:42:49 -0500 | [diff] [blame] | 626 | unsigned long flags; |
| 627 | uint16_t result; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 628 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 629 | lbs_deb_enter(LBS_DEB_HOST); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 630 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 631 | mutex_lock(&priv->lock); |
| 632 | spin_lock_irqsave(&priv->driver_lock, flags); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 633 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 634 | if (!priv->cur_cmd) { |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 635 | lbs_deb_host("CMD_RESP: cur_cmd is NULL\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 636 | ret = -1; |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 637 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 638 | goto done; |
| 639 | } |
David Woodhouse | e125817 | 2007-12-11 23:42:49 -0500 | [diff] [blame] | 640 | |
David Woodhouse | 7003b07 | 2007-12-17 15:22:43 -0500 | [diff] [blame] | 641 | resp = (void *)priv->upld_buf; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 642 | |
David Woodhouse | ac4cced | 2007-12-17 15:12:49 -0500 | [diff] [blame] | 643 | curcmd = le16_to_cpu(resp->command); |
| 644 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 645 | respcmd = le16_to_cpu(resp->command); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 646 | result = le16_to_cpu(resp->result); |
| 647 | |
David Woodhouse | e125817 | 2007-12-11 23:42:49 -0500 | [diff] [blame] | 648 | 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 Williams | ddac452 | 2007-12-11 13:49:39 -0500 | [diff] [blame] | 650 | lbs_deb_hex(LBS_DEB_HOST, "CMD_RESP", (void *) resp, priv->upld_len); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 651 | |
David Woodhouse | ac4cced | 2007-12-17 15:12:49 -0500 | [diff] [blame] | 652 | if (resp->seqnum != resp->seqnum) { |
David Woodhouse | e125817 | 2007-12-11 23:42:49 -0500 | [diff] [blame] | 653 | lbs_pr_info("Received CMD_RESP with invalid sequence %d (expected %d)\n", |
David Woodhouse | ac4cced | 2007-12-17 15:12:49 -0500 | [diff] [blame] | 654 | le16_to_cpu(resp->seqnum), le16_to_cpu(resp->seqnum)); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 655 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 656 | ret = -1; |
| 657 | goto done; |
| 658 | } |
David Woodhouse | e125817 | 2007-12-11 23:42:49 -0500 | [diff] [blame] | 659 | 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 Woodhouse | 8538823 | 2007-12-17 15:41:30 -0500 | [diff] [blame] | 667 | 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 Woodhouse | e125817 | 2007-12-11 23:42:49 -0500 | [diff] [blame] | 677 | /* Now we got response from FW, cancel the command timer */ |
| 678 | del_timer(&priv->command_timer); |
David Woodhouse | 2a34509 | 2007-12-15 19:33:43 -0500 | [diff] [blame] | 679 | 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 Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 685 | |
| 686 | /* Store the response code to cur_cmd_retcode. */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 687 | priv->cur_cmd_retcode = result; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 688 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 689 | if (respcmd == CMD_RET(CMD_802_11_PS_MODE)) { |
David Woodhouse | 38bfab1 | 2007-12-16 23:26:54 -0500 | [diff] [blame] | 690 | struct cmd_ds_802_11_ps_mode *psmode = (void *) &resp[1]; |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 691 | u16 action = le16_to_cpu(psmode->action); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 692 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 693 | lbs_deb_host( |
| 694 | "CMD_RESP: PS_MODE cmd reply result 0x%x, action 0x%x\n", |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 695 | result, action); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 696 | |
| 697 | if (result) { |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 698 | lbs_deb_host("CMD_RESP: PS command failed with 0x%x\n", |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 699 | result); |
| 700 | /* |
| 701 | * We should not re-try enter-ps command in |
| 702 | * ad-hoc mode. It takes place in |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 703 | * lbs_execute_next_command(). |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 704 | */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 705 | if (priv->mode == IW_MODE_ADHOC && |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 706 | action == CMD_SUBCMD_ENTER_PS) |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 707 | priv->psmode = LBS802_11POWERMODECAM; |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 708 | } else if (action == CMD_SUBCMD_ENTER_PS) { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 709 | priv->needtowakeup = 0; |
| 710 | priv->psstate = PS_STATE_AWAKE; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 711 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 712 | lbs_deb_host("CMD_RESP: ENTER_PS command response\n"); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 713 | if (priv->connect_status != LBS_CONNECTED) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 714 | /* |
| 715 | * When Deauth Event received before Enter_PS command |
| 716 | * response, We need to wake up the firmware. |
| 717 | */ |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 718 | lbs_deb_host( |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 719 | "disconnected, invoking lbs_ps_wakeup\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 720 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 721 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
| 722 | mutex_unlock(&priv->lock); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 723 | lbs_ps_wakeup(priv, 0); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 724 | mutex_lock(&priv->lock); |
| 725 | spin_lock_irqsave(&priv->driver_lock, flags); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 726 | } |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 727 | } else if (action == CMD_SUBCMD_EXIT_PS) { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 728 | priv->needtowakeup = 0; |
| 729 | priv->psstate = PS_STATE_FULL_POWER; |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 730 | lbs_deb_host("CMD_RESP: EXIT_PS command response\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 731 | } else { |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 732 | lbs_deb_host("CMD_RESP: PS action 0x%X\n", action); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 733 | } |
| 734 | |
David Woodhouse | 183aeac | 2007-12-15 01:52:54 -0500 | [diff] [blame] | 735 | lbs_complete_command(priv, priv->cur_cmd, result); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 736 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 737 | |
| 738 | ret = 0; |
| 739 | goto done; |
| 740 | } |
| 741 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 742 | /* If the command is not successful, cleanup and return failure */ |
| 743 | if ((result != 0 || !(respcmd & 0x8000))) { |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 744 | lbs_deb_host("CMD_RESP: error 0x%04x in command reply 0x%04x\n", |
| 745 | result, respcmd); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 746 | /* |
| 747 | * Handling errors here |
| 748 | */ |
| 749 | switch (respcmd) { |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 750 | case CMD_RET(CMD_GET_HW_SPEC): |
| 751 | case CMD_RET(CMD_802_11_RESET): |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 752 | lbs_deb_host("CMD_RESP: reset failed\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 753 | break; |
| 754 | |
| 755 | } |
David Woodhouse | 183aeac | 2007-12-15 01:52:54 -0500 | [diff] [blame] | 756 | lbs_complete_command(priv, priv->cur_cmd, result); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 757 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 758 | |
| 759 | ret = -1; |
| 760 | goto done; |
| 761 | } |
| 762 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 763 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
David Woodhouse | 1723047 | 2007-12-07 15:13:05 +0000 | [diff] [blame] | 764 | |
Dan Williams | 7ad994d | 2007-12-11 12:33:30 -0500 | [diff] [blame] | 765 | if (priv->cur_cmd && priv->cur_cmd->callback) { |
| 766 | ret = priv->cur_cmd->callback(priv, priv->cur_cmd->callback_arg, |
Dan Williams | ddac452 | 2007-12-11 13:49:39 -0500 | [diff] [blame] | 767 | resp); |
Dan Williams | 7ad994d | 2007-12-11 12:33:30 -0500 | [diff] [blame] | 768 | } else |
David Woodhouse | 1309b55 | 2007-12-10 13:36:10 -0500 | [diff] [blame] | 769 | ret = handle_cmd_response(priv, 0, resp); |
David Woodhouse | 1723047 | 2007-12-07 15:13:05 +0000 | [diff] [blame] | 770 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 771 | spin_lock_irqsave(&priv->driver_lock, flags); |
David Woodhouse | 1723047 | 2007-12-07 15:13:05 +0000 | [diff] [blame] | 772 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 773 | if (priv->cur_cmd) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 774 | /* Clean up and Put current command back to cmdfreeq */ |
David Woodhouse | 183aeac | 2007-12-15 01:52:54 -0500 | [diff] [blame] | 775 | lbs_complete_command(priv, priv->cur_cmd, result); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 776 | } |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 777 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 778 | |
| 779 | done: |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 780 | mutex_unlock(&priv->lock); |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 781 | lbs_deb_leave_args(LBS_DEB_HOST, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 782 | return ret; |
| 783 | } |
| 784 | |
David Woodhouse | b47ef24 | 2007-12-17 13:26:42 -0500 | [diff] [blame] | 785 | static 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 Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 809 | int lbs_process_event(struct lbs_private *priv) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 810 | { |
| 811 | int ret = 0; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 812 | u32 eventcause; |
| 813 | |
Holger Schurig | 9556d21 | 2007-08-02 13:14:07 -0400 | [diff] [blame] | 814 | lbs_deb_enter(LBS_DEB_CMD); |
| 815 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 816 | spin_lock_irq(&priv->driver_lock); |
| 817 | eventcause = priv->eventcause >> SBI_EVENT_CAUSE_SHIFT; |
| 818 | spin_unlock_irq(&priv->driver_lock); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 819 | |
Holger Schurig | 0b3c07f | 2007-11-28 09:15:11 +0100 | [diff] [blame] | 820 | lbs_deb_cmd("event cause %d\n", eventcause); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 821 | |
Holger Schurig | 0b3c07f | 2007-11-28 09:15:11 +0100 | [diff] [blame] | 822 | switch (eventcause) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 823 | case MACREG_INT_CODE_LINK_SENSED: |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 824 | lbs_deb_cmd("EVENT: MACREG_INT_CODE_LINK_SENSED\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 825 | break; |
| 826 | |
| 827 | case MACREG_INT_CODE_DEAUTHENTICATED: |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 828 | lbs_deb_cmd("EVENT: deauthenticated\n"); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 829 | lbs_mac_event_disconnected(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 830 | break; |
| 831 | |
| 832 | case MACREG_INT_CODE_DISASSOCIATED: |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 833 | lbs_deb_cmd("EVENT: disassociated\n"); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 834 | lbs_mac_event_disconnected(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 835 | break; |
| 836 | |
Holger Schurig | 0b3c07f | 2007-11-28 09:15:11 +0100 | [diff] [blame] | 837 | case MACREG_INT_CODE_LINK_LOST_NO_SCAN: |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 838 | lbs_deb_cmd("EVENT: link lost\n"); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 839 | lbs_mac_event_disconnected(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 840 | break; |
| 841 | |
| 842 | case MACREG_INT_CODE_PS_SLEEP: |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 843 | lbs_deb_cmd("EVENT: sleep\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 844 | |
| 845 | /* handle unexpected PS SLEEP event */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 846 | if (priv->psstate == PS_STATE_FULL_POWER) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 847 | lbs_deb_cmd( |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 848 | "EVENT: in FULL POWER mode, ignoreing PS_SLEEP\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 849 | break; |
| 850 | } |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 851 | priv->psstate = PS_STATE_PRE_SLEEP; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 852 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 853 | lbs_ps_confirm_sleep(priv, (u16) priv->psmode); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 854 | |
| 855 | break; |
| 856 | |
David Woodhouse | b47ef24 | 2007-12-17 13:26:42 -0500 | [diff] [blame] | 857 | case MACREG_INT_CODE_HOST_AWAKE: |
| 858 | lbs_deb_cmd("EVENT: HOST_AWAKE\n"); |
| 859 | lbs_send_confirmwake(priv); |
| 860 | break; |
| 861 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 862 | case MACREG_INT_CODE_PS_AWAKE: |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 863 | lbs_deb_cmd("EVENT: awake\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 864 | /* handle unexpected PS AWAKE event */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 865 | if (priv->psstate == PS_STATE_FULL_POWER) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 866 | lbs_deb_cmd( |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 867 | "EVENT: In FULL POWER mode - ignore PS AWAKE\n"); |
| 868 | break; |
| 869 | } |
| 870 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 871 | priv->psstate = PS_STATE_AWAKE; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 872 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 873 | if (priv->needtowakeup) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 874 | /* |
| 875 | * wait for the command processing to finish |
| 876 | * before resuming sending |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 877 | * priv->needtowakeup will be set to FALSE |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 878 | * in lbs_ps_wakeup() |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 879 | */ |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 880 | lbs_deb_cmd("waking up ...\n"); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 881 | lbs_ps_wakeup(priv, 0); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 882 | } |
| 883 | break; |
| 884 | |
| 885 | case MACREG_INT_CODE_MIC_ERR_UNICAST: |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 886 | lbs_deb_cmd("EVENT: UNICAST MIC ERROR\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 887 | handle_mic_failureevent(priv, MACREG_INT_CODE_MIC_ERR_UNICAST); |
| 888 | break; |
| 889 | |
| 890 | case MACREG_INT_CODE_MIC_ERR_MULTICAST: |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 891 | lbs_deb_cmd("EVENT: MULTICAST MIC ERROR\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 892 | 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 Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 899 | lbs_deb_cmd("EVENT: ADHOC beacon lost\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 900 | break; |
| 901 | |
| 902 | case MACREG_INT_CODE_RSSI_LOW: |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 903 | lbs_pr_alert("EVENT: rssi low\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 904 | break; |
| 905 | case MACREG_INT_CODE_SNR_LOW: |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 906 | lbs_pr_alert("EVENT: snr low\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 907 | break; |
| 908 | case MACREG_INT_CODE_MAX_FAIL: |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 909 | lbs_pr_alert("EVENT: max fail\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 910 | break; |
| 911 | case MACREG_INT_CODE_RSSI_HIGH: |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 912 | lbs_pr_alert("EVENT: rssi high\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 913 | break; |
| 914 | case MACREG_INT_CODE_SNR_HIGH: |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 915 | lbs_pr_alert("EVENT: snr high\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 916 | break; |
| 917 | |
Luis Carlos Cobo Rus | 7d8d28b | 2007-05-25 23:12:19 -0400 | [diff] [blame] | 918 | case MACREG_INT_CODE_MESH_AUTO_STARTED: |
Dan Williams | 5612c01 | 2007-08-02 13:20:12 -0400 | [diff] [blame] | 919 | /* 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 Cobo | 9cdc6d2 | 2007-08-02 11:55:22 -0400 | [diff] [blame] | 924 | lbs_pr_info("EVENT: MESH_AUTO_STARTED\n"); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 925 | priv->mesh_connect_status = LBS_CONNECTED; |
David Woodhouse | a27b9f9 | 2007-12-12 00:41:51 -0500 | [diff] [blame] | 926 | if (priv->mesh_open) { |
Luis Carlos Cobo | 9cdc6d2 | 2007-08-02 11:55:22 -0400 | [diff] [blame] | 927 | netif_carrier_on(priv->mesh_dev); |
David Woodhouse | a27b9f9 | 2007-12-12 00:41:51 -0500 | [diff] [blame] | 928 | if (!priv->tx_pending_len) |
| 929 | netif_wake_queue(priv->mesh_dev); |
Luis Carlos Cobo Rus | 7d8d28b | 2007-05-25 23:12:19 -0400 | [diff] [blame] | 930 | } |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 931 | priv->mode = IW_MODE_ADHOC; |
Luis Carlos Cobo Rus | b8bedef | 2007-05-30 12:14:34 -0400 | [diff] [blame] | 932 | schedule_work(&priv->sync_channel); |
Luis Carlos Cobo Rus | 7d8d28b | 2007-05-25 23:12:19 -0400 | [diff] [blame] | 933 | break; |
| 934 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 935 | default: |
Holger Schurig | 0b3c07f | 2007-11-28 09:15:11 +0100 | [diff] [blame] | 936 | lbs_pr_alert("EVENT: unknown event id %d\n", eventcause); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 937 | break; |
| 938 | } |
| 939 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 940 | spin_lock_irq(&priv->driver_lock); |
| 941 | priv->eventcause = 0; |
| 942 | spin_unlock_irq(&priv->driver_lock); |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 943 | |
Holger Schurig | 9556d21 | 2007-08-02 13:14:07 -0400 | [diff] [blame] | 944 | lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 945 | return ret; |
| 946 | } |