diff options
author | Stanislaw Gruszka <sgruszka@redhat.com> | 2012-02-03 11:31:48 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2012-02-06 14:56:03 -0500 |
commit | d735f9213d11e34e6ed074acea30b6743b3385e6 (patch) | |
tree | 297bbbbf894f3e37eb4bf08872db85f5dbd7585b /drivers/net/wireless/iwlegacy/4965-mac.c | |
parent | d1e14e942430cd42df9913337aebbcaef53e4515 (diff) |
iwlegacy: move wep_keys out of context
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/iwlegacy/4965-mac.c')
-rw-r--r-- | drivers/net/wireless/iwlegacy/4965-mac.c | 58 |
1 files changed, 36 insertions, 22 deletions
diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index ecb7b542b96c..35d868c4ba92 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c | |||
@@ -2808,7 +2808,7 @@ static int | |||
2808 | il4965_static_wepkey_cmd(struct il_priv *il, struct il_rxon_context *ctx, | 2808 | il4965_static_wepkey_cmd(struct il_priv *il, struct il_rxon_context *ctx, |
2809 | bool send_if_empty) | 2809 | bool send_if_empty) |
2810 | { | 2810 | { |
2811 | int i, not_empty = 0; | 2811 | int i; |
2812 | u8 buff[sizeof(struct il_wep_cmd) + | 2812 | u8 buff[sizeof(struct il_wep_cmd) + |
2813 | sizeof(struct il_wep_key) * WEP_KEYS_MAX]; | 2813 | sizeof(struct il_wep_key) * WEP_KEYS_MAX]; |
2814 | struct il_wep_cmd *wep_cmd = (struct il_wep_cmd *)buff; | 2814 | struct il_wep_cmd *wep_cmd = (struct il_wep_cmd *)buff; |
@@ -2818,6 +2818,7 @@ il4965_static_wepkey_cmd(struct il_priv *il, struct il_rxon_context *ctx, | |||
2818 | .data = wep_cmd, | 2818 | .data = wep_cmd, |
2819 | .flags = CMD_SYNC, | 2819 | .flags = CMD_SYNC, |
2820 | }; | 2820 | }; |
2821 | bool not_empty = false; | ||
2821 | 2822 | ||
2822 | might_sleep(); | 2823 | might_sleep(); |
2823 | 2824 | ||
@@ -2825,24 +2826,23 @@ il4965_static_wepkey_cmd(struct il_priv *il, struct il_rxon_context *ctx, | |||
2825 | cmd_size + (sizeof(struct il_wep_key) * WEP_KEYS_MAX)); | 2826 | cmd_size + (sizeof(struct il_wep_key) * WEP_KEYS_MAX)); |
2826 | 2827 | ||
2827 | for (i = 0; i < WEP_KEYS_MAX; i++) { | 2828 | for (i = 0; i < WEP_KEYS_MAX; i++) { |
2829 | u8 key_size = il->_4965.wep_keys[i].key_size; | ||
2830 | |||
2828 | wep_cmd->key[i].key_idx = i; | 2831 | wep_cmd->key[i].key_idx = i; |
2829 | if (ctx->wep_keys[i].key_size) { | 2832 | if (key_size) { |
2830 | wep_cmd->key[i].key_offset = i; | 2833 | wep_cmd->key[i].key_offset = i; |
2831 | not_empty = 1; | 2834 | not_empty = true; |
2832 | } else { | 2835 | } else |
2833 | wep_cmd->key[i].key_offset = WEP_INVALID_OFFSET; | 2836 | wep_cmd->key[i].key_offset = WEP_INVALID_OFFSET; |
2834 | } | ||
2835 | 2837 | ||
2836 | wep_cmd->key[i].key_size = ctx->wep_keys[i].key_size; | 2838 | wep_cmd->key[i].key_size = key_size; |
2837 | memcpy(&wep_cmd->key[i].key[3], ctx->wep_keys[i].key, | 2839 | memcpy(&wep_cmd->key[i].key[3], il->_4965.wep_keys[i].key, key_size); |
2838 | ctx->wep_keys[i].key_size); | ||
2839 | } | 2840 | } |
2840 | 2841 | ||
2841 | wep_cmd->global_key_type = WEP_KEY_WEP_TYPE; | 2842 | wep_cmd->global_key_type = WEP_KEY_WEP_TYPE; |
2842 | wep_cmd->num_keys = WEP_KEYS_MAX; | 2843 | wep_cmd->num_keys = WEP_KEYS_MAX; |
2843 | 2844 | ||
2844 | cmd_size += sizeof(struct il_wep_key) * WEP_KEYS_MAX; | 2845 | cmd_size += sizeof(struct il_wep_key) * WEP_KEYS_MAX; |
2845 | |||
2846 | cmd.len = cmd_size; | 2846 | cmd.len = cmd_size; |
2847 | 2847 | ||
2848 | if (not_empty || send_if_empty) | 2848 | if (not_empty || send_if_empty) |
@@ -2864,19 +2864,20 @@ il4965_remove_default_wep_key(struct il_priv *il, struct il_rxon_context *ctx, | |||
2864 | struct ieee80211_key_conf *keyconf) | 2864 | struct ieee80211_key_conf *keyconf) |
2865 | { | 2865 | { |
2866 | int ret; | 2866 | int ret; |
2867 | int idx = keyconf->keyidx; | ||
2867 | 2868 | ||
2868 | lockdep_assert_held(&il->mutex); | 2869 | lockdep_assert_held(&il->mutex); |
2869 | 2870 | ||
2870 | D_WEP("Removing default WEP key: idx=%d\n", keyconf->keyidx); | 2871 | D_WEP("Removing default WEP key: idx=%d\n", idx); |
2871 | 2872 | ||
2872 | memset(&ctx->wep_keys[keyconf->keyidx], 0, sizeof(ctx->wep_keys[0])); | 2873 | memset(&il->_4965.wep_keys[idx], 0, sizeof(struct il_wep_key)); |
2873 | if (il_is_rfkill(il)) { | 2874 | if (il_is_rfkill(il)) { |
2874 | D_WEP("Not sending C_WEPKEY command due to RFKILL.\n"); | 2875 | D_WEP("Not sending C_WEPKEY command due to RFKILL.\n"); |
2875 | /* but keys in device are clear anyway so return success */ | 2876 | /* but keys in device are clear anyway so return success */ |
2876 | return 0; | 2877 | return 0; |
2877 | } | 2878 | } |
2878 | ret = il4965_static_wepkey_cmd(il, ctx, 1); | 2879 | ret = il4965_static_wepkey_cmd(il, ctx, 1); |
2879 | D_WEP("Remove default WEP key: idx=%d ret=%d\n", keyconf->keyidx, ret); | 2880 | D_WEP("Remove default WEP key: idx=%d ret=%d\n", idx, ret); |
2880 | 2881 | ||
2881 | return ret; | 2882 | return ret; |
2882 | } | 2883 | } |
@@ -2886,11 +2887,12 @@ il4965_set_default_wep_key(struct il_priv *il, struct il_rxon_context *ctx, | |||
2886 | struct ieee80211_key_conf *keyconf) | 2887 | struct ieee80211_key_conf *keyconf) |
2887 | { | 2888 | { |
2888 | int ret; | 2889 | int ret; |
2890 | int len = keyconf->keylen; | ||
2891 | int idx = keyconf->keyidx; | ||
2889 | 2892 | ||
2890 | lockdep_assert_held(&il->mutex); | 2893 | lockdep_assert_held(&il->mutex); |
2891 | 2894 | ||
2892 | if (keyconf->keylen != WEP_KEY_LEN_128 && | 2895 | if (len != WEP_KEY_LEN_128 && len != WEP_KEY_LEN_64) { |
2893 | keyconf->keylen != WEP_KEY_LEN_64) { | ||
2894 | D_WEP("Bad WEP key length %d\n", keyconf->keylen); | 2896 | D_WEP("Bad WEP key length %d\n", keyconf->keylen); |
2895 | return -EINVAL; | 2897 | return -EINVAL; |
2896 | } | 2898 | } |
@@ -2899,14 +2901,12 @@ il4965_set_default_wep_key(struct il_priv *il, struct il_rxon_context *ctx, | |||
2899 | keyconf->hw_key_idx = HW_KEY_DEFAULT; | 2901 | keyconf->hw_key_idx = HW_KEY_DEFAULT; |
2900 | il->stations[IL_AP_ID].keyinfo.cipher = keyconf->cipher; | 2902 | il->stations[IL_AP_ID].keyinfo.cipher = keyconf->cipher; |
2901 | 2903 | ||
2902 | ctx->wep_keys[keyconf->keyidx].key_size = keyconf->keylen; | 2904 | il->_4965.wep_keys[idx].key_size = len; |
2903 | memcpy(&ctx->wep_keys[keyconf->keyidx].key, &keyconf->key, | 2905 | memcpy(&il->_4965.wep_keys[idx].key, &keyconf->key, len); |
2904 | keyconf->keylen); | ||
2905 | 2906 | ||
2906 | ret = il4965_static_wepkey_cmd(il, ctx, false); | 2907 | ret = il4965_static_wepkey_cmd(il, ctx, false); |
2907 | D_WEP("Set default WEP key: len=%d idx=%d ret=%d\n", keyconf->keylen, | ||
2908 | keyconf->keyidx, ret); | ||
2909 | 2908 | ||
2909 | D_WEP("Set default WEP key: len=%d idx=%d ret=%d\n", len, idx, ret); | ||
2910 | return ret; | 2910 | return ret; |
2911 | } | 2911 | } |
2912 | 2912 | ||
@@ -3106,7 +3106,7 @@ il4965_remove_dynamic_key(struct il_priv *il, struct il_rxon_context *ctx, | |||
3106 | 3106 | ||
3107 | lockdep_assert_held(&il->mutex); | 3107 | lockdep_assert_held(&il->mutex); |
3108 | 3108 | ||
3109 | ctx->key_mapping_keys--; | 3109 | il->_4965.key_mapping_keys--; |
3110 | 3110 | ||
3111 | spin_lock_irqsave(&il->sta_lock, flags); | 3111 | spin_lock_irqsave(&il->sta_lock, flags); |
3112 | key_flags = le16_to_cpu(il->stations[sta_id].sta.key.key_flags); | 3112 | key_flags = le16_to_cpu(il->stations[sta_id].sta.key.key_flags); |
@@ -3164,7 +3164,7 @@ il4965_set_dynamic_key(struct il_priv *il, struct il_rxon_context *ctx, | |||
3164 | 3164 | ||
3165 | lockdep_assert_held(&il->mutex); | 3165 | lockdep_assert_held(&il->mutex); |
3166 | 3166 | ||
3167 | ctx->key_mapping_keys++; | 3167 | il->_4965.key_mapping_keys++; |
3168 | keyconf->hw_key_idx = HW_KEY_DYNAMIC; | 3168 | keyconf->hw_key_idx = HW_KEY_DYNAMIC; |
3169 | 3169 | ||
3170 | switch (keyconf->cipher) { | 3170 | switch (keyconf->cipher) { |
@@ -5067,6 +5067,20 @@ __il4965_down(struct il_priv *il) | |||
5067 | del_timer_sync(&il->watchdog); | 5067 | del_timer_sync(&il->watchdog); |
5068 | 5068 | ||
5069 | il_clear_ucode_stations(il, NULL); | 5069 | il_clear_ucode_stations(il, NULL); |
5070 | |||
5071 | /* FIXME: race conditions ? */ | ||
5072 | spin_lock_irq(&il->sta_lock); | ||
5073 | /* | ||
5074 | * Remove all key information that is not stored as part | ||
5075 | * of station information since mac80211 may not have had | ||
5076 | * a chance to remove all the keys. When device is | ||
5077 | * reconfigured by mac80211 after an error all keys will | ||
5078 | * be reconfigured. | ||
5079 | */ | ||
5080 | memset(il->_4965.wep_keys, 0, sizeof(il->_4965.wep_keys)); | ||
5081 | il->_4965.key_mapping_keys = 0; | ||
5082 | spin_unlock_irq(&il->sta_lock); | ||
5083 | |||
5070 | il_dealloc_bcast_stations(il); | 5084 | il_dealloc_bcast_stations(il); |
5071 | il_clear_driver_stations(il); | 5085 | il_clear_driver_stations(il); |
5072 | 5086 | ||
@@ -5613,7 +5627,7 @@ il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, | |||
5613 | if ((key->cipher == WLAN_CIPHER_SUITE_WEP40 || | 5627 | if ((key->cipher == WLAN_CIPHER_SUITE_WEP40 || |
5614 | key->cipher == WLAN_CIPHER_SUITE_WEP104) && !sta) { | 5628 | key->cipher == WLAN_CIPHER_SUITE_WEP104) && !sta) { |
5615 | if (cmd == SET_KEY) | 5629 | if (cmd == SET_KEY) |
5616 | is_default_wep_key = !ctx->key_mapping_keys; | 5630 | is_default_wep_key = !il->_4965.key_mapping_keys; |
5617 | else | 5631 | else |
5618 | is_default_wep_key = | 5632 | is_default_wep_key = |
5619 | (key->hw_key_idx == HW_KEY_DEFAULT); | 5633 | (key->hw_key_idx == HW_KEY_DEFAULT); |