aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEliad Peller <eliad@wizery.com>2016-02-15 05:34:10 -0500
committerJohannes Berg <johannes.berg@intel.com>2016-02-24 03:04:39 -0500
commitca48ebbc7ea7e82e3ae4b55aacead0cdb54ff008 (patch)
treee46cb1aad0ae715f07cfbfc99902245c6425a93e
parent1ad4f639cc3e09d6c8402a0fcc592e2391683e31 (diff)
mac80211: remove ieee80211_get_key_tx_seq/ieee80211_set_key_tx_seq
Since the PNs of all the tx keys are now tracked in the public part of the key struct (with atomic counter), we no longer need these functions. dvm and vt665{5,6} are currently the only users of these functions, so update them accordingly. Signed-off-by: Eliad Peller <eliadx.peller@intel.com> Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
-rw-r--r--drivers/net/wireless/intel/iwlwifi/dvm/lib.c20
-rw-r--r--drivers/staging/vt6655/rxtx.c12
-rw-r--r--drivers/staging/vt6656/rxtx.c12
-rw-r--r--include/net/mac80211.h34
-rw-r--r--net/mac80211/key.c87
5 files changed, 24 insertions, 141 deletions
diff --git a/drivers/net/wireless/intel/iwlwifi/dvm/lib.c b/drivers/net/wireless/intel/iwlwifi/dvm/lib.c
index 4841be2aa499..1799469268ea 100644
--- a/drivers/net/wireless/intel/iwlwifi/dvm/lib.c
+++ b/drivers/net/wireless/intel/iwlwifi/dvm/lib.c
@@ -943,14 +943,16 @@ static void iwlagn_wowlan_program_keys(struct ieee80211_hw *hw,
943 switch (key->cipher) { 943 switch (key->cipher) {
944 case WLAN_CIPHER_SUITE_TKIP: 944 case WLAN_CIPHER_SUITE_TKIP:
945 if (sta) { 945 if (sta) {
946 u64 pn64;
947
946 tkip_sc = data->rsc_tsc->all_tsc_rsc.tkip.unicast_rsc; 948 tkip_sc = data->rsc_tsc->all_tsc_rsc.tkip.unicast_rsc;
947 tkip_tx_sc = &data->rsc_tsc->all_tsc_rsc.tkip.tsc; 949 tkip_tx_sc = &data->rsc_tsc->all_tsc_rsc.tkip.tsc;
948 950
949 rx_p1ks = data->tkip->rx_uni; 951 rx_p1ks = data->tkip->rx_uni;
950 952
951 ieee80211_get_key_tx_seq(key, &seq); 953 pn64 = atomic64_read(&key->tx_pn);
952 tkip_tx_sc->iv16 = cpu_to_le16(seq.tkip.iv16); 954 tkip_tx_sc->iv16 = cpu_to_le16(TKIP_PN_TO_IV16(pn64));
953 tkip_tx_sc->iv32 = cpu_to_le32(seq.tkip.iv32); 955 tkip_tx_sc->iv32 = cpu_to_le32(TKIP_PN_TO_IV32(pn64));
954 956
955 ieee80211_get_tkip_p1k_iv(key, seq.tkip.iv32, p1k); 957 ieee80211_get_tkip_p1k_iv(key, seq.tkip.iv32, p1k);
956 iwlagn_convert_p1k(p1k, data->tkip->tx.p1k); 958 iwlagn_convert_p1k(p1k, data->tkip->tx.p1k);
@@ -996,19 +998,13 @@ static void iwlagn_wowlan_program_keys(struct ieee80211_hw *hw,
996 break; 998 break;
997 case WLAN_CIPHER_SUITE_CCMP: 999 case WLAN_CIPHER_SUITE_CCMP:
998 if (sta) { 1000 if (sta) {
999 u8 *pn = seq.ccmp.pn; 1001 u64 pn64;
1000 1002
1001 aes_sc = data->rsc_tsc->all_tsc_rsc.aes.unicast_rsc; 1003 aes_sc = data->rsc_tsc->all_tsc_rsc.aes.unicast_rsc;
1002 aes_tx_sc = &data->rsc_tsc->all_tsc_rsc.aes.tsc; 1004 aes_tx_sc = &data->rsc_tsc->all_tsc_rsc.aes.tsc;
1003 1005
1004 ieee80211_get_key_tx_seq(key, &seq); 1006 pn64 = atomic64_read(&key->tx_pn);
1005 aes_tx_sc->pn = cpu_to_le64( 1007 aes_tx_sc->pn = cpu_to_le64(pn64);
1006 (u64)pn[5] |
1007 ((u64)pn[4] << 8) |
1008 ((u64)pn[3] << 16) |
1009 ((u64)pn[2] << 24) |
1010 ((u64)pn[1] << 32) |
1011 ((u64)pn[0] << 40));
1012 } else 1008 } else
1013 aes_sc = data->rsc_tsc->all_tsc_rsc.aes.multicast_rsc; 1009 aes_sc = data->rsc_tsc->all_tsc_rsc.aes.multicast_rsc;
1014 1010
diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c
index b668db6a45fb..1a2dda09b69d 100644
--- a/drivers/staging/vt6655/rxtx.c
+++ b/drivers/staging/vt6655/rxtx.c
@@ -1210,7 +1210,7 @@ static void vnt_fill_txkey(struct ieee80211_hdr *hdr, u8 *key_buffer,
1210 struct sk_buff *skb, u16 payload_len, 1210 struct sk_buff *skb, u16 payload_len,
1211 struct vnt_mic_hdr *mic_hdr) 1211 struct vnt_mic_hdr *mic_hdr)
1212{ 1212{
1213 struct ieee80211_key_seq seq; 1213 u64 pn64;
1214 u8 *iv = ((u8 *)hdr + ieee80211_get_hdrlen_from_skb(skb)); 1214 u8 *iv = ((u8 *)hdr + ieee80211_get_hdrlen_from_skb(skb));
1215 1215
1216 /* strip header and icv len from payload */ 1216 /* strip header and icv len from payload */
@@ -1243,9 +1243,13 @@ static void vnt_fill_txkey(struct ieee80211_hdr *hdr, u8 *key_buffer,
1243 mic_hdr->payload_len = cpu_to_be16(payload_len); 1243 mic_hdr->payload_len = cpu_to_be16(payload_len);
1244 ether_addr_copy(mic_hdr->mic_addr2, hdr->addr2); 1244 ether_addr_copy(mic_hdr->mic_addr2, hdr->addr2);
1245 1245
1246 ieee80211_get_key_tx_seq(tx_key, &seq); 1246 pn64 = atomic64_read(&tx_key->tx_pn);
1247 1247 mic_hdr->ccmp_pn[5] = pn64;
1248 memcpy(mic_hdr->ccmp_pn, seq.ccmp.pn, IEEE80211_CCMP_PN_LEN); 1248 mic_hdr->ccmp_pn[4] = pn64 >> 8;
1249 mic_hdr->ccmp_pn[3] = pn64 >> 16;
1250 mic_hdr->ccmp_pn[2] = pn64 >> 24;
1251 mic_hdr->ccmp_pn[1] = pn64 >> 32;
1252 mic_hdr->ccmp_pn[0] = pn64 >> 40;
1249 1253
1250 if (ieee80211_has_a4(hdr->frame_control)) 1254 if (ieee80211_has_a4(hdr->frame_control))
1251 mic_hdr->hlen = cpu_to_be16(28); 1255 mic_hdr->hlen = cpu_to_be16(28);
diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index efb54f53b4f9..76378d225b46 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -719,7 +719,7 @@ static void vnt_fill_txkey(struct vnt_usb_send_context *tx_context,
719 u16 payload_len, struct vnt_mic_hdr *mic_hdr) 719 u16 payload_len, struct vnt_mic_hdr *mic_hdr)
720{ 720{
721 struct ieee80211_hdr *hdr = tx_context->hdr; 721 struct ieee80211_hdr *hdr = tx_context->hdr;
722 struct ieee80211_key_seq seq; 722 u64 pn64;
723 u8 *iv = ((u8 *)hdr + ieee80211_get_hdrlen_from_skb(skb)); 723 u8 *iv = ((u8 *)hdr + ieee80211_get_hdrlen_from_skb(skb));
724 724
725 /* strip header and icv len from payload */ 725 /* strip header and icv len from payload */
@@ -752,9 +752,13 @@ static void vnt_fill_txkey(struct vnt_usb_send_context *tx_context,
752 mic_hdr->payload_len = cpu_to_be16(payload_len); 752 mic_hdr->payload_len = cpu_to_be16(payload_len);
753 ether_addr_copy(mic_hdr->mic_addr2, hdr->addr2); 753 ether_addr_copy(mic_hdr->mic_addr2, hdr->addr2);
754 754
755 ieee80211_get_key_tx_seq(tx_key, &seq); 755 pn64 = atomic64_read(&tx_key->tx_pn);
756 756 mic_hdr->ccmp_pn[5] = pn64;
757 memcpy(mic_hdr->ccmp_pn, seq.ccmp.pn, IEEE80211_CCMP_PN_LEN); 757 mic_hdr->ccmp_pn[4] = pn64 >> 8;
758 mic_hdr->ccmp_pn[3] = pn64 >> 16;
759 mic_hdr->ccmp_pn[2] = pn64 >> 24;
760 mic_hdr->ccmp_pn[1] = pn64 >> 32;
761 mic_hdr->ccmp_pn[0] = pn64 >> 40;
758 762
759 if (ieee80211_has_a4(hdr->frame_control)) 763 if (ieee80211_has_a4(hdr->frame_control))
760 mic_hdr->hlen = cpu_to_be16(28); 764 mic_hdr->hlen = cpu_to_be16(28);
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 15879b49baad..66155d3ad7e6 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -4464,23 +4464,6 @@ void ieee80211_get_tkip_p2k(struct ieee80211_key_conf *keyconf,
4464u8 *ieee80211_tkip_add_iv(u8 *pos, struct ieee80211_key_conf *keyconf, u64 pn); 4464u8 *ieee80211_tkip_add_iv(u8 *pos, struct ieee80211_key_conf *keyconf, u64 pn);
4465 4465
4466/** 4466/**
4467 * ieee80211_get_key_tx_seq - get key TX sequence counter
4468 *
4469 * @keyconf: the parameter passed with the set key
4470 * @seq: buffer to receive the sequence data
4471 *
4472 * This function allows a driver to retrieve the current TX IV/PN
4473 * for the given key. It must not be called if IV generation is
4474 * offloaded to the device.
4475 *
4476 * Note that this function may only be called when no TX processing
4477 * can be done concurrently, for example when queues are stopped
4478 * and the stop has been synchronized.
4479 */
4480void ieee80211_get_key_tx_seq(struct ieee80211_key_conf *keyconf,
4481 struct ieee80211_key_seq *seq);
4482
4483/**
4484 * ieee80211_get_key_rx_seq - get key RX sequence counter 4467 * ieee80211_get_key_rx_seq - get key RX sequence counter
4485 * 4468 *
4486 * @keyconf: the parameter passed with the set key 4469 * @keyconf: the parameter passed with the set key
@@ -4500,23 +4483,6 @@ void ieee80211_get_key_rx_seq(struct ieee80211_key_conf *keyconf,
4500 int tid, struct ieee80211_key_seq *seq); 4483 int tid, struct ieee80211_key_seq *seq);
4501 4484
4502/** 4485/**
4503 * ieee80211_set_key_tx_seq - set key TX sequence counter
4504 *
4505 * @keyconf: the parameter passed with the set key
4506 * @seq: new sequence data
4507 *
4508 * This function allows a driver to set the current TX IV/PNs for the
4509 * given key. This is useful when resuming from WoWLAN sleep and the
4510 * device may have transmitted frames using the PTK, e.g. replies to
4511 * ARP requests.
4512 *
4513 * Note that this function may only be called when no TX processing
4514 * can be done concurrently.
4515 */
4516void ieee80211_set_key_tx_seq(struct ieee80211_key_conf *keyconf,
4517 struct ieee80211_key_seq *seq);
4518
4519/**
4520 * ieee80211_set_key_rx_seq - set key RX sequence counter 4486 * ieee80211_set_key_rx_seq - set key RX sequence counter
4521 * 4487 *
4522 * @keyconf: the parameter passed with the set key 4488 * @keyconf: the parameter passed with the set key
diff --git a/net/mac80211/key.c b/net/mac80211/key.c
index f9c4cb9c6e06..3df7b0392d30 100644
--- a/net/mac80211/key.c
+++ b/net/mac80211/key.c
@@ -932,51 +932,6 @@ void ieee80211_gtk_rekey_notify(struct ieee80211_vif *vif, const u8 *bssid,
932} 932}
933EXPORT_SYMBOL_GPL(ieee80211_gtk_rekey_notify); 933EXPORT_SYMBOL_GPL(ieee80211_gtk_rekey_notify);
934 934
935void ieee80211_get_key_tx_seq(struct ieee80211_key_conf *keyconf,
936 struct ieee80211_key_seq *seq)
937{
938 struct ieee80211_key *key;
939 u64 pn64;
940
941 if (WARN_ON(!(keyconf->flags & IEEE80211_KEY_FLAG_GENERATE_IV)))
942 return;
943
944 key = container_of(keyconf, struct ieee80211_key, conf);
945
946 switch (key->conf.cipher) {
947 case WLAN_CIPHER_SUITE_TKIP:
948 pn64 = atomic64_read(&key->conf.tx_pn);
949 seq->tkip.iv32 = TKIP_PN_TO_IV32(pn64);
950 seq->tkip.iv16 = TKIP_PN_TO_IV16(pn64);
951 break;
952 case WLAN_CIPHER_SUITE_CCMP:
953 case WLAN_CIPHER_SUITE_CCMP_256:
954 case WLAN_CIPHER_SUITE_AES_CMAC:
955 case WLAN_CIPHER_SUITE_BIP_CMAC_256:
956 BUILD_BUG_ON(offsetof(typeof(*seq), ccmp) !=
957 offsetof(typeof(*seq), aes_cmac));
958 case WLAN_CIPHER_SUITE_BIP_GMAC_128:
959 case WLAN_CIPHER_SUITE_BIP_GMAC_256:
960 BUILD_BUG_ON(offsetof(typeof(*seq), ccmp) !=
961 offsetof(typeof(*seq), aes_gmac));
962 case WLAN_CIPHER_SUITE_GCMP:
963 case WLAN_CIPHER_SUITE_GCMP_256:
964 BUILD_BUG_ON(offsetof(typeof(*seq), ccmp) !=
965 offsetof(typeof(*seq), gcmp));
966 pn64 = atomic64_read(&key->conf.tx_pn);
967 seq->ccmp.pn[5] = pn64;
968 seq->ccmp.pn[4] = pn64 >> 8;
969 seq->ccmp.pn[3] = pn64 >> 16;
970 seq->ccmp.pn[2] = pn64 >> 24;
971 seq->ccmp.pn[1] = pn64 >> 32;
972 seq->ccmp.pn[0] = pn64 >> 40;
973 break;
974 default:
975 WARN_ON(1);
976 }
977}
978EXPORT_SYMBOL(ieee80211_get_key_tx_seq);
979
980void ieee80211_get_key_rx_seq(struct ieee80211_key_conf *keyconf, 935void ieee80211_get_key_rx_seq(struct ieee80211_key_conf *keyconf,
981 int tid, struct ieee80211_key_seq *seq) 936 int tid, struct ieee80211_key_seq *seq)
982{ 937{
@@ -1030,48 +985,6 @@ void ieee80211_get_key_rx_seq(struct ieee80211_key_conf *keyconf,
1030} 985}
1031EXPORT_SYMBOL(ieee80211_get_key_rx_seq); 986EXPORT_SYMBOL(ieee80211_get_key_rx_seq);
1032 987
1033void ieee80211_set_key_tx_seq(struct ieee80211_key_conf *keyconf,
1034 struct ieee80211_key_seq *seq)
1035{
1036 struct ieee80211_key *key;
1037 u64 pn64;
1038
1039 key = container_of(keyconf, struct ieee80211_key, conf);
1040
1041 switch (key->conf.cipher) {
1042 case WLAN_CIPHER_SUITE_TKIP:
1043 pn64 = (u64)seq->tkip.iv16 | ((u64)seq->tkip.iv32 << 16);
1044 atomic64_set(&key->conf.tx_pn, pn64);
1045 break;
1046 case WLAN_CIPHER_SUITE_CCMP:
1047 case WLAN_CIPHER_SUITE_CCMP_256:
1048 case WLAN_CIPHER_SUITE_AES_CMAC:
1049 case WLAN_CIPHER_SUITE_BIP_CMAC_256:
1050 BUILD_BUG_ON(offsetof(typeof(*seq), ccmp) !=
1051 offsetof(typeof(*seq), aes_cmac));
1052 case WLAN_CIPHER_SUITE_BIP_GMAC_128:
1053 case WLAN_CIPHER_SUITE_BIP_GMAC_256:
1054 BUILD_BUG_ON(offsetof(typeof(*seq), ccmp) !=
1055 offsetof(typeof(*seq), aes_gmac));
1056 case WLAN_CIPHER_SUITE_GCMP:
1057 case WLAN_CIPHER_SUITE_GCMP_256:
1058 BUILD_BUG_ON(offsetof(typeof(*seq), ccmp) !=
1059 offsetof(typeof(*seq), gcmp));
1060 pn64 = (u64)seq->ccmp.pn[5] |
1061 ((u64)seq->ccmp.pn[4] << 8) |
1062 ((u64)seq->ccmp.pn[3] << 16) |
1063 ((u64)seq->ccmp.pn[2] << 24) |
1064 ((u64)seq->ccmp.pn[1] << 32) |
1065 ((u64)seq->ccmp.pn[0] << 40);
1066 atomic64_set(&key->conf.tx_pn, pn64);
1067 break;
1068 default:
1069 WARN_ON(1);
1070 break;
1071 }
1072}
1073EXPORT_SYMBOL_GPL(ieee80211_set_key_tx_seq);
1074
1075void ieee80211_set_key_rx_seq(struct ieee80211_key_conf *keyconf, 988void ieee80211_set_key_rx_seq(struct ieee80211_key_conf *keyconf,
1076 int tid, struct ieee80211_key_seq *seq) 989 int tid, struct ieee80211_key_seq *seq)
1077{ 990{