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> |
| 7 | #include "host.h" |
| 8 | #include "hostcmd.h" |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 9 | #include "decl.h" |
| 10 | #include "defs.h" |
| 11 | #include "dev.h" |
| 12 | #include "join.h" |
| 13 | #include "wext.h" |
| 14 | |
| 15 | static void cleanup_cmdnode(struct cmd_ctrl_node *ptempnode); |
Holger Schurig | 0d61d04 | 2007-12-05 17:58:06 +0100 | [diff] [blame] | 16 | struct cmd_ctrl_node *lbs_get_cmd_ctrl_node(struct lbs_private *priv); |
| 17 | void lbs_set_cmd_ctrl_node(struct lbs_private *priv, |
| 18 | struct cmd_ctrl_node *ptempnode, |
| 19 | u16 wait_option, void *pdata_buf); |
| 20 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 21 | |
| 22 | static u16 commands_allowed_in_ps[] = { |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 23 | CMD_802_11_RSSI, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 24 | }; |
| 25 | |
| 26 | /** |
| 27 | * @brief This function checks if the commans is allowed |
| 28 | * in PS mode not. |
| 29 | * |
| 30 | * @param command the command ID |
| 31 | * @return TRUE or FALSE |
| 32 | */ |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 33 | static u8 is_command_allowed_in_ps(__le16 command) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 34 | { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 35 | int i; |
| 36 | |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 37 | for (i = 0; i < ARRAY_SIZE(commands_allowed_in_ps); i++) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 38 | if (command == cpu_to_le16(commands_allowed_in_ps[i])) |
| 39 | return 1; |
| 40 | } |
| 41 | |
| 42 | return 0; |
| 43 | } |
| 44 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 45 | static int lbs_cmd_hw_spec(struct lbs_private *priv, struct cmd_ds_command *cmd) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 46 | { |
| 47 | struct cmd_ds_get_hw_spec *hwspec = &cmd->params.hwspec; |
| 48 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 49 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 50 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 51 | cmd->command = cpu_to_le16(CMD_GET_HW_SPEC); |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 52 | cmd->size = cpu_to_le16(sizeof(struct cmd_ds_get_hw_spec) + S_DS_GEN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 53 | memcpy(hwspec->permanentaddr, priv->adapter->current_addr, ETH_ALEN); |
| 54 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 55 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 56 | return 0; |
| 57 | } |
| 58 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 59 | static int lbs_cmd_802_11_ps_mode(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 60 | struct cmd_ds_command *cmd, |
| 61 | u16 cmd_action) |
| 62 | { |
| 63 | struct cmd_ds_802_11_ps_mode *psm = &cmd->params.psmode; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 64 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 65 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 66 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 67 | cmd->command = cpu_to_le16(CMD_802_11_PS_MODE); |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 68 | cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_ps_mode) + |
| 69 | S_DS_GEN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 70 | psm->action = cpu_to_le16(cmd_action); |
| 71 | psm->multipledtim = 0; |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 72 | switch (cmd_action) { |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 73 | case CMD_SUBCMD_ENTER_PS: |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 74 | lbs_deb_cmd("PS command:" "SubCode- Enter PS\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 75 | |
Holger Schurig | 252cf0d | 2007-08-02 13:09:34 -0400 | [diff] [blame] | 76 | psm->locallisteninterval = 0; |
Holger Schurig | 97605c3 | 2007-08-02 13:09:15 -0400 | [diff] [blame] | 77 | psm->nullpktinterval = 0; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 78 | psm->multipledtim = |
Holger Schurig | 56c4656 | 2007-08-02 13:09:49 -0400 | [diff] [blame] | 79 | cpu_to_le16(MRVDRV_DEFAULT_MULTIPLE_DTIM); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 80 | break; |
| 81 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 82 | case CMD_SUBCMD_EXIT_PS: |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 83 | lbs_deb_cmd("PS command:" "SubCode- Exit PS\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 84 | break; |
| 85 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 86 | case CMD_SUBCMD_SLEEP_CONFIRMED: |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 87 | lbs_deb_cmd("PS command: SubCode- sleep confirm\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 88 | break; |
| 89 | |
| 90 | default: |
| 91 | break; |
| 92 | } |
| 93 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 94 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 95 | return 0; |
| 96 | } |
| 97 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 98 | static int lbs_cmd_802_11_inactivity_timeout(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 99 | struct cmd_ds_command *cmd, |
| 100 | u16 cmd_action, void *pdata_buf) |
| 101 | { |
| 102 | u16 *timeout = pdata_buf; |
| 103 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 104 | lbs_deb_enter(LBS_DEB_CMD); |
| 105 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 106 | cmd->command = cpu_to_le16(CMD_802_11_INACTIVITY_TIMEOUT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 107 | cmd->size = |
| 108 | cpu_to_le16(sizeof(struct cmd_ds_802_11_inactivity_timeout) |
| 109 | + S_DS_GEN); |
| 110 | |
| 111 | cmd->params.inactivity_timeout.action = cpu_to_le16(cmd_action); |
| 112 | |
| 113 | if (cmd_action) |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 114 | cmd->params.inactivity_timeout.timeout = cpu_to_le16(*timeout); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 115 | else |
| 116 | cmd->params.inactivity_timeout.timeout = 0; |
| 117 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 118 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 119 | return 0; |
| 120 | } |
| 121 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 122 | static int lbs_cmd_802_11_sleep_params(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 123 | struct cmd_ds_command *cmd, |
| 124 | u16 cmd_action) |
| 125 | { |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 126 | struct lbs_adapter *adapter = priv->adapter; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 127 | struct cmd_ds_802_11_sleep_params *sp = &cmd->params.sleep_params; |
| 128 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 129 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 130 | |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 131 | cmd->size = cpu_to_le16((sizeof(struct cmd_ds_802_11_sleep_params)) + |
| 132 | S_DS_GEN); |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 133 | cmd->command = cpu_to_le16(CMD_802_11_SLEEP_PARAMS); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 134 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 135 | if (cmd_action == CMD_ACT_GET) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 136 | memset(&adapter->sp, 0, sizeof(struct sleep_params)); |
| 137 | memset(sp, 0, sizeof(struct cmd_ds_802_11_sleep_params)); |
| 138 | sp->action = cpu_to_le16(cmd_action); |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 139 | } else if (cmd_action == CMD_ACT_SET) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 140 | sp->action = cpu_to_le16(cmd_action); |
| 141 | sp->error = cpu_to_le16(adapter->sp.sp_error); |
| 142 | sp->offset = cpu_to_le16(adapter->sp.sp_offset); |
| 143 | sp->stabletime = cpu_to_le16(adapter->sp.sp_stabletime); |
| 144 | sp->calcontrol = (u8) adapter->sp.sp_calcontrol; |
| 145 | sp->externalsleepclk = (u8) adapter->sp.sp_extsleepclk; |
| 146 | sp->reserved = cpu_to_le16(adapter->sp.sp_reserved); |
| 147 | } |
| 148 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 149 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 150 | return 0; |
| 151 | } |
| 152 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 153 | static int lbs_cmd_802_11_set_wep(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 154 | struct cmd_ds_command *cmd, |
| 155 | u32 cmd_act, |
| 156 | void * pdata_buf) |
| 157 | { |
| 158 | struct cmd_ds_802_11_set_wep *wep = &cmd->params.wep; |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 159 | struct lbs_adapter *adapter = priv->adapter; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 160 | int ret = 0; |
| 161 | struct assoc_request * assoc_req = pdata_buf; |
| 162 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 163 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 164 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 165 | cmd->command = cpu_to_le16(CMD_802_11_SET_WEP); |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 166 | cmd->size = cpu_to_le16(sizeof(*wep) + S_DS_GEN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 167 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 168 | if (cmd_act == CMD_ACT_ADD) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 169 | int i; |
| 170 | |
| 171 | if (!assoc_req) { |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 172 | lbs_deb_cmd("Invalid association request!"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 173 | ret = -1; |
| 174 | goto done; |
| 175 | } |
| 176 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 177 | wep->action = cpu_to_le16(CMD_ACT_ADD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 178 | |
| 179 | /* default tx key index */ |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 180 | wep->keyindex = cpu_to_le16((u16)(assoc_req->wep_tx_keyidx & |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 181 | (u32)CMD_WEP_KEY_INDEX_MASK)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 182 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 183 | /* Copy key types and material to host command structure */ |
| 184 | for (i = 0; i < 4; i++) { |
Dan Williams | 1443b65 | 2007-08-02 10:45:55 -0400 | [diff] [blame] | 185 | struct enc_key * pkey = &assoc_req->wep_keys[i]; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 186 | |
| 187 | switch (pkey->len) { |
| 188 | case KEY_LEN_WEP_40: |
Holger Schurig | 6470a89 | 2007-10-08 11:07:27 +0200 | [diff] [blame] | 189 | wep->keytype[i] = CMD_TYPE_WEP_40_BIT; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 190 | memmove(&wep->keymaterial[i], pkey->key, |
| 191 | pkey->len); |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 192 | lbs_deb_cmd("SET_WEP: add key %d (40 bit)\n", i); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 193 | break; |
| 194 | case KEY_LEN_WEP_104: |
Holger Schurig | 6470a89 | 2007-10-08 11:07:27 +0200 | [diff] [blame] | 195 | wep->keytype[i] = CMD_TYPE_WEP_104_BIT; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 196 | memmove(&wep->keymaterial[i], pkey->key, |
| 197 | pkey->len); |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 198 | lbs_deb_cmd("SET_WEP: add key %d (104 bit)\n", i); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 199 | break; |
| 200 | case 0: |
| 201 | break; |
| 202 | default: |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 203 | lbs_deb_cmd("SET_WEP: invalid key %d, length %d\n", |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 204 | i, pkey->len); |
| 205 | ret = -1; |
| 206 | goto done; |
| 207 | break; |
| 208 | } |
| 209 | } |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 210 | } else if (cmd_act == CMD_ACT_REMOVE) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 211 | /* ACT_REMOVE clears _all_ WEP keys */ |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 212 | wep->action = cpu_to_le16(CMD_ACT_REMOVE); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 213 | |
| 214 | /* default tx key index */ |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 215 | wep->keyindex = cpu_to_le16((u16)(adapter->wep_tx_keyidx & |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 216 | (u32)CMD_WEP_KEY_INDEX_MASK)); |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 217 | lbs_deb_cmd("SET_WEP: remove key %d\n", adapter->wep_tx_keyidx); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 218 | } |
| 219 | |
| 220 | ret = 0; |
| 221 | |
| 222 | done: |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 223 | lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 224 | return ret; |
| 225 | } |
| 226 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 227 | static int lbs_cmd_802_11_enable_rsn(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 228 | struct cmd_ds_command *cmd, |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 229 | u16 cmd_action, |
| 230 | void * pdata_buf) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 231 | { |
| 232 | struct cmd_ds_802_11_enable_rsn *penableRSN = &cmd->params.enbrsn; |
Dan Williams | 18c96c34 | 2007-06-18 12:01:12 -0400 | [diff] [blame] | 233 | u32 * enable = pdata_buf; |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 234 | |
| 235 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 236 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 237 | cmd->command = cpu_to_le16(CMD_802_11_ENABLE_RSN); |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 238 | cmd->size = cpu_to_le16(sizeof(*penableRSN) + S_DS_GEN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 239 | penableRSN->action = cpu_to_le16(cmd_action); |
Dan Williams | 18c96c34 | 2007-06-18 12:01:12 -0400 | [diff] [blame] | 240 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 241 | if (cmd_action == CMD_ACT_SET) { |
Dan Williams | 18c96c34 | 2007-06-18 12:01:12 -0400 | [diff] [blame] | 242 | if (*enable) |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 243 | penableRSN->enable = cpu_to_le16(CMD_ENABLE_RSN); |
Dan Williams | 18c96c34 | 2007-06-18 12:01:12 -0400 | [diff] [blame] | 244 | else |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 245 | penableRSN->enable = cpu_to_le16(CMD_DISABLE_RSN); |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 246 | lbs_deb_cmd("ENABLE_RSN: %d\n", *enable); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 247 | } |
| 248 | |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 249 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 250 | return 0; |
| 251 | } |
| 252 | |
| 253 | |
Holger Schurig | 3a18864 | 2007-11-26 10:07:14 +0100 | [diff] [blame] | 254 | static ssize_t lbs_tlv_size(const u8 *tlv, u16 size) |
| 255 | { |
| 256 | ssize_t pos = 0; |
| 257 | struct mrvlietypesheader *tlv_h; |
| 258 | while (pos < size) { |
| 259 | u16 length; |
| 260 | tlv_h = (struct mrvlietypesheader *) tlv; |
| 261 | if (tlv_h->len == 0) |
| 262 | return pos; |
| 263 | length = le16_to_cpu(tlv_h->len) + |
| 264 | sizeof(struct mrvlietypesheader); |
| 265 | pos += length; |
| 266 | tlv += length; |
| 267 | } |
| 268 | return pos; |
| 269 | } |
| 270 | |
| 271 | |
| 272 | static void lbs_cmd_802_11_subscribe_event(struct lbs_private *priv, |
| 273 | struct cmd_ds_command *cmd, u16 cmd_action, |
| 274 | void *pdata_buf) |
| 275 | { |
| 276 | struct cmd_ds_802_11_subscribe_event *events = |
| 277 | (struct cmd_ds_802_11_subscribe_event *) pdata_buf; |
| 278 | |
| 279 | /* pdata_buf points to a struct cmd_ds_802_11_subscribe_event and room |
| 280 | * for various Marvell TLVs */ |
| 281 | |
| 282 | lbs_deb_enter(LBS_DEB_CMD); |
| 283 | |
| 284 | cmd->size = cpu_to_le16(sizeof(*events) |
| 285 | - sizeof(events->tlv) |
| 286 | + S_DS_GEN); |
| 287 | cmd->params.subscribe_event.action = cpu_to_le16(cmd_action); |
| 288 | if (cmd_action == CMD_ACT_GET) { |
| 289 | cmd->params.subscribe_event.events = 0; |
| 290 | } else { |
| 291 | ssize_t sz = lbs_tlv_size(events->tlv, sizeof(events->tlv)); |
| 292 | cmd->size = cpu_to_le16(le16_to_cpu(cmd->size) + sz); |
| 293 | cmd->params.subscribe_event.events = events->events; |
| 294 | memcpy(cmd->params.subscribe_event.tlv, events->tlv, sz); |
| 295 | } |
| 296 | |
| 297 | lbs_deb_leave(LBS_DEB_CMD); |
| 298 | } |
| 299 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 300 | static void set_one_wpa_key(struct MrvlIEtype_keyParamSet * pkeyparamset, |
Dan Williams | 1443b65 | 2007-08-02 10:45:55 -0400 | [diff] [blame] | 301 | struct enc_key * pkey) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 302 | { |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 303 | lbs_deb_enter(LBS_DEB_CMD); |
| 304 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 305 | if (pkey->flags & KEY_INFO_WPA_ENABLED) { |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 306 | pkeyparamset->keyinfo |= cpu_to_le16(KEY_INFO_WPA_ENABLED); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 307 | } |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 308 | if (pkey->flags & KEY_INFO_WPA_UNICAST) { |
| 309 | pkeyparamset->keyinfo |= cpu_to_le16(KEY_INFO_WPA_UNICAST); |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 310 | } |
| 311 | if (pkey->flags & KEY_INFO_WPA_MCAST) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 312 | pkeyparamset->keyinfo |= cpu_to_le16(KEY_INFO_WPA_MCAST); |
| 313 | } |
| 314 | |
| 315 | pkeyparamset->type = cpu_to_le16(TLV_TYPE_KEY_MATERIAL); |
Dan Williams | 1443b65 | 2007-08-02 10:45:55 -0400 | [diff] [blame] | 316 | pkeyparamset->keytypeid = cpu_to_le16(pkey->type); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 317 | pkeyparamset->keylen = cpu_to_le16(pkey->len); |
| 318 | memcpy(pkeyparamset->key, pkey->key, pkey->len); |
| 319 | pkeyparamset->length = cpu_to_le16( sizeof(pkeyparamset->keytypeid) |
| 320 | + sizeof(pkeyparamset->keyinfo) |
| 321 | + sizeof(pkeyparamset->keylen) |
| 322 | + sizeof(pkeyparamset->key)); |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 323 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 324 | } |
| 325 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 326 | static int lbs_cmd_802_11_key_material(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 327 | struct cmd_ds_command *cmd, |
| 328 | u16 cmd_action, |
| 329 | u32 cmd_oid, void *pdata_buf) |
| 330 | { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 331 | struct cmd_ds_802_11_key_material *pkeymaterial = |
| 332 | &cmd->params.keymaterial; |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 333 | struct assoc_request * assoc_req = pdata_buf; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 334 | int ret = 0; |
| 335 | int index = 0; |
| 336 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 337 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 338 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 339 | cmd->command = cpu_to_le16(CMD_802_11_KEY_MATERIAL); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 340 | pkeymaterial->action = cpu_to_le16(cmd_action); |
| 341 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 342 | if (cmd_action == CMD_ACT_GET) { |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 343 | cmd->size = cpu_to_le16(S_DS_GEN + sizeof (pkeymaterial->action)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 344 | ret = 0; |
| 345 | goto done; |
| 346 | } |
| 347 | |
| 348 | memset(&pkeymaterial->keyParamSet, 0, sizeof(pkeymaterial->keyParamSet)); |
| 349 | |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 350 | if (test_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags)) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 351 | set_one_wpa_key(&pkeymaterial->keyParamSet[index], |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 352 | &assoc_req->wpa_unicast_key); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 353 | index++; |
| 354 | } |
| 355 | |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 356 | if (test_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags)) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 357 | set_one_wpa_key(&pkeymaterial->keyParamSet[index], |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 358 | &assoc_req->wpa_mcast_key); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 359 | index++; |
| 360 | } |
| 361 | |
| 362 | cmd->size = cpu_to_le16( S_DS_GEN |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 363 | + sizeof (pkeymaterial->action) |
| 364 | + (index * sizeof(struct MrvlIEtype_keyParamSet))); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 365 | |
| 366 | ret = 0; |
| 367 | |
| 368 | done: |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 369 | lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 370 | return ret; |
| 371 | } |
| 372 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 373 | static int lbs_cmd_802_11_reset(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 374 | struct cmd_ds_command *cmd, int cmd_action) |
| 375 | { |
| 376 | struct cmd_ds_802_11_reset *reset = &cmd->params.reset; |
| 377 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 378 | lbs_deb_enter(LBS_DEB_CMD); |
| 379 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 380 | cmd->command = cpu_to_le16(CMD_802_11_RESET); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 381 | cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_reset) + S_DS_GEN); |
| 382 | reset->action = cpu_to_le16(cmd_action); |
| 383 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 384 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 385 | return 0; |
| 386 | } |
| 387 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 388 | static int lbs_cmd_802_11_get_log(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 389 | struct cmd_ds_command *cmd) |
| 390 | { |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 391 | lbs_deb_enter(LBS_DEB_CMD); |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 392 | cmd->command = cpu_to_le16(CMD_802_11_GET_LOG); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 393 | cmd->size = |
| 394 | cpu_to_le16(sizeof(struct cmd_ds_802_11_get_log) + S_DS_GEN); |
| 395 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 396 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 397 | return 0; |
| 398 | } |
| 399 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 400 | static int lbs_cmd_802_11_get_stat(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 401 | struct cmd_ds_command *cmd) |
| 402 | { |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 403 | lbs_deb_enter(LBS_DEB_CMD); |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 404 | cmd->command = cpu_to_le16(CMD_802_11_GET_STAT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 405 | cmd->size = |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 406 | cpu_to_le16(sizeof(struct cmd_ds_802_11_get_stat) + S_DS_GEN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 407 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 408 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 409 | return 0; |
| 410 | } |
| 411 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 412 | static int lbs_cmd_802_11_snmp_mib(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 413 | struct cmd_ds_command *cmd, |
| 414 | int cmd_action, |
| 415 | int cmd_oid, void *pdata_buf) |
| 416 | { |
| 417 | struct cmd_ds_802_11_snmp_mib *pSNMPMIB = &cmd->params.smib; |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 418 | struct lbs_adapter *adapter = priv->adapter; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 419 | u8 ucTemp; |
| 420 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 421 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 422 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 423 | lbs_deb_cmd("SNMP_CMD: cmd_oid = 0x%x\n", cmd_oid); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 424 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 425 | cmd->command = cpu_to_le16(CMD_802_11_SNMP_MIB); |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 426 | cmd->size = cpu_to_le16(sizeof(*pSNMPMIB) + S_DS_GEN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 427 | |
| 428 | switch (cmd_oid) { |
| 429 | case OID_802_11_INFRASTRUCTURE_MODE: |
| 430 | { |
Dan Williams | 0dc5a29 | 2007-05-10 22:58:02 -0400 | [diff] [blame] | 431 | u8 mode = (u8) (size_t) pdata_buf; |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 432 | pSNMPMIB->querytype = cpu_to_le16(CMD_ACT_SET); |
| 433 | pSNMPMIB->oid = cpu_to_le16((u16) DESIRED_BSSTYPE_I); |
Holger Schurig | c2df2ef | 2007-12-07 15:30:44 +0000 | [diff] [blame] | 434 | pSNMPMIB->bufsize = cpu_to_le16(sizeof(u8)); |
Dan Williams | 0dc5a29 | 2007-05-10 22:58:02 -0400 | [diff] [blame] | 435 | if (mode == IW_MODE_ADHOC) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 436 | ucTemp = SNMP_MIB_VALUE_ADHOC; |
Dan Williams | 0dc5a29 | 2007-05-10 22:58:02 -0400 | [diff] [blame] | 437 | } else { |
| 438 | /* Infra and Auto modes */ |
| 439 | ucTemp = SNMP_MIB_VALUE_INFRA; |
| 440 | } |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 441 | |
| 442 | memmove(pSNMPMIB->value, &ucTemp, sizeof(u8)); |
| 443 | |
| 444 | break; |
| 445 | } |
| 446 | |
| 447 | case OID_802_11D_ENABLE: |
| 448 | { |
| 449 | u32 ulTemp; |
| 450 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 451 | pSNMPMIB->oid = cpu_to_le16((u16) DOT11D_I); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 452 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 453 | if (cmd_action == CMD_ACT_SET) { |
Holger Schurig | c2df2ef | 2007-12-07 15:30:44 +0000 | [diff] [blame] | 454 | pSNMPMIB->querytype = cpu_to_le16(CMD_ACT_SET); |
| 455 | pSNMPMIB->bufsize = cpu_to_le16(sizeof(u16)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 456 | ulTemp = *(u32 *)pdata_buf; |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 457 | *((__le16 *)(pSNMPMIB->value)) = |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 458 | cpu_to_le16((u16) ulTemp); |
| 459 | } |
| 460 | break; |
| 461 | } |
| 462 | |
| 463 | case OID_802_11_FRAGMENTATION_THRESHOLD: |
| 464 | { |
| 465 | u32 ulTemp; |
| 466 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 467 | pSNMPMIB->oid = cpu_to_le16((u16) FRAGTHRESH_I); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 468 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 469 | if (cmd_action == CMD_ACT_GET) { |
| 470 | pSNMPMIB->querytype = cpu_to_le16(CMD_ACT_GET); |
| 471 | } else if (cmd_action == CMD_ACT_SET) { |
| 472 | pSNMPMIB->querytype = cpu_to_le16(CMD_ACT_SET); |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 473 | pSNMPMIB->bufsize = cpu_to_le16(sizeof(u16)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 474 | ulTemp = *((u32 *) pdata_buf); |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 475 | *((__le16 *)(pSNMPMIB->value)) = |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 476 | cpu_to_le16((u16) ulTemp); |
| 477 | |
| 478 | } |
| 479 | |
| 480 | break; |
| 481 | } |
| 482 | |
| 483 | case OID_802_11_RTS_THRESHOLD: |
| 484 | { |
| 485 | |
| 486 | u32 ulTemp; |
Holger Schurig | c2df2ef | 2007-12-07 15:30:44 +0000 | [diff] [blame] | 487 | pSNMPMIB->oid = cpu_to_le16(RTSTHRESH_I); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 488 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 489 | if (cmd_action == CMD_ACT_GET) { |
| 490 | pSNMPMIB->querytype = cpu_to_le16(CMD_ACT_GET); |
| 491 | } else if (cmd_action == CMD_ACT_SET) { |
| 492 | pSNMPMIB->querytype = cpu_to_le16(CMD_ACT_SET); |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 493 | pSNMPMIB->bufsize = cpu_to_le16(sizeof(u16)); |
| 494 | ulTemp = *((u32 *)pdata_buf); |
| 495 | *(__le16 *)(pSNMPMIB->value) = |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 496 | cpu_to_le16((u16) ulTemp); |
| 497 | |
| 498 | } |
| 499 | break; |
| 500 | } |
| 501 | case OID_802_11_TX_RETRYCOUNT: |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 502 | pSNMPMIB->oid = cpu_to_le16((u16) SHORT_RETRYLIM_I); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 503 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 504 | if (cmd_action == CMD_ACT_GET) { |
| 505 | pSNMPMIB->querytype = cpu_to_le16(CMD_ACT_GET); |
| 506 | } else if (cmd_action == CMD_ACT_SET) { |
| 507 | pSNMPMIB->querytype = cpu_to_le16(CMD_ACT_SET); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 508 | pSNMPMIB->bufsize = cpu_to_le16(sizeof(u16)); |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 509 | *((__le16 *)(pSNMPMIB->value)) = |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 510 | cpu_to_le16((u16) adapter->txretrycount); |
| 511 | } |
| 512 | |
| 513 | break; |
| 514 | default: |
| 515 | break; |
| 516 | } |
| 517 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 518 | lbs_deb_cmd( |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 519 | "SNMP_CMD: command=0x%x, size=0x%x, seqnum=0x%x, result=0x%x\n", |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 520 | le16_to_cpu(cmd->command), le16_to_cpu(cmd->size), |
| 521 | le16_to_cpu(cmd->seqnum), le16_to_cpu(cmd->result)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 522 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 523 | lbs_deb_cmd( |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 524 | "SNMP_CMD: action 0x%x, oid 0x%x, oidsize 0x%x, value 0x%x\n", |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 525 | le16_to_cpu(pSNMPMIB->querytype), le16_to_cpu(pSNMPMIB->oid), |
| 526 | le16_to_cpu(pSNMPMIB->bufsize), |
| 527 | le16_to_cpu(*(__le16 *) pSNMPMIB->value)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 528 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 529 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 530 | return 0; |
| 531 | } |
| 532 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 533 | static int lbs_cmd_802_11_radio_control(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 534 | struct cmd_ds_command *cmd, |
| 535 | int cmd_action) |
| 536 | { |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 537 | struct lbs_adapter *adapter = priv->adapter; |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 538 | struct cmd_ds_802_11_radio_control *pradiocontrol = &cmd->params.radio; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 539 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 540 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 541 | |
| 542 | cmd->size = |
| 543 | cpu_to_le16((sizeof(struct cmd_ds_802_11_radio_control)) + |
| 544 | S_DS_GEN); |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 545 | cmd->command = cpu_to_le16(CMD_802_11_RADIO_CONTROL); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 546 | |
| 547 | pradiocontrol->action = cpu_to_le16(cmd_action); |
| 548 | |
| 549 | switch (adapter->preamble) { |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 550 | case CMD_TYPE_SHORT_PREAMBLE: |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 551 | pradiocontrol->control = cpu_to_le16(SET_SHORT_PREAMBLE); |
| 552 | break; |
| 553 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 554 | case CMD_TYPE_LONG_PREAMBLE: |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 555 | pradiocontrol->control = cpu_to_le16(SET_LONG_PREAMBLE); |
| 556 | break; |
| 557 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 558 | case CMD_TYPE_AUTO_PREAMBLE: |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 559 | default: |
| 560 | pradiocontrol->control = cpu_to_le16(SET_AUTO_PREAMBLE); |
| 561 | break; |
| 562 | } |
| 563 | |
| 564 | if (adapter->radioon) |
| 565 | pradiocontrol->control |= cpu_to_le16(TURN_ON_RF); |
| 566 | else |
| 567 | pradiocontrol->control &= cpu_to_le16(~TURN_ON_RF); |
| 568 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 569 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 570 | return 0; |
| 571 | } |
| 572 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 573 | static int lbs_cmd_802_11_rf_tx_power(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 574 | struct cmd_ds_command *cmd, |
| 575 | u16 cmd_action, void *pdata_buf) |
| 576 | { |
| 577 | |
| 578 | struct cmd_ds_802_11_rf_tx_power *prtp = &cmd->params.txp; |
| 579 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 580 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 581 | |
| 582 | cmd->size = |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 583 | cpu_to_le16((sizeof(struct cmd_ds_802_11_rf_tx_power)) + S_DS_GEN); |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 584 | cmd->command = cpu_to_le16(CMD_802_11_RF_TX_POWER); |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 585 | prtp->action = cpu_to_le16(cmd_action); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 586 | |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 587 | lbs_deb_cmd("RF_TX_POWER_CMD: size:%d cmd:0x%x Act:%d\n", |
| 588 | le16_to_cpu(cmd->size), le16_to_cpu(cmd->command), |
| 589 | le16_to_cpu(prtp->action)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 590 | |
| 591 | switch (cmd_action) { |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 592 | case CMD_ACT_TX_POWER_OPT_GET: |
| 593 | prtp->action = cpu_to_le16(CMD_ACT_GET); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 594 | prtp->currentlevel = 0; |
| 595 | break; |
| 596 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 597 | case CMD_ACT_TX_POWER_OPT_SET_HIGH: |
| 598 | prtp->action = cpu_to_le16(CMD_ACT_SET); |
| 599 | prtp->currentlevel = cpu_to_le16(CMD_ACT_TX_POWER_INDEX_HIGH); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 600 | break; |
| 601 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 602 | case CMD_ACT_TX_POWER_OPT_SET_MID: |
| 603 | prtp->action = cpu_to_le16(CMD_ACT_SET); |
| 604 | prtp->currentlevel = cpu_to_le16(CMD_ACT_TX_POWER_INDEX_MID); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 605 | break; |
| 606 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 607 | case CMD_ACT_TX_POWER_OPT_SET_LOW: |
| 608 | prtp->action = cpu_to_le16(CMD_ACT_SET); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 609 | prtp->currentlevel = cpu_to_le16(*((u16 *) pdata_buf)); |
| 610 | break; |
| 611 | } |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 612 | |
| 613 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 614 | return 0; |
| 615 | } |
| 616 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 617 | static int lbs_cmd_802_11_monitor_mode(struct lbs_private *priv, |
Luis Carlos Cobo | 965f8bb | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 618 | struct cmd_ds_command *cmd, |
| 619 | u16 cmd_action, void *pdata_buf) |
| 620 | { |
| 621 | struct cmd_ds_802_11_monitor_mode *monitor = &cmd->params.monitor; |
| 622 | |
| 623 | cmd->command = cpu_to_le16(CMD_802_11_MONITOR_MODE); |
| 624 | cmd->size = |
| 625 | cpu_to_le16(sizeof(struct cmd_ds_802_11_monitor_mode) + |
| 626 | S_DS_GEN); |
| 627 | |
| 628 | monitor->action = cpu_to_le16(cmd_action); |
| 629 | if (cmd_action == CMD_ACT_SET) { |
| 630 | monitor->mode = |
| 631 | cpu_to_le16((u16) (*(u32 *) pdata_buf)); |
| 632 | } |
| 633 | |
| 634 | return 0; |
| 635 | } |
| 636 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 637 | static int lbs_cmd_802_11_rate_adapt_rateset(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 638 | struct cmd_ds_command *cmd, |
| 639 | u16 cmd_action) |
| 640 | { |
| 641 | struct cmd_ds_802_11_rate_adapt_rateset |
| 642 | *rateadapt = &cmd->params.rateset; |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 643 | struct lbs_adapter *adapter = priv->adapter; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 644 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 645 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 646 | cmd->size = |
| 647 | cpu_to_le16(sizeof(struct cmd_ds_802_11_rate_adapt_rateset) |
| 648 | + S_DS_GEN); |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 649 | cmd->command = cpu_to_le16(CMD_802_11_RATE_ADAPT_RATESET); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 650 | |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 651 | rateadapt->action = cpu_to_le16(cmd_action); |
| 652 | rateadapt->enablehwauto = cpu_to_le16(adapter->enablehwauto); |
| 653 | rateadapt->bitmap = cpu_to_le16(adapter->ratebitmap); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 654 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 655 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 656 | return 0; |
| 657 | } |
| 658 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 659 | static int lbs_cmd_802_11_data_rate(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 660 | struct cmd_ds_command *cmd, |
| 661 | u16 cmd_action) |
| 662 | { |
| 663 | struct cmd_ds_802_11_data_rate *pdatarate = &cmd->params.drate; |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 664 | struct lbs_adapter *adapter = priv->adapter; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 665 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 666 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 667 | |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 668 | cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_data_rate) + |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 669 | S_DS_GEN); |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 670 | cmd->command = cpu_to_le16(CMD_802_11_DATA_RATE); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 671 | memset(pdatarate, 0, sizeof(struct cmd_ds_802_11_data_rate)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 672 | pdatarate->action = cpu_to_le16(cmd_action); |
| 673 | |
Dan Williams | ffcae95 | 2007-08-02 11:35:46 -0400 | [diff] [blame] | 674 | if (cmd_action == CMD_ACT_SET_TX_FIX_RATE) { |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 675 | pdatarate->rates[0] = lbs_data_rate_to_fw_index(adapter->cur_rate); |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 676 | lbs_deb_cmd("DATA_RATE: set fixed 0x%02X\n", |
Dan Williams | 8c51276 | 2007-08-02 11:40:45 -0400 | [diff] [blame] | 677 | adapter->cur_rate); |
Dan Williams | ffcae95 | 2007-08-02 11:35:46 -0400 | [diff] [blame] | 678 | } else if (cmd_action == CMD_ACT_SET_TX_AUTO) { |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 679 | lbs_deb_cmd("DATA_RATE: setting auto\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 680 | } |
| 681 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 682 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 683 | return 0; |
| 684 | } |
| 685 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 686 | static int lbs_cmd_mac_multicast_adr(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 687 | struct cmd_ds_command *cmd, |
| 688 | u16 cmd_action) |
| 689 | { |
| 690 | struct cmd_ds_mac_multicast_adr *pMCastAdr = &cmd->params.madr; |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 691 | struct lbs_adapter *adapter = priv->adapter; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 692 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 693 | lbs_deb_enter(LBS_DEB_CMD); |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 694 | cmd->size = cpu_to_le16(sizeof(struct cmd_ds_mac_multicast_adr) + |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 695 | S_DS_GEN); |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 696 | cmd->command = cpu_to_le16(CMD_MAC_MULTICAST_ADR); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 697 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 698 | lbs_deb_cmd("MULTICAST_ADR: setting %d addresses\n", pMCastAdr->nr_of_adrs); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 699 | pMCastAdr->action = cpu_to_le16(cmd_action); |
| 700 | pMCastAdr->nr_of_adrs = |
| 701 | cpu_to_le16((u16) adapter->nr_of_multicastmacaddr); |
| 702 | memcpy(pMCastAdr->maclist, adapter->multicastlist, |
| 703 | adapter->nr_of_multicastmacaddr * ETH_ALEN); |
| 704 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 705 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 706 | return 0; |
| 707 | } |
| 708 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 709 | static int lbs_cmd_802_11_rf_channel(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 710 | struct cmd_ds_command *cmd, |
| 711 | int option, void *pdata_buf) |
| 712 | { |
| 713 | struct cmd_ds_802_11_rf_channel *rfchan = &cmd->params.rfchannel; |
| 714 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 715 | lbs_deb_enter(LBS_DEB_CMD); |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 716 | cmd->command = cpu_to_le16(CMD_802_11_RF_CHANNEL); |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 717 | cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_rf_channel) + |
| 718 | S_DS_GEN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 719 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 720 | if (option == CMD_OPT_802_11_RF_CHANNEL_SET) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 721 | rfchan->currentchannel = cpu_to_le16(*((u16 *) pdata_buf)); |
| 722 | } |
| 723 | |
| 724 | rfchan->action = cpu_to_le16(option); |
| 725 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 726 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 727 | return 0; |
| 728 | } |
| 729 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 730 | static int lbs_cmd_802_11_rssi(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 731 | struct cmd_ds_command *cmd) |
| 732 | { |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 733 | struct lbs_adapter *adapter = priv->adapter; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 734 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 735 | lbs_deb_enter(LBS_DEB_CMD); |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 736 | cmd->command = cpu_to_le16(CMD_802_11_RSSI); |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 737 | 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] | 738 | cmd->params.rssi.N = cpu_to_le16(DEFAULT_BCN_AVG_FACTOR); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 739 | |
| 740 | /* reset Beacon SNR/NF/RSSI values */ |
| 741 | adapter->SNR[TYPE_BEACON][TYPE_NOAVG] = 0; |
| 742 | adapter->SNR[TYPE_BEACON][TYPE_AVG] = 0; |
| 743 | adapter->NF[TYPE_BEACON][TYPE_NOAVG] = 0; |
| 744 | adapter->NF[TYPE_BEACON][TYPE_AVG] = 0; |
| 745 | adapter->RSSI[TYPE_BEACON][TYPE_NOAVG] = 0; |
| 746 | adapter->RSSI[TYPE_BEACON][TYPE_AVG] = 0; |
| 747 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 748 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 749 | return 0; |
| 750 | } |
| 751 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 752 | static int lbs_cmd_reg_access(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 753 | struct cmd_ds_command *cmdptr, |
| 754 | u8 cmd_action, void *pdata_buf) |
| 755 | { |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 756 | struct lbs_offset_value *offval; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 757 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 758 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 759 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 760 | offval = (struct lbs_offset_value *)pdata_buf; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 761 | |
Holger Schurig | c2df2ef | 2007-12-07 15:30:44 +0000 | [diff] [blame] | 762 | switch (le16_to_cpu(cmdptr->command)) { |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 763 | case CMD_MAC_REG_ACCESS: |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 764 | { |
| 765 | struct cmd_ds_mac_reg_access *macreg; |
| 766 | |
| 767 | cmdptr->size = |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 768 | cpu_to_le16(sizeof (struct cmd_ds_mac_reg_access) |
| 769 | + S_DS_GEN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 770 | macreg = |
| 771 | (struct cmd_ds_mac_reg_access *)&cmdptr->params. |
| 772 | macreg; |
| 773 | |
| 774 | macreg->action = cpu_to_le16(cmd_action); |
| 775 | macreg->offset = cpu_to_le16((u16) offval->offset); |
| 776 | macreg->value = cpu_to_le32(offval->value); |
| 777 | |
| 778 | break; |
| 779 | } |
| 780 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 781 | case CMD_BBP_REG_ACCESS: |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 782 | { |
| 783 | struct cmd_ds_bbp_reg_access *bbpreg; |
| 784 | |
| 785 | cmdptr->size = |
| 786 | cpu_to_le16(sizeof |
| 787 | (struct cmd_ds_bbp_reg_access) |
| 788 | + S_DS_GEN); |
| 789 | bbpreg = |
| 790 | (struct cmd_ds_bbp_reg_access *)&cmdptr->params. |
| 791 | bbpreg; |
| 792 | |
| 793 | bbpreg->action = cpu_to_le16(cmd_action); |
| 794 | bbpreg->offset = cpu_to_le16((u16) offval->offset); |
| 795 | bbpreg->value = (u8) offval->value; |
| 796 | |
| 797 | break; |
| 798 | } |
| 799 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 800 | case CMD_RF_REG_ACCESS: |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 801 | { |
| 802 | struct cmd_ds_rf_reg_access *rfreg; |
| 803 | |
| 804 | cmdptr->size = |
| 805 | cpu_to_le16(sizeof |
| 806 | (struct cmd_ds_rf_reg_access) + |
| 807 | S_DS_GEN); |
| 808 | rfreg = |
| 809 | (struct cmd_ds_rf_reg_access *)&cmdptr->params. |
| 810 | rfreg; |
| 811 | |
| 812 | rfreg->action = cpu_to_le16(cmd_action); |
| 813 | rfreg->offset = cpu_to_le16((u16) offval->offset); |
| 814 | rfreg->value = (u8) offval->value; |
| 815 | |
| 816 | break; |
| 817 | } |
| 818 | |
| 819 | default: |
| 820 | break; |
| 821 | } |
| 822 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 823 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 824 | return 0; |
| 825 | } |
| 826 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 827 | static int lbs_cmd_802_11_mac_address(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 828 | struct cmd_ds_command *cmd, |
| 829 | u16 cmd_action) |
| 830 | { |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 831 | struct lbs_adapter *adapter = priv->adapter; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 832 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 833 | lbs_deb_enter(LBS_DEB_CMD); |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 834 | cmd->command = cpu_to_le16(CMD_802_11_MAC_ADDRESS); |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 835 | cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_mac_address) + |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 836 | S_DS_GEN); |
| 837 | cmd->result = 0; |
| 838 | |
| 839 | cmd->params.macadd.action = cpu_to_le16(cmd_action); |
| 840 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 841 | if (cmd_action == CMD_ACT_SET) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 842 | memcpy(cmd->params.macadd.macadd, |
| 843 | adapter->current_addr, ETH_ALEN); |
Holger Schurig | ece5619 | 2007-08-02 11:53:06 -0400 | [diff] [blame] | 844 | lbs_deb_hex(LBS_DEB_CMD, "SET_CMD: MAC addr", adapter->current_addr, 6); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 845 | } |
| 846 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 847 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 848 | return 0; |
| 849 | } |
| 850 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 851 | static int lbs_cmd_802_11_eeprom_access(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 852 | struct cmd_ds_command *cmd, |
| 853 | int cmd_action, void *pdata_buf) |
| 854 | { |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 855 | struct lbs_ioctl_regrdwr *ea = pdata_buf; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 856 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 857 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 858 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 859 | cmd->command = cpu_to_le16(CMD_802_11_EEPROM_ACCESS); |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 860 | cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_eeprom_access) + |
| 861 | S_DS_GEN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 862 | cmd->result = 0; |
| 863 | |
| 864 | cmd->params.rdeeprom.action = cpu_to_le16(ea->action); |
| 865 | cmd->params.rdeeprom.offset = cpu_to_le16(ea->offset); |
| 866 | cmd->params.rdeeprom.bytecount = cpu_to_le16(ea->NOB); |
| 867 | cmd->params.rdeeprom.value = 0; |
| 868 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 869 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 870 | return 0; |
| 871 | } |
| 872 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 873 | static int lbs_cmd_bt_access(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 874 | struct cmd_ds_command *cmd, |
| 875 | u16 cmd_action, void *pdata_buf) |
| 876 | { |
| 877 | struct cmd_ds_bt_access *bt_access = &cmd->params.bt; |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 878 | lbs_deb_enter_args(LBS_DEB_CMD, "action %d", cmd_action); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 879 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 880 | cmd->command = cpu_to_le16(CMD_BT_ACCESS); |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 881 | 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] | 882 | cmd->result = 0; |
| 883 | bt_access->action = cpu_to_le16(cmd_action); |
| 884 | |
| 885 | switch (cmd_action) { |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 886 | case CMD_ACT_BT_ACCESS_ADD: |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 887 | memcpy(bt_access->addr1, pdata_buf, 2 * ETH_ALEN); |
Holger Schurig | ece5619 | 2007-08-02 11:53:06 -0400 | [diff] [blame] | 888 | 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] | 889 | break; |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 890 | case CMD_ACT_BT_ACCESS_DEL: |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 891 | memcpy(bt_access->addr1, pdata_buf, 1 * ETH_ALEN); |
Holger Schurig | ece5619 | 2007-08-02 11:53:06 -0400 | [diff] [blame] | 892 | 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] | 893 | break; |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 894 | case CMD_ACT_BT_ACCESS_LIST: |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 895 | bt_access->id = cpu_to_le32(*(u32 *) pdata_buf); |
| 896 | break; |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 897 | case CMD_ACT_BT_ACCESS_RESET: |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 898 | break; |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 899 | case CMD_ACT_BT_ACCESS_SET_INVERT: |
Luis Carlos Cobo | 90e8eaf | 2007-05-25 13:53:26 -0400 | [diff] [blame] | 900 | bt_access->id = cpu_to_le32(*(u32 *) pdata_buf); |
| 901 | break; |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 902 | case CMD_ACT_BT_ACCESS_GET_INVERT: |
Luis Carlos Cobo | 90e8eaf | 2007-05-25 13:53:26 -0400 | [diff] [blame] | 903 | break; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 904 | default: |
| 905 | break; |
| 906 | } |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 907 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 908 | return 0; |
| 909 | } |
| 910 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 911 | static int lbs_cmd_fwt_access(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 912 | struct cmd_ds_command *cmd, |
| 913 | u16 cmd_action, void *pdata_buf) |
| 914 | { |
| 915 | struct cmd_ds_fwt_access *fwt_access = &cmd->params.fwt; |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 916 | lbs_deb_enter_args(LBS_DEB_CMD, "action %d", cmd_action); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 917 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 918 | cmd->command = cpu_to_le16(CMD_FWT_ACCESS); |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 919 | 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] | 920 | cmd->result = 0; |
| 921 | |
| 922 | if (pdata_buf) |
| 923 | memcpy(fwt_access, pdata_buf, sizeof(*fwt_access)); |
| 924 | else |
| 925 | memset(fwt_access, 0, sizeof(*fwt_access)); |
| 926 | |
| 927 | fwt_access->action = cpu_to_le16(cmd_action); |
| 928 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 929 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 930 | return 0; |
| 931 | } |
| 932 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 933 | static int lbs_cmd_mesh_access(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 934 | struct cmd_ds_command *cmd, |
| 935 | u16 cmd_action, void *pdata_buf) |
| 936 | { |
| 937 | struct cmd_ds_mesh_access *mesh_access = &cmd->params.mesh; |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 938 | lbs_deb_enter_args(LBS_DEB_CMD, "action %d", cmd_action); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 939 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 940 | cmd->command = cpu_to_le16(CMD_MESH_ACCESS); |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 941 | cmd->size = cpu_to_le16(sizeof(struct cmd_ds_mesh_access) + S_DS_GEN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 942 | cmd->result = 0; |
| 943 | |
| 944 | if (pdata_buf) |
| 945 | memcpy(mesh_access, pdata_buf, sizeof(*mesh_access)); |
| 946 | else |
| 947 | memset(mesh_access, 0, sizeof(*mesh_access)); |
| 948 | |
| 949 | mesh_access->action = cpu_to_le16(cmd_action); |
| 950 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 951 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 952 | return 0; |
| 953 | } |
| 954 | |
Brajesh Dave | 96287ac | 2007-11-20 17:44:28 -0500 | [diff] [blame] | 955 | static int lbs_cmd_bcn_ctrl(struct lbs_private * priv, |
| 956 | struct cmd_ds_command *cmd, |
| 957 | u16 cmd_action) |
| 958 | { |
| 959 | struct cmd_ds_802_11_beacon_control |
| 960 | *bcn_ctrl = &cmd->params.bcn_ctrl; |
| 961 | struct lbs_adapter *adapter = priv->adapter; |
| 962 | |
| 963 | lbs_deb_enter(LBS_DEB_CMD); |
| 964 | cmd->size = |
| 965 | cpu_to_le16(sizeof(struct cmd_ds_802_11_beacon_control) |
| 966 | + S_DS_GEN); |
| 967 | cmd->command = cpu_to_le16(CMD_802_11_BEACON_CTRL); |
| 968 | |
| 969 | bcn_ctrl->action = cpu_to_le16(cmd_action); |
| 970 | bcn_ctrl->beacon_enable = cpu_to_le16(adapter->beacon_enable); |
| 971 | bcn_ctrl->beacon_period = cpu_to_le16(adapter->beacon_period); |
| 972 | |
| 973 | lbs_deb_leave(LBS_DEB_CMD); |
| 974 | return 0; |
| 975 | } |
| 976 | |
Marcelo Tosatti | 29f5f2a | 2007-10-30 10:52:46 -0400 | [diff] [blame] | 977 | /* |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 978 | * Note: NEVER use lbs_queue_cmd() with addtail==0 other than for |
Marcelo Tosatti | 29f5f2a | 2007-10-30 10:52:46 -0400 | [diff] [blame] | 979 | * the command timer, because it does not account for queued commands. |
| 980 | */ |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 981 | void lbs_queue_cmd(struct lbs_adapter *adapter, |
| 982 | struct cmd_ctrl_node *cmdnode, |
| 983 | u8 addtail) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 984 | { |
| 985 | unsigned long flags; |
| 986 | struct cmd_ds_command *cmdptr; |
| 987 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 988 | lbs_deb_enter(LBS_DEB_HOST); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 989 | |
| 990 | if (!cmdnode) { |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 991 | lbs_deb_host("QUEUE_CMD: cmdnode is NULL\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 992 | goto done; |
| 993 | } |
| 994 | |
| 995 | cmdptr = (struct cmd_ds_command *)cmdnode->bufvirtualaddr; |
| 996 | if (!cmdptr) { |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 997 | lbs_deb_host("QUEUE_CMD: cmdptr is NULL\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 998 | goto done; |
| 999 | } |
| 1000 | |
| 1001 | /* Exit_PS command needs to be queued in the header always. */ |
Holger Schurig | c2df2ef | 2007-12-07 15:30:44 +0000 | [diff] [blame] | 1002 | if (le16_to_cpu(cmdptr->command) == CMD_802_11_PS_MODE) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1003 | struct cmd_ds_802_11_ps_mode *psm = &cmdptr->params.psmode; |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1004 | if (psm->action == cpu_to_le16(CMD_SUBCMD_EXIT_PS)) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1005 | if (adapter->psstate != PS_STATE_FULL_POWER) |
| 1006 | addtail = 0; |
| 1007 | } |
| 1008 | } |
| 1009 | |
| 1010 | spin_lock_irqsave(&adapter->driver_lock, flags); |
| 1011 | |
David Woodhouse | ac47246 | 2007-12-08 00:35:00 +0000 | [diff] [blame] | 1012 | if (addtail) |
Li Zefan | abe3ed1 | 2007-12-06 13:01:21 +0100 | [diff] [blame] | 1013 | list_add_tail(&cmdnode->list, &adapter->cmdpendingq); |
David Woodhouse | ac47246 | 2007-12-08 00:35:00 +0000 | [diff] [blame] | 1014 | else |
Li Zefan | abe3ed1 | 2007-12-06 13:01:21 +0100 | [diff] [blame] | 1015 | list_add(&cmdnode->list, &adapter->cmdpendingq); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1016 | |
| 1017 | spin_unlock_irqrestore(&adapter->driver_lock, flags); |
| 1018 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1019 | lbs_deb_host("QUEUE_CMD: inserted command 0x%04x into cmdpendingq\n", |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 1020 | le16_to_cpu(((struct cmd_ds_gen*)cmdnode->bufvirtualaddr)->command)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1021 | |
| 1022 | done: |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1023 | lbs_deb_leave(LBS_DEB_HOST); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1024 | } |
| 1025 | |
| 1026 | /* |
| 1027 | * TODO: Fix the issue when DownloadcommandToStation is being called the |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1028 | * second time when the command times out. All the cmdptr->xxx are in little |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1029 | * endian and therefore all the comparissions will fail. |
| 1030 | * For now - we are not performing the endian conversion the second time - but |
| 1031 | * for PS and DEEP_SLEEP we need to worry |
| 1032 | */ |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1033 | static int DownloadcommandToStation(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1034 | struct cmd_ctrl_node *cmdnode) |
| 1035 | { |
| 1036 | unsigned long flags; |
| 1037 | struct cmd_ds_command *cmdptr; |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1038 | struct lbs_adapter *adapter = priv->adapter; |
Eugene Teo | b031ac1 | 2007-08-02 13:18:07 -0400 | [diff] [blame] | 1039 | int ret = -1; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1040 | u16 cmdsize; |
| 1041 | u16 command; |
| 1042 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1043 | lbs_deb_enter(LBS_DEB_HOST); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1044 | |
| 1045 | if (!adapter || !cmdnode) { |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1046 | lbs_deb_host("DNLD_CMD: adapter or cmdmode is NULL\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1047 | goto done; |
| 1048 | } |
| 1049 | |
| 1050 | cmdptr = (struct cmd_ds_command *)cmdnode->bufvirtualaddr; |
| 1051 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1052 | spin_lock_irqsave(&adapter->driver_lock, flags); |
| 1053 | if (!cmdptr || !cmdptr->size) { |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1054 | lbs_deb_host("DNLD_CMD: cmdptr is NULL or zero\n"); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1055 | __lbs_cleanup_and_insert_cmd(priv, cmdnode); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1056 | spin_unlock_irqrestore(&adapter->driver_lock, flags); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1057 | goto done; |
| 1058 | } |
| 1059 | |
| 1060 | adapter->cur_cmd = cmdnode; |
| 1061 | adapter->cur_cmd_retcode = 0; |
| 1062 | spin_unlock_irqrestore(&adapter->driver_lock, flags); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1063 | |
Holger Schurig | c2df2ef | 2007-12-07 15:30:44 +0000 | [diff] [blame] | 1064 | cmdsize = le16_to_cpu(cmdptr->size); |
| 1065 | command = le16_to_cpu(cmdptr->command); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1066 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1067 | lbs_deb_host("DNLD_CMD: command 0x%04x, size %d, jiffies %lu\n", |
Holger Schurig | c2df2ef | 2007-12-07 15:30:44 +0000 | [diff] [blame] | 1068 | command, cmdsize, jiffies); |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1069 | lbs_deb_hex(LBS_DEB_HOST, "DNLD_CMD", cmdnode->bufvirtualaddr, cmdsize); |
| 1070 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1071 | cmdnode->cmdwaitqwoken = 0; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1072 | |
Holger Schurig | 208fdd2 | 2007-05-25 12:17:06 -0400 | [diff] [blame] | 1073 | ret = priv->hw_host_to_card(priv, MVMS_CMD, (u8 *) cmdptr, cmdsize); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1074 | |
| 1075 | if (ret != 0) { |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1076 | lbs_deb_host("DNLD_CMD: hw_host_to_card failed\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1077 | spin_lock_irqsave(&adapter->driver_lock, flags); |
Pierre Ossman | 794760f | 2007-08-20 12:24:42 -0400 | [diff] [blame] | 1078 | adapter->cur_cmd_retcode = ret; |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1079 | __lbs_cleanup_and_insert_cmd(priv, adapter->cur_cmd); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1080 | adapter->cur_cmd = NULL; |
| 1081 | spin_unlock_irqrestore(&adapter->driver_lock, flags); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1082 | goto done; |
| 1083 | } |
| 1084 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1085 | lbs_deb_cmd("DNLD_CMD: sent command 0x%04x, jiffies %lu\n", command, jiffies); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1086 | |
| 1087 | /* Setup the timer after transmit command */ |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1088 | if (command == CMD_802_11_SCAN || command == CMD_802_11_AUTHENTICATE |
| 1089 | || command == CMD_802_11_ASSOCIATE) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1090 | mod_timer(&adapter->command_timer, jiffies + (10*HZ)); |
| 1091 | else |
| 1092 | mod_timer(&adapter->command_timer, jiffies + (5*HZ)); |
| 1093 | |
| 1094 | ret = 0; |
| 1095 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1096 | done: |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1097 | lbs_deb_leave_args(LBS_DEB_HOST, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1098 | return ret; |
| 1099 | } |
| 1100 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1101 | static int lbs_cmd_mac_control(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1102 | struct cmd_ds_command *cmd) |
| 1103 | { |
| 1104 | struct cmd_ds_mac_control *mac = &cmd->params.macctrl; |
| 1105 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1106 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1107 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1108 | cmd->command = cpu_to_le16(CMD_MAC_CONTROL); |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 1109 | cmd->size = cpu_to_le16(sizeof(struct cmd_ds_mac_control) + S_DS_GEN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1110 | mac->action = cpu_to_le16(priv->adapter->currentpacketfilter); |
| 1111 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1112 | lbs_deb_cmd("MAC_CONTROL: action 0x%x, size %d\n", |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 1113 | le16_to_cpu(mac->action), le16_to_cpu(cmd->size)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1114 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1115 | lbs_deb_leave(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1116 | return 0; |
| 1117 | } |
| 1118 | |
| 1119 | /** |
| 1120 | * This function inserts command node to cmdfreeq |
| 1121 | * after cleans it. Requires adapter->driver_lock held. |
| 1122 | */ |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1123 | void __lbs_cleanup_and_insert_cmd(struct lbs_private *priv, |
| 1124 | struct cmd_ctrl_node *ptempcmd) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1125 | { |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1126 | struct lbs_adapter *adapter = priv->adapter; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1127 | |
| 1128 | if (!ptempcmd) |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1129 | return; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1130 | |
| 1131 | cleanup_cmdnode(ptempcmd); |
Li Zefan | abe3ed1 | 2007-12-06 13:01:21 +0100 | [diff] [blame] | 1132 | list_add_tail(&ptempcmd->list, &adapter->cmdfreeq); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1133 | } |
| 1134 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1135 | static void lbs_cleanup_and_insert_cmd(struct lbs_private *priv, |
| 1136 | struct cmd_ctrl_node *ptempcmd) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1137 | { |
| 1138 | unsigned long flags; |
| 1139 | |
| 1140 | spin_lock_irqsave(&priv->adapter->driver_lock, flags); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1141 | __lbs_cleanup_and_insert_cmd(priv, ptempcmd); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1142 | spin_unlock_irqrestore(&priv->adapter->driver_lock, flags); |
| 1143 | } |
| 1144 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1145 | int lbs_set_radio_control(struct lbs_private *priv) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1146 | { |
| 1147 | int ret = 0; |
| 1148 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1149 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1150 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1151 | ret = lbs_prepare_and_send_command(priv, |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1152 | CMD_802_11_RADIO_CONTROL, |
| 1153 | CMD_ACT_SET, |
| 1154 | CMD_OPTION_WAITFORRSP, 0, NULL); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1155 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1156 | lbs_deb_cmd("RADIO_SET: radio %d, preamble %d\n", |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1157 | priv->adapter->radioon, priv->adapter->preamble); |
| 1158 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1159 | lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1160 | return ret; |
| 1161 | } |
| 1162 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1163 | int lbs_set_mac_packet_filter(struct lbs_private *priv) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1164 | { |
| 1165 | int ret = 0; |
| 1166 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1167 | lbs_deb_enter(LBS_DEB_CMD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1168 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1169 | /* Send MAC control command to station */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1170 | ret = lbs_prepare_and_send_command(priv, |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1171 | CMD_MAC_CONTROL, 0, 0, 0, NULL); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1172 | |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1173 | lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1174 | return ret; |
| 1175 | } |
| 1176 | |
| 1177 | /** |
| 1178 | * @brief This function prepare the command before send to firmware. |
| 1179 | * |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1180 | * @param priv A pointer to struct lbs_private structure |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1181 | * @param cmd_no command number |
| 1182 | * @param cmd_action command action: GET or SET |
| 1183 | * @param wait_option wait option: wait response or not |
| 1184 | * @param cmd_oid cmd oid: treated as sub command |
| 1185 | * @param pdata_buf A pointer to informaion buffer |
| 1186 | * @return 0 or -1 |
| 1187 | */ |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1188 | int lbs_prepare_and_send_command(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1189 | u16 cmd_no, |
| 1190 | u16 cmd_action, |
| 1191 | u16 wait_option, u32 cmd_oid, void *pdata_buf) |
| 1192 | { |
| 1193 | int ret = 0; |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1194 | struct lbs_adapter *adapter = priv->adapter; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1195 | struct cmd_ctrl_node *cmdnode; |
| 1196 | struct cmd_ds_command *cmdptr; |
| 1197 | unsigned long flags; |
| 1198 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1199 | lbs_deb_enter(LBS_DEB_HOST); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1200 | |
| 1201 | if (!adapter) { |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1202 | lbs_deb_host("PREP_CMD: adapter is NULL\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1203 | ret = -1; |
| 1204 | goto done; |
| 1205 | } |
| 1206 | |
| 1207 | if (adapter->surpriseremoved) { |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1208 | lbs_deb_host("PREP_CMD: card removed\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1209 | ret = -1; |
| 1210 | goto done; |
| 1211 | } |
| 1212 | |
Holger Schurig | 0d61d04 | 2007-12-05 17:58:06 +0100 | [diff] [blame] | 1213 | cmdnode = lbs_get_cmd_ctrl_node(priv); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1214 | |
| 1215 | if (cmdnode == NULL) { |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1216 | lbs_deb_host("PREP_CMD: cmdnode is NULL\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1217 | |
| 1218 | /* Wake up main thread to execute next command */ |
Dan Williams | fe33615 | 2007-08-02 11:32:25 -0400 | [diff] [blame] | 1219 | wake_up_interruptible(&priv->waitq); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1220 | ret = -1; |
| 1221 | goto done; |
| 1222 | } |
| 1223 | |
David Woodhouse | f5ece8f | 2007-12-01 15:15:41 +0000 | [diff] [blame] | 1224 | lbs_set_cmd_ctrl_node(priv, cmdnode, wait_option, pdata_buf); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1225 | |
| 1226 | cmdptr = (struct cmd_ds_command *)cmdnode->bufvirtualaddr; |
| 1227 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1228 | lbs_deb_host("PREP_CMD: command 0x%04x\n", cmd_no); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1229 | |
| 1230 | if (!cmdptr) { |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1231 | lbs_deb_host("PREP_CMD: cmdptr is NULL\n"); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1232 | lbs_cleanup_and_insert_cmd(priv, cmdnode); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1233 | ret = -1; |
| 1234 | goto done; |
| 1235 | } |
| 1236 | |
| 1237 | /* Set sequence number, command and INT option */ |
| 1238 | adapter->seqnum++; |
| 1239 | cmdptr->seqnum = cpu_to_le16(adapter->seqnum); |
| 1240 | |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 1241 | cmdptr->command = cpu_to_le16(cmd_no); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1242 | cmdptr->result = 0; |
| 1243 | |
| 1244 | switch (cmd_no) { |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1245 | case CMD_GET_HW_SPEC: |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1246 | ret = lbs_cmd_hw_spec(priv, cmdptr); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1247 | break; |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1248 | case CMD_802_11_PS_MODE: |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1249 | ret = lbs_cmd_802_11_ps_mode(priv, cmdptr, cmd_action); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1250 | break; |
| 1251 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1252 | case CMD_802_11_SCAN: |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1253 | ret = lbs_cmd_80211_scan(priv, cmdptr, pdata_buf); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1254 | break; |
| 1255 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1256 | case CMD_MAC_CONTROL: |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1257 | ret = lbs_cmd_mac_control(priv, cmdptr); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1258 | break; |
| 1259 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1260 | case CMD_802_11_ASSOCIATE: |
| 1261 | case CMD_802_11_REASSOCIATE: |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1262 | ret = lbs_cmd_80211_associate(priv, cmdptr, pdata_buf); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1263 | break; |
| 1264 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1265 | case CMD_802_11_DEAUTHENTICATE: |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1266 | ret = lbs_cmd_80211_deauthenticate(priv, cmdptr); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1267 | break; |
| 1268 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1269 | case CMD_802_11_SET_WEP: |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1270 | ret = lbs_cmd_802_11_set_wep(priv, cmdptr, cmd_action, pdata_buf); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1271 | break; |
| 1272 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1273 | case CMD_802_11_AD_HOC_START: |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1274 | ret = lbs_cmd_80211_ad_hoc_start(priv, cmdptr, pdata_buf); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1275 | break; |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1276 | case CMD_CODE_DNLD: |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1277 | break; |
| 1278 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1279 | case CMD_802_11_RESET: |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1280 | ret = lbs_cmd_802_11_reset(priv, cmdptr, cmd_action); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1281 | break; |
| 1282 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1283 | case CMD_802_11_GET_LOG: |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1284 | ret = lbs_cmd_802_11_get_log(priv, cmdptr); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1285 | break; |
| 1286 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1287 | case CMD_802_11_AUTHENTICATE: |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1288 | ret = lbs_cmd_80211_authenticate(priv, cmdptr, pdata_buf); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1289 | break; |
| 1290 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1291 | case CMD_802_11_GET_STAT: |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1292 | ret = lbs_cmd_802_11_get_stat(priv, cmdptr); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1293 | break; |
| 1294 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1295 | case CMD_802_11_SNMP_MIB: |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1296 | ret = lbs_cmd_802_11_snmp_mib(priv, cmdptr, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1297 | cmd_action, cmd_oid, pdata_buf); |
| 1298 | break; |
| 1299 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1300 | case CMD_MAC_REG_ACCESS: |
| 1301 | case CMD_BBP_REG_ACCESS: |
| 1302 | case CMD_RF_REG_ACCESS: |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1303 | ret = lbs_cmd_reg_access(priv, cmdptr, cmd_action, pdata_buf); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1304 | break; |
| 1305 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1306 | case CMD_802_11_RF_CHANNEL: |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1307 | ret = lbs_cmd_802_11_rf_channel(priv, cmdptr, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1308 | cmd_action, pdata_buf); |
| 1309 | break; |
| 1310 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1311 | case CMD_802_11_RF_TX_POWER: |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1312 | ret = lbs_cmd_802_11_rf_tx_power(priv, cmdptr, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1313 | cmd_action, pdata_buf); |
| 1314 | break; |
| 1315 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1316 | case CMD_802_11_RADIO_CONTROL: |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1317 | ret = lbs_cmd_802_11_radio_control(priv, cmdptr, cmd_action); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1318 | break; |
| 1319 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1320 | case CMD_802_11_DATA_RATE: |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1321 | ret = lbs_cmd_802_11_data_rate(priv, cmdptr, cmd_action); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1322 | break; |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1323 | case CMD_802_11_RATE_ADAPT_RATESET: |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1324 | ret = lbs_cmd_802_11_rate_adapt_rateset(priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1325 | cmdptr, cmd_action); |
| 1326 | break; |
| 1327 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1328 | case CMD_MAC_MULTICAST_ADR: |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1329 | ret = lbs_cmd_mac_multicast_adr(priv, cmdptr, cmd_action); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1330 | break; |
| 1331 | |
Luis Carlos Cobo | 965f8bb | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 1332 | case CMD_802_11_MONITOR_MODE: |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1333 | ret = lbs_cmd_802_11_monitor_mode(priv, cmdptr, |
Luis Carlos Cobo | 965f8bb | 2007-08-02 13:16:55 -0400 | [diff] [blame] | 1334 | cmd_action, pdata_buf); |
| 1335 | break; |
| 1336 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1337 | case CMD_802_11_AD_HOC_JOIN: |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1338 | ret = lbs_cmd_80211_ad_hoc_join(priv, cmdptr, pdata_buf); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1339 | break; |
| 1340 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1341 | case CMD_802_11_RSSI: |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1342 | ret = lbs_cmd_802_11_rssi(priv, cmdptr); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1343 | break; |
| 1344 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1345 | case CMD_802_11_AD_HOC_STOP: |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1346 | ret = lbs_cmd_80211_ad_hoc_stop(priv, cmdptr); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1347 | break; |
| 1348 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1349 | case CMD_802_11_ENABLE_RSN: |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1350 | ret = lbs_cmd_802_11_enable_rsn(priv, cmdptr, cmd_action, |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 1351 | pdata_buf); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1352 | break; |
| 1353 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1354 | case CMD_802_11_KEY_MATERIAL: |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1355 | ret = lbs_cmd_802_11_key_material(priv, cmdptr, cmd_action, |
Dan Williams | 90a4221 | 2007-05-25 23:01:24 -0400 | [diff] [blame] | 1356 | cmd_oid, pdata_buf); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1357 | break; |
| 1358 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1359 | case CMD_802_11_PAIRWISE_TSC: |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1360 | break; |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1361 | case CMD_802_11_GROUP_TSC: |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1362 | break; |
| 1363 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1364 | case CMD_802_11_MAC_ADDRESS: |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1365 | ret = lbs_cmd_802_11_mac_address(priv, cmdptr, cmd_action); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1366 | break; |
| 1367 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1368 | case CMD_802_11_EEPROM_ACCESS: |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1369 | ret = lbs_cmd_802_11_eeprom_access(priv, cmdptr, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1370 | cmd_action, pdata_buf); |
| 1371 | break; |
| 1372 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1373 | case CMD_802_11_SET_AFC: |
| 1374 | case CMD_802_11_GET_AFC: |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1375 | |
| 1376 | cmdptr->command = cpu_to_le16(cmd_no); |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 1377 | cmdptr->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_afc) + |
| 1378 | S_DS_GEN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1379 | |
| 1380 | memmove(&cmdptr->params.afc, |
| 1381 | pdata_buf, sizeof(struct cmd_ds_802_11_afc)); |
| 1382 | |
| 1383 | ret = 0; |
| 1384 | goto done; |
| 1385 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1386 | case CMD_802_11D_DOMAIN_INFO: |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1387 | ret = lbs_cmd_802_11d_domain_info(priv, cmdptr, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1388 | cmd_no, cmd_action); |
| 1389 | break; |
| 1390 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1391 | case CMD_802_11_SLEEP_PARAMS: |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1392 | ret = lbs_cmd_802_11_sleep_params(priv, cmdptr, cmd_action); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1393 | break; |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1394 | case CMD_802_11_INACTIVITY_TIMEOUT: |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1395 | ret = lbs_cmd_802_11_inactivity_timeout(priv, cmdptr, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1396 | cmd_action, pdata_buf); |
David Woodhouse | f5ece8f | 2007-12-01 15:15:41 +0000 | [diff] [blame] | 1397 | lbs_set_cmd_ctrl_node(priv, cmdnode, 0, pdata_buf); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1398 | break; |
| 1399 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1400 | case CMD_802_11_TPC_CFG: |
| 1401 | cmdptr->command = cpu_to_le16(CMD_802_11_TPC_CFG); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1402 | cmdptr->size = |
| 1403 | cpu_to_le16(sizeof(struct cmd_ds_802_11_tpc_cfg) + |
| 1404 | S_DS_GEN); |
| 1405 | |
| 1406 | memmove(&cmdptr->params.tpccfg, |
| 1407 | pdata_buf, sizeof(struct cmd_ds_802_11_tpc_cfg)); |
| 1408 | |
| 1409 | ret = 0; |
| 1410 | break; |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1411 | case CMD_802_11_LED_GPIO_CTRL: |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1412 | { |
| 1413 | struct mrvlietypes_ledgpio *gpio = |
| 1414 | (struct mrvlietypes_ledgpio*) |
| 1415 | cmdptr->params.ledgpio.data; |
| 1416 | |
| 1417 | memmove(&cmdptr->params.ledgpio, |
| 1418 | pdata_buf, |
| 1419 | sizeof(struct cmd_ds_802_11_led_ctrl)); |
| 1420 | |
| 1421 | cmdptr->command = |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1422 | cpu_to_le16(CMD_802_11_LED_GPIO_CTRL); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1423 | |
| 1424 | #define ACTION_NUMLED_TLVTYPE_LEN_FIELDS_LEN 8 |
| 1425 | cmdptr->size = |
Holger Schurig | c2df2ef | 2007-12-07 15:30:44 +0000 | [diff] [blame] | 1426 | cpu_to_le16(le16_to_cpu(gpio->header.len) |
| 1427 | + S_DS_GEN |
| 1428 | + ACTION_NUMLED_TLVTYPE_LEN_FIELDS_LEN); |
| 1429 | gpio->header.len = gpio->header.len; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1430 | |
| 1431 | ret = 0; |
| 1432 | break; |
| 1433 | } |
Holger Schurig | 3a18864 | 2007-11-26 10:07:14 +0100 | [diff] [blame] | 1434 | case CMD_802_11_SUBSCRIBE_EVENT: |
| 1435 | lbs_cmd_802_11_subscribe_event(priv, cmdptr, |
| 1436 | cmd_action, pdata_buf); |
| 1437 | break; |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1438 | case CMD_802_11_PWR_CFG: |
| 1439 | cmdptr->command = cpu_to_le16(CMD_802_11_PWR_CFG); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1440 | cmdptr->size = |
| 1441 | cpu_to_le16(sizeof(struct cmd_ds_802_11_pwr_cfg) + |
| 1442 | S_DS_GEN); |
| 1443 | memmove(&cmdptr->params.pwrcfg, pdata_buf, |
| 1444 | sizeof(struct cmd_ds_802_11_pwr_cfg)); |
| 1445 | |
| 1446 | ret = 0; |
| 1447 | break; |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1448 | case CMD_BT_ACCESS: |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1449 | ret = lbs_cmd_bt_access(priv, cmdptr, cmd_action, pdata_buf); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1450 | break; |
| 1451 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1452 | case CMD_FWT_ACCESS: |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1453 | ret = lbs_cmd_fwt_access(priv, cmdptr, cmd_action, pdata_buf); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1454 | break; |
| 1455 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1456 | case CMD_MESH_ACCESS: |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1457 | ret = lbs_cmd_mesh_access(priv, cmdptr, cmd_action, pdata_buf); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1458 | break; |
| 1459 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1460 | case CMD_GET_TSF: |
| 1461 | cmdptr->command = cpu_to_le16(CMD_GET_TSF); |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 1462 | cmdptr->size = cpu_to_le16(sizeof(struct cmd_ds_get_tsf) + |
| 1463 | S_DS_GEN); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1464 | ret = 0; |
| 1465 | break; |
Brajesh Dave | 96287ac | 2007-11-20 17:44:28 -0500 | [diff] [blame] | 1466 | case CMD_802_11_BEACON_CTRL: |
| 1467 | ret = lbs_cmd_bcn_ctrl(priv, cmdptr, cmd_action); |
| 1468 | break; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1469 | default: |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1470 | lbs_deb_host("PREP_CMD: unknown command 0x%04x\n", cmd_no); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1471 | ret = -1; |
| 1472 | break; |
| 1473 | } |
| 1474 | |
| 1475 | /* return error, since the command preparation failed */ |
| 1476 | if (ret != 0) { |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1477 | lbs_deb_host("PREP_CMD: command preparation failed\n"); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1478 | lbs_cleanup_and_insert_cmd(priv, cmdnode); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1479 | ret = -1; |
| 1480 | goto done; |
| 1481 | } |
| 1482 | |
| 1483 | cmdnode->cmdwaitqwoken = 0; |
| 1484 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1485 | lbs_queue_cmd(adapter, cmdnode, 1); |
Dan Williams | fe33615 | 2007-08-02 11:32:25 -0400 | [diff] [blame] | 1486 | wake_up_interruptible(&priv->waitq); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1487 | |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1488 | if (wait_option & CMD_OPTION_WAITFORRSP) { |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1489 | lbs_deb_host("PREP_CMD: wait for response\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1490 | might_sleep(); |
| 1491 | wait_event_interruptible(cmdnode->cmdwait_q, |
| 1492 | cmdnode->cmdwaitqwoken); |
| 1493 | } |
| 1494 | |
| 1495 | spin_lock_irqsave(&adapter->driver_lock, flags); |
| 1496 | if (adapter->cur_cmd_retcode) { |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1497 | lbs_deb_host("PREP_CMD: command failed with return code %d\n", |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1498 | adapter->cur_cmd_retcode); |
| 1499 | adapter->cur_cmd_retcode = 0; |
| 1500 | ret = -1; |
| 1501 | } |
| 1502 | spin_unlock_irqrestore(&adapter->driver_lock, flags); |
| 1503 | |
| 1504 | done: |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1505 | lbs_deb_leave_args(LBS_DEB_HOST, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1506 | return ret; |
| 1507 | } |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1508 | EXPORT_SYMBOL_GPL(lbs_prepare_and_send_command); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1509 | |
| 1510 | /** |
| 1511 | * @brief This function allocates the command buffer and link |
| 1512 | * it to command free queue. |
| 1513 | * |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1514 | * @param priv A pointer to struct lbs_private structure |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1515 | * @return 0 or -1 |
| 1516 | */ |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1517 | int lbs_allocate_cmd_buffer(struct lbs_private *priv) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1518 | { |
| 1519 | int ret = 0; |
| 1520 | u32 ulbufsize; |
| 1521 | u32 i; |
| 1522 | struct cmd_ctrl_node *tempcmd_array; |
| 1523 | u8 *ptempvirtualaddr; |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1524 | struct lbs_adapter *adapter = priv->adapter; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1525 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1526 | lbs_deb_enter(LBS_DEB_HOST); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1527 | |
| 1528 | /* Allocate and initialize cmdCtrlNode */ |
| 1529 | ulbufsize = sizeof(struct cmd_ctrl_node) * MRVDRV_NUM_OF_CMD_BUFFER; |
| 1530 | |
Holger Schurig | fb3dddf | 2007-05-25 11:58:22 -0400 | [diff] [blame] | 1531 | if (!(tempcmd_array = kzalloc(ulbufsize, GFP_KERNEL))) { |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1532 | lbs_deb_host("ALLOC_CMD_BUF: tempcmd_array is NULL\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1533 | ret = -1; |
| 1534 | goto done; |
| 1535 | } |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1536 | adapter->cmd_array = tempcmd_array; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1537 | |
| 1538 | /* Allocate and initialize command buffers */ |
| 1539 | ulbufsize = MRVDRV_SIZE_OF_CMD_BUFFER; |
| 1540 | for (i = 0; i < MRVDRV_NUM_OF_CMD_BUFFER; i++) { |
Holger Schurig | fb3dddf | 2007-05-25 11:58:22 -0400 | [diff] [blame] | 1541 | if (!(ptempvirtualaddr = kzalloc(ulbufsize, GFP_KERNEL))) { |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1542 | lbs_deb_host("ALLOC_CMD_BUF: ptempvirtualaddr is NULL\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1543 | ret = -1; |
| 1544 | goto done; |
| 1545 | } |
| 1546 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1547 | /* Update command buffer virtual */ |
| 1548 | tempcmd_array[i].bufvirtualaddr = ptempvirtualaddr; |
| 1549 | } |
| 1550 | |
| 1551 | for (i = 0; i < MRVDRV_NUM_OF_CMD_BUFFER; i++) { |
| 1552 | init_waitqueue_head(&tempcmd_array[i].cmdwait_q); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1553 | lbs_cleanup_and_insert_cmd(priv, &tempcmd_array[i]); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1554 | } |
| 1555 | |
| 1556 | ret = 0; |
Holger Schurig | 9012b28 | 2007-05-25 11:27:16 -0400 | [diff] [blame] | 1557 | |
| 1558 | done: |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1559 | lbs_deb_leave_args(LBS_DEB_HOST, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1560 | return ret; |
| 1561 | } |
| 1562 | |
| 1563 | /** |
| 1564 | * @brief This function frees the command buffer. |
| 1565 | * |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1566 | * @param priv A pointer to struct lbs_private structure |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1567 | * @return 0 or -1 |
| 1568 | */ |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1569 | int lbs_free_cmd_buffer(struct lbs_private *priv) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1570 | { |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 1571 | u32 ulbufsize; /* Someone needs to die for this. Slowly and painfully */ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1572 | unsigned int i; |
| 1573 | struct cmd_ctrl_node *tempcmd_array; |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1574 | struct lbs_adapter *adapter = priv->adapter; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1575 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1576 | lbs_deb_enter(LBS_DEB_HOST); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1577 | |
| 1578 | /* need to check if cmd array is allocated or not */ |
| 1579 | if (adapter->cmd_array == NULL) { |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1580 | lbs_deb_host("FREE_CMD_BUF: cmd_array is NULL\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1581 | goto done; |
| 1582 | } |
| 1583 | |
| 1584 | tempcmd_array = adapter->cmd_array; |
| 1585 | |
| 1586 | /* Release shared memory buffers */ |
| 1587 | ulbufsize = MRVDRV_SIZE_OF_CMD_BUFFER; |
| 1588 | for (i = 0; i < MRVDRV_NUM_OF_CMD_BUFFER; i++) { |
| 1589 | if (tempcmd_array[i].bufvirtualaddr) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1590 | kfree(tempcmd_array[i].bufvirtualaddr); |
| 1591 | tempcmd_array[i].bufvirtualaddr = NULL; |
| 1592 | } |
| 1593 | } |
| 1594 | |
| 1595 | /* Release cmd_ctrl_node */ |
| 1596 | if (adapter->cmd_array) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1597 | kfree(adapter->cmd_array); |
| 1598 | adapter->cmd_array = NULL; |
| 1599 | } |
| 1600 | |
| 1601 | done: |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1602 | lbs_deb_leave(LBS_DEB_HOST); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1603 | return 0; |
| 1604 | } |
| 1605 | |
| 1606 | /** |
| 1607 | * @brief This function gets a free command node if available in |
| 1608 | * 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 cmd_ctrl_node A pointer to cmd_ctrl_node structure or NULL |
| 1612 | */ |
Holger Schurig | 0d61d04 | 2007-12-05 17:58:06 +0100 | [diff] [blame] | 1613 | 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] | 1614 | { |
| 1615 | struct cmd_ctrl_node *tempnode; |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1616 | struct lbs_adapter *adapter = priv->adapter; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1617 | unsigned long flags; |
| 1618 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1619 | lbs_deb_enter(LBS_DEB_HOST); |
| 1620 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1621 | if (!adapter) |
| 1622 | return NULL; |
| 1623 | |
| 1624 | spin_lock_irqsave(&adapter->driver_lock, flags); |
| 1625 | |
| 1626 | if (!list_empty(&adapter->cmdfreeq)) { |
Li Zefan | abe3ed1 | 2007-12-06 13:01:21 +0100 | [diff] [blame] | 1627 | tempnode = list_first_entry(&adapter->cmdfreeq, |
| 1628 | struct cmd_ctrl_node, list); |
| 1629 | list_del(&tempnode->list); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1630 | } else { |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1631 | 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] | 1632 | tempnode = NULL; |
| 1633 | } |
| 1634 | |
| 1635 | spin_unlock_irqrestore(&adapter->driver_lock, flags); |
| 1636 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1637 | if (tempnode) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1638 | cleanup_cmdnode(tempnode); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1639 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1640 | lbs_deb_leave(LBS_DEB_HOST); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1641 | return tempnode; |
| 1642 | } |
| 1643 | |
| 1644 | /** |
| 1645 | * @brief This function cleans command node. |
| 1646 | * |
| 1647 | * @param ptempnode A pointer to cmdCtrlNode structure |
| 1648 | * @return n/a |
| 1649 | */ |
| 1650 | static void cleanup_cmdnode(struct cmd_ctrl_node *ptempnode) |
| 1651 | { |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1652 | lbs_deb_enter(LBS_DEB_HOST); |
| 1653 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1654 | if (!ptempnode) |
| 1655 | return; |
| 1656 | ptempnode->cmdwaitqwoken = 1; |
| 1657 | wake_up_interruptible(&ptempnode->cmdwait_q); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1658 | ptempnode->wait_option = 0; |
| 1659 | ptempnode->pdata_buf = NULL; |
David Woodhouse | 1723047 | 2007-12-07 15:13:05 +0000 | [diff] [blame] | 1660 | ptempnode->callback = NULL; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1661 | |
| 1662 | if (ptempnode->bufvirtualaddr != NULL) |
| 1663 | memset(ptempnode->bufvirtualaddr, 0, MRVDRV_SIZE_OF_CMD_BUFFER); |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1664 | |
| 1665 | lbs_deb_leave(LBS_DEB_HOST); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1666 | } |
| 1667 | |
| 1668 | /** |
| 1669 | * @brief This function initializes the command node. |
| 1670 | * |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1671 | * @param priv A pointer to struct lbs_private structure |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1672 | * @param ptempnode A pointer to cmd_ctrl_node structure |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1673 | * @param wait_option wait option: wait response or not |
| 1674 | * @param pdata_buf A pointer to informaion buffer |
| 1675 | * @return 0 or -1 |
| 1676 | */ |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1677 | void lbs_set_cmd_ctrl_node(struct lbs_private *priv, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1678 | struct cmd_ctrl_node *ptempnode, |
David Woodhouse | f5ece8f | 2007-12-01 15:15:41 +0000 | [diff] [blame] | 1679 | u16 wait_option, void *pdata_buf) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1680 | { |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1681 | lbs_deb_enter(LBS_DEB_HOST); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1682 | |
| 1683 | if (!ptempnode) |
| 1684 | return; |
| 1685 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1686 | ptempnode->wait_option = wait_option; |
| 1687 | ptempnode->pdata_buf = pdata_buf; |
David Woodhouse | 1723047 | 2007-12-07 15:13:05 +0000 | [diff] [blame] | 1688 | ptempnode->callback = NULL; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1689 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1690 | lbs_deb_leave(LBS_DEB_HOST); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1691 | } |
| 1692 | |
| 1693 | /** |
| 1694 | * @brief This function executes next command in command |
| 1695 | * pending queue. It will put fimware back to PS mode |
| 1696 | * if applicable. |
| 1697 | * |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1698 | * @param priv A pointer to struct lbs_private structure |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1699 | * @return 0 or -1 |
| 1700 | */ |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1701 | int lbs_execute_next_command(struct lbs_private *priv) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1702 | { |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1703 | struct lbs_adapter *adapter = priv->adapter; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1704 | struct cmd_ctrl_node *cmdnode = NULL; |
| 1705 | struct cmd_ds_command *cmdptr; |
| 1706 | unsigned long flags; |
| 1707 | int ret = 0; |
| 1708 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1709 | // Debug group is LBS_DEB_THREAD and not LBS_DEB_HOST, because the |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1710 | // only caller to us is lbs_thread() and we get even when a |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1711 | // data packet is received |
| 1712 | lbs_deb_enter(LBS_DEB_THREAD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1713 | |
| 1714 | spin_lock_irqsave(&adapter->driver_lock, flags); |
| 1715 | |
| 1716 | if (adapter->cur_cmd) { |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1717 | lbs_pr_alert( "EXEC_NEXT_CMD: already processing command!\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1718 | spin_unlock_irqrestore(&adapter->driver_lock, flags); |
| 1719 | ret = -1; |
| 1720 | goto done; |
| 1721 | } |
| 1722 | |
| 1723 | if (!list_empty(&adapter->cmdpendingq)) { |
Li Zefan | abe3ed1 | 2007-12-06 13:01:21 +0100 | [diff] [blame] | 1724 | cmdnode = list_first_entry(&adapter->cmdpendingq, |
| 1725 | struct cmd_ctrl_node, list); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1726 | } |
| 1727 | |
| 1728 | spin_unlock_irqrestore(&adapter->driver_lock, flags); |
| 1729 | |
| 1730 | if (cmdnode) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1731 | cmdptr = (struct cmd_ds_command *)cmdnode->bufvirtualaddr; |
| 1732 | |
| 1733 | if (is_command_allowed_in_ps(cmdptr->command)) { |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 1734 | if ((adapter->psstate == PS_STATE_SLEEP) || |
| 1735 | (adapter->psstate == PS_STATE_PRE_SLEEP)) { |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1736 | lbs_deb_host( |
| 1737 | "EXEC_NEXT_CMD: cannot send cmd 0x%04x in psstate %d\n", |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 1738 | le16_to_cpu(cmdptr->command), |
| 1739 | adapter->psstate); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1740 | ret = -1; |
| 1741 | goto done; |
| 1742 | } |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1743 | lbs_deb_host("EXEC_NEXT_CMD: OK to send command " |
| 1744 | "0x%04x in psstate %d\n", |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 1745 | le16_to_cpu(cmdptr->command), |
| 1746 | adapter->psstate); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1747 | } else if (adapter->psstate != PS_STATE_FULL_POWER) { |
| 1748 | /* |
| 1749 | * 1. Non-PS command: |
| 1750 | * Queue it. set needtowakeup to TRUE if current state |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1751 | * is SLEEP, otherwise call lbs_ps_wakeup to send Exit_PS. |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1752 | * 2. PS command but not Exit_PS: |
| 1753 | * Ignore it. |
| 1754 | * 3. PS command Exit_PS: |
| 1755 | * Set needtowakeup to TRUE if current state is SLEEP, |
| 1756 | * otherwise send this command down to firmware |
| 1757 | * immediately. |
| 1758 | */ |
| 1759 | if (cmdptr->command != |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1760 | cpu_to_le16(CMD_802_11_PS_MODE)) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1761 | /* Prepare to send Exit PS, |
| 1762 | * this non PS command will be sent later */ |
| 1763 | if ((adapter->psstate == PS_STATE_SLEEP) |
| 1764 | || (adapter->psstate == PS_STATE_PRE_SLEEP) |
| 1765 | ) { |
| 1766 | /* w/ new scheme, it will not reach here. |
| 1767 | since it is blocked in main_thread. */ |
| 1768 | adapter->needtowakeup = 1; |
| 1769 | } else |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1770 | lbs_ps_wakeup(priv, 0); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1771 | |
| 1772 | ret = 0; |
| 1773 | goto done; |
| 1774 | } else { |
| 1775 | /* |
| 1776 | * PS command. Ignore it if it is not Exit_PS. |
| 1777 | * otherwise send it down immediately. |
| 1778 | */ |
| 1779 | struct cmd_ds_802_11_ps_mode *psm = |
| 1780 | &cmdptr->params.psmode; |
| 1781 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1782 | lbs_deb_host( |
| 1783 | "EXEC_NEXT_CMD: PS cmd, action 0x%02x\n", |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1784 | psm->action); |
| 1785 | if (psm->action != |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1786 | cpu_to_le16(CMD_SUBCMD_EXIT_PS)) { |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1787 | lbs_deb_host( |
| 1788 | "EXEC_NEXT_CMD: ignore ENTER_PS cmd\n"); |
Li Zefan | abe3ed1 | 2007-12-06 13:01:21 +0100 | [diff] [blame] | 1789 | list_del(&cmdnode->list); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1790 | lbs_cleanup_and_insert_cmd(priv, cmdnode); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1791 | |
| 1792 | ret = 0; |
| 1793 | goto done; |
| 1794 | } |
| 1795 | |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 1796 | if ((adapter->psstate == PS_STATE_SLEEP) || |
| 1797 | (adapter->psstate == PS_STATE_PRE_SLEEP)) { |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1798 | lbs_deb_host( |
| 1799 | "EXEC_NEXT_CMD: ignore EXIT_PS cmd in sleep\n"); |
Li Zefan | abe3ed1 | 2007-12-06 13:01:21 +0100 | [diff] [blame] | 1800 | list_del(&cmdnode->list); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1801 | lbs_cleanup_and_insert_cmd(priv, cmdnode); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1802 | adapter->needtowakeup = 1; |
| 1803 | |
| 1804 | ret = 0; |
| 1805 | goto done; |
| 1806 | } |
| 1807 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1808 | lbs_deb_host( |
| 1809 | "EXEC_NEXT_CMD: sending EXIT_PS\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1810 | } |
| 1811 | } |
Li Zefan | abe3ed1 | 2007-12-06 13:01:21 +0100 | [diff] [blame] | 1812 | list_del(&cmdnode->list); |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1813 | lbs_deb_host("EXEC_NEXT_CMD: sending command 0x%04x\n", |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 1814 | le16_to_cpu(cmdptr->command)); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1815 | DownloadcommandToStation(priv, cmdnode); |
| 1816 | } else { |
| 1817 | /* |
| 1818 | * check if in power save mode, if yes, put the device back |
| 1819 | * to PS mode |
| 1820 | */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1821 | if ((adapter->psmode != LBS802_11POWERMODECAM) && |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1822 | (adapter->psstate == PS_STATE_FULL_POWER) && |
Brajesh Dave | 01d77d8 | 2007-11-20 17:44:14 -0500 | [diff] [blame] | 1823 | ((adapter->connect_status == LBS_CONNECTED) || |
| 1824 | (adapter->mesh_connect_status == LBS_CONNECTED))) { |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 1825 | if (adapter->secinfo.WPAenabled || |
| 1826 | adapter->secinfo.WPA2enabled) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1827 | /* check for valid WPA group keys */ |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 1828 | if (adapter->wpa_mcast_key.len || |
| 1829 | adapter->wpa_unicast_key.len) { |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1830 | lbs_deb_host( |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1831 | "EXEC_NEXT_CMD: WPA enabled and GTK_SET" |
| 1832 | " go back to PS_SLEEP"); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1833 | lbs_ps_sleep(priv, 0); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1834 | } |
| 1835 | } else { |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1836 | lbs_deb_host( |
| 1837 | "EXEC_NEXT_CMD: cmdpendingq empty, " |
| 1838 | "go back to PS_SLEEP"); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1839 | lbs_ps_sleep(priv, 0); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1840 | } |
| 1841 | } |
| 1842 | } |
| 1843 | |
| 1844 | ret = 0; |
| 1845 | done: |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1846 | lbs_deb_leave(LBS_DEB_THREAD); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1847 | return ret; |
| 1848 | } |
| 1849 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1850 | void lbs_send_iwevcustom_event(struct lbs_private *priv, s8 *str) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1851 | { |
| 1852 | union iwreq_data iwrq; |
| 1853 | u8 buf[50]; |
| 1854 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1855 | lbs_deb_enter(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1856 | |
| 1857 | memset(&iwrq, 0, sizeof(union iwreq_data)); |
| 1858 | memset(buf, 0, sizeof(buf)); |
| 1859 | |
| 1860 | snprintf(buf, sizeof(buf) - 1, "%s", str); |
| 1861 | |
| 1862 | iwrq.data.length = strlen(buf) + 1 + IW_EV_LCP_LEN; |
| 1863 | |
| 1864 | /* Send Event to upper layer */ |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1865 | lbs_deb_wext("event indication string %s\n", (char *)buf); |
| 1866 | lbs_deb_wext("event indication length %d\n", iwrq.data.length); |
| 1867 | lbs_deb_wext("sending wireless event IWEVCUSTOM for %s\n", str); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1868 | |
Holger Schurig | 634b8f4 | 2007-05-25 13:05:16 -0400 | [diff] [blame] | 1869 | wireless_send_event(priv->dev, IWEVCUSTOM, &iwrq, buf); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1870 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1871 | lbs_deb_leave(LBS_DEB_WEXT); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1872 | } |
| 1873 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1874 | static int sendconfirmsleep(struct lbs_private *priv, u8 *cmdptr, u16 size) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1875 | { |
| 1876 | unsigned long flags; |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1877 | struct lbs_adapter *adapter = priv->adapter; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1878 | int ret = 0; |
| 1879 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1880 | lbs_deb_enter(LBS_DEB_HOST); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1881 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1882 | lbs_deb_host("SEND_SLEEPC_CMD: before download, cmd size %d\n", |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1883 | size); |
| 1884 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1885 | lbs_deb_hex(LBS_DEB_HOST, "sleep confirm command", cmdptr, size); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1886 | |
Holger Schurig | 208fdd2 | 2007-05-25 12:17:06 -0400 | [diff] [blame] | 1887 | ret = priv->hw_host_to_card(priv, MVMS_CMD, cmdptr, size); |
Holger Schurig | 634b8f4 | 2007-05-25 13:05:16 -0400 | [diff] [blame] | 1888 | priv->dnld_sent = DNLD_RES_RECEIVED; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1889 | |
| 1890 | spin_lock_irqsave(&adapter->driver_lock, flags); |
| 1891 | if (adapter->intcounter || adapter->currenttxskb) |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1892 | lbs_deb_host("SEND_SLEEPC_CMD: intcounter %d, currenttxskb %p\n", |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1893 | adapter->intcounter, adapter->currenttxskb); |
| 1894 | spin_unlock_irqrestore(&adapter->driver_lock, flags); |
| 1895 | |
| 1896 | if (ret) { |
| 1897 | lbs_pr_alert( |
| 1898 | "SEND_SLEEPC_CMD: Host to Card failed for Confirm Sleep\n"); |
| 1899 | } else { |
| 1900 | spin_lock_irqsave(&adapter->driver_lock, flags); |
| 1901 | if (!adapter->intcounter) { |
| 1902 | adapter->psstate = PS_STATE_SLEEP; |
| 1903 | } else { |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1904 | lbs_deb_host("SEND_SLEEPC_CMD: after sent, intcounter %d\n", |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1905 | adapter->intcounter); |
| 1906 | } |
| 1907 | spin_unlock_irqrestore(&adapter->driver_lock, flags); |
| 1908 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1909 | lbs_deb_host("SEND_SLEEPC_CMD: sent confirm sleep\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1910 | } |
| 1911 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1912 | lbs_deb_leave_args(LBS_DEB_HOST, "ret %d", ret); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1913 | return ret; |
| 1914 | } |
| 1915 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1916 | void lbs_ps_sleep(struct lbs_private *priv, int wait_option) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1917 | { |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1918 | lbs_deb_enter(LBS_DEB_HOST); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1919 | |
| 1920 | /* |
| 1921 | * PS is currently supported only in Infrastructure mode |
| 1922 | * Remove this check if it is to be supported in IBSS mode also |
| 1923 | */ |
| 1924 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1925 | lbs_prepare_and_send_command(priv, CMD_802_11_PS_MODE, |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1926 | CMD_SUBCMD_ENTER_PS, wait_option, 0, NULL); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1927 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1928 | lbs_deb_leave(LBS_DEB_HOST); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1929 | } |
| 1930 | |
| 1931 | /** |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1932 | * @brief This function sends Exit_PS command to firmware. |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1933 | * |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1934 | * @param priv A pointer to struct lbs_private structure |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1935 | * @param wait_option wait response or not |
| 1936 | * @return n/a |
| 1937 | */ |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1938 | void lbs_ps_wakeup(struct lbs_private *priv, int wait_option) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1939 | { |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 1940 | __le32 Localpsmode; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1941 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1942 | lbs_deb_enter(LBS_DEB_HOST); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1943 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1944 | Localpsmode = cpu_to_le32(LBS802_11POWERMODECAM); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1945 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1946 | lbs_prepare_and_send_command(priv, CMD_802_11_PS_MODE, |
Dan Williams | 0aef64d | 2007-08-02 11:31:18 -0400 | [diff] [blame] | 1947 | CMD_SUBCMD_EXIT_PS, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1948 | wait_option, 0, &Localpsmode); |
| 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 | /** |
| 1954 | * @brief This function checks condition and prepares to |
| 1955 | * send sleep confirm command to firmware if ok. |
| 1956 | * |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1957 | * @param priv A pointer to struct lbs_private structure |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1958 | * @param psmode Power Saving mode |
| 1959 | * @return n/a |
| 1960 | */ |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1961 | void lbs_ps_confirm_sleep(struct lbs_private *priv, u16 psmode) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1962 | { |
| 1963 | unsigned long flags =0; |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 1964 | struct lbs_adapter *adapter = priv->adapter; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1965 | u8 allowed = 1; |
| 1966 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1967 | lbs_deb_enter(LBS_DEB_HOST); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1968 | |
Holger Schurig | 634b8f4 | 2007-05-25 13:05:16 -0400 | [diff] [blame] | 1969 | if (priv->dnld_sent) { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1970 | allowed = 0; |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1971 | lbs_deb_host("dnld_sent was set"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1972 | } |
| 1973 | |
| 1974 | spin_lock_irqsave(&adapter->driver_lock, flags); |
| 1975 | if (adapter->cur_cmd) { |
| 1976 | allowed = 0; |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1977 | lbs_deb_host("cur_cmd was set"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1978 | } |
| 1979 | if (adapter->intcounter > 0) { |
| 1980 | allowed = 0; |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1981 | lbs_deb_host("intcounter %d", adapter->intcounter); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1982 | } |
| 1983 | spin_unlock_irqrestore(&adapter->driver_lock, flags); |
| 1984 | |
| 1985 | if (allowed) { |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1986 | lbs_deb_host("sending lbs_ps_confirm_sleep\n"); |
| 1987 | sendconfirmsleep(priv, (u8 *) & adapter->lbs_ps_confirm_sleep, |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1988 | sizeof(struct PS_CMD_ConfirmSleep)); |
| 1989 | } else { |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1990 | lbs_deb_host("sleep confirm has been delayed\n"); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1991 | } |
| 1992 | |
Holger Schurig | 8ff12da | 2007-08-02 11:54:31 -0400 | [diff] [blame] | 1993 | lbs_deb_leave(LBS_DEB_HOST); |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 1994 | } |
Holger Schurig | 675787e | 2007-12-05 17:58:11 +0100 | [diff] [blame] | 1995 | |
| 1996 | |
| 1997 | /** |
| 1998 | * @brief Simple way to call firmware functions |
| 1999 | * |
| 2000 | * @param priv A pointer to struct lbs_private structure |
| 2001 | * @param psmode one of the many CMD_802_11_xxxx |
| 2002 | * @param cmd pointer to the parameters structure for above command |
| 2003 | * (this should not include the command, size, sequence |
| 2004 | * and result fields from struct cmd_ds_gen) |
| 2005 | * @param cmd_size size structure pointed to by cmd |
| 2006 | * @param rsp pointer to an area where the result should be placed |
| 2007 | * @param rsp_size pointer to the size of the rsp area. If the firmware |
| 2008 | * returns fewer bytes, then this *rsp_size will be |
| 2009 | * changed to the actual size. |
| 2010 | * @return -1 in case of a higher level error, otherwise |
| 2011 | * the result code from the firmware |
| 2012 | */ |
David Woodhouse | 1723047 | 2007-12-07 15:13:05 +0000 | [diff] [blame] | 2013 | |
David Woodhouse | 448a51a | 2007-12-08 00:59:54 +0000 | [diff] [blame^] | 2014 | int lbs_cmd(struct lbs_private *priv, uint16_t command, void *cmd, int cmd_size, |
| 2015 | int (*callback)(uint16_t, struct cmd_ds_command *, struct lbs_private *)) |
Holger Schurig | 675787e | 2007-12-05 17:58:11 +0100 | [diff] [blame] | 2016 | { |
| 2017 | struct lbs_adapter *adapter = priv->adapter; |
| 2018 | struct cmd_ctrl_node *cmdnode; |
| 2019 | struct cmd_ds_gen *cmdptr; |
| 2020 | unsigned long flags; |
| 2021 | int ret = 0; |
| 2022 | |
| 2023 | lbs_deb_enter(LBS_DEB_HOST); |
Holger Schurig | 675787e | 2007-12-05 17:58:11 +0100 | [diff] [blame] | 2024 | |
David Woodhouse | 448a51a | 2007-12-08 00:59:54 +0000 | [diff] [blame^] | 2025 | if (!adapter) { |
Holger Schurig | 675787e | 2007-12-05 17:58:11 +0100 | [diff] [blame] | 2026 | lbs_deb_host("PREP_CMD: adapter is NULL\n"); |
| 2027 | ret = -1; |
| 2028 | goto done; |
| 2029 | } |
| 2030 | |
| 2031 | if (adapter->surpriseremoved) { |
| 2032 | lbs_deb_host("PREP_CMD: card removed\n"); |
| 2033 | ret = -1; |
| 2034 | goto done; |
| 2035 | } |
| 2036 | |
| 2037 | cmdnode = lbs_get_cmd_ctrl_node(priv); |
| 2038 | |
| 2039 | if (cmdnode == NULL) { |
| 2040 | lbs_deb_host("PREP_CMD: cmdnode is NULL\n"); |
| 2041 | |
| 2042 | /* Wake up main thread to execute next command */ |
| 2043 | wake_up_interruptible(&priv->waitq); |
| 2044 | ret = -1; |
| 2045 | goto done; |
| 2046 | } |
| 2047 | |
| 2048 | cmdptr = (struct cmd_ds_gen *)cmdnode->bufvirtualaddr; |
| 2049 | cmdnode->wait_option = CMD_OPTION_WAITFORRSP; |
David Woodhouse | 448a51a | 2007-12-08 00:59:54 +0000 | [diff] [blame^] | 2050 | cmdnode->callback = callback; |
Holger Schurig | 675787e | 2007-12-05 17:58:11 +0100 | [diff] [blame] | 2051 | |
| 2052 | /* Set sequence number, clean result, move to buffer */ |
| 2053 | adapter->seqnum++; |
| 2054 | cmdptr->command = cpu_to_le16(command); |
David Woodhouse | 6228c0a | 2007-12-06 12:38:31 +0000 | [diff] [blame] | 2055 | cmdptr->size = cpu_to_le16(cmd_size + S_DS_GEN); |
Holger Schurig | 675787e | 2007-12-05 17:58:11 +0100 | [diff] [blame] | 2056 | cmdptr->seqnum = cpu_to_le16(adapter->seqnum); |
| 2057 | cmdptr->result = 0; |
| 2058 | memcpy(cmdptr->cmdresp, cmd, cmd_size); |
| 2059 | |
| 2060 | lbs_deb_host("PREP_CMD: command 0x%04x\n", command); |
| 2061 | |
| 2062 | /* here was the big old switch() statement, which is now obsolete, |
| 2063 | * because the caller of lbs_cmd() sets up all of *cmd for us. */ |
| 2064 | |
| 2065 | cmdnode->cmdwaitqwoken = 0; |
| 2066 | lbs_queue_cmd(adapter, cmdnode, 1); |
| 2067 | wake_up_interruptible(&priv->waitq); |
| 2068 | |
| 2069 | might_sleep(); |
| 2070 | wait_event_interruptible(cmdnode->cmdwait_q, cmdnode->cmdwaitqwoken); |
| 2071 | |
| 2072 | spin_lock_irqsave(&adapter->driver_lock, flags); |
| 2073 | if (adapter->cur_cmd_retcode) { |
| 2074 | lbs_deb_host("PREP_CMD: command failed with return code %d\n", |
| 2075 | adapter->cur_cmd_retcode); |
| 2076 | adapter->cur_cmd_retcode = 0; |
| 2077 | ret = -1; |
| 2078 | } |
| 2079 | spin_unlock_irqrestore(&adapter->driver_lock, flags); |
| 2080 | |
| 2081 | done: |
| 2082 | lbs_deb_leave_args(LBS_DEB_HOST, "ret %d", ret); |
| 2083 | return ret; |
| 2084 | } |
| 2085 | EXPORT_SYMBOL_GPL(lbs_cmd); |
| 2086 | |
| 2087 | |