]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - net/mac80211/wpa.c
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[mv-sheeva.git] / net / mac80211 / wpa.c
index 5332014cb22915c20a1f3015ea80f2bb59077833..0adbcc941ac917952d9eb7ed9308e23c4644c720 100644 (file)
@@ -9,10 +9,10 @@
 
 #include <linux/netdevice.h>
 #include <linux/types.h>
-#include <linux/slab.h>
 #include <linux/skbuff.h>
 #include <linux/compiler.h>
 #include <linux/ieee80211.h>
+#include <linux/gfp.h>
 #include <asm/unaligned.h>
 #include <net/mac80211.h>
 
@@ -31,8 +31,8 @@ ieee80211_tx_h_michael_mic_add(struct ieee80211_tx_data *tx)
        unsigned int hdrlen;
        struct ieee80211_hdr *hdr;
        struct sk_buff *skb = tx->skb;
+       struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
        int authenticator;
-       int wpa_test = 0;
        int tail;
 
        hdr = (struct ieee80211_hdr *)skb->data;
@@ -47,16 +47,15 @@ ieee80211_tx_h_michael_mic_add(struct ieee80211_tx_data *tx)
        data = skb->data + hdrlen;
        data_len = skb->len - hdrlen;
 
-       if ((tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) &&
+       if (info->control.hw_key &&
            !(tx->flags & IEEE80211_TX_FRAGMENTED) &&
-           !(tx->key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC) &&
-           !wpa_test) {
-               /* hwaccel - with no need for preallocated room for MMIC */
+           !(tx->key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC)) {
+               /* hwaccel - with no need for SW-generated MMIC */
                return TX_CONTINUE;
        }
 
        tail = MICHAEL_MIC_LEN;
-       if (!(tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE))
+       if (!info->control.hw_key)
                tail += TKIP_ICV_LEN;
 
        if (WARN_ON(skb_tailroom(skb) < tail ||
@@ -147,17 +146,16 @@ static int tkip_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb)
        int len, tail;
        u8 *pos;
 
-       if ((tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) &&
-           !(tx->key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)) {
-               /* hwaccel - with no need for preallocated room for IV/ICV */
-               info->control.hw_key = &tx->key->conf;
+       if (info->control.hw_key &&
+           !(info->control.hw_key->flags & IEEE80211_KEY_FLAG_GENERATE_IV)) {
+               /* hwaccel - with no need for software-generated IV */
                return 0;
        }
 
        hdrlen = ieee80211_hdrlen(hdr->frame_control);
        len = skb->len - hdrlen;
 
-       if (tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)
+       if (info->control.hw_key)
                tail = 0;
        else
                tail = TKIP_ICV_LEN;
@@ -175,13 +173,11 @@ static int tkip_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb)
        if (key->u.tkip.tx.iv16 == 0)
                key->u.tkip.tx.iv32++;
 
-       if (tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) {
-               /* hwaccel - with preallocated room for IV */
-               ieee80211_tkip_add_iv(pos, key, key->u.tkip.tx.iv16);
+       pos = ieee80211_tkip_add_iv(pos, key, key->u.tkip.tx.iv16);
 
-               info->control.hw_key = &tx->key->conf;
+       /* hwaccel - with software IV */
+       if (info->control.hw_key)
                return 0;
-       }
 
        /* Add room for ICV */
        skb_put(skb, TKIP_ICV_LEN);
@@ -363,24 +359,20 @@ static int ccmp_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb)
        int hdrlen, len, tail;
        u8 *pos, *pn;
        int i;
-       bool skip_hw;
-
-       skip_hw = (tx->key->conf.flags & IEEE80211_KEY_FLAG_SW_MGMT) &&
-               ieee80211_is_mgmt(hdr->frame_control);
 
-       if ((tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) &&
-           !(tx->key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV) &&
-           !skip_hw) {
-               /* hwaccel - with no need for preallocated room for CCMP
-                * header or MIC fields */
-               info->control.hw_key = &tx->key->conf;
+       if (info->control.hw_key &&
+           !(info->control.hw_key->flags & IEEE80211_KEY_FLAG_GENERATE_IV)) {
+               /*
+                * hwaccel has no need for preallocated room for CCMP
+                * header or MIC fields
+                */
                return 0;
        }
 
        hdrlen = ieee80211_hdrlen(hdr->frame_control);
        len = skb->len - hdrlen;
 
-       if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)
+       if (info->control.hw_key)
                tail = 0;
        else
                tail = CCMP_MIC_LEN;
@@ -405,11 +397,9 @@ static int ccmp_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb)
 
        ccmp_pn2hdr(pos, pn, key->conf.keyidx);
 
-       if ((key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) && !skip_hw) {
-               /* hwaccel - with preallocated room for CCMP header */
-               info->control.hw_key = &tx->key->conf;
+       /* hwaccel - with software CCMP header */
+       if (info->control.hw_key)
                return 0;
-       }
 
        pos += CCMP_HDR_LEN;
        ccmp_special_blocks(skb, pn, key->u.ccmp.tx_crypto_buf, 0);
@@ -525,11 +515,8 @@ ieee80211_crypto_aes_cmac_encrypt(struct ieee80211_tx_data *tx)
        u8 *pn, aad[20];
        int i;
 
-       if (tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) {
-               /* hwaccel */
-               info->control.hw_key = &tx->key->conf;
+       if (info->control.hw_key)
                return 0;
-       }
 
        if (WARN_ON(skb_tailroom(skb) < sizeof(*mmie)))
                return TX_DROP;