iwlwifi: add missing rcu_read_lock
[safe/jmp/linux-2.6] / drivers / net / wireless / libertas / cmd.c
index 65fd50d..cdb9b96 100644 (file)
@@ -3,9 +3,9 @@
   * It prepares command and sends it to firmware when it is ready.
   */
 
-#include <net/lib80211.h>
 #include <linux/kfifo.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 
 #include "host.h"
 #include "decl.h"
@@ -144,19 +144,6 @@ int lbs_update_hw_spec(struct lbs_private *priv)
        lbs_deb_cmd("GET_HW_SPEC: hardware interface 0x%x, hardware spec 0x%04x\n",
                    cmd.hwifversion, cmd.version);
 
-       /* Determine mesh_fw_ver from fwrelease and fwcapinfo */
-       /* 5.0.16p0 9.0.0.p0 is known to NOT support any mesh */
-       /* 5.110.22 have mesh command with 0xa3 command id */
-       /* 10.0.0.p0 FW brings in mesh config command with different id */
-       /* Check FW version MSB and initialize mesh_fw_ver */
-       if (MRVL_FW_MAJOR_REV(priv->fwrelease) == MRVL_FW_V5)
-               priv->mesh_fw_ver = MESH_FW_OLD;
-       else if ((MRVL_FW_MAJOR_REV(priv->fwrelease) >= MRVL_FW_V10) &&
-               (priv->fwcapinfo & MESH_CAPINFO_ENABLE_MASK))
-               priv->mesh_fw_ver = MESH_FW_NEW;
-       else
-               priv->mesh_fw_ver = MESH_NONE;
-
        /* Clamp region code to 8-bit since FW spec indicates that it should
         * only ever be 8-bit, even though the field size is 16-bit.  Some firmware
         * returns non-zero high 8 bits here.
@@ -390,7 +377,7 @@ int lbs_set_snmp_mib(struct lbs_private *priv, u32 oid, u16 val)
        switch (oid) {
        case SNMP_MIB_OID_BSS_TYPE:
                cmd.bufsize = cpu_to_le16(sizeof(u8));
-               cmd.value[0] = (val == IW_MODE_ADHOC) ? 2 : 1;
+               cmd.value[0] = val;
                break;
        case SNMP_MIB_OID_11D_ENABLE:
        case SNMP_MIB_OID_FRAG_THRESHOLD:
@@ -443,13 +430,7 @@ int lbs_get_snmp_mib(struct lbs_private *priv, u32 oid, u16 *out_val)
 
        switch (le16_to_cpu(cmd.bufsize)) {
        case sizeof(u8):
-               if (oid == SNMP_MIB_OID_BSS_TYPE) {
-                       if (cmd.value[0] == 2)
-                               *out_val = IW_MODE_ADHOC;
-                       else
-                               *out_val = IW_MODE_INFRA;
-               } else
-                       *out_val = cmd.value[0];
+               *out_val = cmd.value[0];
                break;
        case sizeof(u16):
                *out_val = le16_to_cpu(*((__le16 *)(&cmd.value)));
@@ -703,173 +684,6 @@ static int lbs_cmd_reg_access(struct cmd_ds_command *cmdptr,
        return 0;
 }
 
-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;
-       lbs_deb_enter_args(LBS_DEB_CMD, "action %d", cmd_action);
-
-       cmd->command = cpu_to_le16(CMD_BT_ACCESS);
-       cmd->size = cpu_to_le16(sizeof(struct cmd_ds_bt_access) +
-               sizeof(struct cmd_header));
-       cmd->result = 0;
-       bt_access->action = cpu_to_le16(cmd_action);
-
-       switch (cmd_action) {
-       case CMD_ACT_BT_ACCESS_ADD:
-               memcpy(bt_access->addr1, pdata_buf, 2 * ETH_ALEN);
-               lbs_deb_hex(LBS_DEB_MESH, "BT_ADD: blinded MAC addr", bt_access->addr1, 6);
-               break;
-       case CMD_ACT_BT_ACCESS_DEL:
-               memcpy(bt_access->addr1, pdata_buf, 1 * ETH_ALEN);
-               lbs_deb_hex(LBS_DEB_MESH, "BT_DEL: blinded MAC addr", bt_access->addr1, 6);
-               break;
-       case CMD_ACT_BT_ACCESS_LIST:
-               bt_access->id = cpu_to_le32(*(u32 *) pdata_buf);
-               break;
-       case CMD_ACT_BT_ACCESS_RESET:
-               break;
-       case CMD_ACT_BT_ACCESS_SET_INVERT:
-               bt_access->id = cpu_to_le32(*(u32 *) pdata_buf);
-               break;
-       case CMD_ACT_BT_ACCESS_GET_INVERT:
-               break;
-       default:
-               break;
-       }
-       lbs_deb_leave(LBS_DEB_CMD);
-       return 0;
-}
-
-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;
-       lbs_deb_enter_args(LBS_DEB_CMD, "action %d", cmd_action);
-
-       cmd->command = cpu_to_le16(CMD_FWT_ACCESS);
-       cmd->size = cpu_to_le16(sizeof(struct cmd_ds_fwt_access) +
-               sizeof(struct cmd_header));
-       cmd->result = 0;
-
-       if (pdata_buf)
-               memcpy(fwt_access, pdata_buf, sizeof(*fwt_access));
-       else
-               memset(fwt_access, 0, sizeof(*fwt_access));
-
-       fwt_access->action = cpu_to_le16(cmd_action);
-
-       lbs_deb_leave(LBS_DEB_CMD);
-       return 0;
-}
-
-int lbs_mesh_access(struct lbs_private *priv, uint16_t cmd_action,
-                   struct cmd_ds_mesh_access *cmd)
-{
-       int ret;
-
-       lbs_deb_enter_args(LBS_DEB_CMD, "action %d", cmd_action);
-
-       cmd->hdr.command = cpu_to_le16(CMD_MESH_ACCESS);
-       cmd->hdr.size = cpu_to_le16(sizeof(*cmd));
-       cmd->hdr.result = 0;
-
-       cmd->action = cpu_to_le16(cmd_action);
-
-       ret = lbs_cmd_with_response(priv, CMD_MESH_ACCESS, cmd);
-
-       lbs_deb_leave(LBS_DEB_CMD);
-       return ret;
-}
-
-static int __lbs_mesh_config_send(struct lbs_private *priv,
-                                 struct cmd_ds_mesh_config *cmd,
-                                 uint16_t action, uint16_t type)
-{
-       int ret;
-       u16 command = CMD_MESH_CONFIG_OLD;
-
-       lbs_deb_enter(LBS_DEB_CMD);
-
-       /*
-        * Command id is 0xac for v10 FW along with mesh interface
-        * id in bits 14-13-12.
-        */
-       if (priv->mesh_fw_ver == MESH_FW_NEW)
-               command = CMD_MESH_CONFIG |
-                         (MESH_IFACE_ID << MESH_IFACE_BIT_OFFSET);
-
-       cmd->hdr.command = cpu_to_le16(command);
-       cmd->hdr.size = cpu_to_le16(sizeof(struct cmd_ds_mesh_config));
-       cmd->hdr.result = 0;
-
-       cmd->type = cpu_to_le16(type);
-       cmd->action = cpu_to_le16(action);
-
-       ret = lbs_cmd_with_response(priv, command, cmd);
-
-       lbs_deb_leave(LBS_DEB_CMD);
-       return ret;
-}
-
-int lbs_mesh_config_send(struct lbs_private *priv,
-                        struct cmd_ds_mesh_config *cmd,
-                        uint16_t action, uint16_t type)
-{
-       int ret;
-
-       if (!(priv->fwcapinfo & FW_CAPINFO_PERSISTENT_CONFIG))
-               return -EOPNOTSUPP;
-
-       ret = __lbs_mesh_config_send(priv, cmd, action, type);
-       return ret;
-}
-
-/* This function is the CMD_MESH_CONFIG legacy function.  It only handles the
- * START and STOP actions.  The extended actions supported by CMD_MESH_CONFIG
- * are all handled by preparing a struct cmd_ds_mesh_config and passing it to
- * lbs_mesh_config_send.
- */
-int lbs_mesh_config(struct lbs_private *priv, uint16_t action, uint16_t chan)
-{
-       struct cmd_ds_mesh_config cmd;
-       struct mrvl_meshie *ie;
-       DECLARE_SSID_BUF(ssid);
-
-       memset(&cmd, 0, sizeof(cmd));
-       cmd.channel = cpu_to_le16(chan);
-       ie = (struct mrvl_meshie *)cmd.data;
-
-       switch (action) {
-       case CMD_ACT_MESH_CONFIG_START:
-               ie->id = WLAN_EID_GENERIC;
-               ie->val.oui[0] = 0x00;
-               ie->val.oui[1] = 0x50;
-               ie->val.oui[2] = 0x43;
-               ie->val.type = MARVELL_MESH_IE_TYPE;
-               ie->val.subtype = MARVELL_MESH_IE_SUBTYPE;
-               ie->val.version = MARVELL_MESH_IE_VERSION;
-               ie->val.active_protocol_id = MARVELL_MESH_PROTO_ID_HWMP;
-               ie->val.active_metric_id = MARVELL_MESH_METRIC_ID;
-               ie->val.mesh_capability = MARVELL_MESH_CAPABILITY;
-               ie->val.mesh_id_len = priv->mesh_ssid_len;
-               memcpy(ie->val.mesh_id, priv->mesh_ssid, priv->mesh_ssid_len);
-               ie->len = sizeof(struct mrvl_meshie_val) -
-                       IEEE80211_MAX_SSID_LEN + priv->mesh_ssid_len;
-               cmd.length = cpu_to_le16(sizeof(struct mrvl_meshie_val));
-               break;
-       case CMD_ACT_MESH_CONFIG_STOP:
-               break;
-       default:
-               return -1;
-       }
-       lbs_deb_cmd("mesh config action %d type %x channel %d SSID %s\n",
-                   action, priv->mesh_tlv, chan,
-                   print_ssid(ssid, priv->mesh_ssid, priv->mesh_ssid_len));
-
-       return __lbs_mesh_config_send(priv, &cmd, action, priv->mesh_tlv);
-}
-
 static void lbs_queue_cmd(struct lbs_private *priv,
                          struct cmd_ctrl_node *cmdnode)
 {
@@ -1029,9 +843,6 @@ int lbs_set_radio(struct lbs_private *priv, u8 preamble, u8 radio_on)
        if (priv->fwrelease < 0x09000000) {
                switch (preamble) {
                case RADIO_PREAMBLE_SHORT:
-                       if (!(priv->capability & WLAN_CAPABILITY_SHORT_PREAMBLE))
-                               goto out;
-                       /* Fall through */
                case RADIO_PREAMBLE_AUTO:
                case RADIO_PREAMBLE_LONG:
                        cmd.control = cpu_to_le16(preamble);
@@ -1185,6 +996,8 @@ int lbs_prepare_and_send_command(struct lbs_private *priv,
                ret = 0;
                break;
 
+#ifdef CONFIG_LIBERTAS_MESH
+
        case CMD_BT_ACCESS:
                ret = lbs_cmd_bt_access(cmdptr, cmd_action, pdata_buf);
                break;
@@ -1193,6 +1006,8 @@ int lbs_prepare_and_send_command(struct lbs_private *priv,
                ret = lbs_cmd_fwt_access(cmdptr, cmd_action, pdata_buf);
                break;
 
+#endif
+
        case CMD_802_11_BEACON_CTRL:
                ret = lbs_cmd_bcn_ctrl(priv, cmdptr, cmd_action);
                break;
@@ -1491,7 +1306,7 @@ int lbs_execute_next_command(struct lbs_private *priv)
                if ((priv->psmode != LBS802_11POWERMODECAM) &&
                    (priv->psstate == PS_STATE_FULL_POWER) &&
                    ((priv->connect_status == LBS_CONNECTED) ||
-                   (priv->mesh_connect_status == LBS_CONNECTED))) {
+                   lbs_mesh_connected(priv))) {
                        if (priv->secinfo.WPAenabled ||
                            priv->secinfo.WPA2enabled) {
                                /* check for valid WPA group keys */
@@ -1539,7 +1354,7 @@ static void lbs_send_confirmsleep(struct lbs_private *priv)
        priv->dnld_sent = DNLD_RES_RECEIVED;
 
        /* If nothing to do, go back to sleep (?) */
-       if (!__kfifo_len(priv->event_fifo) && !priv->resp_len[priv->resp_idx])
+       if (!kfifo_len(&priv->event_fifo) && !priv->resp_len[priv->resp_idx])
                priv->psstate = PS_STATE_SLEEP;
 
        spin_unlock_irqrestore(&priv->driver_lock, flags);
@@ -1613,7 +1428,7 @@ void lbs_ps_confirm_sleep(struct lbs_private *priv)
        }
 
        /* Pending events or command responses? */
-       if (__kfifo_len(priv->event_fifo) || priv->resp_len[priv->resp_idx]) {
+       if (kfifo_len(&priv->event_fifo) || priv->resp_len[priv->resp_idx]) {
                allowed = 0;
                lbs_deb_host("pending events or command responses\n");
        }