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 | 634b8f49 | 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 | 634b8f49 | 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 | 52507c2 | 2008-01-28 17:25:53 +0100 | [diff] [blame] | 77 | lbs_deb_leave(LBS_DEB_ASSOC); |
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_stat(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 150 | struct cmd_ds_command *resp) |
| 151 | { |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 152 | lbs_deb_enter(LBS_DEB_CMD); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 153 | /* currently priv->wlan802_11Stat is unused |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 154 | |
| 155 | struct cmd_ds_802_11_get_stat *p11Stat = &resp->params.gstat; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 156 | |
| 157 | // TODO Convert it to Big endian befor copy |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 158 | memcpy(&priv->wlan802_11Stat, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 159 | p11Stat, sizeof(struct cmd_ds_802_11_get_stat)); |
| 160 | */ |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 161 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 162 | return 0; |
| 163 | } |
| 164 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 165 | static int lbs_ret_802_11_snmp_mib(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 166 | struct cmd_ds_command *resp) |
| 167 | { |
| 168 | struct cmd_ds_802_11_snmp_mib *smib = &resp->params.smib; |
| 169 | u16 oid = le16_to_cpu(smib->oid); |
| 170 | u16 querytype = le16_to_cpu(smib->querytype); |
| 171 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 172 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 173 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 174 | 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] | 175 | querytype); |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 176 | 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] | 177 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 178 | if (querytype == CMD_ACT_GET) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 179 | switch (oid) { |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 180 | case FRAGTHRESH_I: |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 181 | priv->fragthsd = |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 182 | le16_to_cpu(*((__le16 *)(smib->value))); |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 183 | lbs_deb_cmd("SNMP_RESP: frag threshold %u\n", |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 184 | priv->fragthsd); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 185 | break; |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 186 | case RTSTHRESH_I: |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 187 | priv->rtsthsd = |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 188 | le16_to_cpu(*((__le16 *)(smib->value))); |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 189 | lbs_deb_cmd("SNMP_RESP: rts threshold %u\n", |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 190 | priv->rtsthsd); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 191 | break; |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 192 | case SHORT_RETRYLIM_I: |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 193 | priv->txretrycount = |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 194 | le16_to_cpu(*((__le16 *)(smib->value))); |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 195 | lbs_deb_cmd("SNMP_RESP: tx retry count %u\n", |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 196 | priv->rtsthsd); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 197 | break; |
| 198 | default: |
| 199 | break; |
| 200 | } |
| 201 | } |
| 202 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 203 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 204 | return 0; |
| 205 | } |
| 206 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 207 | static int lbs_ret_802_11_mac_address(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 208 | struct cmd_ds_command *resp) |
| 209 | { |
| 210 | struct cmd_ds_802_11_mac_address *macadd = &resp->params.macadd; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 211 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 212 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 213 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 214 | memcpy(priv->current_addr, macadd->macadd, ETH_ALEN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 215 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 216 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 217 | return 0; |
| 218 | } |
| 219 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 220 | 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] | 221 | struct cmd_ds_command *resp) |
| 222 | { |
| 223 | struct cmd_ds_802_11_rf_tx_power *rtp = &resp->params.txp; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 224 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 225 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 226 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 227 | priv->txpowerlevel = le16_to_cpu(rtp->currentlevel); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 228 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 229 | lbs_deb_cmd("TX power currently %d\n", priv->txpowerlevel); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 230 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 231 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 232 | return 0; |
| 233 | } |
| 234 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 235 | 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] | 236 | struct cmd_ds_command *resp) |
| 237 | { |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 238 | struct cmd_ds_802_11_rate_adapt_rateset *rates = &resp->params.rateset; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 239 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 240 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 241 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 242 | if (rates->action == CMD_ACT_GET) { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 243 | priv->enablehwauto = le16_to_cpu(rates->enablehwauto); |
| 244 | priv->ratebitmap = le16_to_cpu(rates->bitmap); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 245 | } |
| 246 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 247 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 248 | return 0; |
| 249 | } |
| 250 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 251 | static int lbs_ret_802_11_rssi(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 252 | struct cmd_ds_command *resp) |
| 253 | { |
| 254 | struct cmd_ds_802_11_rssi_rsp *rssirsp = &resp->params.rssirsp; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 255 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 256 | lbs_deb_enter(LBS_DEB_CMD); |
| 257 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 258 | /* store the non average value */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 259 | priv->SNR[TYPE_BEACON][TYPE_NOAVG] = le16_to_cpu(rssirsp->SNR); |
| 260 | priv->NF[TYPE_BEACON][TYPE_NOAVG] = le16_to_cpu(rssirsp->noisefloor); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 261 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 262 | priv->SNR[TYPE_BEACON][TYPE_AVG] = le16_to_cpu(rssirsp->avgSNR); |
| 263 | priv->NF[TYPE_BEACON][TYPE_AVG] = le16_to_cpu(rssirsp->avgnoisefloor); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 264 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 265 | priv->RSSI[TYPE_BEACON][TYPE_NOAVG] = |
| 266 | CAL_RSSI(priv->SNR[TYPE_BEACON][TYPE_NOAVG], |
| 267 | priv->NF[TYPE_BEACON][TYPE_NOAVG]); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 268 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 269 | priv->RSSI[TYPE_BEACON][TYPE_AVG] = |
| 270 | CAL_RSSI(priv->SNR[TYPE_BEACON][TYPE_AVG] / AVG_SCALE, |
| 271 | priv->NF[TYPE_BEACON][TYPE_AVG] / AVG_SCALE); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 272 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 273 | lbs_deb_cmd("RSSI: beacon %d, avg %d\n", |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 274 | priv->RSSI[TYPE_BEACON][TYPE_NOAVG], |
| 275 | priv->RSSI[TYPE_BEACON][TYPE_AVG]); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 276 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 277 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 278 | return 0; |
| 279 | } |
| 280 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 281 | static int lbs_ret_802_11_eeprom_access(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 282 | struct cmd_ds_command *resp) |
| 283 | { |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 284 | struct lbs_ioctl_regrdwr *pbuf; |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 285 | pbuf = (struct lbs_ioctl_regrdwr *) priv->prdeeprom; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 286 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 287 | lbs_deb_enter_args(LBS_DEB_CMD, "len %d", |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 288 | le16_to_cpu(resp->params.rdeeprom.bytecount)); |
| 289 | if (pbuf->NOB < le16_to_cpu(resp->params.rdeeprom.bytecount)) { |
| 290 | pbuf->NOB = 0; |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 291 | lbs_deb_cmd("EEPROM read length too big\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 292 | return -1; |
| 293 | } |
| 294 | pbuf->NOB = le16_to_cpu(resp->params.rdeeprom.bytecount); |
| 295 | if (pbuf->NOB > 0) { |
| 296 | |
| 297 | memcpy(&pbuf->value, (u8 *) & resp->params.rdeeprom.value, |
| 298 | le16_to_cpu(resp->params.rdeeprom.bytecount)); |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 299 | lbs_deb_hex(LBS_DEB_CMD, "EEPROM", (char *)&pbuf->value, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 300 | le16_to_cpu(resp->params.rdeeprom.bytecount)); |
| 301 | } |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 302 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 303 | return 0; |
| 304 | } |
| 305 | |
Brajesh Dave | 96287ac | 2007-11-20 17:44:28 -0500 | [diff] [blame] | 306 | static int lbs_ret_802_11_bcn_ctrl(struct lbs_private * priv, |
| 307 | struct cmd_ds_command *resp) |
| 308 | { |
| 309 | struct cmd_ds_802_11_beacon_control *bcn_ctrl = |
| 310 | &resp->params.bcn_ctrl; |
Brajesh Dave | 96287ac | 2007-11-20 17:44:28 -0500 | [diff] [blame] | 311 | |
| 312 | lbs_deb_enter(LBS_DEB_CMD); |
| 313 | |
| 314 | if (bcn_ctrl->action == CMD_ACT_GET) { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 315 | priv->beacon_enable = (u8) le16_to_cpu(bcn_ctrl->beacon_enable); |
| 316 | priv->beacon_period = le16_to_cpu(bcn_ctrl->beacon_period); |
Brajesh Dave | 96287ac | 2007-11-20 17:44:28 -0500 | [diff] [blame] | 317 | } |
| 318 | |
| 319 | lbs_deb_enter(LBS_DEB_CMD); |
| 320 | return 0; |
| 321 | } |
| 322 | |
David Woodhouse | 1309b55 | 2007-12-10 13:36:10 -0500 | [diff] [blame] | 323 | static inline int handle_cmd_response(struct lbs_private *priv, |
| 324 | unsigned long dummy, |
Dan Williams | ddac452 | 2007-12-11 13:49:39 -0500 | [diff] [blame] | 325 | struct cmd_header *cmd_response) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 326 | { |
Dan Williams | ddac452 | 2007-12-11 13:49:39 -0500 | [diff] [blame] | 327 | struct cmd_ds_command *resp = (struct cmd_ds_command *) cmd_response; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 328 | int ret = 0; |
| 329 | unsigned long flags; |
David Woodhouse | 1309b55 | 2007-12-10 13:36:10 -0500 | [diff] [blame] | 330 | uint16_t respcmd = le16_to_cpu(resp->command); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 331 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 332 | lbs_deb_enter(LBS_DEB_HOST); |
| 333 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 334 | switch (respcmd) { |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 335 | case CMD_RET(CMD_MAC_REG_ACCESS): |
| 336 | case CMD_RET(CMD_BBP_REG_ACCESS): |
| 337 | case CMD_RET(CMD_RF_REG_ACCESS): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 338 | ret = lbs_ret_reg_access(priv, respcmd, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 339 | break; |
| 340 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 341 | case CMD_RET_802_11_ASSOCIATE: |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 342 | case CMD_RET(CMD_802_11_ASSOCIATE): |
| 343 | case CMD_RET(CMD_802_11_REASSOCIATE): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 344 | ret = lbs_ret_80211_associate(priv, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 345 | break; |
| 346 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 347 | case CMD_RET(CMD_802_11_DISASSOCIATE): |
| 348 | case CMD_RET(CMD_802_11_DEAUTHENTICATE): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 349 | ret = lbs_ret_80211_disassociate(priv, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 350 | break; |
| 351 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 352 | case CMD_RET(CMD_802_11_AD_HOC_START): |
| 353 | case CMD_RET(CMD_802_11_AD_HOC_JOIN): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 354 | ret = lbs_ret_80211_ad_hoc_start(priv, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 355 | break; |
| 356 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 357 | case CMD_RET(CMD_802_11_GET_STAT): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 358 | ret = lbs_ret_802_11_stat(priv, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 359 | break; |
| 360 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 361 | case CMD_RET(CMD_802_11_SNMP_MIB): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 362 | ret = lbs_ret_802_11_snmp_mib(priv, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 363 | break; |
| 364 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 365 | case CMD_RET(CMD_802_11_RF_TX_POWER): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 366 | ret = lbs_ret_802_11_rf_tx_power(priv, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 367 | break; |
| 368 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 369 | case CMD_RET(CMD_802_11_SET_AFC): |
| 370 | case CMD_RET(CMD_802_11_GET_AFC): |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 371 | spin_lock_irqsave(&priv->driver_lock, flags); |
David Woodhouse | 7556767 | 2007-12-15 02:38:17 -0500 | [diff] [blame] | 372 | memmove((void *)priv->cur_cmd->callback_arg, &resp->params.afc, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 373 | sizeof(struct cmd_ds_802_11_afc)); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 374 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 375 | |
| 376 | break; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 377 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 378 | case CMD_RET(CMD_MAC_MULTICAST_ADR): |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 379 | case CMD_RET(CMD_802_11_RESET): |
| 380 | case CMD_RET(CMD_802_11_AUTHENTICATE): |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 381 | case CMD_RET(CMD_802_11_BEACON_STOP): |
Dan Williams | 18c96c34 | 2007-06-18 12:01:12 -0400 | [diff] [blame] | 382 | break; |
| 383 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 384 | case CMD_RET(CMD_802_11_RATE_ADAPT_RATESET): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 385 | ret = lbs_ret_802_11_rate_adapt_rateset(priv, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 386 | break; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 387 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 388 | case CMD_RET(CMD_802_11_RSSI): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 389 | ret = lbs_ret_802_11_rssi(priv, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 390 | break; |
| 391 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 392 | case CMD_RET(CMD_802_11_MAC_ADDRESS): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 393 | ret = lbs_ret_802_11_mac_address(priv, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 394 | break; |
| 395 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 396 | case CMD_RET(CMD_802_11_AD_HOC_STOP): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 397 | ret = lbs_ret_80211_ad_hoc_stop(priv, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 398 | break; |
| 399 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 400 | case CMD_RET(CMD_802_11_EEPROM_ACCESS): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 401 | ret = lbs_ret_802_11_eeprom_access(priv, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 402 | break; |
| 403 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 404 | case CMD_RET(CMD_802_11D_DOMAIN_INFO): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 405 | ret = lbs_ret_802_11d_domain_info(priv, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 406 | break; |
| 407 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 408 | case CMD_RET(CMD_802_11_TPC_CFG): |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 409 | spin_lock_irqsave(&priv->driver_lock, flags); |
David Woodhouse | 7556767 | 2007-12-15 02:38:17 -0500 | [diff] [blame] | 410 | memmove((void *)priv->cur_cmd->callback_arg, &resp->params.tpccfg, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 411 | sizeof(struct cmd_ds_802_11_tpc_cfg)); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 412 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 413 | break; |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 414 | case CMD_RET(CMD_802_11_LED_GPIO_CTRL): |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 415 | spin_lock_irqsave(&priv->driver_lock, flags); |
David Woodhouse | 7556767 | 2007-12-15 02:38:17 -0500 | [diff] [blame] | 416 | memmove((void *)priv->cur_cmd->callback_arg, &resp->params.ledgpio, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 417 | sizeof(struct cmd_ds_802_11_led_ctrl)); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 418 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 419 | break; |
Holger Schurig | 3a18864 | 2007-11-26 10:07:14 +0100 | [diff] [blame] | 420 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 421 | case CMD_RET(CMD_802_11_PWR_CFG): |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 422 | spin_lock_irqsave(&priv->driver_lock, flags); |
David Woodhouse | 7556767 | 2007-12-15 02:38:17 -0500 | [diff] [blame] | 423 | memmove((void *)priv->cur_cmd->callback_arg, &resp->params.pwrcfg, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 424 | sizeof(struct cmd_ds_802_11_pwr_cfg)); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 425 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 426 | |
| 427 | break; |
| 428 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 429 | case CMD_RET(CMD_GET_TSF): |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 430 | spin_lock_irqsave(&priv->driver_lock, flags); |
David Woodhouse | 7556767 | 2007-12-15 02:38:17 -0500 | [diff] [blame] | 431 | memcpy((void *)priv->cur_cmd->callback_arg, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 432 | &resp->params.gettsf.tsfvalue, sizeof(u64)); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 433 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 434 | break; |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 435 | case CMD_RET(CMD_BT_ACCESS): |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 436 | spin_lock_irqsave(&priv->driver_lock, flags); |
David Woodhouse | 7556767 | 2007-12-15 02:38:17 -0500 | [diff] [blame] | 437 | if (priv->cur_cmd->callback_arg) |
| 438 | memcpy((void *)priv->cur_cmd->callback_arg, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 439 | &resp->params.bt.addr1, 2 * ETH_ALEN); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 440 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 441 | break; |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 442 | case CMD_RET(CMD_FWT_ACCESS): |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 443 | spin_lock_irqsave(&priv->driver_lock, flags); |
David Woodhouse | 7556767 | 2007-12-15 02:38:17 -0500 | [diff] [blame] | 444 | if (priv->cur_cmd->callback_arg) |
| 445 | memcpy((void *)priv->cur_cmd->callback_arg, &resp->params.fwt, |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 446 | sizeof(resp->params.fwt)); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 447 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 448 | break; |
Brajesh Dave | 96287ac | 2007-11-20 17:44:28 -0500 | [diff] [blame] | 449 | case CMD_RET(CMD_802_11_BEACON_CTRL): |
| 450 | ret = lbs_ret_802_11_bcn_ctrl(priv, resp); |
| 451 | break; |
| 452 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 453 | default: |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 454 | lbs_deb_host("CMD_RESP: unknown cmd response 0x%04x\n", |
David Woodhouse | e125817 | 2007-12-11 23:42:49 -0500 | [diff] [blame] | 455 | le16_to_cpu(resp->command)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 456 | break; |
| 457 | } |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 458 | lbs_deb_leave(LBS_DEB_HOST); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 459 | return ret; |
| 460 | } |
| 461 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 462 | int lbs_process_rx_command(struct lbs_private *priv) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 463 | { |
David Woodhouse | e125817 | 2007-12-11 23:42:49 -0500 | [diff] [blame] | 464 | uint16_t respcmd, curcmd; |
Dan Williams | ddac452 | 2007-12-11 13:49:39 -0500 | [diff] [blame] | 465 | struct cmd_header *resp; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 466 | int ret = 0; |
David Woodhouse | e125817 | 2007-12-11 23:42:49 -0500 | [diff] [blame] | 467 | unsigned long flags; |
| 468 | uint16_t result; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 469 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 470 | lbs_deb_enter(LBS_DEB_HOST); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 471 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 472 | mutex_lock(&priv->lock); |
| 473 | spin_lock_irqsave(&priv->driver_lock, flags); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 474 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 475 | if (!priv->cur_cmd) { |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 476 | lbs_deb_host("CMD_RESP: cur_cmd is NULL\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 477 | ret = -1; |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 478 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 479 | goto done; |
| 480 | } |
David Woodhouse | e125817 | 2007-12-11 23:42:49 -0500 | [diff] [blame] | 481 | |
David Woodhouse | 7003b07 | 2007-12-17 15:22:43 -0500 | [diff] [blame] | 482 | resp = (void *)priv->upld_buf; |
Sebastian Siewior | 8a96df8 | 2008-03-04 18:22:27 +0100 | [diff] [blame] | 483 | curcmd = le16_to_cpu(priv->cur_cmd->cmdbuf->command); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 484 | respcmd = le16_to_cpu(resp->command); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 485 | result = le16_to_cpu(resp->result); |
| 486 | |
Holger Schurig | 1afc09ab | 2008-01-29 09:14:40 +0100 | [diff] [blame] | 487 | lbs_deb_cmd("CMD_RESP: response 0x%04x, seq %d, size %d, jiffies %lu\n", |
David Woodhouse | e125817 | 2007-12-11 23:42:49 -0500 | [diff] [blame] | 488 | respcmd, le16_to_cpu(resp->seqnum), priv->upld_len, jiffies); |
Holger Schurig | 1afc09ab | 2008-01-29 09:14:40 +0100 | [diff] [blame] | 489 | lbs_deb_hex(LBS_DEB_CMD, "CMD_RESP", (void *) resp, priv->upld_len); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 490 | |
David Woodhouse | 6305f49 | 2008-03-03 12:20:12 +0100 | [diff] [blame] | 491 | if (resp->seqnum != priv->cur_cmd->cmdbuf->seqnum) { |
David Woodhouse | e125817 | 2007-12-11 23:42:49 -0500 | [diff] [blame] | 492 | lbs_pr_info("Received CMD_RESP with invalid sequence %d (expected %d)\n", |
David Woodhouse | 6305f49 | 2008-03-03 12:20:12 +0100 | [diff] [blame] | 493 | le16_to_cpu(resp->seqnum), le16_to_cpu(priv->cur_cmd->cmdbuf->seqnum)); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 494 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 495 | ret = -1; |
| 496 | goto done; |
| 497 | } |
David Woodhouse | e125817 | 2007-12-11 23:42:49 -0500 | [diff] [blame] | 498 | if (respcmd != CMD_RET(curcmd) && |
Sebastian Siewior | 5f0547c2 | 2008-03-06 10:30:21 +0100 | [diff] [blame] | 499 | respcmd != CMD_RET_802_11_ASSOCIATE && curcmd != CMD_802_11_ASSOCIATE) { |
David Woodhouse | e125817 | 2007-12-11 23:42:49 -0500 | [diff] [blame] | 500 | lbs_pr_info("Invalid CMD_RESP %x to command %x!\n", respcmd, curcmd); |
| 501 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
| 502 | ret = -1; |
| 503 | goto done; |
| 504 | } |
| 505 | |
David Woodhouse | 8538823 | 2007-12-17 15:41:30 -0500 | [diff] [blame] | 506 | if (resp->result == cpu_to_le16(0x0004)) { |
| 507 | /* 0x0004 means -EAGAIN. Drop the response, let it time out |
| 508 | and be resubmitted */ |
| 509 | lbs_pr_info("Firmware returns DEFER to command %x. Will let it time out...\n", |
| 510 | le16_to_cpu(resp->command)); |
| 511 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
| 512 | ret = -1; |
| 513 | goto done; |
| 514 | } |
| 515 | |
David Woodhouse | e125817 | 2007-12-11 23:42:49 -0500 | [diff] [blame] | 516 | /* Now we got response from FW, cancel the command timer */ |
| 517 | del_timer(&priv->command_timer); |
David Woodhouse | 2a34509 | 2007-12-15 19:33:43 -0500 | [diff] [blame] | 518 | priv->cmd_timed_out = 0; |
| 519 | if (priv->nr_retries) { |
| 520 | lbs_pr_info("Received result %x to command %x after %d retries\n", |
| 521 | result, curcmd, priv->nr_retries); |
| 522 | priv->nr_retries = 0; |
| 523 | } |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 524 | |
| 525 | /* Store the response code to cur_cmd_retcode. */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 526 | priv->cur_cmd_retcode = result; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 527 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 528 | if (respcmd == CMD_RET(CMD_802_11_PS_MODE)) { |
David Woodhouse | 38bfab1 | 2007-12-16 23:26:54 -0500 | [diff] [blame] | 529 | struct cmd_ds_802_11_ps_mode *psmode = (void *) &resp[1]; |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 530 | u16 action = le16_to_cpu(psmode->action); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 531 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 532 | lbs_deb_host( |
| 533 | "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] | 534 | result, action); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 535 | |
| 536 | if (result) { |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 537 | lbs_deb_host("CMD_RESP: PS command failed with 0x%x\n", |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 538 | result); |
| 539 | /* |
| 540 | * We should not re-try enter-ps command in |
| 541 | * ad-hoc mode. It takes place in |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 542 | * lbs_execute_next_command(). |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 543 | */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 544 | if (priv->mode == IW_MODE_ADHOC && |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 545 | action == CMD_SUBCMD_ENTER_PS) |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 546 | priv->psmode = LBS802_11POWERMODECAM; |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 547 | } else if (action == CMD_SUBCMD_ENTER_PS) { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 548 | priv->needtowakeup = 0; |
| 549 | priv->psstate = PS_STATE_AWAKE; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 550 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 551 | lbs_deb_host("CMD_RESP: ENTER_PS command response\n"); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 552 | if (priv->connect_status != LBS_CONNECTED) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 553 | /* |
| 554 | * When Deauth Event received before Enter_PS command |
| 555 | * response, We need to wake up the firmware. |
| 556 | */ |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 557 | lbs_deb_host( |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 558 | "disconnected, invoking lbs_ps_wakeup\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 559 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 560 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
| 561 | mutex_unlock(&priv->lock); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 562 | lbs_ps_wakeup(priv, 0); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 563 | mutex_lock(&priv->lock); |
| 564 | spin_lock_irqsave(&priv->driver_lock, flags); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 565 | } |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 566 | } else if (action == CMD_SUBCMD_EXIT_PS) { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 567 | priv->needtowakeup = 0; |
| 568 | priv->psstate = PS_STATE_FULL_POWER; |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 569 | lbs_deb_host("CMD_RESP: EXIT_PS command response\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 570 | } else { |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 571 | lbs_deb_host("CMD_RESP: PS action 0x%X\n", action); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 572 | } |
| 573 | |
David Woodhouse | 183aeac | 2007-12-15 01:52:54 -0500 | [diff] [blame] | 574 | lbs_complete_command(priv, priv->cur_cmd, result); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 575 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 576 | |
| 577 | ret = 0; |
| 578 | goto done; |
| 579 | } |
| 580 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 581 | /* If the command is not successful, cleanup and return failure */ |
| 582 | if ((result != 0 || !(respcmd & 0x8000))) { |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 583 | lbs_deb_host("CMD_RESP: error 0x%04x in command reply 0x%04x\n", |
| 584 | result, respcmd); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 585 | /* |
| 586 | * Handling errors here |
| 587 | */ |
| 588 | switch (respcmd) { |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 589 | case CMD_RET(CMD_GET_HW_SPEC): |
| 590 | case CMD_RET(CMD_802_11_RESET): |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 591 | lbs_deb_host("CMD_RESP: reset failed\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 592 | break; |
| 593 | |
| 594 | } |
David Woodhouse | 183aeac | 2007-12-15 01:52:54 -0500 | [diff] [blame] | 595 | lbs_complete_command(priv, priv->cur_cmd, result); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 596 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 597 | |
| 598 | ret = -1; |
| 599 | goto done; |
| 600 | } |
| 601 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 602 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
David Woodhouse | 1723047 | 2007-12-07 15:13:05 +0000 | [diff] [blame] | 603 | |
Dan Williams | 7ad994d | 2007-12-11 12:33:30 -0500 | [diff] [blame] | 604 | if (priv->cur_cmd && priv->cur_cmd->callback) { |
| 605 | ret = priv->cur_cmd->callback(priv, priv->cur_cmd->callback_arg, |
Dan Williams | ddac452 | 2007-12-11 13:49:39 -0500 | [diff] [blame] | 606 | resp); |
Dan Williams | 7ad994d | 2007-12-11 12:33:30 -0500 | [diff] [blame] | 607 | } else |
David Woodhouse | 1309b55 | 2007-12-10 13:36:10 -0500 | [diff] [blame] | 608 | ret = handle_cmd_response(priv, 0, resp); |
David Woodhouse | 1723047 | 2007-12-07 15:13:05 +0000 | [diff] [blame] | 609 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 610 | spin_lock_irqsave(&priv->driver_lock, flags); |
David Woodhouse | 1723047 | 2007-12-07 15:13:05 +0000 | [diff] [blame] | 611 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 612 | if (priv->cur_cmd) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 613 | /* Clean up and Put current command back to cmdfreeq */ |
David Woodhouse | 183aeac | 2007-12-15 01:52:54 -0500 | [diff] [blame] | 614 | lbs_complete_command(priv, priv->cur_cmd, result); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 615 | } |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 616 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 617 | |
| 618 | done: |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 619 | mutex_unlock(&priv->lock); |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 620 | lbs_deb_leave_args(LBS_DEB_HOST, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 621 | return ret; |
| 622 | } |
| 623 | |
David Woodhouse | b47ef24 | 2007-12-17 13:26:42 -0500 | [diff] [blame] | 624 | static int lbs_send_confirmwake(struct lbs_private *priv) |
| 625 | { |
| 626 | struct cmd_header *cmd = &priv->lbs_ps_confirm_wake; |
| 627 | int ret = 0; |
| 628 | |
| 629 | lbs_deb_enter(LBS_DEB_HOST); |
| 630 | |
| 631 | cmd->command = cpu_to_le16(CMD_802_11_WAKEUP_CONFIRM); |
| 632 | cmd->size = cpu_to_le16(sizeof(*cmd)); |
| 633 | cmd->seqnum = cpu_to_le16(++priv->seqnum); |
| 634 | cmd->result = 0; |
| 635 | |
| 636 | lbs_deb_host("SEND_WAKEC_CMD: before download\n"); |
| 637 | |
| 638 | lbs_deb_hex(LBS_DEB_HOST, "wake confirm command", (void *)cmd, sizeof(*cmd)); |
| 639 | |
| 640 | ret = priv->hw_host_to_card(priv, MVMS_CMD, (void *)cmd, sizeof(*cmd)); |
| 641 | if (ret) |
| 642 | lbs_pr_alert("SEND_WAKEC_CMD: Host to Card failed for Confirm Wake\n"); |
| 643 | |
| 644 | lbs_deb_leave_args(LBS_DEB_HOST, "ret %d", ret); |
| 645 | return ret; |
| 646 | } |
| 647 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 648 | int lbs_process_event(struct lbs_private *priv) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 649 | { |
| 650 | int ret = 0; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 651 | u32 eventcause; |
| 652 | |
Holger Schurig | 9556d21 | 2007-08-02 13:14:07 -0400 | [diff] [blame] | 653 | lbs_deb_enter(LBS_DEB_CMD); |
| 654 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 655 | spin_lock_irq(&priv->driver_lock); |
| 656 | eventcause = priv->eventcause >> SBI_EVENT_CAUSE_SHIFT; |
| 657 | spin_unlock_irq(&priv->driver_lock); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 658 | |
Holger Schurig | 0b3c07f | 2007-11-28 09:15:11 +0100 | [diff] [blame] | 659 | switch (eventcause) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 660 | case MACREG_INT_CODE_LINK_SENSED: |
Holger Schurig | d4ff0ef | 2008-03-19 14:25:18 +0100 | [diff] [blame^] | 661 | lbs_deb_cmd("EVENT: link sensed\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 662 | break; |
| 663 | |
| 664 | case MACREG_INT_CODE_DEAUTHENTICATED: |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 665 | lbs_deb_cmd("EVENT: deauthenticated\n"); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 666 | lbs_mac_event_disconnected(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 667 | break; |
| 668 | |
| 669 | case MACREG_INT_CODE_DISASSOCIATED: |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 670 | lbs_deb_cmd("EVENT: disassociated\n"); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 671 | lbs_mac_event_disconnected(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 672 | break; |
| 673 | |
Holger Schurig | 0b3c07f | 2007-11-28 09:15:11 +0100 | [diff] [blame] | 674 | case MACREG_INT_CODE_LINK_LOST_NO_SCAN: |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 675 | lbs_deb_cmd("EVENT: link lost\n"); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 676 | lbs_mac_event_disconnected(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 677 | break; |
| 678 | |
| 679 | case MACREG_INT_CODE_PS_SLEEP: |
Holger Schurig | d4ff0ef | 2008-03-19 14:25:18 +0100 | [diff] [blame^] | 680 | lbs_deb_cmd("EVENT: ps sleep\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 681 | |
| 682 | /* handle unexpected PS SLEEP event */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 683 | if (priv->psstate == PS_STATE_FULL_POWER) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 684 | lbs_deb_cmd( |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 685 | "EVENT: in FULL POWER mode, ignoreing PS_SLEEP\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 686 | break; |
| 687 | } |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 688 | priv->psstate = PS_STATE_PRE_SLEEP; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 689 | |
Holger Schurig | d4ff0ef | 2008-03-19 14:25:18 +0100 | [diff] [blame^] | 690 | lbs_ps_confirm_sleep(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 691 | |
| 692 | break; |
| 693 | |
David Woodhouse | b47ef24 | 2007-12-17 13:26:42 -0500 | [diff] [blame] | 694 | case MACREG_INT_CODE_HOST_AWAKE: |
Holger Schurig | d4ff0ef | 2008-03-19 14:25:18 +0100 | [diff] [blame^] | 695 | lbs_deb_cmd("EVENT: host awake\n"); |
David Woodhouse | b47ef24 | 2007-12-17 13:26:42 -0500 | [diff] [blame] | 696 | lbs_send_confirmwake(priv); |
| 697 | break; |
| 698 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 699 | case MACREG_INT_CODE_PS_AWAKE: |
Holger Schurig | d4ff0ef | 2008-03-19 14:25:18 +0100 | [diff] [blame^] | 700 | lbs_deb_cmd("EVENT: ps awake\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 701 | /* handle unexpected PS AWAKE event */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 702 | if (priv->psstate == PS_STATE_FULL_POWER) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 703 | lbs_deb_cmd( |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 704 | "EVENT: In FULL POWER mode - ignore PS AWAKE\n"); |
| 705 | break; |
| 706 | } |
| 707 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 708 | priv->psstate = PS_STATE_AWAKE; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 709 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 710 | if (priv->needtowakeup) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 711 | /* |
| 712 | * wait for the command processing to finish |
| 713 | * before resuming sending |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 714 | * priv->needtowakeup will be set to FALSE |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 715 | * in lbs_ps_wakeup() |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 716 | */ |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 717 | lbs_deb_cmd("waking up ...\n"); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 718 | lbs_ps_wakeup(priv, 0); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 719 | } |
| 720 | break; |
| 721 | |
| 722 | case MACREG_INT_CODE_MIC_ERR_UNICAST: |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 723 | lbs_deb_cmd("EVENT: UNICAST MIC ERROR\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 724 | handle_mic_failureevent(priv, MACREG_INT_CODE_MIC_ERR_UNICAST); |
| 725 | break; |
| 726 | |
| 727 | case MACREG_INT_CODE_MIC_ERR_MULTICAST: |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 728 | lbs_deb_cmd("EVENT: MULTICAST MIC ERROR\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 729 | handle_mic_failureevent(priv, MACREG_INT_CODE_MIC_ERR_MULTICAST); |
| 730 | break; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 731 | |
Holger Schurig | d4ff0ef | 2008-03-19 14:25:18 +0100 | [diff] [blame^] | 732 | case MACREG_INT_CODE_MIB_CHANGED: |
| 733 | lbs_deb_cmd("EVENT: MIB CHANGED\n"); |
| 734 | break; |
| 735 | case MACREG_INT_CODE_INIT_DONE: |
| 736 | lbs_deb_cmd("EVENT: INIT DONE\n"); |
| 737 | break; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 738 | case MACREG_INT_CODE_ADHOC_BCN_LOST: |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 739 | lbs_deb_cmd("EVENT: ADHOC beacon lost\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 740 | break; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 741 | case MACREG_INT_CODE_RSSI_LOW: |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 742 | lbs_pr_alert("EVENT: rssi low\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 743 | break; |
| 744 | case MACREG_INT_CODE_SNR_LOW: |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 745 | lbs_pr_alert("EVENT: snr low\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 746 | break; |
| 747 | case MACREG_INT_CODE_MAX_FAIL: |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 748 | lbs_pr_alert("EVENT: max fail\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 749 | break; |
| 750 | case MACREG_INT_CODE_RSSI_HIGH: |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 751 | lbs_pr_alert("EVENT: rssi high\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 752 | break; |
| 753 | case MACREG_INT_CODE_SNR_HIGH: |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 754 | lbs_pr_alert("EVENT: snr high\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 755 | break; |
| 756 | |
Luis Carlos Cobo Rus | 7d8d28b | 2007-05-25 23:12:19 -0400 | [diff] [blame] | 757 | case MACREG_INT_CODE_MESH_AUTO_STARTED: |
Dan Williams | 5612c01 | 2007-08-02 13:20:12 -0400 | [diff] [blame] | 758 | /* Ignore spurious autostart events if autostart is disabled */ |
| 759 | if (!priv->mesh_autostart_enabled) { |
| 760 | lbs_pr_info("EVENT: MESH_AUTO_STARTED (ignoring)\n"); |
| 761 | break; |
| 762 | } |
Luis Carlos Cobo | 9cdc6d2 | 2007-08-02 11:55:22 -0400 | [diff] [blame] | 763 | lbs_pr_info("EVENT: MESH_AUTO_STARTED\n"); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 764 | priv->mesh_connect_status = LBS_CONNECTED; |
David Woodhouse | a27b9f9 | 2007-12-12 00:41:51 -0500 | [diff] [blame] | 765 | if (priv->mesh_open) { |
Luis Carlos Cobo | 9cdc6d2 | 2007-08-02 11:55:22 -0400 | [diff] [blame] | 766 | netif_carrier_on(priv->mesh_dev); |
David Woodhouse | a27b9f9 | 2007-12-12 00:41:51 -0500 | [diff] [blame] | 767 | if (!priv->tx_pending_len) |
| 768 | netif_wake_queue(priv->mesh_dev); |
Luis Carlos Cobo Rus | 7d8d28b | 2007-05-25 23:12:19 -0400 | [diff] [blame] | 769 | } |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 770 | priv->mode = IW_MODE_ADHOC; |
Luis Carlos Cobo Rus | b8bedef | 2007-05-30 12:14:34 -0400 | [diff] [blame] | 771 | schedule_work(&priv->sync_channel); |
Luis Carlos Cobo Rus | 7d8d28b | 2007-05-25 23:12:19 -0400 | [diff] [blame] | 772 | break; |
| 773 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 774 | default: |
Holger Schurig | 0b3c07f | 2007-11-28 09:15:11 +0100 | [diff] [blame] | 775 | lbs_pr_alert("EVENT: unknown event id %d\n", eventcause); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 776 | break; |
| 777 | } |
| 778 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 779 | spin_lock_irq(&priv->driver_lock); |
| 780 | priv->eventcause = 0; |
| 781 | spin_unlock_irq(&priv->driver_lock); |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 782 | |
Holger Schurig | 9556d21 | 2007-08-02 13:14:07 -0400 | [diff] [blame] | 783 | lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 784 | return ret; |
| 785 | } |