Skip to content

Commit ca48ebb

Browse files
elpjmberg-intel
authored andcommitted
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 <[email protected]> Signed-off-by: Emmanuel Grumbach <[email protected]> Signed-off-by: Johannes Berg <[email protected]>
1 parent 1ad4f63 commit ca48ebb

File tree

5 files changed

+24
-141
lines changed

5 files changed

+24
-141
lines changed

drivers/net/wireless/intel/iwlwifi/dvm/lib.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -943,14 +943,16 @@ static void iwlagn_wowlan_program_keys(struct ieee80211_hw *hw,
943943
switch (key->cipher) {
944944
case WLAN_CIPHER_SUITE_TKIP:
945945
if (sta) {
946+
u64 pn64;
947+
946948
tkip_sc = data->rsc_tsc->all_tsc_rsc.tkip.unicast_rsc;
947949
tkip_tx_sc = &data->rsc_tsc->all_tsc_rsc.tkip.tsc;
948950

949951
rx_p1ks = data->tkip->rx_uni;
950952

951-
ieee80211_get_key_tx_seq(key, &seq);
952-
tkip_tx_sc->iv16 = cpu_to_le16(seq.tkip.iv16);
953-
tkip_tx_sc->iv32 = cpu_to_le32(seq.tkip.iv32);
953+
pn64 = atomic64_read(&key->tx_pn);
954+
tkip_tx_sc->iv16 = cpu_to_le16(TKIP_PN_TO_IV16(pn64));
955+
tkip_tx_sc->iv32 = cpu_to_le32(TKIP_PN_TO_IV32(pn64));
954956

955957
ieee80211_get_tkip_p1k_iv(key, seq.tkip.iv32, p1k);
956958
iwlagn_convert_p1k(p1k, data->tkip->tx.p1k);
@@ -996,19 +998,13 @@ static void iwlagn_wowlan_program_keys(struct ieee80211_hw *hw,
996998
break;
997999
case WLAN_CIPHER_SUITE_CCMP:
9981000
if (sta) {
999-
u8 *pn = seq.ccmp.pn;
1001+
u64 pn64;
10001002

10011003
aes_sc = data->rsc_tsc->all_tsc_rsc.aes.unicast_rsc;
10021004
aes_tx_sc = &data->rsc_tsc->all_tsc_rsc.aes.tsc;
10031005

1004-
ieee80211_get_key_tx_seq(key, &seq);
1005-
aes_tx_sc->pn = cpu_to_le64(
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));
1006+
pn64 = atomic64_read(&key->tx_pn);
1007+
aes_tx_sc->pn = cpu_to_le64(pn64);
10121008
} else
10131009
aes_sc = data->rsc_tsc->all_tsc_rsc.aes.multicast_rsc;
10141010

drivers/staging/vt6655/rxtx.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,7 +1210,7 @@ static void vnt_fill_txkey(struct ieee80211_hdr *hdr, u8 *key_buffer,
12101210
struct sk_buff *skb, u16 payload_len,
12111211
struct vnt_mic_hdr *mic_hdr)
12121212
{
1213-
struct ieee80211_key_seq seq;
1213+
u64 pn64;
12141214
u8 *iv = ((u8 *)hdr + ieee80211_get_hdrlen_from_skb(skb));
12151215

12161216
/* strip header and icv len from payload */
@@ -1243,9 +1243,13 @@ static void vnt_fill_txkey(struct ieee80211_hdr *hdr, u8 *key_buffer,
12431243
mic_hdr->payload_len = cpu_to_be16(payload_len);
12441244
ether_addr_copy(mic_hdr->mic_addr2, hdr->addr2);
12451245

1246-
ieee80211_get_key_tx_seq(tx_key, &seq);
1247-
1248-
memcpy(mic_hdr->ccmp_pn, seq.ccmp.pn, IEEE80211_CCMP_PN_LEN);
1246+
pn64 = atomic64_read(&tx_key->tx_pn);
1247+
mic_hdr->ccmp_pn[5] = pn64;
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;
12491253

12501254
if (ieee80211_has_a4(hdr->frame_control))
12511255
mic_hdr->hlen = cpu_to_be16(28);

drivers/staging/vt6656/rxtx.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ static void vnt_fill_txkey(struct vnt_usb_send_context *tx_context,
719719
u16 payload_len, struct vnt_mic_hdr *mic_hdr)
720720
{
721721
struct ieee80211_hdr *hdr = tx_context->hdr;
722-
struct ieee80211_key_seq seq;
722+
u64 pn64;
723723
u8 *iv = ((u8 *)hdr + ieee80211_get_hdrlen_from_skb(skb));
724724

725725
/* strip header and icv len from payload */
@@ -752,9 +752,13 @@ static void vnt_fill_txkey(struct vnt_usb_send_context *tx_context,
752752
mic_hdr->payload_len = cpu_to_be16(payload_len);
753753
ether_addr_copy(mic_hdr->mic_addr2, hdr->addr2);
754754

755-
ieee80211_get_key_tx_seq(tx_key, &seq);
756-
757-
memcpy(mic_hdr->ccmp_pn, seq.ccmp.pn, IEEE80211_CCMP_PN_LEN);
755+
pn64 = atomic64_read(&tx_key->tx_pn);
756+
mic_hdr->ccmp_pn[5] = pn64;
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;
758762

759763
if (ieee80211_has_a4(hdr->frame_control))
760764
mic_hdr->hlen = cpu_to_be16(28);

include/net/mac80211.h

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4463,23 +4463,6 @@ void ieee80211_get_tkip_p2k(struct ieee80211_key_conf *keyconf,
44634463
*/
44644464
u8 *ieee80211_tkip_add_iv(u8 *pos, struct ieee80211_key_conf *keyconf, u64 pn);
44654465

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-
*/
4480-
void ieee80211_get_key_tx_seq(struct ieee80211_key_conf *keyconf,
4481-
struct ieee80211_key_seq *seq);
4482-
44834466
/**
44844467
* ieee80211_get_key_rx_seq - get key RX sequence counter
44854468
*
@@ -4499,23 +4482,6 @@ void ieee80211_get_key_tx_seq(struct ieee80211_key_conf *keyconf,
44994482
void ieee80211_get_key_rx_seq(struct ieee80211_key_conf *keyconf,
45004483
int tid, struct ieee80211_key_seq *seq);
45014484

4502-
/**
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-
*/
4516-
void ieee80211_set_key_tx_seq(struct ieee80211_key_conf *keyconf,
4517-
struct ieee80211_key_seq *seq);
4518-
45194485
/**
45204486
* ieee80211_set_key_rx_seq - set key RX sequence counter
45214487
*

net/mac80211/key.c

Lines changed: 0 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -932,51 +932,6 @@ void ieee80211_gtk_rekey_notify(struct ieee80211_vif *vif, const u8 *bssid,
932932
}
933933
EXPORT_SYMBOL_GPL(ieee80211_gtk_rekey_notify);
934934

935-
void 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-
}
978-
EXPORT_SYMBOL(ieee80211_get_key_tx_seq);
979-
980935
void ieee80211_get_key_rx_seq(struct ieee80211_key_conf *keyconf,
981936
int tid, struct ieee80211_key_seq *seq)
982937
{
@@ -1030,48 +985,6 @@ void ieee80211_get_key_rx_seq(struct ieee80211_key_conf *keyconf,
1030985
}
1031986
EXPORT_SYMBOL(ieee80211_get_key_rx_seq);
1032987

1033-
void 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-
}
1073-
EXPORT_SYMBOL_GPL(ieee80211_set_key_tx_seq);
1074-
1075988
void ieee80211_set_key_rx_seq(struct ieee80211_key_conf *keyconf,
1076989
int tid, struct ieee80211_key_seq *seq)
1077990
{

0 commit comments

Comments
 (0)