Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 290383
b: refs/heads/master
c: d735f92
h: refs/heads/master
i:
  290381: ac76589
  290379: 6c890e4
  290375: 1e54b27
  290367: d9892f0
v: v3
  • Loading branch information
Stanislaw Gruszka authored and John W. Linville committed Feb 6, 2012
1 parent 5c5b1cd commit 27d01e2
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 39 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d1e14e942430cd42df9913337aebbcaef53e4515
refs/heads/master: d735f9213d11e34e6ed074acea30b6743b3385e6
58 changes: 36 additions & 22 deletions trunk/drivers/net/wireless/iwlegacy/4965-mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -2808,7 +2808,7 @@ static int
il4965_static_wepkey_cmd(struct il_priv *il, struct il_rxon_context *ctx,
bool send_if_empty)
{
int i, not_empty = 0;
int i;
u8 buff[sizeof(struct il_wep_cmd) +
sizeof(struct il_wep_key) * WEP_KEYS_MAX];
struct il_wep_cmd *wep_cmd = (struct il_wep_cmd *)buff;
Expand All @@ -2818,31 +2818,31 @@ il4965_static_wepkey_cmd(struct il_priv *il, struct il_rxon_context *ctx,
.data = wep_cmd,
.flags = CMD_SYNC,
};
bool not_empty = false;

might_sleep();

memset(wep_cmd, 0,
cmd_size + (sizeof(struct il_wep_key) * WEP_KEYS_MAX));

for (i = 0; i < WEP_KEYS_MAX; i++) {
u8 key_size = il->_4965.wep_keys[i].key_size;

wep_cmd->key[i].key_idx = i;
if (ctx->wep_keys[i].key_size) {
if (key_size) {
wep_cmd->key[i].key_offset = i;
not_empty = 1;
} else {
not_empty = true;
} else
wep_cmd->key[i].key_offset = WEP_INVALID_OFFSET;
}

wep_cmd->key[i].key_size = ctx->wep_keys[i].key_size;
memcpy(&wep_cmd->key[i].key[3], ctx->wep_keys[i].key,
ctx->wep_keys[i].key_size);
wep_cmd->key[i].key_size = key_size;
memcpy(&wep_cmd->key[i].key[3], il->_4965.wep_keys[i].key, key_size);
}

wep_cmd->global_key_type = WEP_KEY_WEP_TYPE;
wep_cmd->num_keys = WEP_KEYS_MAX;

cmd_size += sizeof(struct il_wep_key) * WEP_KEYS_MAX;

cmd.len = cmd_size;

if (not_empty || send_if_empty)
Expand All @@ -2864,19 +2864,20 @@ il4965_remove_default_wep_key(struct il_priv *il, struct il_rxon_context *ctx,
struct ieee80211_key_conf *keyconf)
{
int ret;
int idx = keyconf->keyidx;

lockdep_assert_held(&il->mutex);

D_WEP("Removing default WEP key: idx=%d\n", keyconf->keyidx);
D_WEP("Removing default WEP key: idx=%d\n", idx);

memset(&ctx->wep_keys[keyconf->keyidx], 0, sizeof(ctx->wep_keys[0]));
memset(&il->_4965.wep_keys[idx], 0, sizeof(struct il_wep_key));
if (il_is_rfkill(il)) {
D_WEP("Not sending C_WEPKEY command due to RFKILL.\n");
/* but keys in device are clear anyway so return success */
return 0;
}
ret = il4965_static_wepkey_cmd(il, ctx, 1);
D_WEP("Remove default WEP key: idx=%d ret=%d\n", keyconf->keyidx, ret);
D_WEP("Remove default WEP key: idx=%d ret=%d\n", idx, ret);

return ret;
}
Expand All @@ -2886,11 +2887,12 @@ il4965_set_default_wep_key(struct il_priv *il, struct il_rxon_context *ctx,
struct ieee80211_key_conf *keyconf)
{
int ret;
int len = keyconf->keylen;
int idx = keyconf->keyidx;

lockdep_assert_held(&il->mutex);

if (keyconf->keylen != WEP_KEY_LEN_128 &&
keyconf->keylen != WEP_KEY_LEN_64) {
if (len != WEP_KEY_LEN_128 && len != WEP_KEY_LEN_64) {
D_WEP("Bad WEP key length %d\n", keyconf->keylen);
return -EINVAL;
}
Expand All @@ -2899,14 +2901,12 @@ il4965_set_default_wep_key(struct il_priv *il, struct il_rxon_context *ctx,
keyconf->hw_key_idx = HW_KEY_DEFAULT;
il->stations[IL_AP_ID].keyinfo.cipher = keyconf->cipher;

ctx->wep_keys[keyconf->keyidx].key_size = keyconf->keylen;
memcpy(&ctx->wep_keys[keyconf->keyidx].key, &keyconf->key,
keyconf->keylen);
il->_4965.wep_keys[idx].key_size = len;
memcpy(&il->_4965.wep_keys[idx].key, &keyconf->key, len);

ret = il4965_static_wepkey_cmd(il, ctx, false);
D_WEP("Set default WEP key: len=%d idx=%d ret=%d\n", keyconf->keylen,
keyconf->keyidx, ret);

D_WEP("Set default WEP key: len=%d idx=%d ret=%d\n", len, idx, ret);
return ret;
}

Expand Down Expand Up @@ -3106,7 +3106,7 @@ il4965_remove_dynamic_key(struct il_priv *il, struct il_rxon_context *ctx,

lockdep_assert_held(&il->mutex);

ctx->key_mapping_keys--;
il->_4965.key_mapping_keys--;

spin_lock_irqsave(&il->sta_lock, flags);
key_flags = le16_to_cpu(il->stations[sta_id].sta.key.key_flags);
Expand Down Expand Up @@ -3164,7 +3164,7 @@ il4965_set_dynamic_key(struct il_priv *il, struct il_rxon_context *ctx,

lockdep_assert_held(&il->mutex);

ctx->key_mapping_keys++;
il->_4965.key_mapping_keys++;
keyconf->hw_key_idx = HW_KEY_DYNAMIC;

switch (keyconf->cipher) {
Expand Down Expand Up @@ -5067,6 +5067,20 @@ __il4965_down(struct il_priv *il)
del_timer_sync(&il->watchdog);

il_clear_ucode_stations(il, NULL);

/* FIXME: race conditions ? */
spin_lock_irq(&il->sta_lock);
/*
* Remove all key information that is not stored as part
* of station information since mac80211 may not have had
* a chance to remove all the keys. When device is
* reconfigured by mac80211 after an error all keys will
* be reconfigured.
*/
memset(il->_4965.wep_keys, 0, sizeof(il->_4965.wep_keys));
il->_4965.key_mapping_keys = 0;
spin_unlock_irq(&il->sta_lock);

il_dealloc_bcast_stations(il);
il_clear_driver_stations(il);

Expand Down Expand Up @@ -5613,7 +5627,7 @@ il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
if ((key->cipher == WLAN_CIPHER_SUITE_WEP40 ||
key->cipher == WLAN_CIPHER_SUITE_WEP104) && !sta) {
if (cmd == SET_KEY)
is_default_wep_key = !ctx->key_mapping_keys;
is_default_wep_key = !il->_4965.key_mapping_keys;
else
is_default_wep_key =
(key->hw_key_idx == HW_KEY_DEFAULT);
Expand Down
19 changes: 3 additions & 16 deletions trunk/drivers/net/wireless/iwlegacy/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -1169,9 +1169,6 @@ struct il_rxon_context {

struct il_qos_info qos_data;

struct il_wep_key wep_keys[WEP_KEYS_MAX];
u8 key_mapping_keys;

__le32 station_flags;

struct {
Expand Down Expand Up @@ -1417,6 +1414,9 @@ struct il_priv {
u8 phy_calib_chain_noise_reset_cmd;
u8 phy_calib_chain_noise_gain_cmd;

u8 key_mapping_keys;
struct il_wep_key wep_keys[WEP_KEYS_MAX];

struct il_notif_stats stats;
#ifdef CONFIG_IWLEGACY_DEBUGFS
struct il_notif_stats accum_stats;
Expand Down Expand Up @@ -2318,24 +2318,11 @@ static inline void
il_clear_driver_stations(struct il_priv *il)
{
unsigned long flags;
struct il_rxon_context *ctx = &il->ctx;

spin_lock_irqsave(&il->sta_lock, flags);
memset(il->stations, 0, sizeof(il->stations));
il->num_stations = 0;

il->ucode_key_table = 0;

/*
* Remove all key information that is not stored as part
* of station information since mac80211 may not have had
* a chance to remove all the keys. When device is
* reconfigured by mac80211 after an error all keys will
* be reconfigured.
*/
memset(ctx->wep_keys, 0, sizeof(ctx->wep_keys));
ctx->key_mapping_keys = 0;

spin_unlock_irqrestore(&il->sta_lock, flags);
}

Expand Down

0 comments on commit 27d01e2

Please sign in to comment.