]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
iwlwifi: add 1X HW WEP support
authorEmmanuel Grumbach <emmanuel.grumbach@intel.com>
Tue, 15 Apr 2008 04:16:07 +0000 (21:16 -0700)
committerJohn W. Linville <linville@tuxdriver.com>
Wed, 16 Apr 2008 19:59:58 +0000 (15:59 -0400)
This patch adds support for HW encryption/decryption in 1X WEP.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/iwlwifi/iwl-4965.h
drivers/net/wireless/iwlwifi/iwl-sta.c
drivers/net/wireless/iwlwifi/iwl-sta.h
drivers/net/wireless/iwlwifi/iwl4965-base.c

index 93df29e4689a65eba11bbe04b3a7c53ed278bf51..23ab5236504b7b56651719b4bb25326404fbdea7 100644 (file)
@@ -461,6 +461,7 @@ struct iwl4965_tid_data {
 struct iwl4965_hw_key {
        enum ieee80211_key_alg alg;
        int keylen;
+       u8 keyidx;
        struct ieee80211_key_conf *conf;
        u8 key[32];
 };
index a48e228e2ffd61c1986aa190d99d6884f3aae7b9..cb964196ad2a1db7533fdcfe4ec704637244162e 100644 (file)
@@ -35,6 +35,7 @@
 #include "iwl-sta.h"
 #include "iwl-io.h"
 #include "iwl-helpers.h"
+#include "iwl-4965.h"
 
 int iwl_send_static_wepkey_cmd(struct iwl_priv *priv, u8 send_if_empty)
 {
@@ -117,3 +118,49 @@ int iwl_set_default_wep_key(struct iwl_priv *priv,
        return ret;
 }
 
+int iwl_set_wep_dynamic_key_info(struct iwl_priv *priv,
+                               struct ieee80211_key_conf *keyconf,
+                               u8 sta_id)
+{
+       unsigned long flags;
+       __le16 key_flags = 0;
+       int ret;
+
+       keyconf->flags &= ~IEEE80211_KEY_FLAG_GENERATE_IV;
+       keyconf->hw_key_idx = keyconf->keyidx;
+
+       key_flags |= (STA_KEY_FLG_WEP | STA_KEY_FLG_MAP_KEY_MSK);
+       key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS);
+       key_flags &= ~STA_KEY_FLG_INVALID;
+
+       if (keyconf->keylen == WEP_KEY_LEN_128)
+               key_flags |= STA_KEY_FLG_KEY_SIZE_MSK;
+
+       if (sta_id == priv->hw_setting.bcast_sta_id)
+               key_flags |= STA_KEY_MULTICAST_MSK;
+
+       spin_lock_irqsave(&priv->sta_lock, flags);
+
+       priv->stations[sta_id].keyinfo.alg = keyconf->alg;
+       priv->stations[sta_id].keyinfo.keylen = keyconf->keylen;
+       priv->stations[sta_id].keyinfo.keyidx = keyconf->keyidx;
+
+       memcpy(priv->stations[sta_id].keyinfo.key,
+                               keyconf->key, keyconf->keylen);
+
+       memcpy(&priv->stations[sta_id].sta.key.key[3],
+                               keyconf->key, keyconf->keylen);
+
+       priv->stations[sta_id].sta.key.key_offset = sta_id % 8; /* FIXME */
+       priv->stations[sta_id].sta.key.key_flags = key_flags;
+
+       priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK;
+       priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK;
+
+       ret = iwl4965_send_add_station(priv,
+               &priv->stations[sta_id].sta, CMD_ASYNC);
+
+       spin_unlock_irqrestore(&priv->sta_lock, flags);
+
+       return ret;
+}
index 50e9f1470d8ddf2f43da26dd4d32cb3514e87d43..78e0254c93b5cffa7d807fe58c974c3a44956df8 100644 (file)
@@ -42,5 +42,8 @@ int iwl_remove_default_wep_key(struct iwl_priv *priv,
                                struct ieee80211_key_conf *key);
 int iwl_set_default_wep_key(struct iwl_priv *priv,
                                struct ieee80211_key_conf *key);
+int iwl_set_wep_dynamic_key_info(struct iwl_priv *priv,
+                               struct ieee80211_key_conf *keyconf,
+                               u8 sta_id);
 
 #endif /* __iwl_sta_h__ */
index dfd2b75492e63a144df7b1716963831ed274c286..37ab1c565ce1eb3874c42b2e380be0d9e1add32a 100644 (file)
@@ -1214,7 +1214,7 @@ static int iwl4965_set_dynamic_key(struct iwl_priv *priv,
                ret = iwl4965_set_tkip_dynamic_key_info(priv, key, sta_id);
                break;
        case ALG_WEP:
-               ret = -EOPNOTSUPP;
+               ret = iwl_set_wep_dynamic_key_info(priv, key, sta_id);
                break;
        default:
                IWL_ERROR("Unknown alg: %s alg = %d\n", __func__, key->alg);
@@ -2138,7 +2138,12 @@ static void iwl4965_build_tx_cmd_hwcrypto(struct iwl_priv *priv,
                        if (wepkey->key_size == WEP_KEY_LEN_128)
                                cmd->cmd.tx.sec_ctl |= TX_CMD_SEC_KEY128;
                } else {
-                       IWL_ERROR("No support for WEP key mappings key\n");
+                       /* the WEP key was sent as dynamic */
+                       keyidx = keyinfo->keyidx;
+                       memcpy(&cmd->cmd.tx.key[3], keyinfo->key,
+                                                       keyinfo->keylen);
+                       if (keyinfo->keylen == WEP_KEY_LEN_128)
+                               cmd->cmd.tx.sec_ctl |= TX_CMD_SEC_KEY128;
                }
 
                cmd->cmd.tx.sec_ctl |= (TX_CMD_SEC_WEP |