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