Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1 | /** |
| 2 | * This file contains the handling of command. |
| 3 | * It prepares command and sends it to firmware when it is ready. |
| 4 | */ |
| 5 | |
| 6 | #include <net/iw_handler.h> |
John W. Linville | 7e272fc | 2008-09-24 18:13:14 -0400 | [diff] [blame] | 7 | #include <net/lib80211.h> |
Holger Schurig | 7919b89 | 2008-04-01 14:50:43 +0200 | [diff] [blame] | 8 | #include <linux/kfifo.h> |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 9 | #include "host.h" |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 10 | #include "decl.h" |
| 11 | #include "defs.h" |
| 12 | #include "dev.h" |
Holger Schurig | 697900a | 2008-04-02 16:27:10 +0200 | [diff] [blame] | 13 | #include "assoc.h" |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 14 | #include "wext.h" |
Holger Schurig | 2d46502 | 2009-10-22 15:30:48 +0200 | [diff] [blame^] | 15 | #include "scan.h" |
Dan Williams | 6e66f03 | 2007-12-11 12:42:16 -0500 | [diff] [blame] | 16 | #include "cmd.h" |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 17 | |
David Woodhouse | 2fd6cfe | 2007-12-11 17:44:10 -0500 | [diff] [blame] | 18 | static struct cmd_ctrl_node *lbs_get_cmd_ctrl_node(struct lbs_private *priv); |
Holger Schurig | 0d61d04 | 2007-12-05 17:58:06 +0100 | [diff] [blame] | 19 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 20 | /** |
Holger Schurig | 8db4a2b | 2008-03-19 10:11:00 +0100 | [diff] [blame] | 21 | * @brief Simple callback that copies response back into command |
| 22 | * |
| 23 | * @param priv A pointer to struct lbs_private structure |
| 24 | * @param extra A pointer to the original command structure for which |
| 25 | * 'resp' is a response |
| 26 | * @param resp A pointer to the command response |
| 27 | * |
| 28 | * @return 0 on success, error on failure |
| 29 | */ |
| 30 | int lbs_cmd_copyback(struct lbs_private *priv, unsigned long extra, |
| 31 | struct cmd_header *resp) |
| 32 | { |
| 33 | struct cmd_header *buf = (void *)extra; |
| 34 | uint16_t copy_len; |
| 35 | |
| 36 | copy_len = min(le16_to_cpu(buf->size), le16_to_cpu(resp->size)); |
| 37 | memcpy(buf, resp, copy_len); |
| 38 | return 0; |
| 39 | } |
| 40 | EXPORT_SYMBOL_GPL(lbs_cmd_copyback); |
| 41 | |
| 42 | /** |
| 43 | * @brief Simple callback that ignores the result. Use this if |
| 44 | * you just want to send a command to the hardware, but don't |
| 45 | * care for the result. |
| 46 | * |
| 47 | * @param priv ignored |
| 48 | * @param extra ignored |
| 49 | * @param resp ignored |
| 50 | * |
| 51 | * @return 0 for success |
| 52 | */ |
| 53 | static int lbs_cmd_async_callback(struct lbs_private *priv, unsigned long extra, |
| 54 | struct cmd_header *resp) |
| 55 | { |
| 56 | return 0; |
| 57 | } |
| 58 | |
| 59 | |
| 60 | /** |
Dan Williams | 852e1f2 | 2007-12-10 15:24:47 -0500 | [diff] [blame] | 61 | * @brief Checks whether a command is allowed in Power Save mode |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 62 | * |
| 63 | * @param command the command ID |
Dan Williams | 852e1f2 | 2007-12-10 15:24:47 -0500 | [diff] [blame] | 64 | * @return 1 if allowed, 0 if not allowed |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 65 | */ |
Dan Williams | 852e1f2 | 2007-12-10 15:24:47 -0500 | [diff] [blame] | 66 | static u8 is_command_allowed_in_ps(u16 cmd) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 67 | { |
Dan Williams | 852e1f2 | 2007-12-10 15:24:47 -0500 | [diff] [blame] | 68 | switch (cmd) { |
| 69 | case CMD_802_11_RSSI: |
| 70 | return 1; |
| 71 | default: |
| 72 | break; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 73 | } |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 74 | return 0; |
| 75 | } |
| 76 | |
Dan Williams | 6e66f03 | 2007-12-11 12:42:16 -0500 | [diff] [blame] | 77 | /** |
Amitkumar Karwar | 63f275d | 2009-10-06 19:20:28 -0700 | [diff] [blame] | 78 | * @brief This function checks if the command is allowed. |
| 79 | * |
| 80 | * @param priv A pointer to lbs_private structure |
| 81 | * @return allowed or not allowed. |
| 82 | */ |
| 83 | |
| 84 | static int lbs_is_cmd_allowed(struct lbs_private *priv) |
| 85 | { |
| 86 | int ret = 1; |
| 87 | |
| 88 | lbs_deb_enter(LBS_DEB_CMD); |
| 89 | |
| 90 | if (!priv->is_auto_deep_sleep_enabled) { |
| 91 | if (priv->is_deep_sleep) { |
| 92 | lbs_deb_cmd("command not allowed in deep sleep\n"); |
| 93 | ret = 0; |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | lbs_deb_leave(LBS_DEB_CMD); |
| 98 | return ret; |
| 99 | } |
| 100 | |
| 101 | /** |
Dan Williams | 6e66f03 | 2007-12-11 12:42:16 -0500 | [diff] [blame] | 102 | * @brief Updates the hardware details like MAC address and regulatory region |
| 103 | * |
| 104 | * @param priv A pointer to struct lbs_private structure |
| 105 | * |
| 106 | * @return 0 on success, error on failure |
| 107 | */ |
| 108 | int lbs_update_hw_spec(struct lbs_private *priv) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 109 | { |
Dan Williams | 6e66f03 | 2007-12-11 12:42:16 -0500 | [diff] [blame] | 110 | struct cmd_ds_get_hw_spec cmd; |
| 111 | int ret = -1; |
| 112 | u32 i; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 113 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 114 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 115 | |
Dan Williams | 6e66f03 | 2007-12-11 12:42:16 -0500 | [diff] [blame] | 116 | memset(&cmd, 0, sizeof(cmd)); |
| 117 | cmd.hdr.size = cpu_to_le16(sizeof(cmd)); |
| 118 | memcpy(cmd.permanentaddr, priv->current_addr, ETH_ALEN); |
David Woodhouse | 689442d | 2007-12-12 16:00:42 -0500 | [diff] [blame] | 119 | ret = lbs_cmd_with_response(priv, CMD_GET_HW_SPEC, &cmd); |
Dan Williams | 6e66f03 | 2007-12-11 12:42:16 -0500 | [diff] [blame] | 120 | if (ret) |
| 121 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 122 | |
Dan Williams | 6e66f03 | 2007-12-11 12:42:16 -0500 | [diff] [blame] | 123 | priv->fwcapinfo = le32_to_cpu(cmd.fwcapinfo); |
Dan Williams | 6e66f03 | 2007-12-11 12:42:16 -0500 | [diff] [blame] | 124 | |
Holger Schurig | dac10a9 | 2008-01-16 15:55:22 +0100 | [diff] [blame] | 125 | /* The firmware release is in an interesting format: the patch |
| 126 | * level is in the most significant nibble ... so fix that: */ |
| 127 | priv->fwrelease = le32_to_cpu(cmd.fwrelease); |
| 128 | priv->fwrelease = (priv->fwrelease << 8) | |
| 129 | (priv->fwrelease >> 24 & 0xff); |
| 130 | |
| 131 | /* Some firmware capabilities: |
| 132 | * CF card firmware 5.0.16p0: cap 0x00000303 |
| 133 | * USB dongle firmware 5.110.17p2: cap 0x00000303 |
| 134 | */ |
Johannes Berg | e174961 | 2008-10-27 15:59:26 -0700 | [diff] [blame] | 135 | lbs_pr_info("%pM, fw %u.%u.%up%u, cap 0x%08x\n", |
| 136 | cmd.permanentaddr, |
Holger Schurig | dac10a9 | 2008-01-16 15:55:22 +0100 | [diff] [blame] | 137 | priv->fwrelease >> 24 & 0xff, |
| 138 | priv->fwrelease >> 16 & 0xff, |
| 139 | priv->fwrelease >> 8 & 0xff, |
| 140 | priv->fwrelease & 0xff, |
| 141 | priv->fwcapinfo); |
Dan Williams | 6e66f03 | 2007-12-11 12:42:16 -0500 | [diff] [blame] | 142 | lbs_deb_cmd("GET_HW_SPEC: hardware interface 0x%x, hardware spec 0x%04x\n", |
| 143 | cmd.hwifversion, cmd.version); |
| 144 | |
Bing Zhao | 684d6b3 | 2009-03-25 09:51:16 -0700 | [diff] [blame] | 145 | /* Determine mesh_fw_ver from fwrelease and fwcapinfo */ |
| 146 | /* 5.0.16p0 9.0.0.p0 is known to NOT support any mesh */ |
| 147 | /* 5.110.22 have mesh command with 0xa3 command id */ |
| 148 | /* 10.0.0.p0 FW brings in mesh config command with different id */ |
| 149 | /* Check FW version MSB and initialize mesh_fw_ver */ |
| 150 | if (MRVL_FW_MAJOR_REV(priv->fwrelease) == MRVL_FW_V5) |
| 151 | priv->mesh_fw_ver = MESH_FW_OLD; |
| 152 | else if ((MRVL_FW_MAJOR_REV(priv->fwrelease) >= MRVL_FW_V10) && |
| 153 | (priv->fwcapinfo & MESH_CAPINFO_ENABLE_MASK)) |
| 154 | priv->mesh_fw_ver = MESH_FW_NEW; |
| 155 | else |
| 156 | priv->mesh_fw_ver = MESH_NONE; |
| 157 | |
Dan Williams | 6e66f03 | 2007-12-11 12:42:16 -0500 | [diff] [blame] | 158 | /* Clamp region code to 8-bit since FW spec indicates that it should |
| 159 | * only ever be 8-bit, even though the field size is 16-bit. Some firmware |
| 160 | * returns non-zero high 8 bits here. |
Marek Vasut | 1548399 | 2009-07-16 19:19:53 +0200 | [diff] [blame] | 161 | * |
| 162 | * Firmware version 4.0.102 used in CF8381 has region code shifted. We |
| 163 | * need to check for this problem and handle it properly. |
Dan Williams | 6e66f03 | 2007-12-11 12:42:16 -0500 | [diff] [blame] | 164 | */ |
Marek Vasut | 1548399 | 2009-07-16 19:19:53 +0200 | [diff] [blame] | 165 | if (MRVL_FW_MAJOR_REV(priv->fwrelease) == MRVL_FW_V4) |
| 166 | priv->regioncode = (le16_to_cpu(cmd.regioncode) >> 8) & 0xFF; |
| 167 | else |
| 168 | priv->regioncode = le16_to_cpu(cmd.regioncode) & 0xFF; |
Dan Williams | 6e66f03 | 2007-12-11 12:42:16 -0500 | [diff] [blame] | 169 | |
| 170 | for (i = 0; i < MRVDRV_MAX_REGION_CODE; i++) { |
| 171 | /* use the region code to search for the index */ |
| 172 | if (priv->regioncode == lbs_region_code_to_index[i]) |
| 173 | break; |
| 174 | } |
| 175 | |
| 176 | /* if it's unidentified region code, use the default (USA) */ |
| 177 | if (i >= MRVDRV_MAX_REGION_CODE) { |
| 178 | priv->regioncode = 0x10; |
| 179 | lbs_pr_info("unidentified region code; using the default (USA)\n"); |
| 180 | } |
| 181 | |
| 182 | if (priv->current_addr[0] == 0xff) |
| 183 | memmove(priv->current_addr, cmd.permanentaddr, ETH_ALEN); |
| 184 | |
| 185 | memcpy(priv->dev->dev_addr, priv->current_addr, ETH_ALEN); |
| 186 | if (priv->mesh_dev) |
| 187 | memcpy(priv->mesh_dev->dev_addr, priv->current_addr, ETH_ALEN); |
| 188 | |
| 189 | if (lbs_set_regiontable(priv, priv->regioncode, 0)) { |
| 190 | ret = -1; |
| 191 | goto out; |
| 192 | } |
| 193 | |
Dan Williams | 6e66f03 | 2007-12-11 12:42:16 -0500 | [diff] [blame] | 194 | out: |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 195 | lbs_deb_leave(LBS_DEB_CMD); |
Dan Williams | 6e66f03 | 2007-12-11 12:42:16 -0500 | [diff] [blame] | 196 | return ret; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 197 | } |
| 198 | |
Anna Neal | 582c1b5 | 2008-10-20 16:46:56 -0700 | [diff] [blame] | 199 | int lbs_host_sleep_cfg(struct lbs_private *priv, uint32_t criteria, |
| 200 | struct wol_config *p_wol_config) |
David Woodhouse | 6ce4fd2 | 2007-12-12 15:19:29 -0500 | [diff] [blame] | 201 | { |
| 202 | struct cmd_ds_host_sleep cmd_config; |
| 203 | int ret; |
| 204 | |
David Woodhouse | 9fae899 | 2007-12-15 03:46:44 -0500 | [diff] [blame] | 205 | cmd_config.hdr.size = cpu_to_le16(sizeof(cmd_config)); |
David Woodhouse | 6ce4fd2 | 2007-12-12 15:19:29 -0500 | [diff] [blame] | 206 | cmd_config.criteria = cpu_to_le32(criteria); |
David Woodhouse | 506e902 | 2007-12-12 20:06:06 -0500 | [diff] [blame] | 207 | cmd_config.gpio = priv->wol_gpio; |
| 208 | cmd_config.gap = priv->wol_gap; |
David Woodhouse | 6ce4fd2 | 2007-12-12 15:19:29 -0500 | [diff] [blame] | 209 | |
Anna Neal | 582c1b5 | 2008-10-20 16:46:56 -0700 | [diff] [blame] | 210 | if (p_wol_config != NULL) |
| 211 | memcpy((uint8_t *)&cmd_config.wol_conf, (uint8_t *)p_wol_config, |
| 212 | sizeof(struct wol_config)); |
| 213 | else |
| 214 | cmd_config.wol_conf.action = CMD_ACT_ACTION_NONE; |
| 215 | |
David Woodhouse | 689442d | 2007-12-12 16:00:42 -0500 | [diff] [blame] | 216 | ret = lbs_cmd_with_response(priv, CMD_802_11_HOST_SLEEP_CFG, &cmd_config); |
David Woodhouse | 506e902 | 2007-12-12 20:06:06 -0500 | [diff] [blame] | 217 | if (!ret) { |
Anna Neal | 582c1b5 | 2008-10-20 16:46:56 -0700 | [diff] [blame] | 218 | if (criteria) { |
| 219 | lbs_deb_cmd("Set WOL criteria to %x\n", criteria); |
| 220 | priv->wol_criteria = criteria; |
| 221 | } else |
| 222 | memcpy((uint8_t *) p_wol_config, |
| 223 | (uint8_t *)&cmd_config.wol_conf, |
| 224 | sizeof(struct wol_config)); |
David Woodhouse | 506e902 | 2007-12-12 20:06:06 -0500 | [diff] [blame] | 225 | } else { |
David Woodhouse | 6ce4fd2 | 2007-12-12 15:19:29 -0500 | [diff] [blame] | 226 | lbs_pr_info("HOST_SLEEP_CFG failed %d\n", ret); |
David Woodhouse | 6ce4fd2 | 2007-12-12 15:19:29 -0500 | [diff] [blame] | 227 | } |
David Woodhouse | 506e902 | 2007-12-12 20:06:06 -0500 | [diff] [blame] | 228 | |
David Woodhouse | 6ce4fd2 | 2007-12-12 15:19:29 -0500 | [diff] [blame] | 229 | return ret; |
| 230 | } |
| 231 | EXPORT_SYMBOL_GPL(lbs_host_sleep_cfg); |
| 232 | |
Holger Schurig | e98a88d | 2008-03-19 14:25:58 +0100 | [diff] [blame] | 233 | static int lbs_cmd_802_11_ps_mode(struct cmd_ds_command *cmd, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 234 | u16 cmd_action) |
| 235 | { |
| 236 | struct cmd_ds_802_11_ps_mode *psm = &cmd->params.psmode; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 237 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 238 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 239 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 240 | cmd->command = cpu_to_le16(CMD_802_11_PS_MODE); |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 241 | cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_ps_mode) + |
| 242 | S_DS_GEN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 243 | psm->action = cpu_to_le16(cmd_action); |
| 244 | psm->multipledtim = 0; |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 245 | switch (cmd_action) { |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 246 | case CMD_SUBCMD_ENTER_PS: |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 247 | lbs_deb_cmd("PS command:" "SubCode- Enter PS\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 248 | |
Holger Schurig | 252cf0d | 2007-08-02 13:09:34 -0400 | [diff] [blame] | 249 | psm->locallisteninterval = 0; |
Holger Schurig | 97605c3 | 2007-08-02 13:09:15 -0400 | [diff] [blame] | 250 | psm->nullpktinterval = 0; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 251 | psm->multipledtim = |
Holger Schurig | 56c4656 | 2007-08-02 13:09:49 -0400 | [diff] [blame] | 252 | cpu_to_le16(MRVDRV_DEFAULT_MULTIPLE_DTIM); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 253 | break; |
| 254 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 255 | case CMD_SUBCMD_EXIT_PS: |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 256 | lbs_deb_cmd("PS command:" "SubCode- Exit PS\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 257 | break; |
| 258 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 259 | case CMD_SUBCMD_SLEEP_CONFIRMED: |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 260 | lbs_deb_cmd("PS command: SubCode- sleep confirm\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 261 | break; |
| 262 | |
| 263 | default: |
| 264 | break; |
| 265 | } |
| 266 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 267 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 268 | return 0; |
| 269 | } |
| 270 | |
David Woodhouse | 3fbe104 | 2007-12-17 23:48:31 -0500 | [diff] [blame] | 271 | int lbs_cmd_802_11_sleep_params(struct lbs_private *priv, uint16_t cmd_action, |
| 272 | struct sleep_params *sp) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 273 | { |
David Woodhouse | 3fbe104 | 2007-12-17 23:48:31 -0500 | [diff] [blame] | 274 | struct cmd_ds_802_11_sleep_params cmd; |
| 275 | int ret; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 276 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 277 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 278 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 279 | if (cmd_action == CMD_ACT_GET) { |
David Woodhouse | 3fbe104 | 2007-12-17 23:48:31 -0500 | [diff] [blame] | 280 | memset(&cmd, 0, sizeof(cmd)); |
| 281 | } else { |
| 282 | cmd.error = cpu_to_le16(sp->sp_error); |
| 283 | cmd.offset = cpu_to_le16(sp->sp_offset); |
| 284 | cmd.stabletime = cpu_to_le16(sp->sp_stabletime); |
| 285 | cmd.calcontrol = sp->sp_calcontrol; |
| 286 | cmd.externalsleepclk = sp->sp_extsleepclk; |
| 287 | cmd.reserved = cpu_to_le16(sp->sp_reserved); |
| 288 | } |
| 289 | cmd.hdr.size = cpu_to_le16(sizeof(cmd)); |
| 290 | cmd.action = cpu_to_le16(cmd_action); |
| 291 | |
| 292 | ret = lbs_cmd_with_response(priv, CMD_802_11_SLEEP_PARAMS, &cmd); |
| 293 | |
| 294 | if (!ret) { |
| 295 | lbs_deb_cmd("error 0x%x, offset 0x%x, stabletime 0x%x, " |
| 296 | "calcontrol 0x%x extsleepclk 0x%x\n", |
| 297 | le16_to_cpu(cmd.error), le16_to_cpu(cmd.offset), |
| 298 | le16_to_cpu(cmd.stabletime), cmd.calcontrol, |
| 299 | cmd.externalsleepclk); |
| 300 | |
| 301 | sp->sp_error = le16_to_cpu(cmd.error); |
| 302 | sp->sp_offset = le16_to_cpu(cmd.offset); |
| 303 | sp->sp_stabletime = le16_to_cpu(cmd.stabletime); |
| 304 | sp->sp_calcontrol = cmd.calcontrol; |
| 305 | sp->sp_extsleepclk = cmd.externalsleepclk; |
| 306 | sp->sp_reserved = le16_to_cpu(cmd.reserved); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 307 | } |
| 308 | |
David Woodhouse | 3fbe104 | 2007-12-17 23:48:31 -0500 | [diff] [blame] | 309 | lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 310 | return 0; |
| 311 | } |
| 312 | |
Amitkumar Karwar | 4912545 | 2009-09-30 20:04:38 -0700 | [diff] [blame] | 313 | static int lbs_wait_for_ds_awake(struct lbs_private *priv) |
| 314 | { |
| 315 | int ret = 0; |
| 316 | |
| 317 | lbs_deb_enter(LBS_DEB_CMD); |
| 318 | |
| 319 | if (priv->is_deep_sleep) { |
| 320 | if (!wait_event_interruptible_timeout(priv->ds_awake_q, |
| 321 | !priv->is_deep_sleep, (10 * HZ))) { |
| 322 | lbs_pr_err("ds_awake_q: timer expired\n"); |
| 323 | ret = -1; |
| 324 | } |
| 325 | } |
| 326 | |
| 327 | lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret); |
| 328 | return ret; |
| 329 | } |
| 330 | |
| 331 | int lbs_set_deep_sleep(struct lbs_private *priv, int deep_sleep) |
| 332 | { |
| 333 | int ret = 0; |
| 334 | |
| 335 | lbs_deb_enter(LBS_DEB_CMD); |
| 336 | |
| 337 | if (deep_sleep) { |
| 338 | if (priv->is_deep_sleep != 1) { |
| 339 | lbs_deb_cmd("deep sleep: sleep\n"); |
| 340 | BUG_ON(!priv->enter_deep_sleep); |
| 341 | ret = priv->enter_deep_sleep(priv); |
| 342 | if (!ret) { |
| 343 | netif_stop_queue(priv->dev); |
| 344 | netif_carrier_off(priv->dev); |
| 345 | } |
| 346 | } else { |
| 347 | lbs_pr_err("deep sleep: already enabled\n"); |
| 348 | } |
| 349 | } else { |
| 350 | if (priv->is_deep_sleep) { |
| 351 | lbs_deb_cmd("deep sleep: wakeup\n"); |
| 352 | BUG_ON(!priv->exit_deep_sleep); |
| 353 | ret = priv->exit_deep_sleep(priv); |
| 354 | if (!ret) { |
| 355 | ret = lbs_wait_for_ds_awake(priv); |
| 356 | if (ret) |
| 357 | lbs_pr_err("deep sleep: wakeup" |
| 358 | "failed\n"); |
| 359 | } |
| 360 | } |
| 361 | } |
| 362 | |
| 363 | lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret); |
| 364 | return ret; |
| 365 | } |
| 366 | |
David Woodhouse | f70dd45 | 2007-12-18 00:18:05 -0500 | [diff] [blame] | 367 | int lbs_cmd_802_11_set_wep(struct lbs_private *priv, uint16_t cmd_action, |
| 368 | struct assoc_request *assoc) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 369 | { |
David Woodhouse | f70dd45 | 2007-12-18 00:18:05 -0500 | [diff] [blame] | 370 | struct cmd_ds_802_11_set_wep cmd; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 371 | int ret = 0; |
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 | |
Holger Schurig | 8d0c7fa | 2008-04-09 10:23:31 +0200 | [diff] [blame] | 375 | memset(&cmd, 0, sizeof(cmd)); |
David Woodhouse | f70dd45 | 2007-12-18 00:18:05 -0500 | [diff] [blame] | 376 | cmd.hdr.command = cpu_to_le16(CMD_802_11_SET_WEP); |
| 377 | cmd.hdr.size = cpu_to_le16(sizeof(cmd)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 378 | |
David Woodhouse | f70dd45 | 2007-12-18 00:18:05 -0500 | [diff] [blame] | 379 | cmd.action = cpu_to_le16(cmd_action); |
| 380 | |
| 381 | if (cmd_action == CMD_ACT_ADD) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 382 | int i; |
| 383 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 384 | /* default tx key index */ |
David Woodhouse | f70dd45 | 2007-12-18 00:18:05 -0500 | [diff] [blame] | 385 | cmd.keyindex = cpu_to_le16(assoc->wep_tx_keyidx & |
| 386 | CMD_WEP_KEY_INDEX_MASK); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 387 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 388 | /* Copy key types and material to host command structure */ |
| 389 | for (i = 0; i < 4; i++) { |
David Woodhouse | f70dd45 | 2007-12-18 00:18:05 -0500 | [diff] [blame] | 390 | struct enc_key *pkey = &assoc->wep_keys[i]; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 391 | |
| 392 | switch (pkey->len) { |
| 393 | case KEY_LEN_WEP_40: |
David Woodhouse | f70dd45 | 2007-12-18 00:18:05 -0500 | [diff] [blame] | 394 | cmd.keytype[i] = CMD_TYPE_WEP_40_BIT; |
| 395 | memmove(cmd.keymaterial[i], pkey->key, pkey->len); |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 396 | lbs_deb_cmd("SET_WEP: add key %d (40 bit)\n", i); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 397 | break; |
| 398 | case KEY_LEN_WEP_104: |
David Woodhouse | f70dd45 | 2007-12-18 00:18:05 -0500 | [diff] [blame] | 399 | cmd.keytype[i] = CMD_TYPE_WEP_104_BIT; |
| 400 | memmove(cmd.keymaterial[i], pkey->key, pkey->len); |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 401 | lbs_deb_cmd("SET_WEP: add key %d (104 bit)\n", i); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 402 | break; |
| 403 | case 0: |
| 404 | break; |
| 405 | default: |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 406 | lbs_deb_cmd("SET_WEP: invalid key %d, length %d\n", |
David Woodhouse | f70dd45 | 2007-12-18 00:18:05 -0500 | [diff] [blame] | 407 | i, pkey->len); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 408 | ret = -1; |
| 409 | goto done; |
| 410 | break; |
| 411 | } |
| 412 | } |
David Woodhouse | f70dd45 | 2007-12-18 00:18:05 -0500 | [diff] [blame] | 413 | } else if (cmd_action == CMD_ACT_REMOVE) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 414 | /* ACT_REMOVE clears _all_ WEP keys */ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 415 | |
| 416 | /* default tx key index */ |
David Woodhouse | f70dd45 | 2007-12-18 00:18:05 -0500 | [diff] [blame] | 417 | cmd.keyindex = cpu_to_le16(priv->wep_tx_keyidx & |
| 418 | CMD_WEP_KEY_INDEX_MASK); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 419 | lbs_deb_cmd("SET_WEP: remove key %d\n", priv->wep_tx_keyidx); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 420 | } |
| 421 | |
David Woodhouse | f70dd45 | 2007-12-18 00:18:05 -0500 | [diff] [blame] | 422 | ret = lbs_cmd_with_response(priv, CMD_802_11_SET_WEP, &cmd); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 423 | done: |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 424 | lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 425 | return ret; |
| 426 | } |
| 427 | |
David Woodhouse | 4f59abf | 2007-12-18 00:47:17 -0500 | [diff] [blame] | 428 | int lbs_cmd_802_11_enable_rsn(struct lbs_private *priv, uint16_t cmd_action, |
| 429 | uint16_t *enable) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 430 | { |
David Woodhouse | 4f59abf | 2007-12-18 00:47:17 -0500 | [diff] [blame] | 431 | struct cmd_ds_802_11_enable_rsn cmd; |
| 432 | int ret; |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 433 | |
| 434 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 435 | |
David Woodhouse | 4f59abf | 2007-12-18 00:47:17 -0500 | [diff] [blame] | 436 | cmd.hdr.size = cpu_to_le16(sizeof(cmd)); |
| 437 | cmd.action = cpu_to_le16(cmd_action); |
Dan Williams | 18c96c34 | 2007-06-18 12:01:12 -0400 | [diff] [blame] | 438 | |
Holger Schurig | 8d0c7fa | 2008-04-09 10:23:31 +0200 | [diff] [blame] | 439 | if (cmd_action == CMD_ACT_GET) |
| 440 | cmd.enable = 0; |
| 441 | else { |
Dan Williams | 18c96c34 | 2007-06-18 12:01:12 -0400 | [diff] [blame] | 442 | if (*enable) |
David Woodhouse | 4f59abf | 2007-12-18 00:47:17 -0500 | [diff] [blame] | 443 | cmd.enable = cpu_to_le16(CMD_ENABLE_RSN); |
Dan Williams | 18c96c34 | 2007-06-18 12:01:12 -0400 | [diff] [blame] | 444 | else |
David Woodhouse | 4f59abf | 2007-12-18 00:47:17 -0500 | [diff] [blame] | 445 | cmd.enable = cpu_to_le16(CMD_DISABLE_RSN); |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 446 | lbs_deb_cmd("ENABLE_RSN: %d\n", *enable); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 447 | } |
| 448 | |
David Woodhouse | 4f59abf | 2007-12-18 00:47:17 -0500 | [diff] [blame] | 449 | ret = lbs_cmd_with_response(priv, CMD_802_11_ENABLE_RSN, &cmd); |
| 450 | if (!ret && cmd_action == CMD_ACT_GET) |
| 451 | *enable = le16_to_cpu(cmd.enable); |
| 452 | |
| 453 | lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret); |
| 454 | return ret; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 455 | } |
| 456 | |
David Woodhouse | 9e1228d | 2008-03-03 12:15:39 +0100 | [diff] [blame] | 457 | static void set_one_wpa_key(struct MrvlIEtype_keyParamSet *keyparam, |
| 458 | struct enc_key *key) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 459 | { |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 460 | lbs_deb_enter(LBS_DEB_CMD); |
| 461 | |
David Woodhouse | 9e1228d | 2008-03-03 12:15:39 +0100 | [diff] [blame] | 462 | if (key->flags & KEY_INFO_WPA_ENABLED) |
| 463 | keyparam->keyinfo |= cpu_to_le16(KEY_INFO_WPA_ENABLED); |
| 464 | if (key->flags & KEY_INFO_WPA_UNICAST) |
| 465 | keyparam->keyinfo |= cpu_to_le16(KEY_INFO_WPA_UNICAST); |
| 466 | if (key->flags & KEY_INFO_WPA_MCAST) |
| 467 | keyparam->keyinfo |= cpu_to_le16(KEY_INFO_WPA_MCAST); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 468 | |
David Woodhouse | 9e1228d | 2008-03-03 12:15:39 +0100 | [diff] [blame] | 469 | keyparam->type = cpu_to_le16(TLV_TYPE_KEY_MATERIAL); |
| 470 | keyparam->keytypeid = cpu_to_le16(key->type); |
| 471 | keyparam->keylen = cpu_to_le16(key->len); |
| 472 | memcpy(keyparam->key, key->key, key->len); |
| 473 | |
| 474 | /* Length field doesn't include the {type,length} header */ |
| 475 | keyparam->length = cpu_to_le16(sizeof(*keyparam) - 4); |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 476 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 477 | } |
| 478 | |
David Woodhouse | 9e1228d | 2008-03-03 12:15:39 +0100 | [diff] [blame] | 479 | int lbs_cmd_802_11_key_material(struct lbs_private *priv, uint16_t cmd_action, |
| 480 | struct assoc_request *assoc) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 481 | { |
David Woodhouse | 9e1228d | 2008-03-03 12:15:39 +0100 | [diff] [blame] | 482 | struct cmd_ds_802_11_key_material cmd; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 483 | int ret = 0; |
| 484 | int index = 0; |
| 485 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 486 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 487 | |
David Woodhouse | 9e1228d | 2008-03-03 12:15:39 +0100 | [diff] [blame] | 488 | cmd.action = cpu_to_le16(cmd_action); |
| 489 | cmd.hdr.size = cpu_to_le16(sizeof(cmd)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 490 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 491 | if (cmd_action == CMD_ACT_GET) { |
David Woodhouse | 9e1228d | 2008-03-03 12:15:39 +0100 | [diff] [blame] | 492 | cmd.hdr.size = cpu_to_le16(S_DS_GEN + 2); |
| 493 | } else { |
| 494 | memset(cmd.keyParamSet, 0, sizeof(cmd.keyParamSet)); |
| 495 | |
| 496 | if (test_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc->flags)) { |
| 497 | set_one_wpa_key(&cmd.keyParamSet[index], |
| 498 | &assoc->wpa_unicast_key); |
| 499 | index++; |
| 500 | } |
| 501 | |
| 502 | if (test_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc->flags)) { |
| 503 | set_one_wpa_key(&cmd.keyParamSet[index], |
| 504 | &assoc->wpa_mcast_key); |
| 505 | index++; |
| 506 | } |
| 507 | |
| 508 | /* The common header and as many keys as we included */ |
| 509 | cmd.hdr.size = cpu_to_le16(offsetof(typeof(cmd), |
| 510 | keyParamSet[index])); |
| 511 | } |
| 512 | ret = lbs_cmd_with_response(priv, CMD_802_11_KEY_MATERIAL, &cmd); |
| 513 | /* Copy the returned key to driver private data */ |
| 514 | if (!ret && cmd_action == CMD_ACT_GET) { |
| 515 | void *buf_ptr = cmd.keyParamSet; |
| 516 | void *resp_end = &(&cmd)[1]; |
| 517 | |
| 518 | while (buf_ptr < resp_end) { |
| 519 | struct MrvlIEtype_keyParamSet *keyparam = buf_ptr; |
| 520 | struct enc_key *key; |
| 521 | uint16_t param_set_len = le16_to_cpu(keyparam->length); |
| 522 | uint16_t key_len = le16_to_cpu(keyparam->keylen); |
| 523 | uint16_t key_flags = le16_to_cpu(keyparam->keyinfo); |
| 524 | uint16_t key_type = le16_to_cpu(keyparam->keytypeid); |
| 525 | void *end; |
| 526 | |
| 527 | end = (void *)keyparam + sizeof(keyparam->type) |
| 528 | + sizeof(keyparam->length) + param_set_len; |
| 529 | |
| 530 | /* Make sure we don't access past the end of the IEs */ |
| 531 | if (end > resp_end) |
| 532 | break; |
| 533 | |
| 534 | if (key_flags & KEY_INFO_WPA_UNICAST) |
| 535 | key = &priv->wpa_unicast_key; |
| 536 | else if (key_flags & KEY_INFO_WPA_MCAST) |
| 537 | key = &priv->wpa_mcast_key; |
| 538 | else |
| 539 | break; |
| 540 | |
| 541 | /* Copy returned key into driver */ |
| 542 | memset(key, 0, sizeof(struct enc_key)); |
| 543 | if (key_len > sizeof(key->key)) |
| 544 | break; |
| 545 | key->type = key_type; |
| 546 | key->flags = key_flags; |
| 547 | key->len = key_len; |
| 548 | memcpy(key->key, keyparam->key, key->len); |
| 549 | |
| 550 | buf_ptr = end + 1; |
| 551 | } |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 552 | } |
| 553 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 554 | lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 555 | return ret; |
| 556 | } |
| 557 | |
Dan Williams | 39fcf7a | 2008-09-10 12:49:00 -0400 | [diff] [blame] | 558 | /** |
| 559 | * @brief Set an SNMP MIB value |
| 560 | * |
| 561 | * @param priv A pointer to struct lbs_private structure |
| 562 | * @param oid The OID to set in the firmware |
| 563 | * @param val Value to set the OID to |
| 564 | * |
| 565 | * @return 0 on success, error on failure |
| 566 | */ |
| 567 | int lbs_set_snmp_mib(struct lbs_private *priv, u32 oid, u16 val) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 568 | { |
Dan Williams | 39fcf7a | 2008-09-10 12:49:00 -0400 | [diff] [blame] | 569 | struct cmd_ds_802_11_snmp_mib cmd; |
| 570 | int ret; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 571 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 572 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 573 | |
Dan Williams | 39fcf7a | 2008-09-10 12:49:00 -0400 | [diff] [blame] | 574 | memset(&cmd, 0, sizeof (cmd)); |
| 575 | cmd.hdr.size = cpu_to_le16(sizeof(cmd)); |
| 576 | cmd.action = cpu_to_le16(CMD_ACT_SET); |
| 577 | cmd.oid = cpu_to_le16((u16) oid); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 578 | |
Dan Williams | 39fcf7a | 2008-09-10 12:49:00 -0400 | [diff] [blame] | 579 | switch (oid) { |
| 580 | case SNMP_MIB_OID_BSS_TYPE: |
| 581 | cmd.bufsize = cpu_to_le16(sizeof(u8)); |
| 582 | cmd.value[0] = (val == IW_MODE_ADHOC) ? 2 : 1; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 583 | break; |
Dan Williams | 39fcf7a | 2008-09-10 12:49:00 -0400 | [diff] [blame] | 584 | case SNMP_MIB_OID_11D_ENABLE: |
| 585 | case SNMP_MIB_OID_FRAG_THRESHOLD: |
| 586 | case SNMP_MIB_OID_RTS_THRESHOLD: |
| 587 | case SNMP_MIB_OID_SHORT_RETRY_LIMIT: |
| 588 | case SNMP_MIB_OID_LONG_RETRY_LIMIT: |
| 589 | cmd.bufsize = cpu_to_le16(sizeof(u16)); |
| 590 | *((__le16 *)(&cmd.value)) = cpu_to_le16(val); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 591 | break; |
| 592 | default: |
Dan Williams | 39fcf7a | 2008-09-10 12:49:00 -0400 | [diff] [blame] | 593 | lbs_deb_cmd("SNMP_CMD: (set) unhandled OID 0x%x\n", oid); |
| 594 | ret = -EINVAL; |
| 595 | goto out; |
| 596 | } |
| 597 | |
| 598 | lbs_deb_cmd("SNMP_CMD: (set) oid 0x%x, oid size 0x%x, value 0x%x\n", |
| 599 | le16_to_cpu(cmd.oid), le16_to_cpu(cmd.bufsize), val); |
| 600 | |
| 601 | ret = lbs_cmd_with_response(priv, CMD_802_11_SNMP_MIB, &cmd); |
| 602 | |
| 603 | out: |
| 604 | lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret); |
| 605 | return ret; |
| 606 | } |
| 607 | |
| 608 | /** |
| 609 | * @brief Get an SNMP MIB value |
| 610 | * |
| 611 | * @param priv A pointer to struct lbs_private structure |
| 612 | * @param oid The OID to retrieve from the firmware |
| 613 | * @param out_val Location for the returned value |
| 614 | * |
| 615 | * @return 0 on success, error on failure |
| 616 | */ |
| 617 | int lbs_get_snmp_mib(struct lbs_private *priv, u32 oid, u16 *out_val) |
| 618 | { |
| 619 | struct cmd_ds_802_11_snmp_mib cmd; |
| 620 | int ret; |
| 621 | |
| 622 | lbs_deb_enter(LBS_DEB_CMD); |
| 623 | |
| 624 | memset(&cmd, 0, sizeof (cmd)); |
| 625 | cmd.hdr.size = cpu_to_le16(sizeof(cmd)); |
| 626 | cmd.action = cpu_to_le16(CMD_ACT_GET); |
| 627 | cmd.oid = cpu_to_le16(oid); |
| 628 | |
| 629 | ret = lbs_cmd_with_response(priv, CMD_802_11_SNMP_MIB, &cmd); |
| 630 | if (ret) |
| 631 | goto out; |
| 632 | |
| 633 | switch (le16_to_cpu(cmd.bufsize)) { |
| 634 | case sizeof(u8): |
| 635 | if (oid == SNMP_MIB_OID_BSS_TYPE) { |
| 636 | if (cmd.value[0] == 2) |
| 637 | *out_val = IW_MODE_ADHOC; |
| 638 | else |
| 639 | *out_val = IW_MODE_INFRA; |
| 640 | } else |
| 641 | *out_val = cmd.value[0]; |
| 642 | break; |
| 643 | case sizeof(u16): |
| 644 | *out_val = le16_to_cpu(*((__le16 *)(&cmd.value))); |
| 645 | break; |
| 646 | default: |
| 647 | lbs_deb_cmd("SNMP_CMD: (get) unhandled OID 0x%x size %d\n", |
| 648 | oid, le16_to_cpu(cmd.bufsize)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 649 | break; |
| 650 | } |
| 651 | |
Dan Williams | 39fcf7a | 2008-09-10 12:49:00 -0400 | [diff] [blame] | 652 | out: |
| 653 | lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret); |
| 654 | return ret; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 655 | } |
| 656 | |
Dan Williams | 87c8c72 | 2008-08-19 15:15:35 -0400 | [diff] [blame] | 657 | /** |
| 658 | * @brief Get the min, max, and current TX power |
| 659 | * |
| 660 | * @param priv A pointer to struct lbs_private structure |
| 661 | * @param curlevel Current power level in dBm |
| 662 | * @param minlevel Minimum supported power level in dBm (optional) |
| 663 | * @param maxlevel Maximum supported power level in dBm (optional) |
| 664 | * |
| 665 | * @return 0 on success, error on failure |
| 666 | */ |
| 667 | int lbs_get_tx_power(struct lbs_private *priv, s16 *curlevel, s16 *minlevel, |
| 668 | s16 *maxlevel) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 669 | { |
Dan Williams | 87c8c72 | 2008-08-19 15:15:35 -0400 | [diff] [blame] | 670 | struct cmd_ds_802_11_rf_tx_power cmd; |
| 671 | int ret; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 672 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 673 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 674 | |
Dan Williams | 87c8c72 | 2008-08-19 15:15:35 -0400 | [diff] [blame] | 675 | memset(&cmd, 0, sizeof(cmd)); |
| 676 | cmd.hdr.size = cpu_to_le16(sizeof(cmd)); |
| 677 | cmd.action = cpu_to_le16(CMD_ACT_GET); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 678 | |
Dan Williams | 87c8c72 | 2008-08-19 15:15:35 -0400 | [diff] [blame] | 679 | ret = lbs_cmd_with_response(priv, CMD_802_11_RF_TX_POWER, &cmd); |
| 680 | if (ret == 0) { |
| 681 | *curlevel = le16_to_cpu(cmd.curlevel); |
| 682 | if (minlevel) |
Holger Schurig | 87bf24f | 2008-10-29 10:35:02 +0100 | [diff] [blame] | 683 | *minlevel = cmd.minlevel; |
Dan Williams | 87c8c72 | 2008-08-19 15:15:35 -0400 | [diff] [blame] | 684 | if (maxlevel) |
Holger Schurig | 87bf24f | 2008-10-29 10:35:02 +0100 | [diff] [blame] | 685 | *maxlevel = cmd.maxlevel; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 686 | } |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 687 | |
| 688 | lbs_deb_leave(LBS_DEB_CMD); |
Dan Williams | 87c8c72 | 2008-08-19 15:15:35 -0400 | [diff] [blame] | 689 | return ret; |
| 690 | } |
| 691 | |
| 692 | /** |
| 693 | * @brief Set the TX power |
| 694 | * |
| 695 | * @param priv A pointer to struct lbs_private structure |
| 696 | * @param dbm The desired power level in dBm |
| 697 | * |
| 698 | * @return 0 on success, error on failure |
| 699 | */ |
| 700 | int lbs_set_tx_power(struct lbs_private *priv, s16 dbm) |
| 701 | { |
| 702 | struct cmd_ds_802_11_rf_tx_power cmd; |
| 703 | int ret; |
| 704 | |
| 705 | lbs_deb_enter(LBS_DEB_CMD); |
| 706 | |
| 707 | memset(&cmd, 0, sizeof(cmd)); |
| 708 | cmd.hdr.size = cpu_to_le16(sizeof(cmd)); |
| 709 | cmd.action = cpu_to_le16(CMD_ACT_SET); |
| 710 | cmd.curlevel = cpu_to_le16(dbm); |
| 711 | |
| 712 | lbs_deb_cmd("SET_RF_TX_POWER: %d dBm\n", dbm); |
| 713 | |
| 714 | ret = lbs_cmd_with_response(priv, CMD_802_11_RF_TX_POWER, &cmd); |
| 715 | |
| 716 | lbs_deb_leave(LBS_DEB_CMD); |
| 717 | return ret; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 718 | } |
| 719 | |
Holger Schurig | e98a88d | 2008-03-19 14:25:58 +0100 | [diff] [blame] | 720 | static int lbs_cmd_802_11_monitor_mode(struct cmd_ds_command *cmd, |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 721 | u16 cmd_action, void *pdata_buf) |
| 722 | { |
| 723 | struct cmd_ds_802_11_monitor_mode *monitor = &cmd->params.monitor; |
| 724 | |
| 725 | cmd->command = cpu_to_le16(CMD_802_11_MONITOR_MODE); |
| 726 | cmd->size = |
| 727 | cpu_to_le16(sizeof(struct cmd_ds_802_11_monitor_mode) + |
| 728 | S_DS_GEN); |
| 729 | |
| 730 | monitor->action = cpu_to_le16(cmd_action); |
| 731 | if (cmd_action == CMD_ACT_SET) { |
| 732 | monitor->mode = |
| 733 | cpu_to_le16((u16) (*(u32 *) pdata_buf)); |
| 734 | } |
| 735 | |
| 736 | return 0; |
| 737 | } |
| 738 | |
Javier Cardona | 85319f9 | 2008-05-24 10:59:49 +0100 | [diff] [blame] | 739 | static __le16 lbs_rate_to_fw_bitmap(int rate, int lower_rates_ok) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 740 | { |
Javier Cardona | 85319f9 | 2008-05-24 10:59:49 +0100 | [diff] [blame] | 741 | /* Bit Rate |
| 742 | * 15:13 Reserved |
| 743 | * 12 54 Mbps |
| 744 | * 11 48 Mbps |
| 745 | * 10 36 Mbps |
| 746 | * 9 24 Mbps |
| 747 | * 8 18 Mbps |
| 748 | * 7 12 Mbps |
| 749 | * 6 9 Mbps |
| 750 | * 5 6 Mbps |
| 751 | * 4 Reserved |
| 752 | * 3 11 Mbps |
| 753 | * 2 5.5 Mbps |
| 754 | * 1 2 Mbps |
| 755 | * 0 1 Mbps |
| 756 | **/ |
| 757 | |
| 758 | uint16_t ratemask; |
| 759 | int i = lbs_data_rate_to_fw_index(rate); |
| 760 | if (lower_rates_ok) |
| 761 | ratemask = (0x1fef >> (12 - i)); |
| 762 | else |
| 763 | ratemask = (1 << i); |
| 764 | return cpu_to_le16(ratemask); |
| 765 | } |
| 766 | |
| 767 | int lbs_cmd_802_11_rate_adapt_rateset(struct lbs_private *priv, |
| 768 | uint16_t cmd_action) |
| 769 | { |
| 770 | struct cmd_ds_802_11_rate_adapt_rateset cmd; |
| 771 | int ret; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 772 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 773 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 774 | |
Javier Cardona | 85319f9 | 2008-05-24 10:59:49 +0100 | [diff] [blame] | 775 | if (!priv->cur_rate && !priv->enablehwauto) |
| 776 | return -EINVAL; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 777 | |
Javier Cardona | 85319f9 | 2008-05-24 10:59:49 +0100 | [diff] [blame] | 778 | cmd.hdr.size = cpu_to_le16(sizeof(cmd)); |
| 779 | |
| 780 | cmd.action = cpu_to_le16(cmd_action); |
| 781 | cmd.enablehwauto = cpu_to_le16(priv->enablehwauto); |
| 782 | cmd.bitmap = lbs_rate_to_fw_bitmap(priv->cur_rate, priv->enablehwauto); |
| 783 | ret = lbs_cmd_with_response(priv, CMD_802_11_RATE_ADAPT_RATESET, &cmd); |
| 784 | if (!ret && cmd_action == CMD_ACT_GET) { |
| 785 | priv->ratebitmap = le16_to_cpu(cmd.bitmap); |
| 786 | priv->enablehwauto = le16_to_cpu(cmd.enablehwauto); |
| 787 | } |
| 788 | |
| 789 | lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret); |
| 790 | return ret; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 791 | } |
Javier Cardona | 85319f9 | 2008-05-24 10:59:49 +0100 | [diff] [blame] | 792 | EXPORT_SYMBOL_GPL(lbs_cmd_802_11_rate_adapt_rateset); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 793 | |
Dan Williams | 8e3c91b | 2007-12-11 15:50:59 -0500 | [diff] [blame] | 794 | /** |
Dan Williams | 8e3c91b | 2007-12-11 15:50:59 -0500 | [diff] [blame] | 795 | * @brief Set the data rate |
| 796 | * |
| 797 | * @param priv A pointer to struct lbs_private structure |
| 798 | * @param rate The desired data rate, or 0 to clear a locked rate |
| 799 | * |
| 800 | * @return 0 on success, error on failure |
| 801 | */ |
| 802 | int lbs_set_data_rate(struct lbs_private *priv, u8 rate) |
| 803 | { |
| 804 | struct cmd_ds_802_11_data_rate cmd; |
| 805 | int ret = 0; |
| 806 | |
| 807 | lbs_deb_enter(LBS_DEB_CMD); |
| 808 | |
| 809 | memset(&cmd, 0, sizeof(cmd)); |
| 810 | cmd.hdr.size = cpu_to_le16(sizeof(cmd)); |
| 811 | |
| 812 | if (rate > 0) { |
| 813 | cmd.action = cpu_to_le16(CMD_ACT_SET_TX_FIX_RATE); |
| 814 | cmd.rates[0] = lbs_data_rate_to_fw_index(rate); |
| 815 | if (cmd.rates[0] == 0) { |
| 816 | lbs_deb_cmd("DATA_RATE: invalid requested rate of" |
| 817 | " 0x%02X\n", rate); |
| 818 | ret = 0; |
| 819 | goto out; |
| 820 | } |
| 821 | lbs_deb_cmd("DATA_RATE: set fixed 0x%02X\n", cmd.rates[0]); |
| 822 | } else { |
| 823 | cmd.action = cpu_to_le16(CMD_ACT_SET_TX_AUTO); |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 824 | lbs_deb_cmd("DATA_RATE: setting auto\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 825 | } |
| 826 | |
David Woodhouse | 689442d | 2007-12-12 16:00:42 -0500 | [diff] [blame] | 827 | ret = lbs_cmd_with_response(priv, CMD_802_11_DATA_RATE, &cmd); |
Dan Williams | 8e3c91b | 2007-12-11 15:50:59 -0500 | [diff] [blame] | 828 | if (ret) |
| 829 | goto out; |
| 830 | |
| 831 | lbs_deb_hex(LBS_DEB_CMD, "DATA_RATE_RESP", (u8 *) &cmd, sizeof (cmd)); |
| 832 | |
| 833 | /* FIXME: get actual rates FW can do if this command actually returns |
| 834 | * all data rates supported. |
| 835 | */ |
| 836 | priv->cur_rate = lbs_fw_index_to_data_rate(cmd.rates[0]); |
| 837 | lbs_deb_cmd("DATA_RATE: current rate is 0x%02x\n", priv->cur_rate); |
| 838 | |
| 839 | out: |
| 840 | lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret); |
| 841 | return ret; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 842 | } |
| 843 | |
Dan Williams | 2dd4b26 | 2007-12-11 16:54:15 -0500 | [diff] [blame] | 844 | /** |
| 845 | * @brief Get the radio channel |
| 846 | * |
| 847 | * @param priv A pointer to struct lbs_private structure |
| 848 | * |
| 849 | * @return The channel on success, error on failure |
| 850 | */ |
Holger Schurig | a3cbfb0 | 2009-10-16 17:33:56 +0200 | [diff] [blame] | 851 | static int lbs_get_channel(struct lbs_private *priv) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 852 | { |
Dan Williams | 2dd4b26 | 2007-12-11 16:54:15 -0500 | [diff] [blame] | 853 | struct cmd_ds_802_11_rf_channel cmd; |
| 854 | int ret = 0; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 855 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 856 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 857 | |
Holger Schurig | 8d0c7fa | 2008-04-09 10:23:31 +0200 | [diff] [blame] | 858 | memset(&cmd, 0, sizeof(cmd)); |
Dan Williams | 2dd4b26 | 2007-12-11 16:54:15 -0500 | [diff] [blame] | 859 | cmd.hdr.size = cpu_to_le16(sizeof(cmd)); |
| 860 | cmd.action = cpu_to_le16(CMD_OPT_802_11_RF_CHANNEL_GET); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 861 | |
David Woodhouse | 689442d | 2007-12-12 16:00:42 -0500 | [diff] [blame] | 862 | ret = lbs_cmd_with_response(priv, CMD_802_11_RF_CHANNEL, &cmd); |
Dan Williams | 2dd4b26 | 2007-12-11 16:54:15 -0500 | [diff] [blame] | 863 | if (ret) |
| 864 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 865 | |
Dan Williams | cb182a6 | 2007-12-11 17:35:51 -0500 | [diff] [blame] | 866 | ret = le16_to_cpu(cmd.channel); |
| 867 | lbs_deb_cmd("current radio channel is %d\n", ret); |
Dan Williams | 2dd4b26 | 2007-12-11 16:54:15 -0500 | [diff] [blame] | 868 | |
| 869 | out: |
| 870 | lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret); |
| 871 | return ret; |
| 872 | } |
| 873 | |
Holger Schurig | 73ab1f2 | 2008-04-02 16:52:19 +0200 | [diff] [blame] | 874 | int lbs_update_channel(struct lbs_private *priv) |
| 875 | { |
| 876 | int ret; |
| 877 | |
| 878 | /* the channel in f/w could be out of sync; get the current channel */ |
| 879 | lbs_deb_enter(LBS_DEB_ASSOC); |
| 880 | |
| 881 | ret = lbs_get_channel(priv); |
| 882 | if (ret > 0) { |
| 883 | priv->curbssparams.channel = ret; |
| 884 | ret = 0; |
| 885 | } |
| 886 | lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret); |
| 887 | return ret; |
| 888 | } |
| 889 | |
Dan Williams | 2dd4b26 | 2007-12-11 16:54:15 -0500 | [diff] [blame] | 890 | /** |
| 891 | * @brief Set the radio channel |
| 892 | * |
| 893 | * @param priv A pointer to struct lbs_private structure |
| 894 | * @param channel The desired channel, or 0 to clear a locked channel |
| 895 | * |
| 896 | * @return 0 on success, error on failure |
| 897 | */ |
| 898 | int lbs_set_channel(struct lbs_private *priv, u8 channel) |
| 899 | { |
| 900 | struct cmd_ds_802_11_rf_channel cmd; |
Manish Katiyar | 96d46d5 | 2008-10-13 16:22:42 +0530 | [diff] [blame] | 901 | #ifdef DEBUG |
Dan Williams | 2dd4b26 | 2007-12-11 16:54:15 -0500 | [diff] [blame] | 902 | u8 old_channel = priv->curbssparams.channel; |
Manish Katiyar | 96d46d5 | 2008-10-13 16:22:42 +0530 | [diff] [blame] | 903 | #endif |
Dan Williams | 2dd4b26 | 2007-12-11 16:54:15 -0500 | [diff] [blame] | 904 | int ret = 0; |
| 905 | |
| 906 | lbs_deb_enter(LBS_DEB_CMD); |
| 907 | |
Holger Schurig | 8d0c7fa | 2008-04-09 10:23:31 +0200 | [diff] [blame] | 908 | memset(&cmd, 0, sizeof(cmd)); |
Dan Williams | 2dd4b26 | 2007-12-11 16:54:15 -0500 | [diff] [blame] | 909 | cmd.hdr.size = cpu_to_le16(sizeof(cmd)); |
| 910 | cmd.action = cpu_to_le16(CMD_OPT_802_11_RF_CHANNEL_SET); |
| 911 | cmd.channel = cpu_to_le16(channel); |
| 912 | |
David Woodhouse | 689442d | 2007-12-12 16:00:42 -0500 | [diff] [blame] | 913 | ret = lbs_cmd_with_response(priv, CMD_802_11_RF_CHANNEL, &cmd); |
Dan Williams | 2dd4b26 | 2007-12-11 16:54:15 -0500 | [diff] [blame] | 914 | if (ret) |
| 915 | goto out; |
| 916 | |
Dan Williams | cb182a6 | 2007-12-11 17:35:51 -0500 | [diff] [blame] | 917 | priv->curbssparams.channel = (uint8_t) le16_to_cpu(cmd.channel); |
| 918 | lbs_deb_cmd("channel switch from %d to %d\n", old_channel, |
| 919 | priv->curbssparams.channel); |
Dan Williams | 2dd4b26 | 2007-12-11 16:54:15 -0500 | [diff] [blame] | 920 | |
| 921 | out: |
| 922 | lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret); |
| 923 | return ret; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 924 | } |
| 925 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 926 | static int lbs_cmd_802_11_rssi(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 927 | struct cmd_ds_command *cmd) |
| 928 | { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 929 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 930 | lbs_deb_enter(LBS_DEB_CMD); |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 931 | cmd->command = cpu_to_le16(CMD_802_11_RSSI); |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 932 | cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_rssi) + S_DS_GEN); |
Holger Schurig | a783f1e | 2007-08-02 13:08:24 -0400 | [diff] [blame] | 933 | cmd->params.rssi.N = cpu_to_le16(DEFAULT_BCN_AVG_FACTOR); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 934 | |
| 935 | /* reset Beacon SNR/NF/RSSI values */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 936 | priv->SNR[TYPE_BEACON][TYPE_NOAVG] = 0; |
| 937 | priv->SNR[TYPE_BEACON][TYPE_AVG] = 0; |
| 938 | priv->NF[TYPE_BEACON][TYPE_NOAVG] = 0; |
| 939 | priv->NF[TYPE_BEACON][TYPE_AVG] = 0; |
| 940 | priv->RSSI[TYPE_BEACON][TYPE_NOAVG] = 0; |
| 941 | priv->RSSI[TYPE_BEACON][TYPE_AVG] = 0; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 942 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 943 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 944 | return 0; |
| 945 | } |
| 946 | |
Holger Schurig | e98a88d | 2008-03-19 14:25:58 +0100 | [diff] [blame] | 947 | static int lbs_cmd_reg_access(struct cmd_ds_command *cmdptr, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 948 | u8 cmd_action, void *pdata_buf) |
| 949 | { |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 950 | struct lbs_offset_value *offval; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 951 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 952 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 953 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 954 | offval = (struct lbs_offset_value *)pdata_buf; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 955 | |
Holger Schurig | c2df2ef | 2007-12-07 15:30:44 +0000 | [diff] [blame] | 956 | switch (le16_to_cpu(cmdptr->command)) { |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 957 | case CMD_MAC_REG_ACCESS: |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 958 | { |
| 959 | struct cmd_ds_mac_reg_access *macreg; |
| 960 | |
| 961 | cmdptr->size = |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 962 | cpu_to_le16(sizeof (struct cmd_ds_mac_reg_access) |
| 963 | + S_DS_GEN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 964 | macreg = |
| 965 | (struct cmd_ds_mac_reg_access *)&cmdptr->params. |
| 966 | macreg; |
| 967 | |
| 968 | macreg->action = cpu_to_le16(cmd_action); |
| 969 | macreg->offset = cpu_to_le16((u16) offval->offset); |
| 970 | macreg->value = cpu_to_le32(offval->value); |
| 971 | |
| 972 | break; |
| 973 | } |
| 974 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 975 | case CMD_BBP_REG_ACCESS: |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 976 | { |
| 977 | struct cmd_ds_bbp_reg_access *bbpreg; |
| 978 | |
| 979 | cmdptr->size = |
| 980 | cpu_to_le16(sizeof |
| 981 | (struct cmd_ds_bbp_reg_access) |
| 982 | + S_DS_GEN); |
| 983 | bbpreg = |
| 984 | (struct cmd_ds_bbp_reg_access *)&cmdptr->params. |
| 985 | bbpreg; |
| 986 | |
| 987 | bbpreg->action = cpu_to_le16(cmd_action); |
| 988 | bbpreg->offset = cpu_to_le16((u16) offval->offset); |
| 989 | bbpreg->value = (u8) offval->value; |
| 990 | |
| 991 | break; |
| 992 | } |
| 993 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 994 | case CMD_RF_REG_ACCESS: |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 995 | { |
| 996 | struct cmd_ds_rf_reg_access *rfreg; |
| 997 | |
| 998 | cmdptr->size = |
| 999 | cpu_to_le16(sizeof |
| 1000 | (struct cmd_ds_rf_reg_access) + |
| 1001 | S_DS_GEN); |
| 1002 | rfreg = |
| 1003 | (struct cmd_ds_rf_reg_access *)&cmdptr->params. |
| 1004 | rfreg; |
| 1005 | |
| 1006 | rfreg->action = cpu_to_le16(cmd_action); |
| 1007 | rfreg->offset = cpu_to_le16((u16) offval->offset); |
| 1008 | rfreg->value = (u8) offval->value; |
| 1009 | |
| 1010 | break; |
| 1011 | } |
| 1012 | |
| 1013 | default: |
| 1014 | break; |
| 1015 | } |
| 1016 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1017 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1018 | return 0; |
| 1019 | } |
| 1020 | |
Holger Schurig | e98a88d | 2008-03-19 14:25:58 +0100 | [diff] [blame] | 1021 | static int lbs_cmd_bt_access(struct cmd_ds_command *cmd, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1022 | u16 cmd_action, void *pdata_buf) |
| 1023 | { |
| 1024 | struct cmd_ds_bt_access *bt_access = &cmd->params.bt; |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1025 | lbs_deb_enter_args(LBS_DEB_CMD, "action %d", cmd_action); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1026 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1027 | cmd->command = cpu_to_le16(CMD_BT_ACCESS); |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 1028 | cmd->size = cpu_to_le16(sizeof(struct cmd_ds_bt_access) + S_DS_GEN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1029 | cmd->result = 0; |
| 1030 | bt_access->action = cpu_to_le16(cmd_action); |
| 1031 | |
| 1032 | switch (cmd_action) { |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1033 | case CMD_ACT_BT_ACCESS_ADD: |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1034 | memcpy(bt_access->addr1, pdata_buf, 2 * ETH_ALEN); |
Holger Schurig | ece5619 | 2007-08-02 11:53:06 -0400 | [diff] [blame] | 1035 | lbs_deb_hex(LBS_DEB_MESH, "BT_ADD: blinded MAC addr", bt_access->addr1, 6); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1036 | break; |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1037 | case CMD_ACT_BT_ACCESS_DEL: |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1038 | memcpy(bt_access->addr1, pdata_buf, 1 * ETH_ALEN); |
Holger Schurig | ece5619 | 2007-08-02 11:53:06 -0400 | [diff] [blame] | 1039 | lbs_deb_hex(LBS_DEB_MESH, "BT_DEL: blinded MAC addr", bt_access->addr1, 6); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1040 | break; |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1041 | case CMD_ACT_BT_ACCESS_LIST: |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1042 | bt_access->id = cpu_to_le32(*(u32 *) pdata_buf); |
| 1043 | break; |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1044 | case CMD_ACT_BT_ACCESS_RESET: |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1045 | break; |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1046 | case CMD_ACT_BT_ACCESS_SET_INVERT: |
Luis Carlos Cobo | 90e8eaf | 2007-05-25 13:53:26 -0400 | [diff] [blame] | 1047 | bt_access->id = cpu_to_le32(*(u32 *) pdata_buf); |
| 1048 | break; |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1049 | case CMD_ACT_BT_ACCESS_GET_INVERT: |
Luis Carlos Cobo | 90e8eaf | 2007-05-25 13:53:26 -0400 | [diff] [blame] | 1050 | break; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1051 | default: |
| 1052 | break; |
| 1053 | } |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1054 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1055 | return 0; |
| 1056 | } |
| 1057 | |
Holger Schurig | e98a88d | 2008-03-19 14:25:58 +0100 | [diff] [blame] | 1058 | static int lbs_cmd_fwt_access(struct cmd_ds_command *cmd, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1059 | u16 cmd_action, void *pdata_buf) |
| 1060 | { |
| 1061 | struct cmd_ds_fwt_access *fwt_access = &cmd->params.fwt; |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1062 | lbs_deb_enter_args(LBS_DEB_CMD, "action %d", cmd_action); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1063 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1064 | cmd->command = cpu_to_le16(CMD_FWT_ACCESS); |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 1065 | cmd->size = cpu_to_le16(sizeof(struct cmd_ds_fwt_access) + S_DS_GEN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1066 | cmd->result = 0; |
| 1067 | |
| 1068 | if (pdata_buf) |
| 1069 | memcpy(fwt_access, pdata_buf, sizeof(*fwt_access)); |
| 1070 | else |
| 1071 | memset(fwt_access, 0, sizeof(*fwt_access)); |
| 1072 | |
| 1073 | fwt_access->action = cpu_to_le16(cmd_action); |
| 1074 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1075 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1076 | return 0; |
| 1077 | } |
| 1078 | |
David Woodhouse | 301eacb | 2007-12-11 15:23:59 -0500 | [diff] [blame] | 1079 | int lbs_mesh_access(struct lbs_private *priv, uint16_t cmd_action, |
| 1080 | struct cmd_ds_mesh_access *cmd) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1081 | { |
David Woodhouse | 301eacb | 2007-12-11 15:23:59 -0500 | [diff] [blame] | 1082 | int ret; |
| 1083 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1084 | lbs_deb_enter_args(LBS_DEB_CMD, "action %d", cmd_action); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1085 | |
David Woodhouse | 301eacb | 2007-12-11 15:23:59 -0500 | [diff] [blame] | 1086 | cmd->hdr.command = cpu_to_le16(CMD_MESH_ACCESS); |
David Woodhouse | 9fae899 | 2007-12-15 03:46:44 -0500 | [diff] [blame] | 1087 | cmd->hdr.size = cpu_to_le16(sizeof(*cmd)); |
David Woodhouse | 301eacb | 2007-12-11 15:23:59 -0500 | [diff] [blame] | 1088 | cmd->hdr.result = 0; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1089 | |
David Woodhouse | 301eacb | 2007-12-11 15:23:59 -0500 | [diff] [blame] | 1090 | cmd->action = cpu_to_le16(cmd_action); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1091 | |
David Woodhouse | 689442d | 2007-12-12 16:00:42 -0500 | [diff] [blame] | 1092 | ret = lbs_cmd_with_response(priv, CMD_MESH_ACCESS, cmd); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1093 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1094 | lbs_deb_leave(LBS_DEB_CMD); |
David Woodhouse | 301eacb | 2007-12-11 15:23:59 -0500 | [diff] [blame] | 1095 | return ret; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1096 | } |
| 1097 | |
Brian Cavagnolo | 1556c0f | 2008-07-21 11:02:46 -0700 | [diff] [blame] | 1098 | static int __lbs_mesh_config_send(struct lbs_private *priv, |
| 1099 | struct cmd_ds_mesh_config *cmd, |
| 1100 | uint16_t action, uint16_t type) |
Javier Cardona | edaea5c | 2008-05-17 00:55:10 -0700 | [diff] [blame] | 1101 | { |
| 1102 | int ret; |
Bing Zhao | 684d6b3 | 2009-03-25 09:51:16 -0700 | [diff] [blame] | 1103 | u16 command = CMD_MESH_CONFIG_OLD; |
Javier Cardona | edaea5c | 2008-05-17 00:55:10 -0700 | [diff] [blame] | 1104 | |
| 1105 | lbs_deb_enter(LBS_DEB_CMD); |
| 1106 | |
Bing Zhao | 684d6b3 | 2009-03-25 09:51:16 -0700 | [diff] [blame] | 1107 | /* |
| 1108 | * Command id is 0xac for v10 FW along with mesh interface |
| 1109 | * id in bits 14-13-12. |
| 1110 | */ |
| 1111 | if (priv->mesh_fw_ver == MESH_FW_NEW) |
| 1112 | command = CMD_MESH_CONFIG | |
| 1113 | (MESH_IFACE_ID << MESH_IFACE_BIT_OFFSET); |
| 1114 | |
| 1115 | cmd->hdr.command = cpu_to_le16(command); |
Javier Cardona | edaea5c | 2008-05-17 00:55:10 -0700 | [diff] [blame] | 1116 | cmd->hdr.size = cpu_to_le16(sizeof(struct cmd_ds_mesh_config)); |
| 1117 | cmd->hdr.result = 0; |
| 1118 | |
| 1119 | cmd->type = cpu_to_le16(type); |
| 1120 | cmd->action = cpu_to_le16(action); |
| 1121 | |
Bing Zhao | 684d6b3 | 2009-03-25 09:51:16 -0700 | [diff] [blame] | 1122 | ret = lbs_cmd_with_response(priv, command, cmd); |
Javier Cardona | edaea5c | 2008-05-17 00:55:10 -0700 | [diff] [blame] | 1123 | |
| 1124 | lbs_deb_leave(LBS_DEB_CMD); |
| 1125 | return ret; |
| 1126 | } |
| 1127 | |
Brian Cavagnolo | 1556c0f | 2008-07-21 11:02:46 -0700 | [diff] [blame] | 1128 | int lbs_mesh_config_send(struct lbs_private *priv, |
| 1129 | struct cmd_ds_mesh_config *cmd, |
| 1130 | uint16_t action, uint16_t type) |
| 1131 | { |
| 1132 | int ret; |
| 1133 | |
| 1134 | if (!(priv->fwcapinfo & FW_CAPINFO_PERSISTENT_CONFIG)) |
| 1135 | return -EOPNOTSUPP; |
| 1136 | |
| 1137 | ret = __lbs_mesh_config_send(priv, cmd, action, type); |
| 1138 | return ret; |
| 1139 | } |
| 1140 | |
Javier Cardona | edaea5c | 2008-05-17 00:55:10 -0700 | [diff] [blame] | 1141 | /* This function is the CMD_MESH_CONFIG legacy function. It only handles the |
| 1142 | * START and STOP actions. The extended actions supported by CMD_MESH_CONFIG |
| 1143 | * are all handled by preparing a struct cmd_ds_mesh_config and passing it to |
| 1144 | * lbs_mesh_config_send. |
| 1145 | */ |
| 1146 | int lbs_mesh_config(struct lbs_private *priv, uint16_t action, uint16_t chan) |
David Woodhouse | 23a397a | 2007-12-11 18:56:42 -0500 | [diff] [blame] | 1147 | { |
| 1148 | struct cmd_ds_mesh_config cmd; |
Javier Cardona | edaea5c | 2008-05-17 00:55:10 -0700 | [diff] [blame] | 1149 | struct mrvl_meshie *ie; |
John W. Linville | 9387b7c | 2008-09-30 20:59:05 -0400 | [diff] [blame] | 1150 | DECLARE_SSID_BUF(ssid); |
David Woodhouse | 23a397a | 2007-12-11 18:56:42 -0500 | [diff] [blame] | 1151 | |
| 1152 | memset(&cmd, 0, sizeof(cmd)); |
David Woodhouse | 8606213 | 2007-12-13 00:32:36 -0500 | [diff] [blame] | 1153 | cmd.channel = cpu_to_le16(chan); |
Javier Cardona | edaea5c | 2008-05-17 00:55:10 -0700 | [diff] [blame] | 1154 | ie = (struct mrvl_meshie *)cmd.data; |
David Woodhouse | 7e22627 | 2007-12-14 22:53:41 -0500 | [diff] [blame] | 1155 | |
Javier Cardona | edaea5c | 2008-05-17 00:55:10 -0700 | [diff] [blame] | 1156 | switch (action) { |
| 1157 | case CMD_ACT_MESH_CONFIG_START: |
Johannes Berg | 2c706002 | 2008-10-30 22:09:54 +0100 | [diff] [blame] | 1158 | ie->id = WLAN_EID_GENERIC; |
Javier Cardona | edaea5c | 2008-05-17 00:55:10 -0700 | [diff] [blame] | 1159 | ie->val.oui[0] = 0x00; |
| 1160 | ie->val.oui[1] = 0x50; |
| 1161 | ie->val.oui[2] = 0x43; |
| 1162 | ie->val.type = MARVELL_MESH_IE_TYPE; |
| 1163 | ie->val.subtype = MARVELL_MESH_IE_SUBTYPE; |
| 1164 | ie->val.version = MARVELL_MESH_IE_VERSION; |
| 1165 | ie->val.active_protocol_id = MARVELL_MESH_PROTO_ID_HWMP; |
| 1166 | ie->val.active_metric_id = MARVELL_MESH_METRIC_ID; |
| 1167 | ie->val.mesh_capability = MARVELL_MESH_CAPABILITY; |
| 1168 | ie->val.mesh_id_len = priv->mesh_ssid_len; |
| 1169 | memcpy(ie->val.mesh_id, priv->mesh_ssid, priv->mesh_ssid_len); |
Johannes Berg | 2c706002 | 2008-10-30 22:09:54 +0100 | [diff] [blame] | 1170 | ie->len = sizeof(struct mrvl_meshie_val) - |
Holger Schurig | 243e84e | 2009-10-22 15:30:47 +0200 | [diff] [blame] | 1171 | IEEE80211_MAX_SSID_LEN + priv->mesh_ssid_len; |
Javier Cardona | edaea5c | 2008-05-17 00:55:10 -0700 | [diff] [blame] | 1172 | cmd.length = cpu_to_le16(sizeof(struct mrvl_meshie_val)); |
| 1173 | break; |
| 1174 | case CMD_ACT_MESH_CONFIG_STOP: |
| 1175 | break; |
| 1176 | default: |
| 1177 | return -1; |
David Woodhouse | 23a397a | 2007-12-11 18:56:42 -0500 | [diff] [blame] | 1178 | } |
Javier Cardona | edaea5c | 2008-05-17 00:55:10 -0700 | [diff] [blame] | 1179 | lbs_deb_cmd("mesh config action %d type %x channel %d SSID %s\n", |
| 1180 | action, priv->mesh_tlv, chan, |
John W. Linville | 9387b7c | 2008-09-30 20:59:05 -0400 | [diff] [blame] | 1181 | print_ssid(ssid, priv->mesh_ssid, priv->mesh_ssid_len)); |
Javier Cardona | edaea5c | 2008-05-17 00:55:10 -0700 | [diff] [blame] | 1182 | |
Brian Cavagnolo | 1556c0f | 2008-07-21 11:02:46 -0700 | [diff] [blame] | 1183 | return __lbs_mesh_config_send(priv, &cmd, action, priv->mesh_tlv); |
David Woodhouse | 23a397a | 2007-12-11 18:56:42 -0500 | [diff] [blame] | 1184 | } |
| 1185 | |
Brajesh Dave | 96287ac | 2007-11-20 17:44:28 -0500 | [diff] [blame] | 1186 | static int lbs_cmd_bcn_ctrl(struct lbs_private * priv, |
| 1187 | struct cmd_ds_command *cmd, |
| 1188 | u16 cmd_action) |
| 1189 | { |
| 1190 | struct cmd_ds_802_11_beacon_control |
| 1191 | *bcn_ctrl = &cmd->params.bcn_ctrl; |
Brajesh Dave | 96287ac | 2007-11-20 17:44:28 -0500 | [diff] [blame] | 1192 | |
| 1193 | lbs_deb_enter(LBS_DEB_CMD); |
| 1194 | cmd->size = |
| 1195 | cpu_to_le16(sizeof(struct cmd_ds_802_11_beacon_control) |
| 1196 | + S_DS_GEN); |
| 1197 | cmd->command = cpu_to_le16(CMD_802_11_BEACON_CTRL); |
| 1198 | |
| 1199 | bcn_ctrl->action = cpu_to_le16(cmd_action); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1200 | bcn_ctrl->beacon_enable = cpu_to_le16(priv->beacon_enable); |
| 1201 | bcn_ctrl->beacon_period = cpu_to_le16(priv->beacon_period); |
Brajesh Dave | 96287ac | 2007-11-20 17:44:28 -0500 | [diff] [blame] | 1202 | |
| 1203 | lbs_deb_leave(LBS_DEB_CMD); |
| 1204 | return 0; |
| 1205 | } |
| 1206 | |
David Woodhouse | 681ffbb | 2007-12-15 20:04:54 -0500 | [diff] [blame] | 1207 | static void lbs_queue_cmd(struct lbs_private *priv, |
| 1208 | struct cmd_ctrl_node *cmdnode) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1209 | { |
| 1210 | unsigned long flags; |
David Woodhouse | 681ffbb | 2007-12-15 20:04:54 -0500 | [diff] [blame] | 1211 | int addtail = 1; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1212 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1213 | lbs_deb_enter(LBS_DEB_HOST); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1214 | |
David Woodhouse | c4ab412 | 2007-12-15 00:41:51 -0500 | [diff] [blame] | 1215 | if (!cmdnode) { |
| 1216 | lbs_deb_host("QUEUE_CMD: cmdnode is NULL\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1217 | goto done; |
| 1218 | } |
David Woodhouse | d9896ee | 2007-12-15 00:09:25 -0500 | [diff] [blame] | 1219 | if (!cmdnode->cmdbuf->size) { |
| 1220 | lbs_deb_host("DNLD_CMD: cmd size is zero\n"); |
| 1221 | goto done; |
| 1222 | } |
David Woodhouse | ae125bf | 2007-12-15 04:22:52 -0500 | [diff] [blame] | 1223 | cmdnode->result = 0; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1224 | |
| 1225 | /* Exit_PS command needs to be queued in the header always. */ |
Dan Williams | ddac452 | 2007-12-11 13:49:39 -0500 | [diff] [blame] | 1226 | if (le16_to_cpu(cmdnode->cmdbuf->command) == CMD_802_11_PS_MODE) { |
David Woodhouse | 38bfab1 | 2007-12-16 23:26:54 -0500 | [diff] [blame] | 1227 | struct cmd_ds_802_11_ps_mode *psm = (void *) &cmdnode->cmdbuf[1]; |
Dan Williams | ddac452 | 2007-12-11 13:49:39 -0500 | [diff] [blame] | 1228 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1229 | if (psm->action == cpu_to_le16(CMD_SUBCMD_EXIT_PS)) { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1230 | if (priv->psstate != PS_STATE_FULL_POWER) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1231 | addtail = 0; |
| 1232 | } |
| 1233 | } |
| 1234 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1235 | spin_lock_irqsave(&priv->driver_lock, flags); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1236 | |
David Woodhouse | ac47246 | 2007-12-08 00:35:00 +0000 | [diff] [blame] | 1237 | if (addtail) |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1238 | list_add_tail(&cmdnode->list, &priv->cmdpendingq); |
David Woodhouse | ac47246 | 2007-12-08 00:35:00 +0000 | [diff] [blame] | 1239 | else |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1240 | list_add(&cmdnode->list, &priv->cmdpendingq); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1241 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1242 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1243 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1244 | lbs_deb_host("QUEUE_CMD: inserted command 0x%04x into cmdpendingq\n", |
David Woodhouse | c4ab412 | 2007-12-15 00:41:51 -0500 | [diff] [blame] | 1245 | le16_to_cpu(cmdnode->cmdbuf->command)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1246 | |
| 1247 | done: |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1248 | lbs_deb_leave(LBS_DEB_HOST); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1249 | } |
| 1250 | |
David Woodhouse | 18c52e7 | 2007-12-17 16:03:58 -0500 | [diff] [blame] | 1251 | static void lbs_submit_command(struct lbs_private *priv, |
| 1252 | struct cmd_ctrl_node *cmdnode) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1253 | { |
| 1254 | unsigned long flags; |
Dan Williams | ddac452 | 2007-12-11 13:49:39 -0500 | [diff] [blame] | 1255 | struct cmd_header *cmd; |
David Woodhouse | 18c52e7 | 2007-12-17 16:03:58 -0500 | [diff] [blame] | 1256 | uint16_t cmdsize; |
| 1257 | uint16_t command; |
Holger Schurig | 57962f0 | 2008-05-14 16:30:28 +0200 | [diff] [blame] | 1258 | int timeo = 3 * HZ; |
David Woodhouse | 18c52e7 | 2007-12-17 16:03:58 -0500 | [diff] [blame] | 1259 | int ret; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1260 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1261 | lbs_deb_enter(LBS_DEB_HOST); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1262 | |
Dan Williams | ddac452 | 2007-12-11 13:49:39 -0500 | [diff] [blame] | 1263 | cmd = cmdnode->cmdbuf; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1264 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1265 | spin_lock_irqsave(&priv->driver_lock, flags); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1266 | priv->cur_cmd = cmdnode; |
| 1267 | priv->cur_cmd_retcode = 0; |
| 1268 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1269 | |
Dan Williams | ddac452 | 2007-12-11 13:49:39 -0500 | [diff] [blame] | 1270 | cmdsize = le16_to_cpu(cmd->size); |
| 1271 | command = le16_to_cpu(cmd->command); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1272 | |
David Woodhouse | 18c52e7 | 2007-12-17 16:03:58 -0500 | [diff] [blame] | 1273 | /* These commands take longer */ |
Dan Williams | be0d76e | 2009-05-22 20:05:25 -0400 | [diff] [blame] | 1274 | if (command == CMD_802_11_SCAN || command == CMD_802_11_ASSOCIATE) |
Holger Schurig | 57962f0 | 2008-05-14 16:30:28 +0200 | [diff] [blame] | 1275 | timeo = 5 * HZ; |
David Woodhouse | 18c52e7 | 2007-12-17 16:03:58 -0500 | [diff] [blame] | 1276 | |
Holger Schurig | e5225b3 | 2008-03-26 10:04:44 +0100 | [diff] [blame] | 1277 | lbs_deb_cmd("DNLD_CMD: command 0x%04x, seq %d, size %d\n", |
| 1278 | command, le16_to_cpu(cmd->seqnum), cmdsize); |
Holger Schurig | 1afc09ab | 2008-01-29 09:14:40 +0100 | [diff] [blame] | 1279 | lbs_deb_hex(LBS_DEB_CMD, "DNLD_CMD", (void *) cmdnode->cmdbuf, cmdsize); |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1280 | |
Dan Williams | ddac452 | 2007-12-11 13:49:39 -0500 | [diff] [blame] | 1281 | ret = priv->hw_host_to_card(priv, MVMS_CMD, (u8 *) cmd, cmdsize); |
David Woodhouse | 18c52e7 | 2007-12-17 16:03:58 -0500 | [diff] [blame] | 1282 | |
David Woodhouse | d9896ee | 2007-12-15 00:09:25 -0500 | [diff] [blame] | 1283 | if (ret) { |
| 1284 | lbs_pr_info("DNLD_CMD: hw_host_to_card failed: %d\n", ret); |
David Woodhouse | 18c52e7 | 2007-12-17 16:03:58 -0500 | [diff] [blame] | 1285 | /* Let the timer kick in and retry, and potentially reset |
| 1286 | the whole thing if the condition persists */ |
Holger Schurig | 57962f0 | 2008-05-14 16:30:28 +0200 | [diff] [blame] | 1287 | timeo = HZ/4; |
Holger Schurig | 1afc09ab | 2008-01-29 09:14:40 +0100 | [diff] [blame] | 1288 | } |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1289 | |
Amitkumar Karwar | 4912545 | 2009-09-30 20:04:38 -0700 | [diff] [blame] | 1290 | if (command == CMD_802_11_DEEP_SLEEP) { |
| 1291 | if (priv->is_auto_deep_sleep_enabled) { |
| 1292 | priv->wakeup_dev_required = 1; |
| 1293 | priv->dnld_sent = 0; |
| 1294 | } |
| 1295 | priv->is_deep_sleep = 1; |
| 1296 | lbs_complete_command(priv, cmdnode, 0); |
| 1297 | } else { |
| 1298 | /* Setup the timer after transmit command */ |
| 1299 | mod_timer(&priv->command_timer, jiffies + timeo); |
| 1300 | } |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1301 | |
David Woodhouse | 18c52e7 | 2007-12-17 16:03:58 -0500 | [diff] [blame] | 1302 | lbs_deb_leave(LBS_DEB_HOST); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1303 | } |
| 1304 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1305 | /** |
| 1306 | * This function inserts command node to cmdfreeq |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1307 | * after cleans it. Requires priv->driver_lock held. |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1308 | */ |
David Woodhouse | 183aeac | 2007-12-15 01:52:54 -0500 | [diff] [blame] | 1309 | static void __lbs_cleanup_and_insert_cmd(struct lbs_private *priv, |
David Woodhouse | 5ba2f8a | 2007-12-15 02:02:56 -0500 | [diff] [blame] | 1310 | struct cmd_ctrl_node *cmdnode) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1311 | { |
David Woodhouse | 5ba2f8a | 2007-12-15 02:02:56 -0500 | [diff] [blame] | 1312 | lbs_deb_enter(LBS_DEB_HOST); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1313 | |
David Woodhouse | 5ba2f8a | 2007-12-15 02:02:56 -0500 | [diff] [blame] | 1314 | if (!cmdnode) |
| 1315 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1316 | |
David Woodhouse | 5ba2f8a | 2007-12-15 02:02:56 -0500 | [diff] [blame] | 1317 | cmdnode->callback = NULL; |
| 1318 | cmdnode->callback_arg = 0; |
| 1319 | |
| 1320 | memset(cmdnode->cmdbuf, 0, LBS_CMD_BUFFER_SIZE); |
| 1321 | |
| 1322 | list_add_tail(&cmdnode->list, &priv->cmdfreeq); |
| 1323 | out: |
| 1324 | lbs_deb_leave(LBS_DEB_HOST); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1325 | } |
| 1326 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1327 | static void lbs_cleanup_and_insert_cmd(struct lbs_private *priv, |
| 1328 | struct cmd_ctrl_node *ptempcmd) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1329 | { |
| 1330 | unsigned long flags; |
| 1331 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1332 | spin_lock_irqsave(&priv->driver_lock, flags); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1333 | __lbs_cleanup_and_insert_cmd(priv, ptempcmd); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1334 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1335 | } |
| 1336 | |
David Woodhouse | 183aeac | 2007-12-15 01:52:54 -0500 | [diff] [blame] | 1337 | void lbs_complete_command(struct lbs_private *priv, struct cmd_ctrl_node *cmd, |
| 1338 | int result) |
| 1339 | { |
| 1340 | if (cmd == priv->cur_cmd) |
| 1341 | priv->cur_cmd_retcode = result; |
David Woodhouse | 5ba2f8a | 2007-12-15 02:02:56 -0500 | [diff] [blame] | 1342 | |
David Woodhouse | ae125bf | 2007-12-15 04:22:52 -0500 | [diff] [blame] | 1343 | cmd->result = result; |
David Woodhouse | 5ba2f8a | 2007-12-15 02:02:56 -0500 | [diff] [blame] | 1344 | cmd->cmdwaitqwoken = 1; |
| 1345 | wake_up_interruptible(&cmd->cmdwait_q); |
| 1346 | |
Holger Schurig | 8db4a2b | 2008-03-19 10:11:00 +0100 | [diff] [blame] | 1347 | if (!cmd->callback || cmd->callback == lbs_cmd_async_callback) |
David Woodhouse | ad12d0f | 2007-12-15 02:06:16 -0500 | [diff] [blame] | 1348 | __lbs_cleanup_and_insert_cmd(priv, cmd); |
David Woodhouse | 183aeac | 2007-12-15 01:52:54 -0500 | [diff] [blame] | 1349 | priv->cur_cmd = NULL; |
| 1350 | } |
| 1351 | |
Dan Williams | d5db2df | 2008-08-21 17:51:07 -0400 | [diff] [blame] | 1352 | int lbs_set_radio(struct lbs_private *priv, u8 preamble, u8 radio_on) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1353 | { |
David Woodhouse | a7c4589 | 2007-12-17 22:43:48 -0500 | [diff] [blame] | 1354 | struct cmd_ds_802_11_radio_control cmd; |
Dan Williams | d5db2df | 2008-08-21 17:51:07 -0400 | [diff] [blame] | 1355 | int ret = -EINVAL; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1356 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1357 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1358 | |
David Woodhouse | a7c4589 | 2007-12-17 22:43:48 -0500 | [diff] [blame] | 1359 | cmd.hdr.size = cpu_to_le16(sizeof(cmd)); |
| 1360 | cmd.action = cpu_to_le16(CMD_ACT_SET); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1361 | |
Dan Williams | d5db2df | 2008-08-21 17:51:07 -0400 | [diff] [blame] | 1362 | /* Only v8 and below support setting the preamble */ |
| 1363 | if (priv->fwrelease < 0x09000000) { |
| 1364 | switch (preamble) { |
| 1365 | case RADIO_PREAMBLE_SHORT: |
| 1366 | if (!(priv->capability & WLAN_CAPABILITY_SHORT_PREAMBLE)) |
| 1367 | goto out; |
| 1368 | /* Fall through */ |
| 1369 | case RADIO_PREAMBLE_AUTO: |
| 1370 | case RADIO_PREAMBLE_LONG: |
| 1371 | cmd.control = cpu_to_le16(preamble); |
| 1372 | break; |
| 1373 | default: |
| 1374 | goto out; |
| 1375 | } |
David Woodhouse | a7c4589 | 2007-12-17 22:43:48 -0500 | [diff] [blame] | 1376 | } |
| 1377 | |
Dan Williams | d5db2df | 2008-08-21 17:51:07 -0400 | [diff] [blame] | 1378 | if (radio_on) |
| 1379 | cmd.control |= cpu_to_le16(0x1); |
| 1380 | else { |
| 1381 | cmd.control &= cpu_to_le16(~0x1); |
| 1382 | priv->txpower_cur = 0; |
| 1383 | } |
David Woodhouse | a7c4589 | 2007-12-17 22:43:48 -0500 | [diff] [blame] | 1384 | |
Dan Williams | d5db2df | 2008-08-21 17:51:07 -0400 | [diff] [blame] | 1385 | lbs_deb_cmd("RADIO_CONTROL: radio %s, preamble %d\n", |
| 1386 | radio_on ? "ON" : "OFF", preamble); |
| 1387 | |
| 1388 | priv->radio_on = radio_on; |
David Woodhouse | a7c4589 | 2007-12-17 22:43:48 -0500 | [diff] [blame] | 1389 | |
| 1390 | ret = lbs_cmd_with_response(priv, CMD_802_11_RADIO_CONTROL, &cmd); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1391 | |
Dan Williams | d5db2df | 2008-08-21 17:51:07 -0400 | [diff] [blame] | 1392 | out: |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1393 | lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1394 | return ret; |
| 1395 | } |
| 1396 | |
Holger Schurig | c97329e | 2008-03-18 11:20:21 +0100 | [diff] [blame] | 1397 | void lbs_set_mac_control(struct lbs_private *priv) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1398 | { |
Holger Schurig | 835d3ac | 2008-03-12 16:05:40 +0100 | [diff] [blame] | 1399 | struct cmd_ds_mac_control cmd; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1400 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1401 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1402 | |
Holger Schurig | 835d3ac | 2008-03-12 16:05:40 +0100 | [diff] [blame] | 1403 | cmd.hdr.size = cpu_to_le16(sizeof(cmd)); |
Holger Schurig | d9e9778 | 2008-03-12 16:06:43 +0100 | [diff] [blame] | 1404 | cmd.action = cpu_to_le16(priv->mac_control); |
Holger Schurig | 835d3ac | 2008-03-12 16:05:40 +0100 | [diff] [blame] | 1405 | cmd.reserved = 0; |
| 1406 | |
David Woodhouse | 75bf45a | 2008-05-20 13:32:45 +0100 | [diff] [blame] | 1407 | lbs_cmd_async(priv, CMD_MAC_CONTROL, &cmd.hdr, sizeof(cmd)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1408 | |
Holger Schurig | c97329e | 2008-03-18 11:20:21 +0100 | [diff] [blame] | 1409 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1410 | } |
| 1411 | |
| 1412 | /** |
| 1413 | * @brief This function prepare the command before send to firmware. |
| 1414 | * |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1415 | * @param priv A pointer to struct lbs_private structure |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1416 | * @param cmd_no command number |
| 1417 | * @param cmd_action command action: GET or SET |
| 1418 | * @param wait_option wait option: wait response or not |
| 1419 | * @param cmd_oid cmd oid: treated as sub command |
| 1420 | * @param pdata_buf A pointer to informaion buffer |
| 1421 | * @return 0 or -1 |
| 1422 | */ |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1423 | int lbs_prepare_and_send_command(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1424 | u16 cmd_no, |
| 1425 | u16 cmd_action, |
| 1426 | u16 wait_option, u32 cmd_oid, void *pdata_buf) |
| 1427 | { |
| 1428 | int ret = 0; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1429 | struct cmd_ctrl_node *cmdnode; |
| 1430 | struct cmd_ds_command *cmdptr; |
| 1431 | unsigned long flags; |
| 1432 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1433 | lbs_deb_enter(LBS_DEB_HOST); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1434 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1435 | if (!priv) { |
| 1436 | lbs_deb_host("PREP_CMD: priv is NULL\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1437 | ret = -1; |
| 1438 | goto done; |
| 1439 | } |
| 1440 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1441 | if (priv->surpriseremoved) { |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1442 | lbs_deb_host("PREP_CMD: card removed\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1443 | ret = -1; |
| 1444 | goto done; |
| 1445 | } |
| 1446 | |
Amitkumar Karwar | 63f275d | 2009-10-06 19:20:28 -0700 | [diff] [blame] | 1447 | if (!lbs_is_cmd_allowed(priv)) { |
| 1448 | ret = -EBUSY; |
| 1449 | goto done; |
| 1450 | } |
| 1451 | |
Holger Schurig | 0d61d04 | 2007-12-05 17:58:06 +0100 | [diff] [blame] | 1452 | cmdnode = lbs_get_cmd_ctrl_node(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1453 | |
| 1454 | if (cmdnode == NULL) { |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1455 | lbs_deb_host("PREP_CMD: cmdnode is NULL\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1456 | |
| 1457 | /* Wake up main thread to execute next command */ |
Dan Williams | fe33615 | 2007-08-02 11:32:25 -0400 | [diff] [blame] | 1458 | wake_up_interruptible(&priv->waitq); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1459 | ret = -1; |
| 1460 | goto done; |
| 1461 | } |
| 1462 | |
Holger Schurig | e98a88d | 2008-03-19 14:25:58 +0100 | [diff] [blame] | 1463 | cmdnode->callback = NULL; |
| 1464 | cmdnode->callback_arg = (unsigned long)pdata_buf; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1465 | |
Dan Williams | ddac452 | 2007-12-11 13:49:39 -0500 | [diff] [blame] | 1466 | cmdptr = (struct cmd_ds_command *)cmdnode->cmdbuf; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1467 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1468 | lbs_deb_host("PREP_CMD: command 0x%04x\n", cmd_no); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1469 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1470 | /* Set sequence number, command and INT option */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1471 | priv->seqnum++; |
| 1472 | cmdptr->seqnum = cpu_to_le16(priv->seqnum); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1473 | |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 1474 | cmdptr->command = cpu_to_le16(cmd_no); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1475 | cmdptr->result = 0; |
| 1476 | |
| 1477 | switch (cmd_no) { |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1478 | case CMD_802_11_PS_MODE: |
Holger Schurig | e98a88d | 2008-03-19 14:25:58 +0100 | [diff] [blame] | 1479 | ret = lbs_cmd_802_11_ps_mode(cmdptr, cmd_action); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1480 | break; |
| 1481 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1482 | case CMD_MAC_REG_ACCESS: |
| 1483 | case CMD_BBP_REG_ACCESS: |
| 1484 | case CMD_RF_REG_ACCESS: |
Holger Schurig | e98a88d | 2008-03-19 14:25:58 +0100 | [diff] [blame] | 1485 | ret = lbs_cmd_reg_access(cmdptr, cmd_action, pdata_buf); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1486 | break; |
| 1487 | |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 1488 | case CMD_802_11_MONITOR_MODE: |
Holger Schurig | e98a88d | 2008-03-19 14:25:58 +0100 | [diff] [blame] | 1489 | ret = lbs_cmd_802_11_monitor_mode(cmdptr, |
Luis Carlos Cobo | 965f8bbc | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 1490 | cmd_action, pdata_buf); |
| 1491 | break; |
| 1492 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1493 | case CMD_802_11_RSSI: |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1494 | ret = lbs_cmd_802_11_rssi(priv, cmdptr); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1495 | break; |
| 1496 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1497 | case CMD_802_11_SET_AFC: |
| 1498 | case CMD_802_11_GET_AFC: |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1499 | |
| 1500 | cmdptr->command = cpu_to_le16(cmd_no); |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 1501 | cmdptr->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_afc) + |
| 1502 | S_DS_GEN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1503 | |
| 1504 | memmove(&cmdptr->params.afc, |
| 1505 | pdata_buf, sizeof(struct cmd_ds_802_11_afc)); |
| 1506 | |
| 1507 | ret = 0; |
| 1508 | goto done; |
| 1509 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1510 | case CMD_802_11_TPC_CFG: |
| 1511 | cmdptr->command = cpu_to_le16(CMD_802_11_TPC_CFG); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1512 | cmdptr->size = |
| 1513 | cpu_to_le16(sizeof(struct cmd_ds_802_11_tpc_cfg) + |
| 1514 | S_DS_GEN); |
| 1515 | |
| 1516 | memmove(&cmdptr->params.tpccfg, |
| 1517 | pdata_buf, sizeof(struct cmd_ds_802_11_tpc_cfg)); |
| 1518 | |
| 1519 | ret = 0; |
| 1520 | break; |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1521 | case CMD_802_11_LED_GPIO_CTRL: |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1522 | { |
Dan Williams | 75b6a61 | 2009-05-22 20:03:09 -0400 | [diff] [blame] | 1523 | struct mrvl_ie_ledgpio *gpio = |
| 1524 | (struct mrvl_ie_ledgpio*) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1525 | cmdptr->params.ledgpio.data; |
| 1526 | |
| 1527 | memmove(&cmdptr->params.ledgpio, |
| 1528 | pdata_buf, |
| 1529 | sizeof(struct cmd_ds_802_11_led_ctrl)); |
| 1530 | |
| 1531 | cmdptr->command = |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1532 | cpu_to_le16(CMD_802_11_LED_GPIO_CTRL); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1533 | |
| 1534 | #define ACTION_NUMLED_TLVTYPE_LEN_FIELDS_LEN 8 |
| 1535 | cmdptr->size = |
Holger Schurig | c2df2ef | 2007-12-07 15:30:44 +0000 | [diff] [blame] | 1536 | cpu_to_le16(le16_to_cpu(gpio->header.len) |
| 1537 | + S_DS_GEN |
| 1538 | + ACTION_NUMLED_TLVTYPE_LEN_FIELDS_LEN); |
| 1539 | gpio->header.len = gpio->header.len; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1540 | |
| 1541 | ret = 0; |
| 1542 | break; |
| 1543 | } |
David Woodhouse | 5844d12 | 2007-12-18 02:01:37 -0500 | [diff] [blame] | 1544 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1545 | case CMD_BT_ACCESS: |
Holger Schurig | e98a88d | 2008-03-19 14:25:58 +0100 | [diff] [blame] | 1546 | ret = lbs_cmd_bt_access(cmdptr, cmd_action, pdata_buf); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1547 | break; |
| 1548 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1549 | case CMD_FWT_ACCESS: |
Holger Schurig | e98a88d | 2008-03-19 14:25:58 +0100 | [diff] [blame] | 1550 | ret = lbs_cmd_fwt_access(cmdptr, cmd_action, pdata_buf); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1551 | break; |
| 1552 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1553 | case CMD_GET_TSF: |
| 1554 | cmdptr->command = cpu_to_le16(CMD_GET_TSF); |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 1555 | cmdptr->size = cpu_to_le16(sizeof(struct cmd_ds_get_tsf) + |
| 1556 | S_DS_GEN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1557 | ret = 0; |
| 1558 | break; |
Brajesh Dave | 96287ac | 2007-11-20 17:44:28 -0500 | [diff] [blame] | 1559 | case CMD_802_11_BEACON_CTRL: |
| 1560 | ret = lbs_cmd_bcn_ctrl(priv, cmdptr, cmd_action); |
| 1561 | break; |
Amitkumar Karwar | 4912545 | 2009-09-30 20:04:38 -0700 | [diff] [blame] | 1562 | case CMD_802_11_DEEP_SLEEP: |
| 1563 | cmdptr->command = cpu_to_le16(CMD_802_11_DEEP_SLEEP); |
| 1564 | cmdptr->size = cpu_to_le16(S_DS_GEN); |
| 1565 | break; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1566 | default: |
David Woodhouse | e37fc6e | 2008-05-20 11:47:16 +0100 | [diff] [blame] | 1567 | lbs_pr_err("PREP_CMD: unknown command 0x%04x\n", cmd_no); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1568 | ret = -1; |
| 1569 | break; |
| 1570 | } |
| 1571 | |
| 1572 | /* return error, since the command preparation failed */ |
| 1573 | if (ret != 0) { |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1574 | lbs_deb_host("PREP_CMD: command preparation failed\n"); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1575 | lbs_cleanup_and_insert_cmd(priv, cmdnode); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1576 | ret = -1; |
| 1577 | goto done; |
| 1578 | } |
| 1579 | |
| 1580 | cmdnode->cmdwaitqwoken = 0; |
| 1581 | |
David Woodhouse | 681ffbb | 2007-12-15 20:04:54 -0500 | [diff] [blame] | 1582 | lbs_queue_cmd(priv, cmdnode); |
Dan Williams | fe33615 | 2007-08-02 11:32:25 -0400 | [diff] [blame] | 1583 | wake_up_interruptible(&priv->waitq); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1584 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1585 | if (wait_option & CMD_OPTION_WAITFORRSP) { |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1586 | lbs_deb_host("PREP_CMD: wait for response\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1587 | might_sleep(); |
| 1588 | wait_event_interruptible(cmdnode->cmdwait_q, |
| 1589 | cmdnode->cmdwaitqwoken); |
| 1590 | } |
| 1591 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1592 | spin_lock_irqsave(&priv->driver_lock, flags); |
| 1593 | if (priv->cur_cmd_retcode) { |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1594 | lbs_deb_host("PREP_CMD: command failed with return code %d\n", |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1595 | priv->cur_cmd_retcode); |
| 1596 | priv->cur_cmd_retcode = 0; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1597 | ret = -1; |
| 1598 | } |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1599 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1600 | |
| 1601 | done: |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1602 | lbs_deb_leave_args(LBS_DEB_HOST, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1603 | return ret; |
| 1604 | } |
| 1605 | |
| 1606 | /** |
| 1607 | * @brief This function allocates the command buffer and link |
| 1608 | * it to command free queue. |
| 1609 | * |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1610 | * @param priv A pointer to struct lbs_private structure |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1611 | * @return 0 or -1 |
| 1612 | */ |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1613 | int lbs_allocate_cmd_buffer(struct lbs_private *priv) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1614 | { |
| 1615 | int ret = 0; |
Dan Williams | ddac452 | 2007-12-11 13:49:39 -0500 | [diff] [blame] | 1616 | u32 bufsize; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1617 | u32 i; |
Dan Williams | ddac452 | 2007-12-11 13:49:39 -0500 | [diff] [blame] | 1618 | struct cmd_ctrl_node *cmdarray; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1619 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1620 | lbs_deb_enter(LBS_DEB_HOST); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1621 | |
Dan Williams | ddac452 | 2007-12-11 13:49:39 -0500 | [diff] [blame] | 1622 | /* Allocate and initialize the command array */ |
| 1623 | bufsize = sizeof(struct cmd_ctrl_node) * LBS_NUM_CMD_BUFFERS; |
| 1624 | if (!(cmdarray = kzalloc(bufsize, GFP_KERNEL))) { |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1625 | lbs_deb_host("ALLOC_CMD_BUF: tempcmd_array is NULL\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1626 | ret = -1; |
| 1627 | goto done; |
| 1628 | } |
Dan Williams | ddac452 | 2007-12-11 13:49:39 -0500 | [diff] [blame] | 1629 | priv->cmd_array = cmdarray; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1630 | |
Dan Williams | ddac452 | 2007-12-11 13:49:39 -0500 | [diff] [blame] | 1631 | /* Allocate and initialize each command buffer in the command array */ |
| 1632 | for (i = 0; i < LBS_NUM_CMD_BUFFERS; i++) { |
| 1633 | cmdarray[i].cmdbuf = kzalloc(LBS_CMD_BUFFER_SIZE, GFP_KERNEL); |
| 1634 | if (!cmdarray[i].cmdbuf) { |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1635 | lbs_deb_host("ALLOC_CMD_BUF: ptempvirtualaddr is NULL\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1636 | ret = -1; |
| 1637 | goto done; |
| 1638 | } |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1639 | } |
| 1640 | |
Dan Williams | ddac452 | 2007-12-11 13:49:39 -0500 | [diff] [blame] | 1641 | for (i = 0; i < LBS_NUM_CMD_BUFFERS; i++) { |
| 1642 | init_waitqueue_head(&cmdarray[i].cmdwait_q); |
| 1643 | lbs_cleanup_and_insert_cmd(priv, &cmdarray[i]); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1644 | } |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1645 | ret = 0; |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1646 | |
| 1647 | done: |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1648 | lbs_deb_leave_args(LBS_DEB_HOST, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1649 | return ret; |
| 1650 | } |
| 1651 | |
| 1652 | /** |
| 1653 | * @brief This function frees the command buffer. |
| 1654 | * |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1655 | * @param priv A pointer to struct lbs_private structure |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1656 | * @return 0 or -1 |
| 1657 | */ |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1658 | int lbs_free_cmd_buffer(struct lbs_private *priv) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1659 | { |
Dan Williams | ddac452 | 2007-12-11 13:49:39 -0500 | [diff] [blame] | 1660 | struct cmd_ctrl_node *cmdarray; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1661 | unsigned int i; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1662 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1663 | lbs_deb_enter(LBS_DEB_HOST); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1664 | |
| 1665 | /* need to check if cmd array is allocated or not */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1666 | if (priv->cmd_array == NULL) { |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1667 | lbs_deb_host("FREE_CMD_BUF: cmd_array is NULL\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1668 | goto done; |
| 1669 | } |
| 1670 | |
Dan Williams | ddac452 | 2007-12-11 13:49:39 -0500 | [diff] [blame] | 1671 | cmdarray = priv->cmd_array; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1672 | |
| 1673 | /* Release shared memory buffers */ |
Dan Williams | ddac452 | 2007-12-11 13:49:39 -0500 | [diff] [blame] | 1674 | for (i = 0; i < LBS_NUM_CMD_BUFFERS; i++) { |
| 1675 | if (cmdarray[i].cmdbuf) { |
| 1676 | kfree(cmdarray[i].cmdbuf); |
| 1677 | cmdarray[i].cmdbuf = NULL; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1678 | } |
| 1679 | } |
| 1680 | |
| 1681 | /* Release cmd_ctrl_node */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1682 | if (priv->cmd_array) { |
| 1683 | kfree(priv->cmd_array); |
| 1684 | priv->cmd_array = NULL; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1685 | } |
| 1686 | |
| 1687 | done: |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1688 | lbs_deb_leave(LBS_DEB_HOST); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1689 | return 0; |
| 1690 | } |
| 1691 | |
| 1692 | /** |
| 1693 | * @brief This function gets a free command node if available in |
| 1694 | * command free queue. |
| 1695 | * |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1696 | * @param priv A pointer to struct lbs_private structure |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1697 | * @return cmd_ctrl_node A pointer to cmd_ctrl_node structure or NULL |
| 1698 | */ |
David Woodhouse | 2fd6cfe | 2007-12-11 17:44:10 -0500 | [diff] [blame] | 1699 | static struct cmd_ctrl_node *lbs_get_cmd_ctrl_node(struct lbs_private *priv) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1700 | { |
| 1701 | struct cmd_ctrl_node *tempnode; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1702 | unsigned long flags; |
| 1703 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1704 | lbs_deb_enter(LBS_DEB_HOST); |
| 1705 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1706 | if (!priv) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1707 | return NULL; |
| 1708 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1709 | spin_lock_irqsave(&priv->driver_lock, flags); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1710 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1711 | if (!list_empty(&priv->cmdfreeq)) { |
| 1712 | tempnode = list_first_entry(&priv->cmdfreeq, |
Li Zefan | abe3ed1 | 2007-12-06 13:01:21 +0100 | [diff] [blame] | 1713 | struct cmd_ctrl_node, list); |
| 1714 | list_del(&tempnode->list); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1715 | } else { |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1716 | lbs_deb_host("GET_CMD_NODE: cmd_ctrl_node is not available\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1717 | tempnode = NULL; |
| 1718 | } |
| 1719 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1720 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1721 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1722 | lbs_deb_leave(LBS_DEB_HOST); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1723 | return tempnode; |
| 1724 | } |
| 1725 | |
| 1726 | /** |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1727 | * @brief This function executes next command in command |
Nick Andrew | 877d031 | 2009-01-26 11:06:57 +0100 | [diff] [blame] | 1728 | * pending queue. It will put firmware back to PS mode |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1729 | * if applicable. |
| 1730 | * |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1731 | * @param priv A pointer to struct lbs_private structure |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1732 | * @return 0 or -1 |
| 1733 | */ |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1734 | int lbs_execute_next_command(struct lbs_private *priv) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1735 | { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1736 | struct cmd_ctrl_node *cmdnode = NULL; |
Dan Williams | ddac452 | 2007-12-11 13:49:39 -0500 | [diff] [blame] | 1737 | struct cmd_header *cmd; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1738 | unsigned long flags; |
| 1739 | int ret = 0; |
| 1740 | |
Holger Schurig | 1afc09ab | 2008-01-29 09:14:40 +0100 | [diff] [blame] | 1741 | /* Debug group is LBS_DEB_THREAD and not LBS_DEB_HOST, because the |
| 1742 | * only caller to us is lbs_thread() and we get even when a |
| 1743 | * data packet is received */ |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1744 | lbs_deb_enter(LBS_DEB_THREAD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1745 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1746 | spin_lock_irqsave(&priv->driver_lock, flags); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1747 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1748 | if (priv->cur_cmd) { |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1749 | lbs_pr_alert( "EXEC_NEXT_CMD: already processing command!\n"); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1750 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1751 | ret = -1; |
| 1752 | goto done; |
| 1753 | } |
| 1754 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1755 | if (!list_empty(&priv->cmdpendingq)) { |
| 1756 | cmdnode = list_first_entry(&priv->cmdpendingq, |
Li Zefan | abe3ed1 | 2007-12-06 13:01:21 +0100 | [diff] [blame] | 1757 | struct cmd_ctrl_node, list); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1758 | } |
| 1759 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1760 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1761 | |
| 1762 | if (cmdnode) { |
Dan Williams | ddac452 | 2007-12-11 13:49:39 -0500 | [diff] [blame] | 1763 | cmd = cmdnode->cmdbuf; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1764 | |
Dan Williams | ddac452 | 2007-12-11 13:49:39 -0500 | [diff] [blame] | 1765 | if (is_command_allowed_in_ps(le16_to_cpu(cmd->command))) { |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1766 | if ((priv->psstate == PS_STATE_SLEEP) || |
| 1767 | (priv->psstate == PS_STATE_PRE_SLEEP)) { |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1768 | lbs_deb_host( |
| 1769 | "EXEC_NEXT_CMD: cannot send cmd 0x%04x in psstate %d\n", |
Dan Williams | ddac452 | 2007-12-11 13:49:39 -0500 | [diff] [blame] | 1770 | le16_to_cpu(cmd->command), |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1771 | priv->psstate); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1772 | ret = -1; |
| 1773 | goto done; |
| 1774 | } |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1775 | lbs_deb_host("EXEC_NEXT_CMD: OK to send command " |
Dan Williams | ddac452 | 2007-12-11 13:49:39 -0500 | [diff] [blame] | 1776 | "0x%04x in psstate %d\n", |
| 1777 | le16_to_cpu(cmd->command), priv->psstate); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1778 | } else if (priv->psstate != PS_STATE_FULL_POWER) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1779 | /* |
| 1780 | * 1. Non-PS command: |
| 1781 | * Queue it. set needtowakeup to TRUE if current state |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1782 | * is SLEEP, otherwise call lbs_ps_wakeup to send Exit_PS. |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1783 | * 2. PS command but not Exit_PS: |
| 1784 | * Ignore it. |
| 1785 | * 3. PS command Exit_PS: |
| 1786 | * Set needtowakeup to TRUE if current state is SLEEP, |
| 1787 | * otherwise send this command down to firmware |
| 1788 | * immediately. |
| 1789 | */ |
Dan Williams | ddac452 | 2007-12-11 13:49:39 -0500 | [diff] [blame] | 1790 | if (cmd->command != cpu_to_le16(CMD_802_11_PS_MODE)) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1791 | /* Prepare to send Exit PS, |
| 1792 | * this non PS command will be sent later */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1793 | if ((priv->psstate == PS_STATE_SLEEP) |
| 1794 | || (priv->psstate == PS_STATE_PRE_SLEEP) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1795 | ) { |
| 1796 | /* w/ new scheme, it will not reach here. |
| 1797 | since it is blocked in main_thread. */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1798 | priv->needtowakeup = 1; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1799 | } else |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1800 | lbs_ps_wakeup(priv, 0); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1801 | |
| 1802 | ret = 0; |
| 1803 | goto done; |
| 1804 | } else { |
| 1805 | /* |
| 1806 | * PS command. Ignore it if it is not Exit_PS. |
| 1807 | * otherwise send it down immediately. |
| 1808 | */ |
David Woodhouse | 38bfab1 | 2007-12-16 23:26:54 -0500 | [diff] [blame] | 1809 | struct cmd_ds_802_11_ps_mode *psm = (void *)&cmd[1]; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1810 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1811 | lbs_deb_host( |
| 1812 | "EXEC_NEXT_CMD: PS cmd, action 0x%02x\n", |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1813 | psm->action); |
| 1814 | if (psm->action != |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1815 | cpu_to_le16(CMD_SUBCMD_EXIT_PS)) { |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1816 | lbs_deb_host( |
| 1817 | "EXEC_NEXT_CMD: ignore ENTER_PS cmd\n"); |
Li Zefan | abe3ed1 | 2007-12-06 13:01:21 +0100 | [diff] [blame] | 1818 | list_del(&cmdnode->list); |
David Woodhouse | 183aeac | 2007-12-15 01:52:54 -0500 | [diff] [blame] | 1819 | spin_lock_irqsave(&priv->driver_lock, flags); |
| 1820 | lbs_complete_command(priv, cmdnode, 0); |
| 1821 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1822 | |
| 1823 | ret = 0; |
| 1824 | goto done; |
| 1825 | } |
| 1826 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1827 | if ((priv->psstate == PS_STATE_SLEEP) || |
| 1828 | (priv->psstate == PS_STATE_PRE_SLEEP)) { |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1829 | lbs_deb_host( |
| 1830 | "EXEC_NEXT_CMD: ignore EXIT_PS cmd in sleep\n"); |
Li Zefan | abe3ed1 | 2007-12-06 13:01:21 +0100 | [diff] [blame] | 1831 | list_del(&cmdnode->list); |
David Woodhouse | 183aeac | 2007-12-15 01:52:54 -0500 | [diff] [blame] | 1832 | spin_lock_irqsave(&priv->driver_lock, flags); |
| 1833 | lbs_complete_command(priv, cmdnode, 0); |
| 1834 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1835 | priv->needtowakeup = 1; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1836 | |
| 1837 | ret = 0; |
| 1838 | goto done; |
| 1839 | } |
| 1840 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1841 | lbs_deb_host( |
| 1842 | "EXEC_NEXT_CMD: sending EXIT_PS\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1843 | } |
| 1844 | } |
Li Zefan | abe3ed1 | 2007-12-06 13:01:21 +0100 | [diff] [blame] | 1845 | list_del(&cmdnode->list); |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1846 | lbs_deb_host("EXEC_NEXT_CMD: sending command 0x%04x\n", |
Dan Williams | ddac452 | 2007-12-11 13:49:39 -0500 | [diff] [blame] | 1847 | le16_to_cpu(cmd->command)); |
David Woodhouse | d9896ee | 2007-12-15 00:09:25 -0500 | [diff] [blame] | 1848 | lbs_submit_command(priv, cmdnode); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1849 | } else { |
| 1850 | /* |
| 1851 | * check if in power save mode, if yes, put the device back |
| 1852 | * to PS mode |
| 1853 | */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1854 | if ((priv->psmode != LBS802_11POWERMODECAM) && |
| 1855 | (priv->psstate == PS_STATE_FULL_POWER) && |
| 1856 | ((priv->connect_status == LBS_CONNECTED) || |
| 1857 | (priv->mesh_connect_status == LBS_CONNECTED))) { |
| 1858 | if (priv->secinfo.WPAenabled || |
| 1859 | priv->secinfo.WPA2enabled) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1860 | /* check for valid WPA group keys */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1861 | if (priv->wpa_mcast_key.len || |
| 1862 | priv->wpa_unicast_key.len) { |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1863 | lbs_deb_host( |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1864 | "EXEC_NEXT_CMD: WPA enabled and GTK_SET" |
| 1865 | " go back to PS_SLEEP"); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1866 | lbs_ps_sleep(priv, 0); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1867 | } |
| 1868 | } else { |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1869 | lbs_deb_host( |
| 1870 | "EXEC_NEXT_CMD: cmdpendingq empty, " |
| 1871 | "go back to PS_SLEEP"); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1872 | lbs_ps_sleep(priv, 0); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1873 | } |
| 1874 | } |
| 1875 | } |
| 1876 | |
| 1877 | ret = 0; |
| 1878 | done: |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1879 | lbs_deb_leave(LBS_DEB_THREAD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1880 | return ret; |
| 1881 | } |
| 1882 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1883 | void lbs_send_iwevcustom_event(struct lbs_private *priv, s8 *str) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1884 | { |
| 1885 | union iwreq_data iwrq; |
| 1886 | u8 buf[50]; |
| 1887 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1888 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1889 | |
| 1890 | memset(&iwrq, 0, sizeof(union iwreq_data)); |
| 1891 | memset(buf, 0, sizeof(buf)); |
| 1892 | |
| 1893 | snprintf(buf, sizeof(buf) - 1, "%s", str); |
| 1894 | |
| 1895 | iwrq.data.length = strlen(buf) + 1 + IW_EV_LCP_LEN; |
| 1896 | |
| 1897 | /* Send Event to upper layer */ |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1898 | lbs_deb_wext("event indication string %s\n", (char *)buf); |
| 1899 | lbs_deb_wext("event indication length %d\n", iwrq.data.length); |
| 1900 | lbs_deb_wext("sending wireless event IWEVCUSTOM for %s\n", str); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1901 | |
Holger Schurig | 634b8f4 | 2007-05-25 13:05:16 -0400 | [diff] [blame] | 1902 | wireless_send_event(priv->dev, IWEVCUSTOM, &iwrq, buf); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1903 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1904 | lbs_deb_leave(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1905 | } |
| 1906 | |
Holger Schurig | f539f2e | 2008-03-26 13:22:11 +0100 | [diff] [blame] | 1907 | static void lbs_send_confirmsleep(struct lbs_private *priv) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1908 | { |
| 1909 | unsigned long flags; |
Holger Schurig | f539f2e | 2008-03-26 13:22:11 +0100 | [diff] [blame] | 1910 | int ret; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1911 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1912 | lbs_deb_enter(LBS_DEB_HOST); |
Holger Schurig | f539f2e | 2008-03-26 13:22:11 +0100 | [diff] [blame] | 1913 | lbs_deb_hex(LBS_DEB_HOST, "sleep confirm", (u8 *) &confirm_sleep, |
| 1914 | sizeof(confirm_sleep)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1915 | |
Holger Schurig | f539f2e | 2008-03-26 13:22:11 +0100 | [diff] [blame] | 1916 | ret = priv->hw_host_to_card(priv, MVMS_CMD, (u8 *) &confirm_sleep, |
| 1917 | sizeof(confirm_sleep)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1918 | if (ret) { |
Holger Schurig | f539f2e | 2008-03-26 13:22:11 +0100 | [diff] [blame] | 1919 | lbs_pr_alert("confirm_sleep failed\n"); |
Holger Schurig | 7919b89 | 2008-04-01 14:50:43 +0200 | [diff] [blame] | 1920 | goto out; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1921 | } |
Holger Schurig | 7919b89 | 2008-04-01 14:50:43 +0200 | [diff] [blame] | 1922 | |
| 1923 | spin_lock_irqsave(&priv->driver_lock, flags); |
| 1924 | |
Holger Schurig | a01f545 | 2008-06-04 11:10:40 +0200 | [diff] [blame] | 1925 | /* We don't get a response on the sleep-confirmation */ |
| 1926 | priv->dnld_sent = DNLD_RES_RECEIVED; |
| 1927 | |
Holger Schurig | 7919b89 | 2008-04-01 14:50:43 +0200 | [diff] [blame] | 1928 | /* If nothing to do, go back to sleep (?) */ |
| 1929 | if (!__kfifo_len(priv->event_fifo) && !priv->resp_len[priv->resp_idx]) |
| 1930 | priv->psstate = PS_STATE_SLEEP; |
| 1931 | |
| 1932 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
| 1933 | |
| 1934 | out: |
Holger Schurig | f539f2e | 2008-03-26 13:22:11 +0100 | [diff] [blame] | 1935 | lbs_deb_leave(LBS_DEB_HOST); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1936 | } |
| 1937 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1938 | void lbs_ps_sleep(struct lbs_private *priv, int wait_option) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1939 | { |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1940 | lbs_deb_enter(LBS_DEB_HOST); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1941 | |
| 1942 | /* |
| 1943 | * PS is currently supported only in Infrastructure mode |
| 1944 | * Remove this check if it is to be supported in IBSS mode also |
| 1945 | */ |
| 1946 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1947 | lbs_prepare_and_send_command(priv, CMD_802_11_PS_MODE, |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1948 | CMD_SUBCMD_ENTER_PS, wait_option, 0, NULL); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1949 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1950 | lbs_deb_leave(LBS_DEB_HOST); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1951 | } |
| 1952 | |
| 1953 | /** |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1954 | * @brief This function sends Exit_PS command to firmware. |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1955 | * |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1956 | * @param priv A pointer to struct lbs_private structure |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1957 | * @param wait_option wait response or not |
| 1958 | * @return n/a |
| 1959 | */ |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1960 | void lbs_ps_wakeup(struct lbs_private *priv, int wait_option) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1961 | { |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 1962 | __le32 Localpsmode; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1963 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1964 | lbs_deb_enter(LBS_DEB_HOST); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1965 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1966 | Localpsmode = cpu_to_le32(LBS802_11POWERMODECAM); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1967 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1968 | lbs_prepare_and_send_command(priv, CMD_802_11_PS_MODE, |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1969 | CMD_SUBCMD_EXIT_PS, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1970 | wait_option, 0, &Localpsmode); |
| 1971 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1972 | lbs_deb_leave(LBS_DEB_HOST); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1973 | } |
| 1974 | |
| 1975 | /** |
| 1976 | * @brief This function checks condition and prepares to |
| 1977 | * send sleep confirm command to firmware if ok. |
| 1978 | * |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1979 | * @param priv A pointer to struct lbs_private structure |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1980 | * @param psmode Power Saving mode |
| 1981 | * @return n/a |
| 1982 | */ |
Holger Schurig | d4ff0ef | 2008-03-19 14:25:18 +0100 | [diff] [blame] | 1983 | void lbs_ps_confirm_sleep(struct lbs_private *priv) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1984 | { |
| 1985 | unsigned long flags =0; |
Holger Schurig | d4ff0ef | 2008-03-19 14:25:18 +0100 | [diff] [blame] | 1986 | int allowed = 1; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1987 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1988 | lbs_deb_enter(LBS_DEB_HOST); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1989 | |
Holger Schurig | a01f545 | 2008-06-04 11:10:40 +0200 | [diff] [blame] | 1990 | spin_lock_irqsave(&priv->driver_lock, flags); |
Holger Schurig | 634b8f4 | 2007-05-25 13:05:16 -0400 | [diff] [blame] | 1991 | if (priv->dnld_sent) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1992 | allowed = 0; |
David Woodhouse | 23d36ee | 2007-12-12 00:14:21 -0500 | [diff] [blame] | 1993 | lbs_deb_host("dnld_sent was set\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1994 | } |
| 1995 | |
Holger Schurig | 7919b89 | 2008-04-01 14:50:43 +0200 | [diff] [blame] | 1996 | /* In-progress command? */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 1997 | if (priv->cur_cmd) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1998 | allowed = 0; |
David Woodhouse | 23d36ee | 2007-12-12 00:14:21 -0500 | [diff] [blame] | 1999 | lbs_deb_host("cur_cmd was set\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2000 | } |
Holger Schurig | 7919b89 | 2008-04-01 14:50:43 +0200 | [diff] [blame] | 2001 | |
| 2002 | /* Pending events or command responses? */ |
| 2003 | if (__kfifo_len(priv->event_fifo) || priv->resp_len[priv->resp_idx]) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2004 | allowed = 0; |
Holger Schurig | 7919b89 | 2008-04-01 14:50:43 +0200 | [diff] [blame] | 2005 | lbs_deb_host("pending events or command responses\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2006 | } |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 2007 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2008 | |
| 2009 | if (allowed) { |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 2010 | lbs_deb_host("sending lbs_ps_confirm_sleep\n"); |
Holger Schurig | f539f2e | 2008-03-26 13:22:11 +0100 | [diff] [blame] | 2011 | lbs_send_confirmsleep(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2012 | } else { |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 2013 | lbs_deb_host("sleep confirm has been delayed\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2014 | } |
| 2015 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 2016 | lbs_deb_leave(LBS_DEB_HOST); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 2017 | } |
Holger Schurig | 675787e | 2007-12-05 17:58:11 +0100 | [diff] [blame] | 2018 | |
| 2019 | |
Anna Neal | 0112c9e | 2008-09-11 11:17:25 -0700 | [diff] [blame] | 2020 | /** |
| 2021 | * @brief Configures the transmission power control functionality. |
| 2022 | * |
| 2023 | * @param priv A pointer to struct lbs_private structure |
| 2024 | * @param enable Transmission power control enable |
| 2025 | * @param p0 Power level when link quality is good (dBm). |
| 2026 | * @param p1 Power level when link quality is fair (dBm). |
| 2027 | * @param p2 Power level when link quality is poor (dBm). |
| 2028 | * @param usesnr Use Signal to Noise Ratio in TPC |
| 2029 | * |
| 2030 | * @return 0 on success |
| 2031 | */ |
| 2032 | int lbs_set_tpc_cfg(struct lbs_private *priv, int enable, int8_t p0, int8_t p1, |
| 2033 | int8_t p2, int usesnr) |
| 2034 | { |
| 2035 | struct cmd_ds_802_11_tpc_cfg cmd; |
| 2036 | int ret; |
| 2037 | |
| 2038 | memset(&cmd, 0, sizeof(cmd)); |
| 2039 | cmd.hdr.size = cpu_to_le16(sizeof(cmd)); |
| 2040 | cmd.action = cpu_to_le16(CMD_ACT_SET); |
| 2041 | cmd.enable = !!enable; |
Anna Neal | 3ed6e08 | 2008-09-26 11:34:35 -0400 | [diff] [blame] | 2042 | cmd.usesnr = !!usesnr; |
Anna Neal | 0112c9e | 2008-09-11 11:17:25 -0700 | [diff] [blame] | 2043 | cmd.P0 = p0; |
| 2044 | cmd.P1 = p1; |
| 2045 | cmd.P2 = p2; |
| 2046 | |
| 2047 | ret = lbs_cmd_with_response(priv, CMD_802_11_TPC_CFG, &cmd); |
| 2048 | |
| 2049 | return ret; |
| 2050 | } |
| 2051 | |
| 2052 | /** |
| 2053 | * @brief Configures the power adaptation settings. |
| 2054 | * |
| 2055 | * @param priv A pointer to struct lbs_private structure |
| 2056 | * @param enable Power adaptation enable |
| 2057 | * @param p0 Power level for 1, 2, 5.5 and 11 Mbps (dBm). |
| 2058 | * @param p1 Power level for 6, 9, 12, 18, 22, 24 and 36 Mbps (dBm). |
| 2059 | * @param p2 Power level for 48 and 54 Mbps (dBm). |
| 2060 | * |
| 2061 | * @return 0 on Success |
| 2062 | */ |
| 2063 | |
| 2064 | int lbs_set_power_adapt_cfg(struct lbs_private *priv, int enable, int8_t p0, |
| 2065 | int8_t p1, int8_t p2) |
| 2066 | { |
| 2067 | struct cmd_ds_802_11_pa_cfg cmd; |
| 2068 | int ret; |
| 2069 | |
| 2070 | memset(&cmd, 0, sizeof(cmd)); |
| 2071 | cmd.hdr.size = cpu_to_le16(sizeof(cmd)); |
| 2072 | cmd.action = cpu_to_le16(CMD_ACT_SET); |
| 2073 | cmd.enable = !!enable; |
| 2074 | cmd.P0 = p0; |
| 2075 | cmd.P1 = p1; |
| 2076 | cmd.P2 = p2; |
| 2077 | |
| 2078 | ret = lbs_cmd_with_response(priv, CMD_802_11_PA_CFG , &cmd); |
| 2079 | |
| 2080 | return ret; |
| 2081 | } |
| 2082 | |
| 2083 | |
Holger Schurig | 6d898b1 | 2009-10-14 16:49:53 +0200 | [diff] [blame] | 2084 | struct cmd_ctrl_node *__lbs_cmd_async(struct lbs_private *priv, |
Holger Schurig | 8db4a2b | 2008-03-19 10:11:00 +0100 | [diff] [blame] | 2085 | uint16_t command, struct cmd_header *in_cmd, int in_cmd_size, |
| 2086 | int (*callback)(struct lbs_private *, unsigned long, struct cmd_header *), |
| 2087 | unsigned long callback_arg) |
Holger Schurig | 675787e | 2007-12-05 17:58:11 +0100 | [diff] [blame] | 2088 | { |
Holger Schurig | 675787e | 2007-12-05 17:58:11 +0100 | [diff] [blame] | 2089 | struct cmd_ctrl_node *cmdnode; |
Holger Schurig | 675787e | 2007-12-05 17:58:11 +0100 | [diff] [blame] | 2090 | |
| 2091 | lbs_deb_enter(LBS_DEB_HOST); |
Holger Schurig | 675787e | 2007-12-05 17:58:11 +0100 | [diff] [blame] | 2092 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 2093 | if (priv->surpriseremoved) { |
Holger Schurig | 675787e | 2007-12-05 17:58:11 +0100 | [diff] [blame] | 2094 | lbs_deb_host("PREP_CMD: card removed\n"); |
David Woodhouse | 3399ea5 | 2007-12-15 03:09:33 -0500 | [diff] [blame] | 2095 | cmdnode = ERR_PTR(-ENOENT); |
Holger Schurig | 675787e | 2007-12-05 17:58:11 +0100 | [diff] [blame] | 2096 | goto done; |
| 2097 | } |
| 2098 | |
Amitkumar Karwar | 63f275d | 2009-10-06 19:20:28 -0700 | [diff] [blame] | 2099 | if (!lbs_is_cmd_allowed(priv)) { |
| 2100 | cmdnode = ERR_PTR(-EBUSY); |
| 2101 | goto done; |
| 2102 | } |
| 2103 | |
Holger Schurig | 675787e | 2007-12-05 17:58:11 +0100 | [diff] [blame] | 2104 | cmdnode = lbs_get_cmd_ctrl_node(priv); |
Holger Schurig | 675787e | 2007-12-05 17:58:11 +0100 | [diff] [blame] | 2105 | if (cmdnode == NULL) { |
| 2106 | lbs_deb_host("PREP_CMD: cmdnode is NULL\n"); |
| 2107 | |
| 2108 | /* Wake up main thread to execute next command */ |
| 2109 | wake_up_interruptible(&priv->waitq); |
David Woodhouse | 3399ea5 | 2007-12-15 03:09:33 -0500 | [diff] [blame] | 2110 | cmdnode = ERR_PTR(-ENOBUFS); |
Holger Schurig | 675787e | 2007-12-05 17:58:11 +0100 | [diff] [blame] | 2111 | goto done; |
| 2112 | } |
| 2113 | |
David Woodhouse | 448a51a | 2007-12-08 00:59:54 +0000 | [diff] [blame] | 2114 | cmdnode->callback = callback; |
David Woodhouse | 1309b55 | 2007-12-10 13:36:10 -0500 | [diff] [blame] | 2115 | cmdnode->callback_arg = callback_arg; |
Holger Schurig | 675787e | 2007-12-05 17:58:11 +0100 | [diff] [blame] | 2116 | |
Dan Williams | 7ad994d | 2007-12-11 12:33:30 -0500 | [diff] [blame] | 2117 | /* Copy the incoming command to the buffer */ |
Dan Williams | ddac452 | 2007-12-11 13:49:39 -0500 | [diff] [blame] | 2118 | memcpy(cmdnode->cmdbuf, in_cmd, in_cmd_size); |
Dan Williams | 7ad994d | 2007-12-11 12:33:30 -0500 | [diff] [blame] | 2119 | |
Holger Schurig | 675787e | 2007-12-05 17:58:11 +0100 | [diff] [blame] | 2120 | /* Set sequence number, clean result, move to buffer */ |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 2121 | priv->seqnum++; |
Dan Williams | ddac452 | 2007-12-11 13:49:39 -0500 | [diff] [blame] | 2122 | cmdnode->cmdbuf->command = cpu_to_le16(command); |
| 2123 | cmdnode->cmdbuf->size = cpu_to_le16(in_cmd_size); |
| 2124 | cmdnode->cmdbuf->seqnum = cpu_to_le16(priv->seqnum); |
| 2125 | cmdnode->cmdbuf->result = 0; |
Holger Schurig | 675787e | 2007-12-05 17:58:11 +0100 | [diff] [blame] | 2126 | |
| 2127 | lbs_deb_host("PREP_CMD: command 0x%04x\n", command); |
| 2128 | |
Holger Schurig | 675787e | 2007-12-05 17:58:11 +0100 | [diff] [blame] | 2129 | cmdnode->cmdwaitqwoken = 0; |
David Woodhouse | 681ffbb | 2007-12-15 20:04:54 -0500 | [diff] [blame] | 2130 | lbs_queue_cmd(priv, cmdnode); |
Holger Schurig | 675787e | 2007-12-05 17:58:11 +0100 | [diff] [blame] | 2131 | wake_up_interruptible(&priv->waitq); |
| 2132 | |
David Woodhouse | 3399ea5 | 2007-12-15 03:09:33 -0500 | [diff] [blame] | 2133 | done: |
| 2134 | lbs_deb_leave_args(LBS_DEB_HOST, "ret %p", cmdnode); |
| 2135 | return cmdnode; |
| 2136 | } |
| 2137 | |
Holger Schurig | 8db4a2b | 2008-03-19 10:11:00 +0100 | [diff] [blame] | 2138 | void lbs_cmd_async(struct lbs_private *priv, uint16_t command, |
| 2139 | struct cmd_header *in_cmd, int in_cmd_size) |
| 2140 | { |
| 2141 | lbs_deb_enter(LBS_DEB_CMD); |
| 2142 | __lbs_cmd_async(priv, command, in_cmd, in_cmd_size, |
| 2143 | lbs_cmd_async_callback, 0); |
| 2144 | lbs_deb_leave(LBS_DEB_CMD); |
| 2145 | } |
| 2146 | |
David Woodhouse | 3399ea5 | 2007-12-15 03:09:33 -0500 | [diff] [blame] | 2147 | int __lbs_cmd(struct lbs_private *priv, uint16_t command, |
| 2148 | struct cmd_header *in_cmd, int in_cmd_size, |
| 2149 | int (*callback)(struct lbs_private *, unsigned long, struct cmd_header *), |
| 2150 | unsigned long callback_arg) |
| 2151 | { |
| 2152 | struct cmd_ctrl_node *cmdnode; |
| 2153 | unsigned long flags; |
| 2154 | int ret = 0; |
| 2155 | |
| 2156 | lbs_deb_enter(LBS_DEB_HOST); |
| 2157 | |
| 2158 | cmdnode = __lbs_cmd_async(priv, command, in_cmd, in_cmd_size, |
| 2159 | callback, callback_arg); |
| 2160 | if (IS_ERR(cmdnode)) { |
| 2161 | ret = PTR_ERR(cmdnode); |
| 2162 | goto done; |
| 2163 | } |
| 2164 | |
Holger Schurig | 675787e | 2007-12-05 17:58:11 +0100 | [diff] [blame] | 2165 | might_sleep(); |
| 2166 | wait_event_interruptible(cmdnode->cmdwait_q, cmdnode->cmdwaitqwoken); |
| 2167 | |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 2168 | spin_lock_irqsave(&priv->driver_lock, flags); |
David Woodhouse | ae125bf | 2007-12-15 04:22:52 -0500 | [diff] [blame] | 2169 | ret = cmdnode->result; |
| 2170 | if (ret) |
| 2171 | lbs_pr_info("PREP_CMD: command 0x%04x failed: %d\n", |
| 2172 | command, ret); |
David Woodhouse | 3399ea5 | 2007-12-15 03:09:33 -0500 | [diff] [blame] | 2173 | |
David Woodhouse | ad12d0f | 2007-12-15 02:06:16 -0500 | [diff] [blame] | 2174 | __lbs_cleanup_and_insert_cmd(priv, cmdnode); |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 2175 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
Holger Schurig | 675787e | 2007-12-05 17:58:11 +0100 | [diff] [blame] | 2176 | |
| 2177 | done: |
| 2178 | lbs_deb_leave_args(LBS_DEB_HOST, "ret %d", ret); |
| 2179 | return ret; |
| 2180 | } |
Dan Williams | 14e865b | 2007-12-10 15:11:23 -0500 | [diff] [blame] | 2181 | EXPORT_SYMBOL_GPL(__lbs_cmd); |
Holger Schurig | 675787e | 2007-12-05 17:58:11 +0100 | [diff] [blame] | 2182 | |
| 2183 | |