Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1 | /** |
| 2 | * This file contains the handling of command |
| 3 | * responses as well as events generated by firmware. |
| 4 | */ |
| 5 | #include <linux/delay.h> |
| 6 | #include <linux/if_arp.h> |
| 7 | #include <linux/netdevice.h> |
| 8 | |
| 9 | #include <net/iw_handler.h> |
| 10 | |
| 11 | #include "host.h" |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 12 | #include "decl.h" |
| 13 | #include "defs.h" |
| 14 | #include "dev.h" |
| 15 | #include "join.h" |
| 16 | #include "wext.h" |
| 17 | |
| 18 | /** |
| 19 | * @brief This function handles disconnect event. it |
| 20 | * reports disconnect to upper layer, clean tx/rx packets, |
| 21 | * reset link state etc. |
| 22 | * |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 23 | * @param priv A pointer to struct lbs_private structure |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 24 | * @return n/a |
| 25 | */ |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 26 | void lbs_mac_event_disconnected(struct lbs_private *priv) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 27 | { |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 28 | struct lbs_adapter *adapter = priv->adapter; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 29 | union iwreq_data wrqu; |
| 30 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 31 | if (adapter->connect_status != LBS_CONNECTED) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 32 | return; |
| 33 | |
Holger Schurig | 9184346 | 2007-11-28 14:05:02 +0100 | [diff] [blame] | 34 | lbs_deb_enter(LBS_DEB_ASSOC); |
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 | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 63 | adapter->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 | */ |
| 68 | memset(&adapter->curbssparams.bssid, 0, ETH_ALEN); |
Dan Williams | d8efea2 | 2007-05-28 23:54:55 -0400 | [diff] [blame] | 69 | memset(&adapter->curbssparams.ssid, 0, IW_ESSID_MAX_SIZE); |
| 70 | adapter->curbssparams.ssid_len = 0; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 71 | |
| 72 | if (adapter->psstate != PS_STATE_FULL_POWER) { |
| 73 | /* make firmware to exit PS mode */ |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 74 | lbs_deb_cmd("disconnected, so exit PS mode\n"); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 75 | lbs_ps_wakeup(priv, 0); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 76 | } |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 77 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | /** |
| 81 | * @brief This function handles MIC failure event. |
| 82 | * |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 83 | * @param priv A pointer to struct lbs_private structure |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 84 | * @para event the event id |
| 85 | * @return n/a |
| 86 | */ |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 87 | static void handle_mic_failureevent(struct lbs_private *priv, u32 event) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 88 | { |
| 89 | char buf[50]; |
| 90 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 91 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 92 | memset(buf, 0, sizeof(buf)); |
| 93 | |
| 94 | sprintf(buf, "%s", "MLME-MICHAELMICFAILURE.indication "); |
| 95 | |
| 96 | if (event == MACREG_INT_CODE_MIC_ERR_UNICAST) { |
| 97 | strcat(buf, "unicast "); |
| 98 | } else { |
| 99 | strcat(buf, "multicast "); |
| 100 | } |
| 101 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 102 | lbs_send_iwevcustom_event(priv, buf); |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 103 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 104 | } |
| 105 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 106 | static int lbs_ret_reg_access(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 107 | u16 type, struct cmd_ds_command *resp) |
| 108 | { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 109 | int ret = 0; |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 110 | struct lbs_adapter *adapter = priv->adapter; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 111 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 112 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 113 | |
| 114 | switch (type) { |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 115 | case CMD_RET(CMD_MAC_REG_ACCESS): |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 116 | { |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 117 | struct cmd_ds_mac_reg_access *reg = &resp->params.macreg; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 118 | |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 119 | adapter->offsetvalue.offset = (u32)le16_to_cpu(reg->offset); |
| 120 | adapter->offsetvalue.value = le32_to_cpu(reg->value); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 121 | break; |
| 122 | } |
| 123 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 124 | case CMD_RET(CMD_BBP_REG_ACCESS): |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 125 | { |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 126 | struct cmd_ds_bbp_reg_access *reg = &resp->params.bbpreg; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 127 | |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 128 | adapter->offsetvalue.offset = (u32)le16_to_cpu(reg->offset); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 129 | adapter->offsetvalue.value = reg->value; |
| 130 | break; |
| 131 | } |
| 132 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 133 | case CMD_RET(CMD_RF_REG_ACCESS): |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 134 | { |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 135 | struct cmd_ds_rf_reg_access *reg = &resp->params.rfreg; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 136 | |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 137 | adapter->offsetvalue.offset = (u32)le16_to_cpu(reg->offset); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 138 | adapter->offsetvalue.value = reg->value; |
| 139 | break; |
| 140 | } |
| 141 | |
| 142 | default: |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 143 | ret = -1; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 144 | } |
| 145 | |
Holger Schurig | 8b17d72 | 2007-10-08 11:09:30 +0200 | [diff] [blame] | 146 | lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret); |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 147 | return ret; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 148 | } |
| 149 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 150 | static int lbs_ret_get_hw_spec(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 151 | struct cmd_ds_command *resp) |
| 152 | { |
| 153 | u32 i; |
| 154 | struct cmd_ds_get_hw_spec *hwspec = &resp->params.hwspec; |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 155 | struct lbs_adapter *adapter = priv->adapter; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 156 | int ret = 0; |
Joe Perches | 0795af5 | 2007-10-03 17:59:30 -0700 | [diff] [blame] | 157 | DECLARE_MAC_BUF(mac); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 158 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 159 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 160 | |
| 161 | adapter->fwcapinfo = le32_to_cpu(hwspec->fwcapinfo); |
| 162 | |
David Woodhouse | e5b3d47 | 2007-05-25 23:40:21 -0400 | [diff] [blame] | 163 | memcpy(adapter->fwreleasenumber, hwspec->fwreleasenumber, 4); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 164 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 165 | 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] | 166 | adapter->fwreleasenumber[2], adapter->fwreleasenumber[1], |
| 167 | adapter->fwreleasenumber[0], adapter->fwreleasenumber[3]); |
Joe Perches | 0795af5 | 2007-10-03 17:59:30 -0700 | [diff] [blame] | 168 | lbs_deb_cmd("GET_HW_SPEC: MAC addr %s\n", |
| 169 | print_mac(mac, hwspec->permanentaddr)); |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 170 | 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] | 171 | hwspec->hwifversion, hwspec->version); |
| 172 | |
Marek Vašut | 70500f5 | 2007-08-20 12:55:41 -0400 | [diff] [blame] | 173 | /* Clamp region code to 8-bit since FW spec indicates that it should |
| 174 | * only ever be 8-bit, even though the field size is 16-bit. Some firmware |
| 175 | * returns non-zero high 8 bits here. |
| 176 | */ |
| 177 | adapter->regioncode = le16_to_cpu(hwspec->regioncode) & 0xFF; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 178 | |
| 179 | for (i = 0; i < MRVDRV_MAX_REGION_CODE; i++) { |
| 180 | /* use the region code to search for the index */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 181 | if (adapter->regioncode == lbs_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 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 199 | if (lbs_set_regiontable(priv, adapter->regioncode, 0)) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 200 | ret = -1; |
| 201 | goto done; |
| 202 | } |
| 203 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 204 | if (lbs_set_universaltable(priv, 0)) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 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 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 214 | static int lbs_ret_802_11_sleep_params(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 215 | struct cmd_ds_command *resp) |
| 216 | { |
| 217 | struct cmd_ds_802_11_sleep_params *sp = &resp->params.sleep_params; |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 218 | struct lbs_adapter *adapter = priv->adapter; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 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 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 238 | static int lbs_ret_802_11_stat(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 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; |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 245 | struct lbs_adapter *adapter = priv->adapter; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 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 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 255 | static int lbs_ret_802_11_snmp_mib(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 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 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 297 | static int lbs_ret_802_11_key_material(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 298 | struct cmd_ds_command *resp) |
| 299 | { |
| 300 | struct cmd_ds_802_11_key_material *pkeymaterial = |
| 301 | &resp->params.keymaterial; |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 302 | struct lbs_adapter *adapter = priv->adapter; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 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 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 353 | static int lbs_ret_802_11_mac_address(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 354 | struct cmd_ds_command *resp) |
| 355 | { |
| 356 | struct cmd_ds_802_11_mac_address *macadd = &resp->params.macadd; |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 357 | struct lbs_adapter *adapter = priv->adapter; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 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 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 367 | 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] | 368 | struct cmd_ds_command *resp) |
| 369 | { |
| 370 | struct cmd_ds_802_11_rf_tx_power *rtp = &resp->params.txp; |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 371 | struct lbs_adapter *adapter = priv->adapter; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 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 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 383 | static int lbs_ret_802_11_rate_adapt_rateset(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 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; |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 387 | struct lbs_adapter *adapter = priv->adapter; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 388 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 389 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 390 | |
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 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 400 | static int lbs_ret_802_11_data_rate(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 401 | struct cmd_ds_command *resp) |
| 402 | { |
| 403 | struct cmd_ds_802_11_data_rate *pdatarate = &resp->params.drate; |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 404 | struct lbs_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 | */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 414 | adapter->cur_rate = lbs_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 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 421 | static int lbs_ret_802_11_rf_channel(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 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; |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 425 | struct lbs_adapter *adapter = priv->adapter; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 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 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 444 | static int lbs_ret_802_11_rssi(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 445 | struct cmd_ds_command *resp) |
| 446 | { |
| 447 | struct cmd_ds_802_11_rssi_rsp *rssirsp = &resp->params.rssirsp; |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 448 | struct lbs_adapter *adapter = priv->adapter; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 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 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 475 | static int lbs_ret_802_11_eeprom_access(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 476 | struct cmd_ds_command *resp) |
| 477 | { |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 478 | struct lbs_adapter *adapter = priv->adapter; |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 479 | struct lbs_ioctl_regrdwr *pbuf; |
| 480 | pbuf = (struct lbs_ioctl_regrdwr *) adapter->prdeeprom; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 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 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 501 | static int lbs_ret_get_log(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 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; |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 505 | struct lbs_adapter *adapter = priv->adapter; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 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 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 516 | static int lbs_ret_802_11_enable_rsn(struct lbs_private *priv, |
Dan Williams | 18c96c34 | 2007-06-18 12:01:12 -0400 | [diff] [blame] | 517 | struct cmd_ds_command *resp) |
| 518 | { |
| 519 | struct cmd_ds_802_11_enable_rsn *enable_rsn = &resp->params.enbrsn; |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 520 | struct lbs_adapter *adapter = priv->adapter; |
Dan Williams | 18c96c34 | 2007-06-18 12:01:12 -0400 | [diff] [blame] | 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 | |
Brajesh Dave | 96287ac | 2007-11-20 17:44:28 -0500 | [diff] [blame] | 534 | static int lbs_ret_802_11_bcn_ctrl(struct lbs_private * priv, |
| 535 | struct cmd_ds_command *resp) |
| 536 | { |
| 537 | struct cmd_ds_802_11_beacon_control *bcn_ctrl = |
| 538 | &resp->params.bcn_ctrl; |
| 539 | struct lbs_adapter *adapter = priv->adapter; |
| 540 | |
| 541 | lbs_deb_enter(LBS_DEB_CMD); |
| 542 | |
| 543 | if (bcn_ctrl->action == CMD_ACT_GET) { |
| 544 | adapter->beacon_enable = (u8) le16_to_cpu(bcn_ctrl->beacon_enable); |
| 545 | adapter->beacon_period = le16_to_cpu(bcn_ctrl->beacon_period); |
| 546 | } |
| 547 | |
| 548 | lbs_deb_enter(LBS_DEB_CMD); |
| 549 | return 0; |
| 550 | } |
| 551 | |
Holger Schurig | 3a18864 | 2007-11-26 10:07:14 +0100 | [diff] [blame] | 552 | static int lbs_ret_802_11_subscribe_event(struct lbs_private *priv, |
| 553 | struct cmd_ds_command *resp) |
| 554 | { |
| 555 | struct lbs_adapter *adapter = priv->adapter; |
| 556 | struct cmd_ds_802_11_subscribe_event *cmd_event = |
| 557 | &resp->params.subscribe_event; |
| 558 | struct cmd_ds_802_11_subscribe_event *dst_event = |
| 559 | adapter->cur_cmd->pdata_buf; |
| 560 | |
| 561 | lbs_deb_enter(LBS_DEB_CMD); |
| 562 | |
| 563 | if (dst_event->action == cpu_to_le16(CMD_ACT_GET)) { |
Holger Schurig | c2df2ef | 2007-12-07 15:30:44 +0000 | [diff] [blame] | 564 | dst_event->events = cmd_event->events; |
Holger Schurig | 3a18864 | 2007-11-26 10:07:14 +0100 | [diff] [blame] | 565 | memcpy(dst_event->tlv, cmd_event->tlv, sizeof(dst_event->tlv)); |
| 566 | } |
| 567 | |
| 568 | lbs_deb_leave(LBS_DEB_CMD); |
| 569 | return 0; |
| 570 | } |
| 571 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 572 | static inline int handle_cmd_response(u16 respcmd, |
| 573 | struct cmd_ds_command *resp, |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 574 | struct lbs_private *priv) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 575 | { |
| 576 | int ret = 0; |
| 577 | unsigned long flags; |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 578 | struct lbs_adapter *adapter = priv->adapter; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 579 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 580 | lbs_deb_enter(LBS_DEB_HOST); |
| 581 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 582 | switch (respcmd) { |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 583 | case CMD_RET(CMD_MAC_REG_ACCESS): |
| 584 | case CMD_RET(CMD_BBP_REG_ACCESS): |
| 585 | case CMD_RET(CMD_RF_REG_ACCESS): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 586 | ret = lbs_ret_reg_access(priv, respcmd, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 587 | break; |
| 588 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 589 | case CMD_RET(CMD_GET_HW_SPEC): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 590 | ret = lbs_ret_get_hw_spec(priv, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 591 | break; |
| 592 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 593 | case CMD_RET(CMD_802_11_SCAN): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 594 | ret = lbs_ret_80211_scan(priv, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 595 | break; |
| 596 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 597 | case CMD_RET(CMD_802_11_GET_LOG): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 598 | ret = lbs_ret_get_log(priv, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 599 | break; |
| 600 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 601 | case CMD_RET_802_11_ASSOCIATE: |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 602 | case CMD_RET(CMD_802_11_ASSOCIATE): |
| 603 | case CMD_RET(CMD_802_11_REASSOCIATE): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 604 | ret = lbs_ret_80211_associate(priv, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 605 | break; |
| 606 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 607 | case CMD_RET(CMD_802_11_DISASSOCIATE): |
| 608 | case CMD_RET(CMD_802_11_DEAUTHENTICATE): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 609 | ret = lbs_ret_80211_disassociate(priv, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 610 | break; |
| 611 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 612 | case CMD_RET(CMD_802_11_AD_HOC_START): |
| 613 | case CMD_RET(CMD_802_11_AD_HOC_JOIN): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 614 | ret = lbs_ret_80211_ad_hoc_start(priv, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 615 | break; |
| 616 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 617 | case CMD_RET(CMD_802_11_GET_STAT): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 618 | ret = lbs_ret_802_11_stat(priv, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 619 | break; |
| 620 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 621 | case CMD_RET(CMD_802_11_SNMP_MIB): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 622 | ret = lbs_ret_802_11_snmp_mib(priv, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 623 | break; |
| 624 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 625 | case CMD_RET(CMD_802_11_RF_TX_POWER): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 626 | ret = lbs_ret_802_11_rf_tx_power(priv, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 627 | break; |
| 628 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 629 | case CMD_RET(CMD_802_11_SET_AFC): |
| 630 | case CMD_RET(CMD_802_11_GET_AFC): |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 631 | spin_lock_irqsave(&adapter->driver_lock, flags); |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 632 | memmove(adapter->cur_cmd->pdata_buf, &resp->params.afc, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 633 | sizeof(struct cmd_ds_802_11_afc)); |
| 634 | spin_unlock_irqrestore(&adapter->driver_lock, flags); |
| 635 | |
| 636 | break; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 637 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 638 | case CMD_RET(CMD_MAC_MULTICAST_ADR): |
| 639 | case CMD_RET(CMD_MAC_CONTROL): |
| 640 | case CMD_RET(CMD_802_11_SET_WEP): |
| 641 | case CMD_RET(CMD_802_11_RESET): |
| 642 | case CMD_RET(CMD_802_11_AUTHENTICATE): |
| 643 | case CMD_RET(CMD_802_11_RADIO_CONTROL): |
| 644 | case CMD_RET(CMD_802_11_BEACON_STOP): |
Dan Williams | 18c96c34 | 2007-06-18 12:01:12 -0400 | [diff] [blame] | 645 | break; |
| 646 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 647 | case CMD_RET(CMD_802_11_ENABLE_RSN): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 648 | ret = lbs_ret_802_11_enable_rsn(priv, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 649 | break; |
| 650 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 651 | case CMD_RET(CMD_802_11_DATA_RATE): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 652 | ret = lbs_ret_802_11_data_rate(priv, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 653 | break; |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 654 | case CMD_RET(CMD_802_11_RATE_ADAPT_RATESET): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 655 | ret = lbs_ret_802_11_rate_adapt_rateset(priv, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 656 | break; |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 657 | case CMD_RET(CMD_802_11_RF_CHANNEL): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 658 | ret = lbs_ret_802_11_rf_channel(priv, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 659 | break; |
| 660 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 661 | case CMD_RET(CMD_802_11_RSSI): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 662 | ret = lbs_ret_802_11_rssi(priv, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 663 | break; |
| 664 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 665 | case CMD_RET(CMD_802_11_MAC_ADDRESS): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 666 | ret = lbs_ret_802_11_mac_address(priv, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 667 | break; |
| 668 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 669 | case CMD_RET(CMD_802_11_AD_HOC_STOP): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 670 | ret = lbs_ret_80211_ad_hoc_stop(priv, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 671 | break; |
| 672 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 673 | case CMD_RET(CMD_802_11_KEY_MATERIAL): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 674 | ret = lbs_ret_802_11_key_material(priv, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 675 | break; |
| 676 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 677 | case CMD_RET(CMD_802_11_EEPROM_ACCESS): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 678 | ret = lbs_ret_802_11_eeprom_access(priv, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 679 | break; |
| 680 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 681 | case CMD_RET(CMD_802_11D_DOMAIN_INFO): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 682 | ret = lbs_ret_802_11d_domain_info(priv, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 683 | break; |
| 684 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 685 | case CMD_RET(CMD_802_11_SLEEP_PARAMS): |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 686 | ret = lbs_ret_802_11_sleep_params(priv, resp); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 687 | break; |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 688 | case CMD_RET(CMD_802_11_INACTIVITY_TIMEOUT): |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 689 | spin_lock_irqsave(&adapter->driver_lock, flags); |
| 690 | *((u16 *) adapter->cur_cmd->pdata_buf) = |
| 691 | le16_to_cpu(resp->params.inactivity_timeout.timeout); |
| 692 | spin_unlock_irqrestore(&adapter->driver_lock, flags); |
| 693 | break; |
| 694 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 695 | case CMD_RET(CMD_802_11_TPC_CFG): |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 696 | spin_lock_irqsave(&adapter->driver_lock, flags); |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 697 | memmove(adapter->cur_cmd->pdata_buf, &resp->params.tpccfg, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 698 | sizeof(struct cmd_ds_802_11_tpc_cfg)); |
| 699 | spin_unlock_irqrestore(&adapter->driver_lock, flags); |
| 700 | break; |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 701 | case CMD_RET(CMD_802_11_LED_GPIO_CTRL): |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 702 | spin_lock_irqsave(&adapter->driver_lock, flags); |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 703 | memmove(adapter->cur_cmd->pdata_buf, &resp->params.ledgpio, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 704 | sizeof(struct cmd_ds_802_11_led_ctrl)); |
| 705 | spin_unlock_irqrestore(&adapter->driver_lock, flags); |
| 706 | break; |
Holger Schurig | 3a18864 | 2007-11-26 10:07:14 +0100 | [diff] [blame] | 707 | case CMD_RET(CMD_802_11_SUBSCRIBE_EVENT): |
| 708 | ret = lbs_ret_802_11_subscribe_event(priv, resp); |
| 709 | break; |
| 710 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 711 | case CMD_RET(CMD_802_11_PWR_CFG): |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 712 | spin_lock_irqsave(&adapter->driver_lock, flags); |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 713 | memmove(adapter->cur_cmd->pdata_buf, &resp->params.pwrcfg, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 714 | sizeof(struct cmd_ds_802_11_pwr_cfg)); |
| 715 | spin_unlock_irqrestore(&adapter->driver_lock, flags); |
| 716 | |
| 717 | break; |
| 718 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 719 | case CMD_RET(CMD_GET_TSF): |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 720 | spin_lock_irqsave(&adapter->driver_lock, flags); |
| 721 | memcpy(priv->adapter->cur_cmd->pdata_buf, |
| 722 | &resp->params.gettsf.tsfvalue, sizeof(u64)); |
| 723 | spin_unlock_irqrestore(&adapter->driver_lock, flags); |
| 724 | break; |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 725 | case CMD_RET(CMD_BT_ACCESS): |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 726 | spin_lock_irqsave(&adapter->driver_lock, flags); |
| 727 | if (adapter->cur_cmd->pdata_buf) |
| 728 | memcpy(adapter->cur_cmd->pdata_buf, |
| 729 | &resp->params.bt.addr1, 2 * ETH_ALEN); |
| 730 | spin_unlock_irqrestore(&adapter->driver_lock, flags); |
| 731 | break; |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 732 | case CMD_RET(CMD_FWT_ACCESS): |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 733 | spin_lock_irqsave(&adapter->driver_lock, flags); |
| 734 | if (adapter->cur_cmd->pdata_buf) |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 735 | memcpy(adapter->cur_cmd->pdata_buf, &resp->params.fwt, |
| 736 | sizeof(resp->params.fwt)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 737 | spin_unlock_irqrestore(&adapter->driver_lock, flags); |
| 738 | break; |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 739 | case CMD_RET(CMD_MESH_ACCESS): |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 740 | if (adapter->cur_cmd->pdata_buf) |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 741 | memcpy(adapter->cur_cmd->pdata_buf, &resp->params.mesh, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 742 | sizeof(resp->params.mesh)); |
| 743 | break; |
Brajesh Dave | 96287ac | 2007-11-20 17:44:28 -0500 | [diff] [blame] | 744 | case CMD_RET(CMD_802_11_BEACON_CTRL): |
| 745 | ret = lbs_ret_802_11_bcn_ctrl(priv, resp); |
| 746 | break; |
| 747 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 748 | default: |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 749 | lbs_deb_host("CMD_RESP: unknown cmd response 0x%04x\n", |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 750 | resp->command); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 751 | break; |
| 752 | } |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 753 | lbs_deb_leave(LBS_DEB_HOST); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 754 | return ret; |
| 755 | } |
| 756 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 757 | int lbs_process_rx_command(struct lbs_private *priv) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 758 | { |
| 759 | u16 respcmd; |
| 760 | struct cmd_ds_command *resp; |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 761 | struct lbs_adapter *adapter = priv->adapter; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 762 | int ret = 0; |
| 763 | ulong flags; |
| 764 | u16 result; |
| 765 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 766 | lbs_deb_enter(LBS_DEB_HOST); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 767 | |
| 768 | /* Now we got response from FW, cancel the command timer */ |
| 769 | del_timer(&adapter->command_timer); |
| 770 | |
| 771 | mutex_lock(&adapter->lock); |
| 772 | spin_lock_irqsave(&adapter->driver_lock, flags); |
| 773 | |
| 774 | if (!adapter->cur_cmd) { |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 775 | lbs_deb_host("CMD_RESP: cur_cmd is NULL\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 776 | ret = -1; |
| 777 | spin_unlock_irqrestore(&adapter->driver_lock, flags); |
| 778 | goto done; |
| 779 | } |
| 780 | resp = (struct cmd_ds_command *)(adapter->cur_cmd->bufvirtualaddr); |
| 781 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 782 | respcmd = le16_to_cpu(resp->command); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 783 | result = le16_to_cpu(resp->result); |
| 784 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 785 | lbs_deb_host("CMD_RESP: response 0x%04x, size %d, jiffies %lu\n", |
| 786 | respcmd, priv->upld_len, jiffies); |
| 787 | lbs_deb_hex(LBS_DEB_HOST, "CMD_RESP", adapter->cur_cmd->bufvirtualaddr, |
| 788 | priv->upld_len); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 789 | |
| 790 | if (!(respcmd & 0x8000)) { |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 791 | lbs_deb_host("invalid response!\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 792 | adapter->cur_cmd_retcode = -1; |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 793 | __lbs_cleanup_and_insert_cmd(priv, adapter->cur_cmd); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 794 | adapter->cur_cmd = NULL; |
| 795 | spin_unlock_irqrestore(&adapter->driver_lock, flags); |
| 796 | ret = -1; |
| 797 | goto done; |
| 798 | } |
| 799 | |
| 800 | /* Store the response code to cur_cmd_retcode. */ |
Holger Schurig | 675787e | 2007-12-05 17:58:11 +0100 | [diff] [blame] | 801 | adapter->cur_cmd_retcode = result; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 802 | |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 803 | if (respcmd == CMD_RET(CMD_802_11_PS_MODE)) { |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 804 | struct cmd_ds_802_11_ps_mode *psmode = &resp->params.psmode; |
| 805 | u16 action = le16_to_cpu(psmode->action); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 806 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 807 | lbs_deb_host( |
| 808 | "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] | 809 | result, action); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 810 | |
| 811 | if (result) { |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 812 | lbs_deb_host("CMD_RESP: PS command failed with 0x%x\n", |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 813 | result); |
| 814 | /* |
| 815 | * We should not re-try enter-ps command in |
| 816 | * ad-hoc mode. It takes place in |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 817 | * lbs_execute_next_command(). |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 818 | */ |
| 819 | if (adapter->mode == IW_MODE_ADHOC && |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 820 | action == CMD_SUBCMD_ENTER_PS) |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 821 | adapter->psmode = LBS802_11POWERMODECAM; |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 822 | } else if (action == CMD_SUBCMD_ENTER_PS) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 823 | adapter->needtowakeup = 0; |
| 824 | adapter->psstate = PS_STATE_AWAKE; |
| 825 | |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 826 | lbs_deb_host("CMD_RESP: ENTER_PS command response\n"); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 827 | if (adapter->connect_status != LBS_CONNECTED) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 828 | /* |
| 829 | * When Deauth Event received before Enter_PS command |
| 830 | * response, We need to wake up the firmware. |
| 831 | */ |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 832 | lbs_deb_host( |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 833 | "disconnected, invoking lbs_ps_wakeup\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 834 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 835 | spin_unlock_irqrestore(&adapter->driver_lock, flags); |
Dan Williams | 6cfb008 | 2007-05-25 17:33:28 -0400 | [diff] [blame] | 836 | mutex_unlock(&adapter->lock); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 837 | lbs_ps_wakeup(priv, 0); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 838 | mutex_lock(&adapter->lock); |
| 839 | spin_lock_irqsave(&adapter->driver_lock, flags); |
| 840 | } |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 841 | } else if (action == CMD_SUBCMD_EXIT_PS) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 842 | adapter->needtowakeup = 0; |
| 843 | adapter->psstate = PS_STATE_FULL_POWER; |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 844 | lbs_deb_host("CMD_RESP: EXIT_PS command response\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 845 | } else { |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 846 | lbs_deb_host("CMD_RESP: PS action 0x%X\n", action); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 847 | } |
| 848 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 849 | __lbs_cleanup_and_insert_cmd(priv, adapter->cur_cmd); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 850 | adapter->cur_cmd = NULL; |
| 851 | spin_unlock_irqrestore(&adapter->driver_lock, flags); |
| 852 | |
| 853 | ret = 0; |
| 854 | goto done; |
| 855 | } |
| 856 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 857 | /* If the command is not successful, cleanup and return failure */ |
| 858 | if ((result != 0 || !(respcmd & 0x8000))) { |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 859 | lbs_deb_host("CMD_RESP: error 0x%04x in command reply 0x%04x\n", |
| 860 | result, respcmd); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 861 | /* |
| 862 | * Handling errors here |
| 863 | */ |
| 864 | switch (respcmd) { |
Holger Schurig | 6b63cd0 | 2007-08-02 11:53:36 -0400 | [diff] [blame] | 865 | case CMD_RET(CMD_GET_HW_SPEC): |
| 866 | case CMD_RET(CMD_802_11_RESET): |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 867 | lbs_deb_host("CMD_RESP: reset failed\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 868 | break; |
| 869 | |
| 870 | } |
| 871 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 872 | __lbs_cleanup_and_insert_cmd(priv, adapter->cur_cmd); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 873 | adapter->cur_cmd = NULL; |
| 874 | spin_unlock_irqrestore(&adapter->driver_lock, flags); |
| 875 | |
| 876 | ret = -1; |
| 877 | goto done; |
| 878 | } |
| 879 | |
David Woodhouse | 1723047 | 2007-12-07 15:13:05 +0000 | [diff] [blame] | 880 | spin_unlock_irqrestore(&adapter->driver_lock, flags); |
| 881 | |
| 882 | if (adapter->cur_cmd && adapter->cur_cmd->callback) |
| 883 | ret = adapter->cur_cmd->callback(respcmd, resp, priv); |
| 884 | else |
Holger Schurig | 675787e | 2007-12-05 17:58:11 +0100 | [diff] [blame] | 885 | ret = handle_cmd_response(respcmd, resp, priv); |
David Woodhouse | 1723047 | 2007-12-07 15:13:05 +0000 | [diff] [blame] | 886 | |
| 887 | spin_lock_irqsave(&adapter->driver_lock, flags); |
| 888 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 889 | if (adapter->cur_cmd) { |
| 890 | /* Clean up and Put current command back to cmdfreeq */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 891 | __lbs_cleanup_and_insert_cmd(priv, adapter->cur_cmd); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 892 | adapter->cur_cmd = NULL; |
| 893 | } |
| 894 | spin_unlock_irqrestore(&adapter->driver_lock, flags); |
| 895 | |
| 896 | done: |
| 897 | mutex_unlock(&adapter->lock); |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 898 | lbs_deb_leave_args(LBS_DEB_HOST, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 899 | return ret; |
| 900 | } |
| 901 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 902 | int lbs_process_event(struct lbs_private *priv) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 903 | { |
| 904 | int ret = 0; |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 905 | struct lbs_adapter *adapter = priv->adapter; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 906 | u32 eventcause; |
| 907 | |
Holger Schurig | 9556d21 | 2007-08-02 13:14:07 -0400 | [diff] [blame] | 908 | lbs_deb_enter(LBS_DEB_CMD); |
| 909 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 910 | spin_lock_irq(&adapter->driver_lock); |
Holger Schurig | 0b3c07f | 2007-11-28 09:15:11 +0100 | [diff] [blame] | 911 | eventcause = adapter->eventcause >> SBI_EVENT_CAUSE_SHIFT; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 912 | spin_unlock_irq(&adapter->driver_lock); |
| 913 | |
Holger Schurig | 0b3c07f | 2007-11-28 09:15:11 +0100 | [diff] [blame] | 914 | lbs_deb_cmd("event cause %d\n", eventcause); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 915 | |
Holger Schurig | 0b3c07f | 2007-11-28 09:15:11 +0100 | [diff] [blame] | 916 | switch (eventcause) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 917 | case MACREG_INT_CODE_LINK_SENSED: |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 918 | lbs_deb_cmd("EVENT: MACREG_INT_CODE_LINK_SENSED\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 919 | break; |
| 920 | |
| 921 | case MACREG_INT_CODE_DEAUTHENTICATED: |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 922 | lbs_deb_cmd("EVENT: deauthenticated\n"); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 923 | lbs_mac_event_disconnected(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 924 | break; |
| 925 | |
| 926 | case MACREG_INT_CODE_DISASSOCIATED: |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 927 | lbs_deb_cmd("EVENT: disassociated\n"); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 928 | lbs_mac_event_disconnected(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 929 | break; |
| 930 | |
Holger Schurig | 0b3c07f | 2007-11-28 09:15:11 +0100 | [diff] [blame] | 931 | case MACREG_INT_CODE_LINK_LOST_NO_SCAN: |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 932 | lbs_deb_cmd("EVENT: link lost\n"); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 933 | lbs_mac_event_disconnected(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 934 | break; |
| 935 | |
| 936 | case MACREG_INT_CODE_PS_SLEEP: |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 937 | lbs_deb_cmd("EVENT: sleep\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 938 | |
| 939 | /* handle unexpected PS SLEEP event */ |
| 940 | if (adapter->psstate == PS_STATE_FULL_POWER) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 941 | lbs_deb_cmd( |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 942 | "EVENT: in FULL POWER mode, ignoreing PS_SLEEP\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 943 | break; |
| 944 | } |
| 945 | adapter->psstate = PS_STATE_PRE_SLEEP; |
| 946 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 947 | lbs_ps_confirm_sleep(priv, (u16) adapter->psmode); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 948 | |
| 949 | break; |
| 950 | |
| 951 | case MACREG_INT_CODE_PS_AWAKE: |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 952 | lbs_deb_cmd("EVENT: awake\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 953 | |
| 954 | /* handle unexpected PS AWAKE event */ |
| 955 | if (adapter->psstate == PS_STATE_FULL_POWER) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 956 | lbs_deb_cmd( |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 957 | "EVENT: In FULL POWER mode - ignore PS AWAKE\n"); |
| 958 | break; |
| 959 | } |
| 960 | |
| 961 | adapter->psstate = PS_STATE_AWAKE; |
| 962 | |
| 963 | if (adapter->needtowakeup) { |
| 964 | /* |
| 965 | * wait for the command processing to finish |
| 966 | * before resuming sending |
| 967 | * adapter->needtowakeup will be set to FALSE |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 968 | * in lbs_ps_wakeup() |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 969 | */ |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 970 | lbs_deb_cmd("waking up ...\n"); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 971 | lbs_ps_wakeup(priv, 0); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 972 | } |
| 973 | break; |
| 974 | |
| 975 | case MACREG_INT_CODE_MIC_ERR_UNICAST: |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 976 | lbs_deb_cmd("EVENT: UNICAST MIC ERROR\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 977 | handle_mic_failureevent(priv, MACREG_INT_CODE_MIC_ERR_UNICAST); |
| 978 | break; |
| 979 | |
| 980 | case MACREG_INT_CODE_MIC_ERR_MULTICAST: |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 981 | lbs_deb_cmd("EVENT: MULTICAST MIC ERROR\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 982 | handle_mic_failureevent(priv, MACREG_INT_CODE_MIC_ERR_MULTICAST); |
| 983 | break; |
| 984 | case MACREG_INT_CODE_MIB_CHANGED: |
| 985 | case MACREG_INT_CODE_INIT_DONE: |
| 986 | break; |
| 987 | |
| 988 | case MACREG_INT_CODE_ADHOC_BCN_LOST: |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 989 | lbs_deb_cmd("EVENT: ADHOC beacon lost\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 990 | break; |
| 991 | |
| 992 | case MACREG_INT_CODE_RSSI_LOW: |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 993 | lbs_pr_alert("EVENT: rssi low\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 994 | break; |
| 995 | case MACREG_INT_CODE_SNR_LOW: |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 996 | lbs_pr_alert("EVENT: snr low\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 997 | break; |
| 998 | case MACREG_INT_CODE_MAX_FAIL: |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 999 | lbs_pr_alert("EVENT: max fail\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1000 | break; |
| 1001 | case MACREG_INT_CODE_RSSI_HIGH: |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 1002 | lbs_pr_alert("EVENT: rssi high\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1003 | break; |
| 1004 | case MACREG_INT_CODE_SNR_HIGH: |
Holger Schurig | a6c8700 | 2007-08-02 11:54:10 -0400 | [diff] [blame] | 1005 | lbs_pr_alert("EVENT: snr high\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1006 | break; |
| 1007 | |
Luis Carlos Cobo Rus | 7d8d28b | 2007-05-25 23:12:19 -0400 | [diff] [blame] | 1008 | case MACREG_INT_CODE_MESH_AUTO_STARTED: |
Dan Williams | 5612c01 | 2007-08-02 13:20:12 -0400 | [diff] [blame] | 1009 | /* Ignore spurious autostart events if autostart is disabled */ |
| 1010 | if (!priv->mesh_autostart_enabled) { |
| 1011 | lbs_pr_info("EVENT: MESH_AUTO_STARTED (ignoring)\n"); |
| 1012 | break; |
| 1013 | } |
Luis Carlos Cobo | 9cdc6d2 | 2007-08-02 11:55:22 -0400 | [diff] [blame] | 1014 | lbs_pr_info("EVENT: MESH_AUTO_STARTED\n"); |
Brajesh Dave | 01d77d8 | 2007-11-20 17:44:14 -0500 | [diff] [blame] | 1015 | adapter->mesh_connect_status = LBS_CONNECTED; |
Luis Carlos Cobo Rus | 7d8d28b | 2007-05-25 23:12:19 -0400 | [diff] [blame] | 1016 | if (priv->mesh_open == 1) { |
Luis Carlos Cobo | 9cdc6d2 | 2007-08-02 11:55:22 -0400 | [diff] [blame] | 1017 | netif_wake_queue(priv->mesh_dev); |
| 1018 | netif_carrier_on(priv->mesh_dev); |
Luis Carlos Cobo Rus | 7d8d28b | 2007-05-25 23:12:19 -0400 | [diff] [blame] | 1019 | } |
Luis Carlos Cobo | 9cdc6d2 | 2007-08-02 11:55:22 -0400 | [diff] [blame] | 1020 | adapter->mode = IW_MODE_ADHOC; |
Luis Carlos Cobo Rus | b8bedef | 2007-05-30 12:14:34 -0400 | [diff] [blame] | 1021 | schedule_work(&priv->sync_channel); |
Luis Carlos Cobo Rus | 7d8d28b | 2007-05-25 23:12:19 -0400 | [diff] [blame] | 1022 | break; |
| 1023 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1024 | default: |
Holger Schurig | 0b3c07f | 2007-11-28 09:15:11 +0100 | [diff] [blame] | 1025 | lbs_pr_alert("EVENT: unknown event id %d\n", eventcause); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1026 | break; |
| 1027 | } |
| 1028 | |
| 1029 | spin_lock_irq(&adapter->driver_lock); |
| 1030 | adapter->eventcause = 0; |
| 1031 | spin_unlock_irq(&adapter->driver_lock); |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1032 | |
Holger Schurig | 9556d21 | 2007-08-02 13:14:07 -0400 | [diff] [blame] | 1033 | lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1034 | return ret; |
| 1035 | } |