Skip to content

Commit 76708de

Browse files
Felix Fietkaulinvjw
authored andcommitted
mac80211: free up 2 bytes in skb->cb
Free up 2 bytes in skb->cb to be used for multi-rate retry later. Move iv_len and icv_len initialization into key alloc. Signed-off-by: Felix Fietkau <nbd@openwrt.org> Signed-off-by: John W. Linville <linville@tuxdriver.com>
1 parent 417bd25 commit 76708de

File tree

10 files changed

+29
-21
lines changed

10 files changed

+29
-21
lines changed

drivers/net/wireless/ath5k/base.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1188,7 +1188,7 @@ ath5k_txbuf_setup(struct ath5k_softc *sc, struct ath5k_buf *bf)
11881188

11891189
if (info->control.hw_key) {
11901190
keyidx = info->control.hw_key->hw_key_idx;
1191-
pktlen += info->control.icv_len;
1191+
pktlen += info->control.hw_key->icv_len;
11921192
}
11931193
ret = ah->ah_setup_tx_desc(ah, ds, pktlen,
11941194
ieee80211_get_hdrlen_from_skb(skb), AR5K_PKT_TYPE_NORMAL,

drivers/net/wireless/ath9k/xmit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ static int ath_tx_prepare(struct ath_softc *sc,
237237

238238
if (tx_info->control.hw_key) {
239239
txctl->keyix = tx_info->control.hw_key->hw_key_idx;
240-
txctl->frmlen += tx_info->control.icv_len;
240+
txctl->frmlen += tx_info->control.hw_key->icv_len;
241241

242242
if (tx_info->control.hw_key->alg == ALG_WEP)
243243
txctl->keytype = ATH9K_KEY_TYPE_WEP;

drivers/net/wireless/b43/xmit.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,15 +252,15 @@ int b43_generate_txhdr(struct b43_wldev *dev,
252252
}
253253

254254
/* Hardware appends ICV. */
255-
plcp_fragment_len += info->control.icv_len;
255+
plcp_fragment_len += info->control.hw_key->icv_len;
256256

257257
key_idx = b43_kidx_to_fw(dev, key_idx);
258258
mac_ctl |= (key_idx << B43_TXH_MAC_KEYIDX_SHIFT) &
259259
B43_TXH_MAC_KEYIDX;
260260
mac_ctl |= (key->algorithm << B43_TXH_MAC_KEYALG_SHIFT) &
261261
B43_TXH_MAC_KEYALG;
262262
wlhdr_len = ieee80211_hdrlen(fctl);
263-
iv_len = min((size_t) info->control.iv_len,
263+
iv_len = min((size_t) info->control.hw_key->iv_len,
264264
ARRAY_SIZE(txhdr->iv));
265265
memcpy(txhdr->iv, ((u8 *) wlhdr) + wlhdr_len, iv_len);
266266
}

drivers/net/wireless/b43legacy/xmit.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ static int generate_txhdr_fw3(struct b43legacy_wldev *dev,
243243

244244
if (key->enabled) {
245245
/* Hardware appends ICV. */
246-
plcp_fragment_len += info->control.icv_len;
246+
plcp_fragment_len += info->control.hw_key->icv_len;
247247

248248
key_idx = b43legacy_kidx_to_fw(dev, key_idx);
249249
mac_ctl |= (key_idx << B43legacy_TX4_MAC_KEYIDX_SHIFT) &
@@ -252,7 +252,7 @@ static int generate_txhdr_fw3(struct b43legacy_wldev *dev,
252252
B43legacy_TX4_MAC_KEYALG_SHIFT) &
253253
B43legacy_TX4_MAC_KEYALG;
254254
wlhdr_len = ieee80211_hdrlen(wlhdr->frame_control);
255-
iv_len = min((size_t)info->control.iv_len,
255+
iv_len = min((size_t)info->control.hw_key->iv_len,
256256
ARRAY_SIZE(txhdr->iv));
257257
memcpy(txhdr->iv, ((u8 *)wlhdr) + wlhdr_len, iv_len);
258258
} else {

drivers/net/wireless/rt2x00/rt2x00crypto.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ unsigned int rt2x00crypto_tx_overhead(struct ieee80211_tx_info *tx_info)
5656
* note that these lengths should only be added when
5757
* mac80211 does not generate it.
5858
*/
59-
overhead += tx_info->control.icv_len;
59+
overhead += key->icv_len;
6060

6161
if (!(key->flags & IEEE80211_KEY_FLAG_GENERATE_IV))
62-
overhead += tx_info->control.iv_len;
62+
overhead += key->iv_len;
6363

6464
if (!(key->flags & IEEE80211_KEY_FLAG_GENERATE_MMIC)) {
6565
if (key->alg == ALG_TKIP)

drivers/net/wireless/rt2x00/rt2x00queue.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb)
374374
struct queue_entry *entry = rt2x00queue_get_entry(queue, Q_INDEX);
375375
struct txentry_desc txdesc;
376376
struct skb_frame_desc *skbdesc;
377-
unsigned int iv_len = IEEE80211_SKB_CB(skb)->control.iv_len;
377+
unsigned int iv_len;
378378

379379
if (unlikely(rt2x00queue_full(queue)))
380380
return -EINVAL;
@@ -410,8 +410,11 @@ int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb)
410410
* the frame so we can provide it to the driver seperately.
411411
*/
412412
if (test_bit(ENTRY_TXD_ENCRYPT, &txdesc.flags) &&
413-
!test_bit(ENTRY_TXD_ENCRYPT_IV, &txdesc.flags))
413+
!test_bit(ENTRY_TXD_ENCRYPT_IV, &txdesc.flags) &&
414+
(IEEE80211_SKB_CB(skb)->control.hw_key != NULL)) {
415+
iv_len = IEEE80211_SKB_CB(skb)->control.hw_key->iv_len;
414416
rt2x00crypto_tx_remove_iv(skb, iv_len);
417+
}
415418

416419
/*
417420
* It could be possible that the queue was corrupted and this

include/net/mac80211.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,6 @@ struct ieee80211_tx_info {
337337
unsigned long jiffies;
338338
s8 rts_cts_rate_idx, alt_retry_rate_idx;
339339
u8 retry_limit;
340-
u8 icv_len;
341-
u8 iv_len;
342340
} control;
343341
struct {
344342
u64 ampdu_ack_map;
@@ -635,6 +633,8 @@ enum ieee80211_key_flags {
635633
*/
636634
struct ieee80211_key_conf {
637635
enum ieee80211_key_alg alg;
636+
u8 icv_len;
637+
u8 iv_len;
638638
u8 hw_key_idx;
639639
u8 flags;
640640
s8 keyidx;

net/mac80211/key.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,20 @@ struct ieee80211_key *ieee80211_key_alloc(enum ieee80211_key_alg alg,
281281
key->conf.alg = alg;
282282
key->conf.keyidx = idx;
283283
key->conf.keylen = key_len;
284+
switch (alg) {
285+
case ALG_WEP:
286+
key->conf.iv_len = WEP_IV_LEN;
287+
key->conf.icv_len = WEP_ICV_LEN;
288+
break;
289+
case ALG_TKIP:
290+
key->conf.iv_len = TKIP_IV_LEN;
291+
key->conf.icv_len = TKIP_ICV_LEN;
292+
break;
293+
case ALG_CCMP:
294+
key->conf.iv_len = CCMP_HDR_LEN;
295+
key->conf.icv_len = CCMP_MIC_LEN;
296+
break;
297+
}
284298
memcpy(key->conf.key, key_data, key_len);
285299
INIT_LIST_HEAD(&key->list);
286300
INIT_LIST_HEAD(&key->todo);

net/mac80211/wep.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,6 @@ static int wep_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb)
313313
{
314314
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
315315

316-
info->control.iv_len = WEP_IV_LEN;
317-
info->control.icv_len = WEP_ICV_LEN;
318-
319316
if (!(tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) {
320317
if (ieee80211_wep_encrypt(tx->local, skb, tx->key))
321318
return -1;

net/mac80211/wpa.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,6 @@ static int tkip_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb)
152152
int len, tail;
153153
u8 *pos;
154154

155-
info->control.icv_len = TKIP_ICV_LEN;
156-
info->control.iv_len = TKIP_IV_LEN;
157-
158155
if ((tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) &&
159156
!(tx->key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)) {
160157
/* hwaccel - with no need for preallocated room for IV/ICV */
@@ -374,9 +371,6 @@ static int ccmp_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb)
374371
u8 *pos, *pn;
375372
int i;
376373

377-
info->control.icv_len = CCMP_MIC_LEN;
378-
info->control.iv_len = CCMP_HDR_LEN;
379-
380374
if ((tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) &&
381375
!(tx->key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)) {
382376
/* hwaccel - with no need for preallocated room for CCMP "

0 commit comments

Comments
 (0)