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 | * |
| 23 | * @param priv A pointer to wlan_private structure |
| 24 | * @return n/a |
| 25 | */ |
| 26 | void libertas_mac_event_disconnected(wlan_private * priv) |
| 27 | { |
| 28 | wlan_adapter *adapter = priv->adapter; |
| 29 | union iwreq_data wrqu; |
| 30 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 31 | if (adapter->connect_status != LIBERTAS_CONNECTED) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 32 | return; |
| 33 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 34 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 35 | |
| 36 | memset(wrqu.ap_addr.sa_data, 0x00, ETH_ALEN); |
| 37 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 38 | |
| 39 | /* |
| 40 | * Cisco AP sends EAP failure and de-auth in less than 0.5 ms. |
| 41 | * It causes problem in the Supplicant |
| 42 | */ |
| 43 | |
| 44 | msleep_interruptible(1000); |
Holger Schurig | 634b8f4 | 2007-05-25 13:05:16 -0400 | [diff] [blame] | 45 | wireless_send_event(priv->dev, SIOCGIWAP, &wrqu, NULL); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 46 | |
| 47 | /* Free Tx and Rx packets */ |
| 48 | kfree_skb(priv->adapter->currenttxskb); |
| 49 | priv->adapter->currenttxskb = NULL; |
| 50 | |
| 51 | /* report disconnect to upper layer */ |
Holger Schurig | 634b8f4 | 2007-05-25 13:05:16 -0400 | [diff] [blame] | 52 | netif_stop_queue(priv->dev); |
| 53 | netif_carrier_off(priv->dev); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 54 | |
| 55 | /* reset SNR/NF/RSSI values */ |
| 56 | memset(adapter->SNR, 0x00, sizeof(adapter->SNR)); |
| 57 | memset(adapter->NF, 0x00, sizeof(adapter->NF)); |
| 58 | memset(adapter->RSSI, 0x00, sizeof(adapter->RSSI)); |
| 59 | memset(adapter->rawSNR, 0x00, sizeof(adapter->rawSNR)); |
| 60 | memset(adapter->rawNF, 0x00, sizeof(adapter->rawNF)); |
| 61 | adapter->nextSNRNF = 0; |
| 62 | adapter->numSNRNF = 0; |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 63 | lbs_deb_cmd("current SSID '%s', length %u\n", |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 64 | escape_essid(adapter->curbssparams.ssid, |
| 65 | adapter->curbssparams.ssid_len), |
| 66 | adapter->curbssparams.ssid_len); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 67 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 68 | adapter->connect_status = LIBERTAS_DISCONNECTED; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 69 | |
Dan Williams | e76850d | 2007-05-25 17:09:41 -0400 | [diff] [blame] | 70 | /* Clear out associated SSID and BSSID since connection is |
| 71 | * no longer valid. |
| 72 | */ |
| 73 | memset(&adapter->curbssparams.bssid, 0, ETH_ALEN); |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 74 | memset(&adapter->curbssparams.ssid, 0, IW_ESSID_MAX_SIZE); |
| 75 | adapter->curbssparams.ssid_len = 0; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 76 | |
| 77 | if (adapter->psstate != PS_STATE_FULL_POWER) { |
| 78 | /* make firmware to exit PS mode */ |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 79 | lbs_deb_cmd("disconnected, so exit PS mode\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 80 | libertas_ps_wakeup(priv, 0); |
| 81 | } |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 82 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | /** |
| 86 | * @brief This function handles MIC failure event. |
| 87 | * |
| 88 | * @param priv A pointer to wlan_private structure |
| 89 | * @para event the event id |
| 90 | * @return n/a |
| 91 | */ |
| 92 | static void handle_mic_failureevent(wlan_private * priv, u32 event) |
| 93 | { |
| 94 | char buf[50]; |
| 95 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 96 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 97 | memset(buf, 0, sizeof(buf)); |
| 98 | |
| 99 | sprintf(buf, "%s", "MLME-MICHAELMICFAILURE.indication "); |
| 100 | |
| 101 | if (event == MACREG_INT_CODE_MIC_ERR_UNICAST) { |
| 102 | strcat(buf, "unicast "); |
| 103 | } else { |
| 104 | strcat(buf, "multicast "); |
| 105 | } |
| 106 | |
| 107 | libertas_send_iwevcustom_event(priv, buf); |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 108 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | static int wlan_ret_reg_access(wlan_private * priv, |
| 112 | u16 type, struct cmd_ds_command *resp) |
| 113 | { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 114 | int ret = 0; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 115 | wlan_adapter *adapter = priv->adapter; |
| 116 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 117 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 118 | |
| 119 | switch (type) { |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 120 | case CMD_RET(CMD_MAC_REG_ACCESS): |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 121 | { |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 122 | struct cmd_ds_mac_reg_access *reg = &resp->params.macreg; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 123 | |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 124 | adapter->offsetvalue.offset = (u32)le16_to_cpu(reg->offset); |
| 125 | adapter->offsetvalue.value = le32_to_cpu(reg->value); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 126 | break; |
| 127 | } |
| 128 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 129 | case CMD_RET(CMD_BBP_REG_ACCESS): |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 130 | { |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 131 | struct cmd_ds_bbp_reg_access *reg = &resp->params.bbpreg; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 132 | |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 133 | adapter->offsetvalue.offset = (u32)le16_to_cpu(reg->offset); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 134 | adapter->offsetvalue.value = reg->value; |
| 135 | break; |
| 136 | } |
| 137 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 138 | case CMD_RET(CMD_RF_REG_ACCESS): |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 139 | { |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 140 | struct cmd_ds_rf_reg_access *reg = &resp->params.rfreg; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 141 | |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 142 | adapter->offsetvalue.offset = (u32)le16_to_cpu(reg->offset); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 143 | adapter->offsetvalue.value = reg->value; |
| 144 | break; |
| 145 | } |
| 146 | |
| 147 | default: |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 148 | ret = -1; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 149 | } |
| 150 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 151 | lbs_deb_enter_args(LBS_DEB_CMD, "ret %d", ret); |
| 152 | return ret; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 153 | } |
| 154 | |
| 155 | static int wlan_ret_get_hw_spec(wlan_private * priv, |
| 156 | struct cmd_ds_command *resp) |
| 157 | { |
| 158 | u32 i; |
| 159 | struct cmd_ds_get_hw_spec *hwspec = &resp->params.hwspec; |
| 160 | wlan_adapter *adapter = priv->adapter; |
| 161 | int ret = 0; |
| 162 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 163 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 164 | |
| 165 | adapter->fwcapinfo = le32_to_cpu(hwspec->fwcapinfo); |
| 166 | |
David Woodhouse | e5b3d47 | 2007-05-25 23:40:21 -0400 | [diff] [blame] | 167 | memcpy(adapter->fwreleasenumber, hwspec->fwreleasenumber, 4); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 168 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 169 | lbs_deb_cmd("GET_HW_SPEC: firmware release %u.%u.%up%u\n", |
David Woodhouse | e5b3d47 | 2007-05-25 23:40:21 -0400 | [diff] [blame] | 170 | adapter->fwreleasenumber[2], adapter->fwreleasenumber[1], |
| 171 | adapter->fwreleasenumber[0], adapter->fwreleasenumber[3]); |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 172 | lbs_deb_cmd("GET_HW_SPEC: MAC addr " MAC_FMT "\n", |
Holger Schurig | 0a6d055 | 2007-08-02 11:50:35 -0400 | [diff] [blame] | 173 | MAC_ARG(hwspec->permanentaddr)); |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 174 | lbs_deb_cmd("GET_HW_SPEC: hardware interface 0x%x, hardware spec 0x%04x\n", |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 175 | hwspec->hwifversion, hwspec->version); |
| 176 | |
| 177 | adapter->regioncode = le16_to_cpu(hwspec->regioncode); |
| 178 | |
| 179 | for (i = 0; i < MRVDRV_MAX_REGION_CODE; i++) { |
| 180 | /* use the region code to search for the index */ |
| 181 | if (adapter->regioncode == libertas_region_code_to_index[i]) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 182 | break; |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | /* if it's unidentified region code, use the default (USA) */ |
| 187 | if (i >= MRVDRV_MAX_REGION_CODE) { |
| 188 | adapter->regioncode = 0x10; |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 189 | lbs_pr_info("unidentified region code; using the default (USA)\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 190 | } |
| 191 | |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 192 | if (adapter->current_addr[0] == 0xff) |
| 193 | memmove(adapter->current_addr, hwspec->permanentaddr, ETH_ALEN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 194 | |
Holger Schurig | 634b8f4 | 2007-05-25 13:05:16 -0400 | [diff] [blame] | 195 | memcpy(priv->dev->dev_addr, adapter->current_addr, ETH_ALEN); |
Holger Schurig | 78523da | 2007-05-25 11:49:19 -0400 | [diff] [blame] | 196 | if (priv->mesh_dev) |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 197 | memcpy(priv->mesh_dev->dev_addr, adapter->current_addr, ETH_ALEN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 198 | |
| 199 | if (libertas_set_regiontable(priv, adapter->regioncode, 0)) { |
| 200 | ret = -1; |
| 201 | goto done; |
| 202 | } |
| 203 | |
| 204 | if (libertas_set_universaltable(priv, 0)) { |
| 205 | ret = -1; |
| 206 | goto done; |
| 207 | } |
| 208 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 209 | done: |
| 210 | lbs_deb_enter_args(LBS_DEB_CMD, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 211 | return ret; |
| 212 | } |
| 213 | |
| 214 | static int wlan_ret_802_11_sleep_params(wlan_private * priv, |
| 215 | struct cmd_ds_command *resp) |
| 216 | { |
| 217 | struct cmd_ds_802_11_sleep_params *sp = &resp->params.sleep_params; |
| 218 | wlan_adapter *adapter = priv->adapter; |
| 219 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 220 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 221 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 222 | lbs_deb_cmd("error 0x%x, offset 0x%x, stabletime 0x%x, calcontrol 0x%x " |
| 223 | "extsleepclk 0x%x\n", le16_to_cpu(sp->error), |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 224 | le16_to_cpu(sp->offset), le16_to_cpu(sp->stabletime), |
| 225 | sp->calcontrol, sp->externalsleepclk); |
| 226 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 227 | adapter->sp.sp_error = le16_to_cpu(sp->error); |
| 228 | adapter->sp.sp_offset = le16_to_cpu(sp->offset); |
| 229 | adapter->sp.sp_stabletime = le16_to_cpu(sp->stabletime); |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 230 | adapter->sp.sp_calcontrol = sp->calcontrol; |
| 231 | adapter->sp.sp_extsleepclk = sp->externalsleepclk; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 232 | adapter->sp.sp_reserved = le16_to_cpu(sp->reserved); |
| 233 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 234 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 235 | return 0; |
| 236 | } |
| 237 | |
| 238 | static int wlan_ret_802_11_stat(wlan_private * priv, |
| 239 | struct cmd_ds_command *resp) |
| 240 | { |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 241 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 242 | /* currently adapter->wlan802_11Stat is unused |
| 243 | |
| 244 | struct cmd_ds_802_11_get_stat *p11Stat = &resp->params.gstat; |
| 245 | wlan_adapter *adapter = priv->adapter; |
| 246 | |
| 247 | // TODO Convert it to Big endian befor copy |
| 248 | memcpy(&adapter->wlan802_11Stat, |
| 249 | p11Stat, sizeof(struct cmd_ds_802_11_get_stat)); |
| 250 | */ |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 251 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 252 | return 0; |
| 253 | } |
| 254 | |
| 255 | static int wlan_ret_802_11_snmp_mib(wlan_private * priv, |
| 256 | struct cmd_ds_command *resp) |
| 257 | { |
| 258 | struct cmd_ds_802_11_snmp_mib *smib = &resp->params.smib; |
| 259 | u16 oid = le16_to_cpu(smib->oid); |
| 260 | u16 querytype = le16_to_cpu(smib->querytype); |
| 261 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 262 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 263 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 264 | 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] | 265 | querytype); |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 266 | 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] | 267 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 268 | if (querytype == CMD_ACT_GET) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 269 | switch (oid) { |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 270 | case FRAGTHRESH_I: |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 271 | priv->adapter->fragthsd = |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 272 | le16_to_cpu(*((__le16 *)(smib->value))); |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 273 | lbs_deb_cmd("SNMP_RESP: frag threshold %u\n", |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 274 | priv->adapter->fragthsd); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 275 | break; |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 276 | case RTSTHRESH_I: |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 277 | priv->adapter->rtsthsd = |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 278 | le16_to_cpu(*((__le16 *)(smib->value))); |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 279 | lbs_deb_cmd("SNMP_RESP: rts threshold %u\n", |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 280 | priv->adapter->rtsthsd); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 281 | break; |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 282 | case SHORT_RETRYLIM_I: |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 283 | priv->adapter->txretrycount = |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 284 | le16_to_cpu(*((__le16 *)(smib->value))); |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 285 | lbs_deb_cmd("SNMP_RESP: tx retry count %u\n", |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 286 | priv->adapter->rtsthsd); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 287 | break; |
| 288 | default: |
| 289 | break; |
| 290 | } |
| 291 | } |
| 292 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 293 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 294 | return 0; |
| 295 | } |
| 296 | |
| 297 | static int wlan_ret_802_11_key_material(wlan_private * priv, |
| 298 | struct cmd_ds_command *resp) |
| 299 | { |
| 300 | struct cmd_ds_802_11_key_material *pkeymaterial = |
| 301 | &resp->params.keymaterial; |
| 302 | wlan_adapter *adapter = priv->adapter; |
| 303 | u16 action = le16_to_cpu(pkeymaterial->action); |
| 304 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 305 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 306 | |
| 307 | /* Copy the returned key to driver private data */ |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 308 | if (action == CMD_ACT_GET) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 309 | u8 * buf_ptr = (u8 *) &pkeymaterial->keyParamSet; |
| 310 | u8 * resp_end = (u8 *) (resp + le16_to_cpu(resp->size)); |
| 311 | |
| 312 | while (buf_ptr < resp_end) { |
| 313 | struct MrvlIEtype_keyParamSet * pkeyparamset = |
| 314 | (struct MrvlIEtype_keyParamSet *) buf_ptr; |
Dan Williams | 1443b65 | 2007-08-02 10:45:55 -0400 | [diff] [blame] | 315 | struct enc_key * pkey; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 316 | u16 param_set_len = le16_to_cpu(pkeyparamset->length); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 317 | u16 key_len = le16_to_cpu(pkeyparamset->keylen); |
Dan Williams | 1443b65 | 2007-08-02 10:45:55 -0400 | [diff] [blame] | 318 | u16 key_flags = le16_to_cpu(pkeyparamset->keyinfo); |
| 319 | u16 key_type = le16_to_cpu(pkeyparamset->keytypeid); |
| 320 | u8 * end; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 321 | |
| 322 | end = (u8 *) pkeyparamset + sizeof (pkeyparamset->type) |
| 323 | + sizeof (pkeyparamset->length) |
| 324 | + param_set_len; |
| 325 | /* Make sure we don't access past the end of the IEs */ |
| 326 | if (end > resp_end) |
| 327 | break; |
| 328 | |
Dan Williams | 1443b65 | 2007-08-02 10:45:55 -0400 | [diff] [blame] | 329 | if (key_flags & KEY_INFO_WPA_UNICAST) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 330 | pkey = &adapter->wpa_unicast_key; |
Dan Williams | 1443b65 | 2007-08-02 10:45:55 -0400 | [diff] [blame] | 331 | else if (key_flags & KEY_INFO_WPA_MCAST) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 332 | pkey = &adapter->wpa_mcast_key; |
| 333 | else |
| 334 | break; |
| 335 | |
| 336 | /* Copy returned key into driver */ |
Dan Williams | 1443b65 | 2007-08-02 10:45:55 -0400 | [diff] [blame] | 337 | memset(pkey, 0, sizeof(struct enc_key)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 338 | if (key_len > sizeof(pkey->key)) |
| 339 | break; |
Dan Williams | 1443b65 | 2007-08-02 10:45:55 -0400 | [diff] [blame] | 340 | pkey->type = key_type; |
| 341 | pkey->flags = key_flags; |
| 342 | pkey->len = key_len; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 343 | memcpy(pkey->key, pkeyparamset->key, pkey->len); |
| 344 | |
| 345 | buf_ptr = end + 1; |
| 346 | } |
| 347 | } |
| 348 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 349 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 350 | return 0; |
| 351 | } |
| 352 | |
| 353 | static int wlan_ret_802_11_mac_address(wlan_private * priv, |
| 354 | struct cmd_ds_command *resp) |
| 355 | { |
| 356 | struct cmd_ds_802_11_mac_address *macadd = &resp->params.macadd; |
| 357 | wlan_adapter *adapter = priv->adapter; |
| 358 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 359 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 360 | |
| 361 | memcpy(adapter->current_addr, macadd->macadd, ETH_ALEN); |
| 362 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 363 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 364 | return 0; |
| 365 | } |
| 366 | |
| 367 | static int wlan_ret_802_11_rf_tx_power(wlan_private * priv, |
| 368 | struct cmd_ds_command *resp) |
| 369 | { |
| 370 | struct cmd_ds_802_11_rf_tx_power *rtp = &resp->params.txp; |
| 371 | wlan_adapter *adapter = priv->adapter; |
| 372 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 373 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 374 | |
| 375 | adapter->txpowerlevel = le16_to_cpu(rtp->currentlevel); |
| 376 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 377 | lbs_deb_cmd("TX power currently %d\n", adapter->txpowerlevel); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 378 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 379 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 380 | return 0; |
| 381 | } |
| 382 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 383 | static int wlan_ret_802_11_rate_adapt_rateset(wlan_private * priv, |
| 384 | struct cmd_ds_command *resp) |
| 385 | { |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 386 | struct cmd_ds_802_11_rate_adapt_rateset *rates = &resp->params.rateset; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 387 | wlan_adapter *adapter = priv->adapter; |
| 388 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 389 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 390 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 391 | if (rates->action == CMD_ACT_GET) { |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 392 | adapter->enablehwauto = le16_to_cpu(rates->enablehwauto); |
| 393 | adapter->ratebitmap = le16_to_cpu(rates->bitmap); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 394 | } |
| 395 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 396 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 397 | return 0; |
| 398 | } |
| 399 | |
| 400 | static int wlan_ret_802_11_data_rate(wlan_private * priv, |
| 401 | struct cmd_ds_command *resp) |
| 402 | { |
| 403 | struct cmd_ds_802_11_data_rate *pdatarate = &resp->params.drate; |
| 404 | wlan_adapter *adapter = priv->adapter; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 405 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 406 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 407 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 408 | lbs_deb_hex(LBS_DEB_CMD, "DATA_RATE_RESP", (u8 *) pdatarate, |
Dan Williams | 8c51276 | 2007-08-02 11:40:45 -0400 | [diff] [blame] | 409 | sizeof(struct cmd_ds_802_11_data_rate)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 410 | |
Dan Williams | 8c51276 | 2007-08-02 11:40:45 -0400 | [diff] [blame] | 411 | /* FIXME: get actual rates FW can do if this command actually returns |
| 412 | * all data rates supported. |
| 413 | */ |
| 414 | adapter->cur_rate = libertas_fw_index_to_data_rate(pdatarate->rates[0]); |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 415 | lbs_deb_cmd("DATA_RATE: current rate 0x%02x\n", adapter->cur_rate); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 416 | |
Dan Williams | 8c51276 | 2007-08-02 11:40:45 -0400 | [diff] [blame] | 417 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 418 | return 0; |
| 419 | } |
| 420 | |
| 421 | static int wlan_ret_802_11_rf_channel(wlan_private * priv, |
| 422 | struct cmd_ds_command *resp) |
| 423 | { |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 424 | struct cmd_ds_802_11_rf_channel *rfchannel = &resp->params.rfchannel; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 425 | wlan_adapter *adapter = priv->adapter; |
| 426 | u16 action = le16_to_cpu(rfchannel->action); |
| 427 | u16 newchannel = le16_to_cpu(rfchannel->currentchannel); |
| 428 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 429 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 430 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 431 | if (action == CMD_OPT_802_11_RF_CHANNEL_GET |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 432 | && adapter->curbssparams.channel != newchannel) { |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 433 | lbs_deb_cmd("channel switch from %d to %d\n", |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 434 | adapter->curbssparams.channel, newchannel); |
| 435 | |
| 436 | /* Update the channel again */ |
| 437 | adapter->curbssparams.channel = newchannel; |
| 438 | } |
| 439 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 440 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 441 | return 0; |
| 442 | } |
| 443 | |
| 444 | static int wlan_ret_802_11_rssi(wlan_private * priv, |
| 445 | struct cmd_ds_command *resp) |
| 446 | { |
| 447 | struct cmd_ds_802_11_rssi_rsp *rssirsp = &resp->params.rssirsp; |
| 448 | wlan_adapter *adapter = priv->adapter; |
| 449 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 450 | lbs_deb_enter(LBS_DEB_CMD); |
| 451 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 452 | /* store the non average value */ |
| 453 | adapter->SNR[TYPE_BEACON][TYPE_NOAVG] = le16_to_cpu(rssirsp->SNR); |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 454 | adapter->NF[TYPE_BEACON][TYPE_NOAVG] = le16_to_cpu(rssirsp->noisefloor); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 455 | |
| 456 | adapter->SNR[TYPE_BEACON][TYPE_AVG] = le16_to_cpu(rssirsp->avgSNR); |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 457 | adapter->NF[TYPE_BEACON][TYPE_AVG] = le16_to_cpu(rssirsp->avgnoisefloor); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 458 | |
| 459 | adapter->RSSI[TYPE_BEACON][TYPE_NOAVG] = |
| 460 | CAL_RSSI(adapter->SNR[TYPE_BEACON][TYPE_NOAVG], |
| 461 | adapter->NF[TYPE_BEACON][TYPE_NOAVG]); |
| 462 | |
| 463 | adapter->RSSI[TYPE_BEACON][TYPE_AVG] = |
| 464 | CAL_RSSI(adapter->SNR[TYPE_BEACON][TYPE_AVG] / AVG_SCALE, |
| 465 | adapter->NF[TYPE_BEACON][TYPE_AVG] / AVG_SCALE); |
| 466 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 467 | lbs_deb_cmd("RSSI: beacon %d, avg %d\n", |
| 468 | adapter->RSSI[TYPE_BEACON][TYPE_NOAVG], |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 469 | adapter->RSSI[TYPE_BEACON][TYPE_AVG]); |
| 470 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 471 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 472 | return 0; |
| 473 | } |
| 474 | |
| 475 | static int wlan_ret_802_11_eeprom_access(wlan_private * priv, |
| 476 | struct cmd_ds_command *resp) |
| 477 | { |
| 478 | wlan_adapter *adapter = priv->adapter; |
| 479 | struct wlan_ioctl_regrdwr *pbuf; |
| 480 | pbuf = (struct wlan_ioctl_regrdwr *) adapter->prdeeprom; |
| 481 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 482 | lbs_deb_enter_args(LBS_DEB_CMD, "len %d", |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 483 | le16_to_cpu(resp->params.rdeeprom.bytecount)); |
| 484 | if (pbuf->NOB < le16_to_cpu(resp->params.rdeeprom.bytecount)) { |
| 485 | pbuf->NOB = 0; |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 486 | lbs_deb_cmd("EEPROM read length too big\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 487 | return -1; |
| 488 | } |
| 489 | pbuf->NOB = le16_to_cpu(resp->params.rdeeprom.bytecount); |
| 490 | if (pbuf->NOB > 0) { |
| 491 | |
| 492 | memcpy(&pbuf->value, (u8 *) & resp->params.rdeeprom.value, |
| 493 | le16_to_cpu(resp->params.rdeeprom.bytecount)); |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 494 | lbs_deb_hex(LBS_DEB_CMD, "EEPROM", (char *)&pbuf->value, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 495 | le16_to_cpu(resp->params.rdeeprom.bytecount)); |
| 496 | } |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 497 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 498 | return 0; |
| 499 | } |
| 500 | |
| 501 | static int wlan_ret_get_log(wlan_private * priv, |
| 502 | struct cmd_ds_command *resp) |
| 503 | { |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 504 | struct cmd_ds_802_11_get_log *logmessage = &resp->params.glog; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 505 | wlan_adapter *adapter = priv->adapter; |
| 506 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 507 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 508 | |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 509 | /* Stored little-endian */ |
| 510 | memcpy(&adapter->logmsg, logmessage, sizeof(struct cmd_ds_802_11_get_log)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 511 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 512 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 513 | return 0; |
| 514 | } |
| 515 | |
Dan Williams | 18c96c34 | 2007-06-18 12:01:12 -0400 | [diff] [blame] | 516 | static int libertas_ret_802_11_enable_rsn(wlan_private * priv, |
| 517 | struct cmd_ds_command *resp) |
| 518 | { |
| 519 | struct cmd_ds_802_11_enable_rsn *enable_rsn = &resp->params.enbrsn; |
| 520 | wlan_adapter *adapter = priv->adapter; |
| 521 | u32 * pdata_buf = adapter->cur_cmd->pdata_buf; |
| 522 | |
| 523 | lbs_deb_enter(LBS_DEB_CMD); |
| 524 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 525 | if (enable_rsn->action == cpu_to_le16(CMD_ACT_GET)) { |
Dan Williams | 18c96c34 | 2007-06-18 12:01:12 -0400 | [diff] [blame] | 526 | if (pdata_buf) |
| 527 | *pdata_buf = (u32) le16_to_cpu(enable_rsn->enable); |
| 528 | } |
| 529 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 530 | lbs_deb_leave(LBS_DEB_CMD); |
Dan Williams | 18c96c34 | 2007-06-18 12:01:12 -0400 | [diff] [blame] | 531 | return 0; |
| 532 | } |
| 533 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 534 | static inline int handle_cmd_response(u16 respcmd, |
| 535 | struct cmd_ds_command *resp, |
| 536 | wlan_private *priv) |
| 537 | { |
| 538 | int ret = 0; |
| 539 | unsigned long flags; |
| 540 | wlan_adapter *adapter = priv->adapter; |
| 541 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 542 | lbs_deb_enter(LBS_DEB_HOST); |
| 543 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 544 | switch (respcmd) { |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 545 | case CMD_RET(CMD_MAC_REG_ACCESS): |
| 546 | case CMD_RET(CMD_BBP_REG_ACCESS): |
| 547 | case CMD_RET(CMD_RF_REG_ACCESS): |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 548 | ret = wlan_ret_reg_access(priv, respcmd, resp); |
| 549 | break; |
| 550 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 551 | case CMD_RET(CMD_GET_HW_SPEC): |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 552 | ret = wlan_ret_get_hw_spec(priv, resp); |
| 553 | break; |
| 554 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 555 | case CMD_RET(CMD_802_11_SCAN): |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 556 | ret = libertas_ret_80211_scan(priv, resp); |
| 557 | break; |
| 558 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 559 | case CMD_RET(CMD_802_11_GET_LOG): |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 560 | ret = wlan_ret_get_log(priv, resp); |
| 561 | break; |
| 562 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 563 | case CMD_RET_802_11_ASSOCIATE: |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 564 | case CMD_RET(CMD_802_11_ASSOCIATE): |
| 565 | case CMD_RET(CMD_802_11_REASSOCIATE): |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 566 | ret = libertas_ret_80211_associate(priv, resp); |
| 567 | break; |
| 568 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 569 | case CMD_RET(CMD_802_11_DISASSOCIATE): |
| 570 | case CMD_RET(CMD_802_11_DEAUTHENTICATE): |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 571 | ret = libertas_ret_80211_disassociate(priv, resp); |
| 572 | break; |
| 573 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 574 | case CMD_RET(CMD_802_11_AD_HOC_START): |
| 575 | case CMD_RET(CMD_802_11_AD_HOC_JOIN): |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 576 | ret = libertas_ret_80211_ad_hoc_start(priv, resp); |
| 577 | break; |
| 578 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 579 | case CMD_RET(CMD_802_11_GET_STAT): |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 580 | ret = wlan_ret_802_11_stat(priv, resp); |
| 581 | break; |
| 582 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 583 | case CMD_RET(CMD_802_11_SNMP_MIB): |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 584 | ret = wlan_ret_802_11_snmp_mib(priv, resp); |
| 585 | break; |
| 586 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 587 | case CMD_RET(CMD_802_11_RF_TX_POWER): |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 588 | ret = wlan_ret_802_11_rf_tx_power(priv, resp); |
| 589 | break; |
| 590 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 591 | case CMD_RET(CMD_802_11_SET_AFC): |
| 592 | case CMD_RET(CMD_802_11_GET_AFC): |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 593 | spin_lock_irqsave(&adapter->driver_lock, flags); |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 594 | memmove(adapter->cur_cmd->pdata_buf, &resp->params.afc, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 595 | sizeof(struct cmd_ds_802_11_afc)); |
| 596 | spin_unlock_irqrestore(&adapter->driver_lock, flags); |
| 597 | |
| 598 | break; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 599 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 600 | case CMD_RET(CMD_MAC_MULTICAST_ADR): |
| 601 | case CMD_RET(CMD_MAC_CONTROL): |
| 602 | case CMD_RET(CMD_802_11_SET_WEP): |
| 603 | case CMD_RET(CMD_802_11_RESET): |
| 604 | case CMD_RET(CMD_802_11_AUTHENTICATE): |
| 605 | case CMD_RET(CMD_802_11_RADIO_CONTROL): |
| 606 | case CMD_RET(CMD_802_11_BEACON_STOP): |
Dan Williams | 18c96c34 | 2007-06-18 12:01:12 -0400 | [diff] [blame] | 607 | break; |
| 608 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 609 | case CMD_RET(CMD_802_11_ENABLE_RSN): |
Dan Williams | 18c96c34 | 2007-06-18 12:01:12 -0400 | [diff] [blame] | 610 | ret = libertas_ret_802_11_enable_rsn(priv, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 611 | break; |
| 612 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 613 | case CMD_RET(CMD_802_11_DATA_RATE): |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 614 | ret = wlan_ret_802_11_data_rate(priv, resp); |
| 615 | break; |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 616 | case CMD_RET(CMD_802_11_RATE_ADAPT_RATESET): |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 617 | ret = wlan_ret_802_11_rate_adapt_rateset(priv, resp); |
| 618 | break; |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 619 | case CMD_RET(CMD_802_11_RF_CHANNEL): |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 620 | ret = wlan_ret_802_11_rf_channel(priv, resp); |
| 621 | break; |
| 622 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 623 | case CMD_RET(CMD_802_11_RSSI): |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 624 | ret = wlan_ret_802_11_rssi(priv, resp); |
| 625 | break; |
| 626 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 627 | case CMD_RET(CMD_802_11_MAC_ADDRESS): |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 628 | ret = wlan_ret_802_11_mac_address(priv, resp); |
| 629 | break; |
| 630 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 631 | case CMD_RET(CMD_802_11_AD_HOC_STOP): |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 632 | ret = libertas_ret_80211_ad_hoc_stop(priv, resp); |
| 633 | break; |
| 634 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 635 | case CMD_RET(CMD_802_11_KEY_MATERIAL): |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 636 | ret = wlan_ret_802_11_key_material(priv, resp); |
| 637 | break; |
| 638 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 639 | case CMD_RET(CMD_802_11_EEPROM_ACCESS): |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 640 | ret = wlan_ret_802_11_eeprom_access(priv, resp); |
| 641 | break; |
| 642 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 643 | case CMD_RET(CMD_802_11D_DOMAIN_INFO): |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 644 | ret = libertas_ret_802_11d_domain_info(priv, resp); |
| 645 | break; |
| 646 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 647 | case CMD_RET(CMD_802_11_SLEEP_PARAMS): |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 648 | ret = wlan_ret_802_11_sleep_params(priv, resp); |
| 649 | break; |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 650 | case CMD_RET(CMD_802_11_INACTIVITY_TIMEOUT): |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 651 | spin_lock_irqsave(&adapter->driver_lock, flags); |
| 652 | *((u16 *) adapter->cur_cmd->pdata_buf) = |
| 653 | le16_to_cpu(resp->params.inactivity_timeout.timeout); |
| 654 | spin_unlock_irqrestore(&adapter->driver_lock, flags); |
| 655 | break; |
| 656 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 657 | case CMD_RET(CMD_802_11_TPC_CFG): |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 658 | spin_lock_irqsave(&adapter->driver_lock, flags); |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 659 | memmove(adapter->cur_cmd->pdata_buf, &resp->params.tpccfg, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 660 | sizeof(struct cmd_ds_802_11_tpc_cfg)); |
| 661 | spin_unlock_irqrestore(&adapter->driver_lock, flags); |
| 662 | break; |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 663 | case CMD_RET(CMD_802_11_LED_GPIO_CTRL): |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 664 | spin_lock_irqsave(&adapter->driver_lock, flags); |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 665 | memmove(adapter->cur_cmd->pdata_buf, &resp->params.ledgpio, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 666 | sizeof(struct cmd_ds_802_11_led_ctrl)); |
| 667 | spin_unlock_irqrestore(&adapter->driver_lock, flags); |
| 668 | break; |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 669 | case CMD_RET(CMD_802_11_PWR_CFG): |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 670 | spin_lock_irqsave(&adapter->driver_lock, flags); |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 671 | memmove(adapter->cur_cmd->pdata_buf, &resp->params.pwrcfg, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 672 | sizeof(struct cmd_ds_802_11_pwr_cfg)); |
| 673 | spin_unlock_irqrestore(&adapter->driver_lock, flags); |
| 674 | |
| 675 | break; |
| 676 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 677 | case CMD_RET(CMD_GET_TSF): |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 678 | spin_lock_irqsave(&adapter->driver_lock, flags); |
| 679 | memcpy(priv->adapter->cur_cmd->pdata_buf, |
| 680 | &resp->params.gettsf.tsfvalue, sizeof(u64)); |
| 681 | spin_unlock_irqrestore(&adapter->driver_lock, flags); |
| 682 | break; |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 683 | case CMD_RET(CMD_BT_ACCESS): |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 684 | spin_lock_irqsave(&adapter->driver_lock, flags); |
| 685 | if (adapter->cur_cmd->pdata_buf) |
| 686 | memcpy(adapter->cur_cmd->pdata_buf, |
| 687 | &resp->params.bt.addr1, 2 * ETH_ALEN); |
| 688 | spin_unlock_irqrestore(&adapter->driver_lock, flags); |
| 689 | break; |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 690 | case CMD_RET(CMD_FWT_ACCESS): |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 691 | spin_lock_irqsave(&adapter->driver_lock, flags); |
| 692 | if (adapter->cur_cmd->pdata_buf) |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 693 | memcpy(adapter->cur_cmd->pdata_buf, &resp->params.fwt, |
| 694 | sizeof(resp->params.fwt)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 695 | spin_unlock_irqrestore(&adapter->driver_lock, flags); |
| 696 | break; |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 697 | case CMD_RET(CMD_MESH_ACCESS): |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 698 | if (adapter->cur_cmd->pdata_buf) |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 699 | memcpy(adapter->cur_cmd->pdata_buf, &resp->params.mesh, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 700 | sizeof(resp->params.mesh)); |
| 701 | break; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 702 | default: |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 703 | lbs_deb_host("CMD_RESP: unknown cmd response 0x%04x\n", |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 704 | resp->command); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 705 | break; |
| 706 | } |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 707 | lbs_deb_leave(LBS_DEB_HOST); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 708 | return ret; |
| 709 | } |
| 710 | |
| 711 | int libertas_process_rx_command(wlan_private * priv) |
| 712 | { |
| 713 | u16 respcmd; |
| 714 | struct cmd_ds_command *resp; |
| 715 | wlan_adapter *adapter = priv->adapter; |
| 716 | int ret = 0; |
| 717 | ulong flags; |
| 718 | u16 result; |
| 719 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 720 | lbs_deb_enter(LBS_DEB_HOST); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 721 | |
| 722 | /* Now we got response from FW, cancel the command timer */ |
| 723 | del_timer(&adapter->command_timer); |
| 724 | |
| 725 | mutex_lock(&adapter->lock); |
| 726 | spin_lock_irqsave(&adapter->driver_lock, flags); |
| 727 | |
| 728 | if (!adapter->cur_cmd) { |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 729 | lbs_deb_host("CMD_RESP: cur_cmd is NULL\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 730 | ret = -1; |
| 731 | spin_unlock_irqrestore(&adapter->driver_lock, flags); |
| 732 | goto done; |
| 733 | } |
| 734 | resp = (struct cmd_ds_command *)(adapter->cur_cmd->bufvirtualaddr); |
| 735 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 736 | respcmd = le16_to_cpu(resp->command); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 737 | result = le16_to_cpu(resp->result); |
| 738 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 739 | lbs_deb_host("CMD_RESP: response 0x%04x, size %d, jiffies %lu\n", |
| 740 | respcmd, priv->upld_len, jiffies); |
| 741 | lbs_deb_hex(LBS_DEB_HOST, "CMD_RESP", adapter->cur_cmd->bufvirtualaddr, |
| 742 | priv->upld_len); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 743 | |
| 744 | if (!(respcmd & 0x8000)) { |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 745 | lbs_deb_host("invalid response!\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 746 | adapter->cur_cmd_retcode = -1; |
| 747 | __libertas_cleanup_and_insert_cmd(priv, adapter->cur_cmd); |
| 748 | adapter->nr_cmd_pending--; |
| 749 | adapter->cur_cmd = NULL; |
| 750 | spin_unlock_irqrestore(&adapter->driver_lock, flags); |
| 751 | ret = -1; |
| 752 | goto done; |
| 753 | } |
| 754 | |
| 755 | /* Store the response code to cur_cmd_retcode. */ |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 756 | adapter->cur_cmd_retcode = result;; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 757 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 758 | if (respcmd == CMD_RET(CMD_802_11_PS_MODE)) { |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 759 | struct cmd_ds_802_11_ps_mode *psmode = &resp->params.psmode; |
| 760 | u16 action = le16_to_cpu(psmode->action); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 761 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 762 | lbs_deb_host( |
| 763 | "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] | 764 | result, action); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 765 | |
| 766 | if (result) { |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 767 | lbs_deb_host("CMD_RESP: PS command failed with 0x%x\n", |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 768 | result); |
| 769 | /* |
| 770 | * We should not re-try enter-ps command in |
| 771 | * ad-hoc mode. It takes place in |
| 772 | * libertas_execute_next_command(). |
| 773 | */ |
| 774 | if (adapter->mode == IW_MODE_ADHOC && |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 775 | action == CMD_SUBCMD_ENTER_PS) |
| 776 | adapter->psmode = WLAN802_11POWERMODECAM; |
| 777 | } else if (action == CMD_SUBCMD_ENTER_PS) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 778 | adapter->needtowakeup = 0; |
| 779 | adapter->psstate = PS_STATE_AWAKE; |
| 780 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 781 | lbs_deb_host("CMD_RESP: ENTER_PS command response\n"); |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 782 | if (adapter->connect_status != LIBERTAS_CONNECTED) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 783 | /* |
| 784 | * When Deauth Event received before Enter_PS command |
| 785 | * response, We need to wake up the firmware. |
| 786 | */ |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 787 | lbs_deb_host( |
| 788 | "disconnected, invoking libertas_ps_wakeup\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 789 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 790 | spin_unlock_irqrestore(&adapter->driver_lock, flags); |
Dan Williams | 6cfb008 | 2007-05-25 17:33:28 -0400 | [diff] [blame] | 791 | mutex_unlock(&adapter->lock); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 792 | libertas_ps_wakeup(priv, 0); |
| 793 | mutex_lock(&adapter->lock); |
| 794 | spin_lock_irqsave(&adapter->driver_lock, flags); |
| 795 | } |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 796 | } else if (action == CMD_SUBCMD_EXIT_PS) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 797 | adapter->needtowakeup = 0; |
| 798 | adapter->psstate = PS_STATE_FULL_POWER; |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 799 | lbs_deb_host("CMD_RESP: EXIT_PS command response\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 800 | } else { |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 801 | lbs_deb_host("CMD_RESP: PS action 0x%X\n", action); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 802 | } |
| 803 | |
| 804 | __libertas_cleanup_and_insert_cmd(priv, adapter->cur_cmd); |
| 805 | adapter->nr_cmd_pending--; |
| 806 | adapter->cur_cmd = NULL; |
| 807 | spin_unlock_irqrestore(&adapter->driver_lock, flags); |
| 808 | |
| 809 | ret = 0; |
| 810 | goto done; |
| 811 | } |
| 812 | |
| 813 | if (adapter->cur_cmd->cmdflags & CMD_F_HOSTCMD) { |
| 814 | /* Copy the response back to response buffer */ |
Dan Williams | 8362cd4 | 2007-08-03 09:40:55 -0400 | [diff] [blame^] | 815 | memcpy(adapter->cur_cmd->pdata_buf, resp, |
| 816 | le16_to_cpu(resp->size)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 817 | adapter->cur_cmd->cmdflags &= ~CMD_F_HOSTCMD; |
| 818 | } |
| 819 | |
| 820 | /* If the command is not successful, cleanup and return failure */ |
| 821 | if ((result != 0 || !(respcmd & 0x8000))) { |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 822 | lbs_deb_host("CMD_RESP: error 0x%04x in command reply 0x%04x\n", |
| 823 | result, respcmd); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 824 | /* |
| 825 | * Handling errors here |
| 826 | */ |
| 827 | switch (respcmd) { |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 828 | case CMD_RET(CMD_GET_HW_SPEC): |
| 829 | case CMD_RET(CMD_802_11_RESET): |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 830 | lbs_deb_host("CMD_RESP: reset failed\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 831 | break; |
| 832 | |
| 833 | } |
| 834 | |
| 835 | __libertas_cleanup_and_insert_cmd(priv, adapter->cur_cmd); |
| 836 | adapter->nr_cmd_pending--; |
| 837 | adapter->cur_cmd = NULL; |
| 838 | spin_unlock_irqrestore(&adapter->driver_lock, flags); |
| 839 | |
| 840 | ret = -1; |
| 841 | goto done; |
| 842 | } |
| 843 | |
| 844 | spin_unlock_irqrestore(&adapter->driver_lock, flags); |
| 845 | |
| 846 | ret = handle_cmd_response(respcmd, resp, priv); |
| 847 | |
| 848 | spin_lock_irqsave(&adapter->driver_lock, flags); |
| 849 | if (adapter->cur_cmd) { |
| 850 | /* Clean up and Put current command back to cmdfreeq */ |
| 851 | __libertas_cleanup_and_insert_cmd(priv, adapter->cur_cmd); |
| 852 | adapter->nr_cmd_pending--; |
| 853 | WARN_ON(adapter->nr_cmd_pending > 128); |
| 854 | adapter->cur_cmd = NULL; |
| 855 | } |
| 856 | spin_unlock_irqrestore(&adapter->driver_lock, flags); |
| 857 | |
| 858 | done: |
| 859 | mutex_unlock(&adapter->lock); |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 860 | lbs_deb_leave_args(LBS_DEB_HOST, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 861 | return ret; |
| 862 | } |
| 863 | |
| 864 | int libertas_process_event(wlan_private * priv) |
| 865 | { |
| 866 | int ret = 0; |
| 867 | wlan_adapter *adapter = priv->adapter; |
| 868 | u32 eventcause; |
| 869 | |
Holger Schurig | 9556d21 | 2007-08-02 13:14:07 -0400 | [diff] [blame] | 870 | lbs_deb_enter(LBS_DEB_CMD); |
| 871 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 872 | spin_lock_irq(&adapter->driver_lock); |
| 873 | eventcause = adapter->eventcause; |
| 874 | spin_unlock_irq(&adapter->driver_lock); |
| 875 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 876 | lbs_deb_cmd("event cause 0x%x\n", eventcause); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 877 | |
| 878 | switch (eventcause >> SBI_EVENT_CAUSE_SHIFT) { |
| 879 | case MACREG_INT_CODE_LINK_SENSED: |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 880 | lbs_deb_cmd("EVENT: MACREG_INT_CODE_LINK_SENSED\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 881 | break; |
| 882 | |
| 883 | case MACREG_INT_CODE_DEAUTHENTICATED: |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 884 | lbs_deb_cmd("EVENT: deauthenticated\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 885 | libertas_mac_event_disconnected(priv); |
| 886 | break; |
| 887 | |
| 888 | case MACREG_INT_CODE_DISASSOCIATED: |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 889 | lbs_deb_cmd("EVENT: disassociated\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 890 | libertas_mac_event_disconnected(priv); |
| 891 | break; |
| 892 | |
| 893 | case MACREG_INT_CODE_LINK_LOSE_NO_SCAN: |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 894 | lbs_deb_cmd("EVENT: link lost\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 895 | libertas_mac_event_disconnected(priv); |
| 896 | break; |
| 897 | |
| 898 | case MACREG_INT_CODE_PS_SLEEP: |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 899 | lbs_deb_cmd("EVENT: sleep\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 900 | |
| 901 | /* handle unexpected PS SLEEP event */ |
| 902 | if (adapter->psstate == PS_STATE_FULL_POWER) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 903 | lbs_deb_cmd( |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 904 | "EVENT: in FULL POWER mode, ignoreing PS_SLEEP\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 905 | break; |
| 906 | } |
| 907 | adapter->psstate = PS_STATE_PRE_SLEEP; |
| 908 | |
| 909 | libertas_ps_confirm_sleep(priv, (u16) adapter->psmode); |
| 910 | |
| 911 | break; |
| 912 | |
| 913 | case MACREG_INT_CODE_PS_AWAKE: |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 914 | lbs_deb_cmd("EVENT: awake\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 915 | |
| 916 | /* handle unexpected PS AWAKE event */ |
| 917 | if (adapter->psstate == PS_STATE_FULL_POWER) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 918 | lbs_deb_cmd( |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 919 | "EVENT: In FULL POWER mode - ignore PS AWAKE\n"); |
| 920 | break; |
| 921 | } |
| 922 | |
| 923 | adapter->psstate = PS_STATE_AWAKE; |
| 924 | |
| 925 | if (adapter->needtowakeup) { |
| 926 | /* |
| 927 | * wait for the command processing to finish |
| 928 | * before resuming sending |
| 929 | * adapter->needtowakeup will be set to FALSE |
| 930 | * in libertas_ps_wakeup() |
| 931 | */ |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 932 | lbs_deb_cmd("waking up ...\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 933 | libertas_ps_wakeup(priv, 0); |
| 934 | } |
| 935 | break; |
| 936 | |
| 937 | case MACREG_INT_CODE_MIC_ERR_UNICAST: |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 938 | lbs_deb_cmd("EVENT: UNICAST MIC ERROR\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 939 | handle_mic_failureevent(priv, MACREG_INT_CODE_MIC_ERR_UNICAST); |
| 940 | break; |
| 941 | |
| 942 | case MACREG_INT_CODE_MIC_ERR_MULTICAST: |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 943 | lbs_deb_cmd("EVENT: MULTICAST MIC ERROR\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 944 | handle_mic_failureevent(priv, MACREG_INT_CODE_MIC_ERR_MULTICAST); |
| 945 | break; |
| 946 | case MACREG_INT_CODE_MIB_CHANGED: |
| 947 | case MACREG_INT_CODE_INIT_DONE: |
| 948 | break; |
| 949 | |
| 950 | case MACREG_INT_CODE_ADHOC_BCN_LOST: |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 951 | lbs_deb_cmd("EVENT: ADHOC beacon lost\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 952 | break; |
| 953 | |
| 954 | case MACREG_INT_CODE_RSSI_LOW: |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 955 | lbs_pr_alert("EVENT: rssi low\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 956 | break; |
| 957 | case MACREG_INT_CODE_SNR_LOW: |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 958 | lbs_pr_alert("EVENT: snr low\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 959 | break; |
| 960 | case MACREG_INT_CODE_MAX_FAIL: |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 961 | lbs_pr_alert("EVENT: max fail\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 962 | break; |
| 963 | case MACREG_INT_CODE_RSSI_HIGH: |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 964 | lbs_pr_alert("EVENT: rssi high\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 965 | break; |
| 966 | case MACREG_INT_CODE_SNR_HIGH: |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 967 | lbs_pr_alert("EVENT: snr high\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 968 | break; |
| 969 | |
Luis Carlos Cobo Rus | 7d8d28b | 2007-05-25 23:12:19 -0400 | [diff] [blame] | 970 | case MACREG_INT_CODE_MESH_AUTO_STARTED: |
Dan Williams | 5612c01 | 2007-08-02 13:20:12 -0400 | [diff] [blame] | 971 | /* Ignore spurious autostart events if autostart is disabled */ |
| 972 | if (!priv->mesh_autostart_enabled) { |
| 973 | lbs_pr_info("EVENT: MESH_AUTO_STARTED (ignoring)\n"); |
| 974 | break; |
| 975 | } |
Luis Carlos Cobo | 9cdc6d2 | 2007-08-02 11:55:22 -0400 | [diff] [blame] | 976 | lbs_pr_info("EVENT: MESH_AUTO_STARTED\n"); |
| 977 | adapter->connect_status = LIBERTAS_CONNECTED; |
Luis Carlos Cobo Rus | 7d8d28b | 2007-05-25 23:12:19 -0400 | [diff] [blame] | 978 | if (priv->mesh_open == 1) { |
Luis Carlos Cobo | 9cdc6d2 | 2007-08-02 11:55:22 -0400 | [diff] [blame] | 979 | netif_wake_queue(priv->mesh_dev); |
| 980 | netif_carrier_on(priv->mesh_dev); |
Luis Carlos Cobo Rus | 7d8d28b | 2007-05-25 23:12:19 -0400 | [diff] [blame] | 981 | } |
Luis Carlos Cobo | 9cdc6d2 | 2007-08-02 11:55:22 -0400 | [diff] [blame] | 982 | adapter->mode = IW_MODE_ADHOC; |
Luis Carlos Cobo Rus | b8bedef | 2007-05-30 12:14:34 -0400 | [diff] [blame] | 983 | schedule_work(&priv->sync_channel); |
Luis Carlos Cobo Rus | 7d8d28b | 2007-05-25 23:12:19 -0400 | [diff] [blame] | 984 | break; |
| 985 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 986 | default: |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 987 | lbs_pr_alert("EVENT: unknown event id 0x%04x\n", |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 988 | eventcause >> SBI_EVENT_CAUSE_SHIFT); |
| 989 | break; |
| 990 | } |
| 991 | |
| 992 | spin_lock_irq(&adapter->driver_lock); |
| 993 | adapter->eventcause = 0; |
| 994 | spin_unlock_irq(&adapter->driver_lock); |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 995 | |
Holger Schurig | 9556d21 | 2007-08-02 13:14:07 -0400 | [diff] [blame] | 996 | lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 997 | return ret; |
| 998 | } |