aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/iwl-sta.c
diff options
context:
space:
mode:
authorEmmanuel Grumbach <emmanuel.grumbach@intel.com>2008-04-15 00:16:08 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-04-16 15:59:58 -0400
commit80fb47a11eaf3d1d70c02f3dc7976eaac9b0eef2 (patch)
treeb9d94392f6e9ca2f98b85ab9b968656b71cc50e8 /drivers/net/wireless/iwlwifi/iwl-sta.c
parent0211ddda9deb681a804572936cd49e466a1aa88b (diff)
iwlwifi: maintain uCode key table state
This patch fix book keeping of key table in the driver to be synchronized with uCode 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>
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-sta.c')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-sta.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-sta.c b/drivers/net/wireless/iwlwifi/iwl-sta.c
index cb964196ad2a..41238f208ed5 100644
--- a/drivers/net/wireless/iwlwifi/iwl-sta.c
+++ b/drivers/net/wireless/iwlwifi/iwl-sta.c
@@ -36,6 +36,18 @@
36#include "iwl-io.h" 36#include "iwl-io.h"
37#include "iwl-helpers.h" 37#include "iwl-helpers.h"
38#include "iwl-4965.h" 38#include "iwl-4965.h"
39#include "iwl-sta.h"
40
41int iwl_get_free_ucode_key_index(struct iwl_priv *priv)
42{
43 int i;
44
45 for (i = 0; i < STA_KEY_MAX_NUM; i++)
46 if (test_and_set_bit(i, &priv->ucode_key_table))
47 return i;
48
49 return -1;
50}
39 51
40int iwl_send_static_wepkey_cmd(struct iwl_priv *priv, u8 send_if_empty) 52int iwl_send_static_wepkey_cmd(struct iwl_priv *priv, u8 send_if_empty)
41{ 53{
@@ -81,14 +93,19 @@ int iwl_send_static_wepkey_cmd(struct iwl_priv *priv, u8 send_if_empty)
81} 93}
82 94
83int iwl_remove_default_wep_key(struct iwl_priv *priv, 95int iwl_remove_default_wep_key(struct iwl_priv *priv,
84 struct ieee80211_key_conf *key) 96 struct ieee80211_key_conf *keyconf)
85{ 97{
86 int ret; 98 int ret;
87 unsigned long flags; 99 unsigned long flags;
88 100
89 spin_lock_irqsave(&priv->sta_lock, flags); 101 spin_lock_irqsave(&priv->sta_lock, flags);
102
103 if (!test_and_clear_bit(keyconf->keyidx, &priv->ucode_key_table))
104 IWL_ERROR("index %d not used in uCode key table.\n",
105 keyconf->keyidx);
106
90 priv->default_wep_key--; 107 priv->default_wep_key--;
91 memset(&priv->wep_keys[key->keyidx], 0, sizeof(priv->wep_keys[0])); 108 memset(&priv->wep_keys[keyconf->keyidx], 0, sizeof(priv->wep_keys[0]));
92 ret = iwl_send_static_wepkey_cmd(priv, 1); 109 ret = iwl_send_static_wepkey_cmd(priv, 1);
93 spin_unlock_irqrestore(&priv->sta_lock, flags); 110 spin_unlock_irqrestore(&priv->sta_lock, flags);
94 111
@@ -108,6 +125,10 @@ int iwl_set_default_wep_key(struct iwl_priv *priv,
108 spin_lock_irqsave(&priv->sta_lock, flags); 125 spin_lock_irqsave(&priv->sta_lock, flags);
109 priv->default_wep_key++; 126 priv->default_wep_key++;
110 127
128 if (test_and_set_bit(keyconf->keyidx, &priv->ucode_key_table))
129 IWL_ERROR("index %d already used in uCode key table.\n",
130 keyconf->keyidx);
131
111 priv->wep_keys[keyconf->keyidx].key_size = keyconf->keylen; 132 priv->wep_keys[keyconf->keyidx].key_size = keyconf->keylen;
112 memcpy(&priv->wep_keys[keyconf->keyidx].key, &keyconf->key, 133 memcpy(&priv->wep_keys[keyconf->keyidx].key, &keyconf->key,
113 keyconf->keylen); 134 keyconf->keylen);
@@ -151,7 +172,8 @@ int iwl_set_wep_dynamic_key_info(struct iwl_priv *priv,
151 memcpy(&priv->stations[sta_id].sta.key.key[3], 172 memcpy(&priv->stations[sta_id].sta.key.key[3],
152 keyconf->key, keyconf->keylen); 173 keyconf->key, keyconf->keylen);
153 174
154 priv->stations[sta_id].sta.key.key_offset = sta_id % 8; /* FIXME */ 175 priv->stations[sta_id].sta.key.key_offset =
176 iwl_get_free_ucode_key_index(priv);
155 priv->stations[sta_id].sta.key.key_flags = key_flags; 177 priv->stations[sta_id].sta.key.key_flags = key_flags;
156 178
157 priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; 179 priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK;