aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStanislaw Gruszka <sgruszka@redhat.com>2012-02-03 11:31:48 -0500
committerJohn W. Linville <linville@tuxdriver.com>2012-02-06 14:56:03 -0500
commitd735f9213d11e34e6ed074acea30b6743b3385e6 (patch)
tree297bbbbf894f3e37eb4bf08872db85f5dbd7585b
parentd1e14e942430cd42df9913337aebbcaef53e4515 (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>
-rw-r--r--drivers/net/wireless/iwlegacy/4965-mac.c58
-rw-r--r--drivers/net/wireless/iwlegacy/common.h19
2 files changed, 39 insertions, 38 deletions
diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c
index ecb7b542b96..35d868c4ba9 100644
--- a/drivers/net/wireless/iwlegacy/4965-mac.c
+++ b/drivers/net/wireless/iwlegacy/4965-mac.c
@@ -2808,7 +2808,7 @@ static int
2808il4965_static_wepkey_cmd(struct il_priv *il, struct il_rxon_context *ctx, 2808il4965_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);
diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h
index 89922e0a70d..811e768637c 100644
--- a/drivers/net/wireless/iwlegacy/common.h
+++ b/drivers/net/wireless/iwlegacy/common.h
@@ -1169,9 +1169,6 @@ struct il_rxon_context {
1169 1169
1170 struct il_qos_info qos_data; 1170 struct il_qos_info qos_data;
1171 1171
1172 struct il_wep_key wep_keys[WEP_KEYS_MAX];
1173 u8 key_mapping_keys;
1174
1175 __le32 station_flags; 1172 __le32 station_flags;
1176 1173
1177 struct { 1174 struct {
@@ -1417,6 +1414,9 @@ struct il_priv {
1417 u8 phy_calib_chain_noise_reset_cmd; 1414 u8 phy_calib_chain_noise_reset_cmd;
1418 u8 phy_calib_chain_noise_gain_cmd; 1415 u8 phy_calib_chain_noise_gain_cmd;
1419 1416
1417 u8 key_mapping_keys;
1418 struct il_wep_key wep_keys[WEP_KEYS_MAX];
1419
1420 struct il_notif_stats stats; 1420 struct il_notif_stats stats;
1421#ifdef CONFIG_IWLEGACY_DEBUGFS 1421#ifdef CONFIG_IWLEGACY_DEBUGFS
1422 struct il_notif_stats accum_stats; 1422 struct il_notif_stats accum_stats;
@@ -2318,24 +2318,11 @@ static inline void
2318il_clear_driver_stations(struct il_priv *il) 2318il_clear_driver_stations(struct il_priv *il)
2319{ 2319{
2320 unsigned long flags; 2320 unsigned long flags;
2321 struct il_rxon_context *ctx = &il->ctx;
2322 2321
2323 spin_lock_irqsave(&il->sta_lock, flags); 2322 spin_lock_irqsave(&il->sta_lock, flags);
2324 memset(il->stations, 0, sizeof(il->stations)); 2323 memset(il->stations, 0, sizeof(il->stations));
2325 il->num_stations = 0; 2324 il->num_stations = 0;
2326
2327 il->ucode_key_table = 0; 2325 il->ucode_key_table = 0;
2328
2329 /*
2330 * Remove all key information that is not stored as part
2331 * of station information since mac80211 may not have had
2332 * a chance to remove all the keys. When device is
2333 * reconfigured by mac80211 after an error all keys will
2334 * be reconfigured.
2335 */
2336 memset(ctx->wep_keys, 0, sizeof(ctx->wep_keys));
2337 ctx->key_mapping_keys = 0;
2338
2339 spin_unlock_irqrestore(&il->sta_lock, flags); 2326 spin_unlock_irqrestore(&il->sta_lock, flags);
2340} 2327}
2341 2328