]> err.no Git - linux-2.6/blobdiff - drivers/net/wireless/libertas/cmd.c
Merge branches 'at91', 'dyntick', 'ep93xx', 'iop', 'ixp', 'misc', 'orion', 'omap...
[linux-2.6] / drivers / net / wireless / libertas / cmd.c
index 59801f103e66b3ac2020133a47a7cf1262af7ad7..8124fd9b1353523c603e679914d2fd839ac6f97b 100644 (file)
@@ -4,12 +4,13 @@
   */
 
 #include <net/iw_handler.h>
+#include <linux/kfifo.h>
 #include "host.h"
 #include "hostcmd.h"
 #include "decl.h"
 #include "defs.h"
 #include "dev.h"
-#include "join.h"
+#include "assoc.h"
 #include "wext.h"
 #include "cmd.h"
 
@@ -295,6 +296,7 @@ int lbs_cmd_802_11_set_wep(struct lbs_private *priv, uint16_t cmd_action,
 
        lbs_deb_enter(LBS_DEB_CMD);
 
+       memset(&cmd, 0, sizeof(cmd));
        cmd.hdr.command = cpu_to_le16(CMD_802_11_SET_WEP);
        cmd.hdr.size = cpu_to_le16(sizeof(cmd));
 
@@ -358,7 +360,9 @@ int lbs_cmd_802_11_enable_rsn(struct lbs_private *priv, uint16_t cmd_action,
        cmd.hdr.size = cpu_to_le16(sizeof(cmd));
        cmd.action = cpu_to_le16(cmd_action);
 
-       if (cmd_action == CMD_ACT_SET) {
+       if (cmd_action == CMD_ACT_GET)
+               cmd.enable = 0;
+       else {
                if (*enable)
                        cmd.enable = cpu_to_le16(CMD_ENABLE_RSN);
                else
@@ -810,6 +814,7 @@ int lbs_get_channel(struct lbs_private *priv)
 
        lbs_deb_enter(LBS_DEB_CMD);
 
+       memset(&cmd, 0, sizeof(cmd));
        cmd.hdr.size = cpu_to_le16(sizeof(cmd));
        cmd.action = cpu_to_le16(CMD_OPT_802_11_RF_CHANNEL_GET);
 
@@ -825,6 +830,22 @@ out:
        return ret;
 }
 
+int lbs_update_channel(struct lbs_private *priv)
+{
+       int ret;
+
+       /* the channel in f/w could be out of sync; get the current channel */
+       lbs_deb_enter(LBS_DEB_ASSOC);
+
+       ret = lbs_get_channel(priv);
+       if (ret > 0) {
+               priv->curbssparams.channel = ret;
+               ret = 0;
+       }
+       lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret);
+       return ret;
+}
+
 /**
  *  @brief Set the radio channel
  *
@@ -841,6 +862,7 @@ int lbs_set_channel(struct lbs_private *priv, u8 channel)
 
        lbs_deb_enter(LBS_DEB_CMD);
 
+       memset(&cmd, 0, sizeof(cmd));
        cmd.hdr.size = cpu_to_le16(sizeof(cmd));
        cmd.action = cpu_to_le16(CMD_OPT_802_11_RF_CHANNEL_SET);
        cmd.channel = cpu_to_le16(channel);
@@ -953,50 +975,6 @@ static int lbs_cmd_reg_access(struct cmd_ds_command *cmdptr,
        return 0;
 }
 
-static int lbs_cmd_802_11_mac_address(struct lbs_private *priv,
-                                      struct cmd_ds_command *cmd,
-                                      u16 cmd_action)
-{
-
-       lbs_deb_enter(LBS_DEB_CMD);
-       cmd->command = cpu_to_le16(CMD_802_11_MAC_ADDRESS);
-       cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_mac_address) +
-                            S_DS_GEN);
-       cmd->result = 0;
-
-       cmd->params.macadd.action = cpu_to_le16(cmd_action);
-
-       if (cmd_action == CMD_ACT_SET) {
-               memcpy(cmd->params.macadd.macadd,
-                      priv->current_addr, ETH_ALEN);
-               lbs_deb_hex(LBS_DEB_CMD, "SET_CMD: MAC addr", priv->current_addr, 6);
-       }
-
-       lbs_deb_leave(LBS_DEB_CMD);
-       return 0;
-}
-
-static int lbs_cmd_802_11_eeprom_access(struct cmd_ds_command *cmd,
-                                       void *pdata_buf)
-{
-       struct lbs_ioctl_regrdwr *ea = pdata_buf;
-
-       lbs_deb_enter(LBS_DEB_CMD);
-
-       cmd->command = cpu_to_le16(CMD_802_11_EEPROM_ACCESS);
-       cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_eeprom_access) +
-                               S_DS_GEN);
-       cmd->result = 0;
-
-       cmd->params.rdeeprom.action = cpu_to_le16(ea->action);
-       cmd->params.rdeeprom.offset = cpu_to_le16(ea->offset);
-       cmd->params.rdeeprom.bytecount = cpu_to_le16(ea->NOB);
-       cmd->params.rdeeprom.value = 0;
-
-       lbs_deb_leave(LBS_DEB_CMD);
-       return 0;
-}
-
 static int lbs_cmd_bt_access(struct cmd_ds_command *cmd,
                               u16 cmd_action, void *pdata_buf)
 {
@@ -1186,8 +1164,8 @@ static void lbs_submit_command(struct lbs_private *priv,
            command == CMD_802_11_AUTHENTICATE)
                timeo = 10 * HZ;
 
-       lbs_deb_cmd("DNLD_CMD: command 0x%04x, seq %d, size %d, jiffies %lu\n",
-                    command, le16_to_cpu(cmd->seqnum), cmdsize, jiffies);
+       lbs_deb_cmd("DNLD_CMD: command 0x%04x, seq %d, size %d\n",
+                    command, le16_to_cpu(cmd->seqnum), cmdsize);
        lbs_deb_hex(LBS_DEB_CMD, "DNLD_CMD", (void *) cmdnode->cmdbuf, cmdsize);
 
        ret = priv->hw_host_to_card(priv, MVMS_CMD, (u8 *) cmd, cmdsize);
@@ -1435,14 +1413,6 @@ int lbs_prepare_and_send_command(struct lbs_private *priv,
                ret = lbs_cmd_80211_ad_hoc_stop(cmdptr);
                break;
 
-       case CMD_802_11_MAC_ADDRESS:
-               ret = lbs_cmd_802_11_mac_address(priv, cmdptr, cmd_action);
-               break;
-
-       case CMD_802_11_EEPROM_ACCESS:
-               ret = lbs_cmd_802_11_eeprom_access(cmdptr, pdata_buf);
-               break;
-
        case CMD_802_11_SET_AFC:
        case CMD_802_11_GET_AFC:
 
@@ -1496,16 +1466,6 @@ int lbs_prepare_and_send_command(struct lbs_private *priv,
                        break;
                }
 
-       case CMD_802_11_PWR_CFG:
-               cmdptr->command = cpu_to_le16(CMD_802_11_PWR_CFG);
-               cmdptr->size =
-                   cpu_to_le16(sizeof(struct cmd_ds_802_11_pwr_cfg) +
-                                    S_DS_GEN);
-               memmove(&cmdptr->params.pwrcfg, pdata_buf,
-                       sizeof(struct cmd_ds_802_11_pwr_cfg));
-
-               ret = 0;
-               break;
        case CMD_BT_ACCESS:
                ret = lbs_cmd_bt_access(cmdptr, cmd_action, pdata_buf);
                break;
@@ -1864,38 +1824,35 @@ void lbs_send_iwevcustom_event(struct lbs_private *priv, s8 *str)
        lbs_deb_leave(LBS_DEB_WEXT);
 }
 
-static int sendconfirmsleep(struct lbs_private *priv, u8 *cmdptr, u16 size)
+static void lbs_send_confirmsleep(struct lbs_private *priv)
 {
        unsigned long flags;
-       int ret = 0;
+       int ret;
 
        lbs_deb_enter(LBS_DEB_HOST);
-       lbs_deb_hex(LBS_DEB_HOST, "sleep confirm command", cmdptr, size);
+       lbs_deb_hex(LBS_DEB_HOST, "sleep confirm", (u8 *) &confirm_sleep,
+               sizeof(confirm_sleep));
 
-       ret = priv->hw_host_to_card(priv, MVMS_CMD, cmdptr, size);
+       ret = priv->hw_host_to_card(priv, MVMS_CMD, (u8 *) &confirm_sleep,
+               sizeof(confirm_sleep));
+       if (ret) {
+               lbs_pr_alert("confirm_sleep failed\n");
+               goto out;
+       }
 
        spin_lock_irqsave(&priv->driver_lock, flags);
-       if (priv->intcounter || priv->currenttxskb)
-               lbs_deb_host("SEND_SLEEPC_CMD: intcounter %d, currenttxskb %p\n",
-                      priv->intcounter, priv->currenttxskb);
-       spin_unlock_irqrestore(&priv->driver_lock, flags);
 
-       if (ret) {
-               lbs_pr_alert(
-                      "SEND_SLEEPC_CMD: Host to Card failed for Confirm Sleep\n");
-       } else {
-               spin_lock_irqsave(&priv->driver_lock, flags);
-               if (!priv->intcounter) {
-                       priv->psstate = PS_STATE_SLEEP;
-               } else {
-                       lbs_deb_host("SEND_SLEEPC_CMD: after sent, intcounter %d\n",
-                              priv->intcounter);
-               }
-               spin_unlock_irqrestore(&priv->driver_lock, flags);
-       }
+       /* We don't get a response on the sleep-confirmation */
+       priv->dnld_sent = DNLD_RES_RECEIVED;
 
-       lbs_deb_leave_args(LBS_DEB_HOST, "ret %d", ret);
-       return ret;
+       /* If nothing to do, go back to sleep (?) */
+       if (!__kfifo_len(priv->event_fifo) && !priv->resp_len[priv->resp_idx])
+               priv->psstate = PS_STATE_SLEEP;
+
+       spin_unlock_irqrestore(&priv->driver_lock, flags);
+
+out:
+       lbs_deb_leave(LBS_DEB_HOST);
 }
 
 void lbs_ps_sleep(struct lbs_private *priv, int wait_option)
@@ -1950,26 +1907,28 @@ void lbs_ps_confirm_sleep(struct lbs_private *priv)
 
        lbs_deb_enter(LBS_DEB_HOST);
 
+       spin_lock_irqsave(&priv->driver_lock, flags);
        if (priv->dnld_sent) {
                allowed = 0;
                lbs_deb_host("dnld_sent was set\n");
        }
 
-       spin_lock_irqsave(&priv->driver_lock, flags);
+       /* In-progress command? */
        if (priv->cur_cmd) {
                allowed = 0;
                lbs_deb_host("cur_cmd was set\n");
        }
-       if (priv->intcounter > 0) {
+
+       /* Pending events or command responses? */
+       if (__kfifo_len(priv->event_fifo) || priv->resp_len[priv->resp_idx]) {
                allowed = 0;
-               lbs_deb_host("intcounter %d\n", priv->intcounter);
+               lbs_deb_host("pending events or command responses\n");
        }
        spin_unlock_irqrestore(&priv->driver_lock, flags);
 
        if (allowed) {
                lbs_deb_host("sending lbs_ps_confirm_sleep\n");
-               sendconfirmsleep(priv, (u8 *) & priv->lbs_ps_confirm_sleep,
-                                sizeof(struct PS_CMD_ConfirmSleep));
+               lbs_send_confirmsleep(priv);
        } else {
                lbs_deb_host("sleep confirm has been delayed\n");
        }