libertas: move lbs_update_channel out of assoc.c
[deliverable/linux.git] / drivers / net / wireless / libertas / cmd.c
index be461c5c42ae84191b6f8dba914eb9cf3a09db30..4a82f5114ca0a21509ca07d05417b166775b5660 100644 (file)
@@ -9,14 +9,11 @@
 #include "decl.h"
 #include "defs.h"
 #include "dev.h"
-#include "join.h"
+#include "assoc.h"
 #include "wext.h"
 #include "cmd.h"
 
 static struct cmd_ctrl_node *lbs_get_cmd_ctrl_node(struct lbs_private *priv);
-static void lbs_set_cmd_ctrl_node(struct lbs_private *priv,
-                   struct cmd_ctrl_node *ptempnode,
-                   void *pdata_buf);
 
 
 /**
@@ -183,8 +180,7 @@ int lbs_host_sleep_cfg(struct lbs_private *priv, uint32_t criteria)
 }
 EXPORT_SYMBOL_GPL(lbs_host_sleep_cfg);
 
-static int lbs_cmd_802_11_ps_mode(struct lbs_private *priv,
-                                  struct cmd_ds_command *cmd,
+static int lbs_cmd_802_11_ps_mode(struct cmd_ds_command *cmd,
                                   u16 cmd_action)
 {
        struct cmd_ds_802_11_ps_mode *psm = &cmd->params.psmode;
@@ -479,8 +475,7 @@ int lbs_cmd_802_11_key_material(struct lbs_private *priv, uint16_t cmd_action,
        return ret;
 }
 
-static int lbs_cmd_802_11_reset(struct lbs_private *priv,
-                                struct cmd_ds_command *cmd, int cmd_action)
+static int lbs_cmd_802_11_reset(struct cmd_ds_command *cmd, int cmd_action)
 {
        struct cmd_ds_802_11_reset *reset = &cmd->params.reset;
 
@@ -494,30 +489,6 @@ static int lbs_cmd_802_11_reset(struct lbs_private *priv,
        return 0;
 }
 
-static int lbs_cmd_802_11_get_log(struct lbs_private *priv,
-                                  struct cmd_ds_command *cmd)
-{
-       lbs_deb_enter(LBS_DEB_CMD);
-       cmd->command = cpu_to_le16(CMD_802_11_GET_LOG);
-       cmd->size =
-               cpu_to_le16(sizeof(struct cmd_ds_802_11_get_log) + S_DS_GEN);
-
-       lbs_deb_leave(LBS_DEB_CMD);
-       return 0;
-}
-
-static int lbs_cmd_802_11_get_stat(struct lbs_private *priv,
-                                   struct cmd_ds_command *cmd)
-{
-       lbs_deb_enter(LBS_DEB_CMD);
-       cmd->command = cpu_to_le16(CMD_802_11_GET_STAT);
-       cmd->size =
-           cpu_to_le16(sizeof(struct cmd_ds_802_11_get_stat) + S_DS_GEN);
-
-       lbs_deb_leave(LBS_DEB_CMD);
-       return 0;
-}
-
 static int lbs_cmd_802_11_snmp_mib(struct lbs_private *priv,
                                    struct cmd_ds_command *cmd,
                                    int cmd_action,
@@ -638,8 +609,7 @@ static int lbs_cmd_802_11_snmp_mib(struct lbs_private *priv,
        return 0;
 }
 
-static int lbs_cmd_802_11_rf_tx_power(struct lbs_private *priv,
-                                      struct cmd_ds_command *cmd,
+static int lbs_cmd_802_11_rf_tx_power(struct cmd_ds_command *cmd,
                                       u16 cmd_action, void *pdata_buf)
 {
 
@@ -682,8 +652,7 @@ static int lbs_cmd_802_11_rf_tx_power(struct lbs_private *priv,
        return 0;
 }
 
-static int lbs_cmd_802_11_monitor_mode(struct lbs_private *priv,
-                                     struct cmd_ds_command *cmd,
+static int lbs_cmd_802_11_monitor_mode(struct cmd_ds_command *cmd,
                                      u16 cmd_action, void *pdata_buf)
 {
        struct cmd_ds_802_11_monitor_mode *monitor = &cmd->params.monitor;
@@ -856,6 +825,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
  *
@@ -910,8 +895,7 @@ static int lbs_cmd_802_11_rssi(struct lbs_private *priv,
        return 0;
 }
 
-static int lbs_cmd_reg_access(struct lbs_private *priv,
-                              struct cmd_ds_command *cmdptr,
+static int lbs_cmd_reg_access(struct cmd_ds_command *cmdptr,
                               u8 cmd_action, void *pdata_buf)
 {
        struct lbs_offset_value *offval;
@@ -985,53 +969,7 @@ static int lbs_cmd_reg_access(struct lbs_private *priv,
        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 lbs_private *priv,
-                                        struct cmd_ds_command *cmd,
-                                        int cmd_action, 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 lbs_private *priv,
-                              struct cmd_ds_command *cmd,
+static int lbs_cmd_bt_access(struct cmd_ds_command *cmd,
                               u16 cmd_action, void *pdata_buf)
 {
        struct cmd_ds_bt_access *bt_access = &cmd->params.bt;
@@ -1068,8 +1006,7 @@ static int lbs_cmd_bt_access(struct lbs_private *priv,
        return 0;
 }
 
-static int lbs_cmd_fwt_access(struct lbs_private *priv,
-                              struct cmd_ds_command *cmd,
+static int lbs_cmd_fwt_access(struct cmd_ds_command *cmd,
                               u16 cmd_action, void *pdata_buf)
 {
        struct cmd_ds_fwt_access *fwt_access = &cmd->params.fwt;
@@ -1221,8 +1158,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);
@@ -1326,9 +1263,8 @@ int lbs_set_radio_control(struct lbs_private *priv)
        return ret;
 }
 
-int lbs_set_mac_control(struct lbs_private *priv)
+void lbs_set_mac_control(struct lbs_private *priv)
 {
-       int ret = 0;
        struct cmd_ds_mac_control cmd;
 
        lbs_deb_enter(LBS_DEB_CMD);
@@ -1337,10 +1273,10 @@ int lbs_set_mac_control(struct lbs_private *priv)
        cmd.action = cpu_to_le16(priv->mac_control);
        cmd.reserved = 0;
 
-       ret = lbs_cmd_with_response(priv, CMD_MAC_CONTROL, &cmd);
+       lbs_cmd_async(priv, CMD_MAC_CONTROL,
+               &cmd.hdr, sizeof(cmd));
 
-       lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret);
-       return ret;
+       lbs_deb_leave(LBS_DEB_CMD);
 }
 
 /**
@@ -1389,7 +1325,8 @@ int lbs_prepare_and_send_command(struct lbs_private *priv,
                goto done;
        }
 
-       lbs_set_cmd_ctrl_node(priv, cmdnode, pdata_buf);
+       cmdnode->callback = NULL;
+       cmdnode->callback_arg = (unsigned long)pdata_buf;
 
        cmdptr = (struct cmd_ds_command *)cmdnode->cmdbuf;
 
@@ -1404,7 +1341,7 @@ int lbs_prepare_and_send_command(struct lbs_private *priv,
 
        switch (cmd_no) {
        case CMD_802_11_PS_MODE:
-               ret = lbs_cmd_802_11_ps_mode(priv, cmdptr, cmd_action);
+               ret = lbs_cmd_802_11_ps_mode(cmdptr, cmd_action);
                break;
 
        case CMD_802_11_ASSOCIATE:
@@ -1421,21 +1358,13 @@ int lbs_prepare_and_send_command(struct lbs_private *priv,
                break;
 
        case CMD_802_11_RESET:
-               ret = lbs_cmd_802_11_reset(priv, cmdptr, cmd_action);
-               break;
-
-       case CMD_802_11_GET_LOG:
-               ret = lbs_cmd_802_11_get_log(priv, cmdptr);
+               ret = lbs_cmd_802_11_reset(cmdptr, cmd_action);
                break;
 
        case CMD_802_11_AUTHENTICATE:
                ret = lbs_cmd_80211_authenticate(priv, cmdptr, pdata_buf);
                break;
 
-       case CMD_802_11_GET_STAT:
-               ret = lbs_cmd_802_11_get_stat(priv, cmdptr);
-               break;
-
        case CMD_802_11_SNMP_MIB:
                ret = lbs_cmd_802_11_snmp_mib(priv, cmdptr,
                                               cmd_action, cmd_oid, pdata_buf);
@@ -1444,12 +1373,12 @@ int lbs_prepare_and_send_command(struct lbs_private *priv,
        case CMD_MAC_REG_ACCESS:
        case CMD_BBP_REG_ACCESS:
        case CMD_RF_REG_ACCESS:
-               ret = lbs_cmd_reg_access(priv, cmdptr, cmd_action, pdata_buf);
+               ret = lbs_cmd_reg_access(cmdptr, cmd_action, pdata_buf);
                break;
 
        case CMD_802_11_RF_TX_POWER:
-               ret = lbs_cmd_802_11_rf_tx_power(priv, cmdptr,
-                                                 cmd_action, pdata_buf);
+               ret = lbs_cmd_802_11_rf_tx_power(cmdptr,
+                                                cmd_action, pdata_buf);
                break;
 
        case CMD_802_11_RATE_ADAPT_RATESET:
@@ -1462,7 +1391,7 @@ int lbs_prepare_and_send_command(struct lbs_private *priv,
                break;
 
        case CMD_802_11_MONITOR_MODE:
-               ret = lbs_cmd_802_11_monitor_mode(priv, cmdptr,
+               ret = lbs_cmd_802_11_monitor_mode(cmdptr,
                                          cmd_action, pdata_buf);
                break;
 
@@ -1475,16 +1404,7 @@ int lbs_prepare_and_send_command(struct lbs_private *priv,
                break;
 
        case CMD_802_11_AD_HOC_STOP:
-               ret = lbs_cmd_80211_ad_hoc_stop(priv, 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(priv, cmdptr,
-                                                   cmd_action, pdata_buf);
+               ret = lbs_cmd_80211_ad_hoc_stop(cmdptr);
                break;
 
        case CMD_802_11_SET_AFC:
@@ -1540,22 +1460,12 @@ 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(priv, cmdptr, cmd_action, pdata_buf);
+               ret = lbs_cmd_bt_access(cmdptr, cmd_action, pdata_buf);
                break;
 
        case CMD_FWT_ACCESS:
-               ret = lbs_cmd_fwt_access(priv, cmdptr, cmd_action, pdata_buf);
+               ret = lbs_cmd_fwt_access(cmdptr, cmd_action, pdata_buf);
                break;
 
        case CMD_GET_TSF:
@@ -1727,36 +1637,6 @@ static struct cmd_ctrl_node *lbs_get_cmd_ctrl_node(struct lbs_private *priv)
        return tempnode;
 }
 
-/**
- *  @brief This function cleans command node.
- *
- *  @param ptempnode   A pointer to cmdCtrlNode structure
- *  @return            n/a
- */
-
-/**
- *  @brief This function initializes the command node.
- *
- *  @param priv                A pointer to struct lbs_private structure
- *  @param ptempnode   A pointer to cmd_ctrl_node structure
- *  @param pdata_buf   A pointer to informaion buffer
- *  @return            0 or -1
- */
-static void lbs_set_cmd_ctrl_node(struct lbs_private *priv,
-                                 struct cmd_ctrl_node *ptempnode,
-                                 void *pdata_buf)
-{
-       lbs_deb_enter(LBS_DEB_HOST);
-
-       if (!ptempnode)
-               return;
-
-       ptempnode->callback = NULL;
-       ptempnode->callback_arg = (unsigned long)pdata_buf;
-
-       lbs_deb_leave(LBS_DEB_HOST);
-}
-
 /**
  *  @brief This function executes next command in command
  *  pending queue. It will put fimware back to PS mode
@@ -1938,44 +1818,27 @@ 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", (u8 *) &confirm_sleep,
+               sizeof(confirm_sleep));
 
-       lbs_deb_host("SEND_SLEEPC_CMD: before download, cmd size %d\n",
-              size);
-
-       lbs_deb_hex(LBS_DEB_HOST, "sleep confirm command", cmdptr, size);
-
-       ret = priv->hw_host_to_card(priv, MVMS_CMD, cmdptr, size);
-
-       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);
+       ret = priv->hw_host_to_card(priv, MVMS_CMD, (u8 *) &confirm_sleep,
+               sizeof(confirm_sleep));
 
        if (ret) {
-               lbs_pr_alert(
-                      "SEND_SLEEPC_CMD: Host to Card failed for Confirm Sleep\n");
+               lbs_pr_alert("confirm_sleep failed\n");
        } else {
                spin_lock_irqsave(&priv->driver_lock, flags);
-               if (!priv->intcounter) {
+               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);
-
-               lbs_deb_host("SEND_SLEEPC_CMD: sent confirm sleep\n");
        }
-
-       lbs_deb_leave_args(LBS_DEB_HOST, "ret %d", ret);
-       return ret;
+       lbs_deb_leave(LBS_DEB_HOST);
 }
 
 void lbs_ps_sleep(struct lbs_private *priv, int wait_option)
@@ -2023,10 +1886,10 @@ void lbs_ps_wakeup(struct lbs_private *priv, int wait_option)
  *  @param psmode      Power Saving mode
  *  @return            n/a
  */
-void lbs_ps_confirm_sleep(struct lbs_private *priv, u16 psmode)
+void lbs_ps_confirm_sleep(struct lbs_private *priv)
 {
        unsigned long flags =0;
-       u8 allowed = 1;
+       int allowed = 1;
 
        lbs_deb_enter(LBS_DEB_HOST);
 
@@ -2048,8 +1911,7 @@ void lbs_ps_confirm_sleep(struct lbs_private *priv, u16 psmode)
 
        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");
        }
This page took 0.030194 seconds and 5 git commands to generate.