aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00
diff options
context:
space:
mode:
authorIvo van Doorn <ivdoorn@gmail.com>2009-04-26 10:08:30 -0400
committerJohn W. Linville <linville@tuxdriver.com>2009-05-06 15:14:49 -0400
commit9eb4e21e289beba9cfe34f24920eee83c144e62f (patch)
treeab2da2b66f308e94159742b52a126787a8e2d1a5 /drivers/net/wireless/rt2x00
parentbbb33881ae5bfe4197a005dc03b29b7dcc07fa28 (diff)
rt2x00: Move iv_len into tx descriptor data
By placing the iv_len into the tx descriptor data and by passing this data to the crypto IV handlers we can save multiple calls to ieee80211_get_hdrlen_from_skb() and some if-statements when copying/removing the IV data from the outgoing frame. Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/rt2x00')
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00crypto.c19
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00lib.h10
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00queue.c8
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00queue.h2
4 files changed, 19 insertions, 20 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2x00crypto.c b/drivers/net/wireless/rt2x00/rt2x00crypto.c
index 0b41845d9543..ae31581372c0 100644
--- a/drivers/net/wireless/rt2x00/rt2x00crypto.c
+++ b/drivers/net/wireless/rt2x00/rt2x00crypto.c
@@ -66,6 +66,7 @@ void rt2x00crypto_create_tx_descriptor(struct queue_entry *entry,
66 66
67 txdesc->key_idx = hw_key->hw_key_idx; 67 txdesc->key_idx = hw_key->hw_key_idx;
68 txdesc->iv_offset = ieee80211_get_hdrlen_from_skb(entry->skb); 68 txdesc->iv_offset = ieee80211_get_hdrlen_from_skb(entry->skb);
69 txdesc->iv_len = hw_key->iv_len;
69 70
70 if (!(hw_key->flags & IEEE80211_KEY_FLAG_GENERATE_IV)) 71 if (!(hw_key->flags & IEEE80211_KEY_FLAG_GENERATE_IV))
71 __set_bit(ENTRY_TXD_ENCRYPT_IV, &txdesc->flags); 72 __set_bit(ENTRY_TXD_ENCRYPT_IV, &txdesc->flags);
@@ -103,34 +104,32 @@ unsigned int rt2x00crypto_tx_overhead(struct rt2x00_dev *rt2x00dev,
103 return overhead; 104 return overhead;
104} 105}
105 106
106void rt2x00crypto_tx_copy_iv(struct sk_buff *skb, unsigned int iv_len) 107void rt2x00crypto_tx_copy_iv(struct sk_buff *skb, struct txentry_desc *txdesc)
107{ 108{
108 struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb); 109 struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb);
109 unsigned int header_length = ieee80211_get_hdrlen_from_skb(skb);
110 110
111 if (unlikely(!iv_len)) 111 if (unlikely(!txdesc->iv_len))
112 return; 112 return;
113 113
114 /* Copy IV/EIV data */ 114 /* Copy IV/EIV data */
115 memcpy(skbdesc->iv, skb->data + header_length, iv_len); 115 memcpy(skbdesc->iv, skb->data + txdesc->iv_offset, txdesc->iv_len);
116} 116}
117 117
118void rt2x00crypto_tx_remove_iv(struct sk_buff *skb, unsigned int iv_len) 118void rt2x00crypto_tx_remove_iv(struct sk_buff *skb, struct txentry_desc *txdesc)
119{ 119{
120 struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb); 120 struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb);
121 unsigned int header_length = ieee80211_get_hdrlen_from_skb(skb);
122 121
123 if (unlikely(!iv_len)) 122 if (unlikely(!txdesc->iv_len))
124 return; 123 return;
125 124
126 /* Copy IV/EIV data */ 125 /* Copy IV/EIV data */
127 memcpy(skbdesc->iv, skb->data + header_length, iv_len); 126 memcpy(skbdesc->iv, skb->data + txdesc->iv_offset, txdesc->iv_len);
128 127
129 /* Move ieee80211 header */ 128 /* Move ieee80211 header */
130 memmove(skb->data + iv_len, skb->data, header_length); 129 memmove(skb->data + txdesc->iv_len, skb->data, txdesc->iv_offset);
131 130
132 /* Pull buffer to correct size */ 131 /* Pull buffer to correct size */
133 skb_pull(skb, iv_len); 132 skb_pull(skb, txdesc->iv_len);
134 133
135 /* IV/EIV data has officially be stripped */ 134 /* IV/EIV data has officially be stripped */
136 skbdesc->flags |= FRAME_DESC_IV_STRIPPED; 135 skbdesc->flags |= FRAME_DESC_IV_STRIPPED;
diff --git a/drivers/net/wireless/rt2x00/rt2x00lib.h b/drivers/net/wireless/rt2x00/rt2x00lib.h
index a631613177d0..af3c47bd43bd 100644
--- a/drivers/net/wireless/rt2x00/rt2x00lib.h
+++ b/drivers/net/wireless/rt2x00/rt2x00lib.h
@@ -295,8 +295,10 @@ void rt2x00crypto_create_tx_descriptor(struct queue_entry *entry,
295 struct txentry_desc *txdesc); 295 struct txentry_desc *txdesc);
296unsigned int rt2x00crypto_tx_overhead(struct rt2x00_dev *rt2x00dev, 296unsigned int rt2x00crypto_tx_overhead(struct rt2x00_dev *rt2x00dev,
297 struct sk_buff *skb); 297 struct sk_buff *skb);
298void rt2x00crypto_tx_copy_iv(struct sk_buff *skb, unsigned int iv_len); 298void rt2x00crypto_tx_copy_iv(struct sk_buff *skb,
299void rt2x00crypto_tx_remove_iv(struct sk_buff *skb, unsigned int iv_len); 299 struct txentry_desc *txdesc);
300void rt2x00crypto_tx_remove_iv(struct sk_buff *skb,
301 struct txentry_desc *txdesc);
300void rt2x00crypto_tx_insert_iv(struct sk_buff *skb); 302void rt2x00crypto_tx_insert_iv(struct sk_buff *skb);
301void rt2x00crypto_rx_insert_iv(struct sk_buff *skb, unsigned int align, 303void rt2x00crypto_rx_insert_iv(struct sk_buff *skb, unsigned int align,
302 unsigned int header_length, 304 unsigned int header_length,
@@ -319,12 +321,12 @@ static inline unsigned int rt2x00crypto_tx_overhead(struct rt2x00_dev *rt2x00dev
319} 321}
320 322
321static inline void rt2x00crypto_tx_copy_iv(struct sk_buff *skb, 323static inline void rt2x00crypto_tx_copy_iv(struct sk_buff *skb,
322 unsigned int iv_len) 324 struct txentry_desc *txdesc)
323{ 325{
324} 326}
325 327
326static inline void rt2x00crypto_tx_remove_iv(struct sk_buff *skb, 328static inline void rt2x00crypto_tx_remove_iv(struct sk_buff *skb,
327 unsigned int iv_len) 329 struct txentry_desc *txdesc)
328{ 330{
329} 331}
330 332
diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
index a5664bd8493e..6f78915b364c 100644
--- a/drivers/net/wireless/rt2x00/rt2x00queue.c
+++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
@@ -368,7 +368,6 @@ int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb)
368 struct queue_entry *entry = rt2x00queue_get_entry(queue, Q_INDEX); 368 struct queue_entry *entry = rt2x00queue_get_entry(queue, Q_INDEX);
369 struct txentry_desc txdesc; 369 struct txentry_desc txdesc;
370 struct skb_frame_desc *skbdesc; 370 struct skb_frame_desc *skbdesc;
371 unsigned int iv_len = 0;
372 u8 rate_idx, rate_flags; 371 u8 rate_idx, rate_flags;
373 372
374 if (unlikely(rt2x00queue_full(queue))) 373 if (unlikely(rt2x00queue_full(queue)))
@@ -390,9 +389,6 @@ int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb)
390 entry->skb = skb; 389 entry->skb = skb;
391 rt2x00queue_create_tx_descriptor(entry, &txdesc); 390 rt2x00queue_create_tx_descriptor(entry, &txdesc);
392 391
393 if (IEEE80211_SKB_CB(skb)->control.hw_key != NULL)
394 iv_len = IEEE80211_SKB_CB(skb)->control.hw_key->iv_len;
395
396 /* 392 /*
397 * All information is retrieved from the skb->cb array, 393 * All information is retrieved from the skb->cb array,
398 * now we should claim ownership of the driver part of that 394 * now we should claim ownership of the driver part of that
@@ -415,9 +411,9 @@ int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb)
415 if (test_bit(ENTRY_TXD_ENCRYPT, &txdesc.flags) && 411 if (test_bit(ENTRY_TXD_ENCRYPT, &txdesc.flags) &&
416 !test_bit(ENTRY_TXD_ENCRYPT_IV, &txdesc.flags)) { 412 !test_bit(ENTRY_TXD_ENCRYPT_IV, &txdesc.flags)) {
417 if (test_bit(DRIVER_REQUIRE_COPY_IV, &queue->rt2x00dev->flags)) 413 if (test_bit(DRIVER_REQUIRE_COPY_IV, &queue->rt2x00dev->flags))
418 rt2x00crypto_tx_copy_iv(skb, iv_len); 414 rt2x00crypto_tx_copy_iv(skb, &txdesc);
419 else 415 else
420 rt2x00crypto_tx_remove_iv(skb, iv_len); 416 rt2x00crypto_tx_remove_iv(skb, &txdesc);
421 } 417 }
422 418
423 /* 419 /*
diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.h b/drivers/net/wireless/rt2x00/rt2x00queue.h
index 97e2ab08f080..e3bfd73e319b 100644
--- a/drivers/net/wireless/rt2x00/rt2x00queue.h
+++ b/drivers/net/wireless/rt2x00/rt2x00queue.h
@@ -280,6 +280,7 @@ enum txentry_desc_flags {
280 * @cipher: Cipher type used for encryption. 280 * @cipher: Cipher type used for encryption.
281 * @key_idx: Key index used for encryption. 281 * @key_idx: Key index used for encryption.
282 * @iv_offset: Position where IV should be inserted by hardware. 282 * @iv_offset: Position where IV should be inserted by hardware.
283 * @iv_len: Length of IV data.
283 */ 284 */
284struct txentry_desc { 285struct txentry_desc {
285 unsigned long flags; 286 unsigned long flags;
@@ -302,6 +303,7 @@ struct txentry_desc {
302 enum cipher cipher; 303 enum cipher cipher;
303 u16 key_idx; 304 u16 key_idx;
304 u16 iv_offset; 305 u16 iv_offset;
306 u16 iv_len;
305}; 307};
306 308
307/** 309/**