diff options
author | Johannes Berg <johannes.berg@intel.com> | 2010-08-23 04:46:43 -0400 |
---|---|---|
committer | Wey-Yi Guy <wey-yi.w.guy@intel.com> | 2010-08-27 12:25:56 -0400 |
commit | c10afb6e844b7936092396f719b794c4d0038f27 (patch) | |
tree | 32d2aa88058ff320063fdec5f606235acc2e3015 /drivers/net/wireless/iwlwifi/iwl-sta.c | |
parent | 2995bafafd4d9d2f840b51b0121997be09fb8b47 (diff) |
iwlwifi: make hw crypto context aware
HW crypto needs to be aware of the context, and there
are different command IDs for the WEP keys per context,
so move the key tracking variables and command IDs into
the context structure.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-sta.c')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-sta.c | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-sta.c b/drivers/net/wireless/iwlwifi/iwl-sta.c index f5500cc8a44e..ac6e2be35284 100644 --- a/drivers/net/wireless/iwlwifi/iwl-sta.c +++ b/drivers/net/wireless/iwlwifi/iwl-sta.c | |||
@@ -724,7 +724,7 @@ int iwl_get_free_ucode_key_index(struct iwl_priv *priv) | |||
724 | { | 724 | { |
725 | int i; | 725 | int i; |
726 | 726 | ||
727 | for (i = 0; i < STA_KEY_MAX_NUM; i++) | 727 | for (i = 0; i < priv->sta_key_max_num; i++) |
728 | if (!test_and_set_bit(i, &priv->ucode_key_table)) | 728 | if (!test_and_set_bit(i, &priv->ucode_key_table)) |
729 | return i; | 729 | return i; |
730 | 730 | ||
@@ -732,7 +732,9 @@ int iwl_get_free_ucode_key_index(struct iwl_priv *priv) | |||
732 | } | 732 | } |
733 | EXPORT_SYMBOL(iwl_get_free_ucode_key_index); | 733 | EXPORT_SYMBOL(iwl_get_free_ucode_key_index); |
734 | 734 | ||
735 | static int iwl_send_static_wepkey_cmd(struct iwl_priv *priv, u8 send_if_empty) | 735 | static int iwl_send_static_wepkey_cmd(struct iwl_priv *priv, |
736 | struct iwl_rxon_context *ctx, | ||
737 | bool send_if_empty) | ||
736 | { | 738 | { |
737 | int i, not_empty = 0; | 739 | int i, not_empty = 0; |
738 | u8 buff[sizeof(struct iwl_wep_cmd) + | 740 | u8 buff[sizeof(struct iwl_wep_cmd) + |
@@ -740,7 +742,7 @@ static int iwl_send_static_wepkey_cmd(struct iwl_priv *priv, u8 send_if_empty) | |||
740 | struct iwl_wep_cmd *wep_cmd = (struct iwl_wep_cmd *)buff; | 742 | struct iwl_wep_cmd *wep_cmd = (struct iwl_wep_cmd *)buff; |
741 | size_t cmd_size = sizeof(struct iwl_wep_cmd); | 743 | size_t cmd_size = sizeof(struct iwl_wep_cmd); |
742 | struct iwl_host_cmd cmd = { | 744 | struct iwl_host_cmd cmd = { |
743 | .id = REPLY_WEPKEY, | 745 | .id = ctx->wep_key_cmd, |
744 | .data = wep_cmd, | 746 | .data = wep_cmd, |
745 | .flags = CMD_SYNC, | 747 | .flags = CMD_SYNC, |
746 | }; | 748 | }; |
@@ -752,16 +754,16 @@ static int iwl_send_static_wepkey_cmd(struct iwl_priv *priv, u8 send_if_empty) | |||
752 | 754 | ||
753 | for (i = 0; i < WEP_KEYS_MAX ; i++) { | 755 | for (i = 0; i < WEP_KEYS_MAX ; i++) { |
754 | wep_cmd->key[i].key_index = i; | 756 | wep_cmd->key[i].key_index = i; |
755 | if (priv->wep_keys[i].key_size) { | 757 | if (ctx->wep_keys[i].key_size) { |
756 | wep_cmd->key[i].key_offset = i; | 758 | wep_cmd->key[i].key_offset = i; |
757 | not_empty = 1; | 759 | not_empty = 1; |
758 | } else { | 760 | } else { |
759 | wep_cmd->key[i].key_offset = WEP_INVALID_OFFSET; | 761 | wep_cmd->key[i].key_offset = WEP_INVALID_OFFSET; |
760 | } | 762 | } |
761 | 763 | ||
762 | wep_cmd->key[i].key_size = priv->wep_keys[i].key_size; | 764 | wep_cmd->key[i].key_size = ctx->wep_keys[i].key_size; |
763 | memcpy(&wep_cmd->key[i].key[3], priv->wep_keys[i].key, | 765 | memcpy(&wep_cmd->key[i].key[3], ctx->wep_keys[i].key, |
764 | priv->wep_keys[i].key_size); | 766 | ctx->wep_keys[i].key_size); |
765 | } | 767 | } |
766 | 768 | ||
767 | wep_cmd->global_key_type = WEP_KEY_WEP_TYPE; | 769 | wep_cmd->global_key_type = WEP_KEY_WEP_TYPE; |
@@ -777,15 +779,17 @@ static int iwl_send_static_wepkey_cmd(struct iwl_priv *priv, u8 send_if_empty) | |||
777 | return 0; | 779 | return 0; |
778 | } | 780 | } |
779 | 781 | ||
780 | int iwl_restore_default_wep_keys(struct iwl_priv *priv) | 782 | int iwl_restore_default_wep_keys(struct iwl_priv *priv, |
783 | struct iwl_rxon_context *ctx) | ||
781 | { | 784 | { |
782 | lockdep_assert_held(&priv->mutex); | 785 | lockdep_assert_held(&priv->mutex); |
783 | 786 | ||
784 | return iwl_send_static_wepkey_cmd(priv, 0); | 787 | return iwl_send_static_wepkey_cmd(priv, ctx, false); |
785 | } | 788 | } |
786 | EXPORT_SYMBOL(iwl_restore_default_wep_keys); | 789 | EXPORT_SYMBOL(iwl_restore_default_wep_keys); |
787 | 790 | ||
788 | int iwl_remove_default_wep_key(struct iwl_priv *priv, | 791 | int iwl_remove_default_wep_key(struct iwl_priv *priv, |
792 | struct iwl_rxon_context *ctx, | ||
789 | struct ieee80211_key_conf *keyconf) | 793 | struct ieee80211_key_conf *keyconf) |
790 | { | 794 | { |
791 | int ret; | 795 | int ret; |
@@ -795,13 +799,13 @@ int iwl_remove_default_wep_key(struct iwl_priv *priv, | |||
795 | IWL_DEBUG_WEP(priv, "Removing default WEP key: idx=%d\n", | 799 | IWL_DEBUG_WEP(priv, "Removing default WEP key: idx=%d\n", |
796 | keyconf->keyidx); | 800 | keyconf->keyidx); |
797 | 801 | ||
798 | memset(&priv->wep_keys[keyconf->keyidx], 0, sizeof(priv->wep_keys[0])); | 802 | memset(&ctx->wep_keys[keyconf->keyidx], 0, sizeof(ctx->wep_keys[0])); |
799 | if (iwl_is_rfkill(priv)) { | 803 | if (iwl_is_rfkill(priv)) { |
800 | IWL_DEBUG_WEP(priv, "Not sending REPLY_WEPKEY command due to RFKILL.\n"); | 804 | IWL_DEBUG_WEP(priv, "Not sending REPLY_WEPKEY command due to RFKILL.\n"); |
801 | /* but keys in device are clear anyway so return success */ | 805 | /* but keys in device are clear anyway so return success */ |
802 | return 0; | 806 | return 0; |
803 | } | 807 | } |
804 | ret = iwl_send_static_wepkey_cmd(priv, 1); | 808 | ret = iwl_send_static_wepkey_cmd(priv, ctx, 1); |
805 | IWL_DEBUG_WEP(priv, "Remove default WEP key: idx=%d ret=%d\n", | 809 | IWL_DEBUG_WEP(priv, "Remove default WEP key: idx=%d ret=%d\n", |
806 | keyconf->keyidx, ret); | 810 | keyconf->keyidx, ret); |
807 | 811 | ||
@@ -827,11 +831,11 @@ int iwl_set_default_wep_key(struct iwl_priv *priv, | |||
827 | keyconf->hw_key_idx = HW_KEY_DEFAULT; | 831 | keyconf->hw_key_idx = HW_KEY_DEFAULT; |
828 | priv->stations[ctx->ap_sta_id].keyinfo.cipher = keyconf->cipher; | 832 | priv->stations[ctx->ap_sta_id].keyinfo.cipher = keyconf->cipher; |
829 | 833 | ||
830 | priv->wep_keys[keyconf->keyidx].key_size = keyconf->keylen; | 834 | ctx->wep_keys[keyconf->keyidx].key_size = keyconf->keylen; |
831 | memcpy(&priv->wep_keys[keyconf->keyidx].key, &keyconf->key, | 835 | memcpy(&ctx->wep_keys[keyconf->keyidx].key, &keyconf->key, |
832 | keyconf->keylen); | 836 | keyconf->keylen); |
833 | 837 | ||
834 | ret = iwl_send_static_wepkey_cmd(priv, 0); | 838 | ret = iwl_send_static_wepkey_cmd(priv, ctx, false); |
835 | IWL_DEBUG_WEP(priv, "Set default WEP key: len=%d idx=%d ret=%d\n", | 839 | IWL_DEBUG_WEP(priv, "Set default WEP key: len=%d idx=%d ret=%d\n", |
836 | keyconf->keylen, keyconf->keyidx, ret); | 840 | keyconf->keylen, keyconf->keyidx, ret); |
837 | 841 | ||
@@ -1029,8 +1033,9 @@ void iwl_update_tkip_key(struct iwl_priv *priv, | |||
1029 | EXPORT_SYMBOL(iwl_update_tkip_key); | 1033 | EXPORT_SYMBOL(iwl_update_tkip_key); |
1030 | 1034 | ||
1031 | int iwl_remove_dynamic_key(struct iwl_priv *priv, | 1035 | int iwl_remove_dynamic_key(struct iwl_priv *priv, |
1032 | struct ieee80211_key_conf *keyconf, | 1036 | struct iwl_rxon_context *ctx, |
1033 | u8 sta_id) | 1037 | struct ieee80211_key_conf *keyconf, |
1038 | u8 sta_id) | ||
1034 | { | 1039 | { |
1035 | unsigned long flags; | 1040 | unsigned long flags; |
1036 | u16 key_flags; | 1041 | u16 key_flags; |
@@ -1039,7 +1044,7 @@ int iwl_remove_dynamic_key(struct iwl_priv *priv, | |||
1039 | 1044 | ||
1040 | lockdep_assert_held(&priv->mutex); | 1045 | lockdep_assert_held(&priv->mutex); |
1041 | 1046 | ||
1042 | priv->key_mapping_key--; | 1047 | ctx->key_mapping_keys--; |
1043 | 1048 | ||
1044 | spin_lock_irqsave(&priv->sta_lock, flags); | 1049 | spin_lock_irqsave(&priv->sta_lock, flags); |
1045 | key_flags = le16_to_cpu(priv->stations[sta_id].sta.key.key_flags); | 1050 | key_flags = le16_to_cpu(priv->stations[sta_id].sta.key.key_flags); |
@@ -1098,7 +1103,7 @@ int iwl_set_dynamic_key(struct iwl_priv *priv, struct iwl_rxon_context *ctx, | |||
1098 | 1103 | ||
1099 | lockdep_assert_held(&priv->mutex); | 1104 | lockdep_assert_held(&priv->mutex); |
1100 | 1105 | ||
1101 | priv->key_mapping_key++; | 1106 | ctx->key_mapping_keys++; |
1102 | keyconf->hw_key_idx = HW_KEY_DYNAMIC; | 1107 | keyconf->hw_key_idx = HW_KEY_DYNAMIC; |
1103 | 1108 | ||
1104 | switch (keyconf->cipher) { | 1109 | switch (keyconf->cipher) { |