]> err.no Git - linux-2.6/blobdiff - net/mac80211/tx.c
mac80211: move tx crypto decision
[linux-2.6] / net / mac80211 / tx.c
index e177a8dc23b98d8e56ec8fb8b0f833f48fe3f773..8302c70da9a41e8095e38c5c3f455c835e6bfb41 100644 (file)
@@ -322,16 +322,27 @@ static void purge_old_ps_buffers(struct ieee80211_local *local)
               wiphy_name(local->hw.wiphy), purged);
 }
 
-static inline ieee80211_txrx_result
+static ieee80211_txrx_result
 ieee80211_tx_h_multicast_ps_buf(struct ieee80211_txrx_data *tx)
 {
-       /* broadcast/multicast frame */
-       /* If any of the associated stations is in power save mode,
-        * the frame is buffered to be sent after DTIM beacon frame */
-       if ((tx->local->hw.flags & IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING) &&
-           tx->sdata->type != IEEE80211_IF_TYPE_WDS &&
-           tx->sdata->bss && atomic_read(&tx->sdata->bss->num_sta_ps) &&
-           !(tx->fc & IEEE80211_FCTL_ORDER)) {
+       /*
+        * broadcast/multicast frame
+        *
+        * If any of the associated stations is in power save mode,
+        * the frame is buffered to be sent after DTIM beacon frame.
+        * This is done either by the hardware or us.
+        */
+
+       /* not AP/IBSS or ordered frame */
+       if (!tx->sdata->bss || (tx->fc & IEEE80211_FCTL_ORDER))
+               return TXRX_CONTINUE;
+
+       /* no stations in PS mode */
+       if (!atomic_read(&tx->sdata->bss->num_sta_ps))
+               return TXRX_CONTINUE;
+
+       /* buffered in mac80211 */
+       if (tx->local->hw.flags & IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING) {
                if (tx->local->total_ps_buffered >= TOTAL_MAX_TX_BUFFER)
                        purge_old_ps_buffers(tx->local);
                if (skb_queue_len(&tx->sdata->bss->ps_bc_buf) >=
@@ -348,10 +359,13 @@ ieee80211_tx_h_multicast_ps_buf(struct ieee80211_txrx_data *tx)
                return TXRX_QUEUED;
        }
 
+       /* buffered in hardware */
+       tx->u.tx.control->flags |= IEEE80211_TXCTL_SEND_AFTER_DTIM;
+
        return TXRX_CONTINUE;
 }
 
-static inline ieee80211_txrx_result
+static ieee80211_txrx_result
 ieee80211_tx_h_unicast_ps_buf(struct ieee80211_txrx_data *tx)
 {
        struct sta_info *sta = tx->sta;
@@ -424,11 +438,7 @@ static ieee80211_txrx_result
 ieee80211_tx_h_select_key(struct ieee80211_txrx_data *tx)
 {
        struct ieee80211_key *key;
-       const struct ieee80211_hdr *hdr;
-       u16 fc;
-
-       hdr = (const struct ieee80211_hdr *) tx->skb->data;
-       fc = le16_to_cpu(hdr->frame_control);
+       u16 fc = tx->fc;
 
        if (unlikely(tx->u.tx.control->flags & IEEE80211_TXCTL_DO_NOT_ENCRYPT))
                tx->key = NULL;
@@ -441,16 +451,34 @@ ieee80211_tx_h_select_key(struct ieee80211_txrx_data *tx)
                 !(tx->flags & IEEE80211_TXRXD_TX_INJECTED)) {
                I802_DEBUG_INC(tx->local->tx_handlers_drop_unencrypted);
                return TXRX_DROP;
-       } else {
+       } else
                tx->key = NULL;
-               tx->u.tx.control->flags |= IEEE80211_TXCTL_DO_NOT_ENCRYPT;
-       }
 
        if (tx->key) {
+               u16 ftype, stype;
+
                tx->key->tx_rx_count++;
                /* TODO: add threshold stuff again */
+
+               switch (tx->key->conf.alg) {
+               case ALG_WEP:
+                       ftype = fc & IEEE80211_FCTL_FTYPE;
+                       stype = fc & IEEE80211_FCTL_STYPE;
+
+                       if (ftype == IEEE80211_FTYPE_MGMT &&
+                           stype == IEEE80211_STYPE_AUTH)
+                               break;
+               case ALG_TKIP:
+               case ALG_CCMP:
+                       if (!WLAN_FC_DATA_PRESENT(fc))
+                               tx->key = NULL;
+                       break;
+               }
        }
 
+       if (!tx->key || !(tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE))
+               tx->u.tx.control->flags |= IEEE80211_TXCTL_DO_NOT_ENCRYPT;
+
        return TXRX_CONTINUE;
 }
 
@@ -692,15 +720,6 @@ ieee80211_tx_h_misc(struct ieee80211_txrx_data *tx)
                }
        }
 
-       /*
-        * Tell hardware to not encrypt when we had sw crypto.
-        * Because we use the same flag to internally indicate that
-        * no (software) encryption should be done, we have to set it
-        * after all crypto handlers.
-        */
-       if (tx->key && !(tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE))
-               tx->u.tx.control->flags |= IEEE80211_TXCTL_DO_NOT_ENCRYPT;
-
        return TXRX_CONTINUE;
 }