]> err.no Git - linux-2.6/blobdiff - net/mac80211/tx.c
Convert ERR_PTR(PTR_ERR(p)) instances to ERR_CAST(p)
[linux-2.6] / net / mac80211 / tx.c
index 1b772ee2fe14ce9904e3a72274439be5aa4583c3..67b509edd431024ea62623d023f5cf309005af64 100644 (file)
@@ -176,7 +176,7 @@ static u16 ieee80211_duration(struct ieee80211_txrx_data *tx, int group_addr,
         * to closest integer */
 
        dur = ieee80211_frame_duration(local, 10, rate, erp,
-                      tx->sdata->flags & IEEE80211_SDATA_SHORT_PREAMBLE);
+                               tx->sdata->bss_conf.use_short_preamble);
 
        if (next_frag_len) {
                /* Frame is fragmented: duration increases with time needed to
@@ -185,8 +185,7 @@ static u16 ieee80211_duration(struct ieee80211_txrx_data *tx, int group_addr,
                /* next fragment */
                dur += ieee80211_frame_duration(local, next_frag_len,
                                txrate->rate, erp,
-                               tx->sdata->flags &
-                                       IEEE80211_SDATA_SHORT_PREAMBLE);
+                               tx->sdata->bss_conf.use_short_preamble);
        }
 
        return dur;
@@ -237,7 +236,7 @@ ieee80211_tx_h_check_assoc(struct ieee80211_txrx_data *tx)
 
        if (likely(tx->flags & IEEE80211_TXRXD_TXUNICAST)) {
                if (unlikely(!(sta_flags & WLAN_STA_ASSOC) &&
-                            tx->sdata->type != IEEE80211_IF_TYPE_IBSS &&
+                            tx->sdata->vif.type != IEEE80211_IF_TYPE_IBSS &&
                             (tx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA)) {
 #ifdef CONFIG_MAC80211_VERBOSE_DEBUG
                        DECLARE_MAC_BUF(mac);
@@ -251,7 +250,7 @@ ieee80211_tx_h_check_assoc(struct ieee80211_txrx_data *tx)
        } else {
                if (unlikely((tx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA &&
                             tx->local->num_sta == 0 &&
-                            tx->sdata->type != IEEE80211_IF_TYPE_IBSS)) {
+                            tx->sdata->vif.type != IEEE80211_IF_TYPE_IBSS)) {
                        /*
                         * No associated STAs - no need to send multicast
                         * frames.
@@ -294,7 +293,7 @@ static void purge_old_ps_buffers(struct ieee80211_local *local)
        list_for_each_entry_rcu(sdata, &local->interfaces, list) {
                struct ieee80211_if_ap *ap;
                if (sdata->dev == local->mdev ||
-                   sdata->type != IEEE80211_IF_TYPE_AP)
+                   sdata->vif.type != IEEE80211_IF_TYPE_AP)
                        continue;
                ap = &sdata->u.ap;
                skb = skb_dequeue(&ap->ps_bc_buf);
@@ -605,7 +604,7 @@ ieee80211_tx_h_rate_ctrl(struct ieee80211_txrx_data *tx)
                tx->u.tx.control->alt_retry_rate = -1;
 
        if (tx->u.tx.mode->mode == MODE_IEEE80211G &&
-           (tx->sdata->flags & IEEE80211_SDATA_USE_PROTECTION) &&
+           tx->sdata->bss_conf.use_cts_prot &&
            (tx->flags & IEEE80211_TXRXD_FRAGMENTED) && rsel.nonerp) {
                tx->u.tx.last_frag_rate = tx->u.tx.rate;
                if (rsel.probe)
@@ -667,7 +666,7 @@ ieee80211_tx_h_misc(struct ieee80211_txrx_data *tx)
        if (mode->mode == MODE_IEEE80211G &&
            (tx->u.tx.rate->flags & IEEE80211_RATE_ERP) &&
            (tx->flags & IEEE80211_TXRXD_TXUNICAST) &&
-           (tx->sdata->flags & IEEE80211_SDATA_USE_PROTECTION) &&
+           tx->sdata->bss_conf.use_cts_prot &&
            !(control->flags & IEEE80211_TXCTL_USE_RTS_CTS))
                control->flags |= IEEE80211_TXCTL_USE_CTS_PROTECT;
 
@@ -676,7 +675,7 @@ ieee80211_tx_h_misc(struct ieee80211_txrx_data *tx)
         * available on the network at the current point in time. */
        if (((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA) &&
            (tx->u.tx.rate->flags & IEEE80211_RATE_PREAMBLE2) &&
-           (tx->sdata->flags & IEEE80211_SDATA_SHORT_PREAMBLE) &&
+           tx->sdata->bss_conf.use_short_preamble &&
            (!tx->sta || (tx->sta->flags & WLAN_STA_SHORT_PREAMBLE))) {
                tx->u.tx.control->tx_rate = tx->u.tx.rate->val2;
        }
@@ -949,7 +948,7 @@ __ieee80211_tx_prepare(struct ieee80211_txrx_data *tx,
 
        /* process and remove the injection radiotap header */
        sdata = IEEE80211_DEV_TO_SUB_IF(dev);
-       if (unlikely(sdata->type == IEEE80211_IF_TYPE_MNTR)) {
+       if (unlikely(sdata->vif.type == IEEE80211_IF_TYPE_MNTR)) {
                if (__ieee80211_parse_tx_radiotap(tx, skb) == TXRX_DROP)
                        return TXRX_DROP;
 
@@ -1252,7 +1251,7 @@ int ieee80211_master_start_xmit(struct sk_buff *skb,
        }
 
        control.vif = &osdata->vif;
-       control.type = osdata->type;
+       control.type = osdata->vif.type;
        if (pkt_data->flags & IEEE80211_TXPD_REQ_TX_STATUS)
                control.flags |= IEEE80211_TXCTL_REQ_TX_STATUS;
        if (pkt_data->flags & IEEE80211_TXPD_DO_NOT_ENCRYPT)
@@ -1371,7 +1370,7 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb,
        ethertype = (skb->data[12] << 8) | skb->data[13];
        fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA;
 
-       switch (sdata->type) {
+       switch (sdata->vif.type) {
        case IEEE80211_IF_TYPE_AP:
        case IEEE80211_IF_TYPE_VLAN:
                fc |= IEEE80211_FCTL_FROMDS;
@@ -1628,7 +1627,8 @@ void ieee80211_tx_pending(unsigned long data)
 
 static void ieee80211_beacon_add_tim(struct ieee80211_local *local,
                                     struct ieee80211_if_ap *bss,
-                                    struct sk_buff *skb)
+                                    struct sk_buff *skb,
+                                    struct beacon_data *beacon)
 {
        u8 *pos, *tim;
        int aid0 = 0;
@@ -1644,7 +1644,7 @@ static void ieee80211_beacon_add_tim(struct ieee80211_local *local,
                                          IEEE80211_MAX_AID+1);
 
        if (bss->dtim_count == 0)
-               bss->dtim_count = bss->dtim_period - 1;
+               bss->dtim_count = beacon->dtim_period - 1;
        else
                bss->dtim_count--;
 
@@ -1652,7 +1652,7 @@ static void ieee80211_beacon_add_tim(struct ieee80211_local *local,
        *pos++ = WLAN_EID_TIM;
        *pos++ = 4;
        *pos++ = bss->dtim_count;
-       *pos++ = bss->dtim_period;
+       *pos++ = beacon->dtim_period;
 
        if (bss->dtim_count == 0 && !skb_queue_empty(&bss->ps_bc_buf))
                aid0 = 1;
@@ -1700,44 +1700,43 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw,
        struct ieee80211_sub_if_data *sdata = NULL;
        struct ieee80211_if_ap *ap = NULL;
        struct rate_selection rsel;
-       u8 *b_head, *b_tail;
-       int bh_len, bt_len;
+       struct beacon_data *beacon;
+
+       rcu_read_lock();
 
        sdata = vif_to_sdata(vif);
        bdev = sdata->dev;
        ap = &sdata->u.ap;
 
-       if (!ap || sdata->type != IEEE80211_IF_TYPE_AP ||
-           !ap->beacon_head) {
+       beacon = rcu_dereference(ap->beacon);
+
+       if (!ap || sdata->vif.type != IEEE80211_IF_TYPE_AP || !beacon) {
 #ifdef CONFIG_MAC80211_VERBOSE_DEBUG
                if (net_ratelimit())
                        printk(KERN_DEBUG "no beacon data avail for %s\n",
                               bdev->name);
 #endif /* CONFIG_MAC80211_VERBOSE_DEBUG */
-               return NULL;
+               skb = NULL;
+               goto out;
        }
 
-       /* Assume we are generating the normal beacon locally */
-       b_head = ap->beacon_head;
-       b_tail = ap->beacon_tail;
-       bh_len = ap->beacon_head_len;
-       bt_len = ap->beacon_tail_len;
-
-       skb = dev_alloc_skb(local->tx_headroom +
-               bh_len + bt_len + 256 /* maximum TIM len */);
+       /* headroom, head length, tail length and maximum TIM length */
+       skb = dev_alloc_skb(local->tx_headroom + beacon->head_len +
+                           beacon->tail_len + 256);
        if (!skb)
-               return NULL;
+               goto out;
 
        skb_reserve(skb, local->tx_headroom);
-       memcpy(skb_put(skb, bh_len), b_head, bh_len);
+       memcpy(skb_put(skb, beacon->head_len), beacon->head,
+              beacon->head_len);
 
        ieee80211_include_sequence(sdata, (struct ieee80211_hdr *)skb->data);
 
-       ieee80211_beacon_add_tim(local, ap, skb);
+       ieee80211_beacon_add_tim(local, ap, skb, beacon);
 
-       if (b_tail) {
-               memcpy(skb_put(skb, bt_len), b_tail, bt_len);
-       }
+       if (beacon->tail)
+               memcpy(skb_put(skb, beacon->tail_len), beacon->tail,
+                      beacon->tail_len);
 
        if (control) {
                rate_control_get_rate(local->mdev, local->oper_hw_mode, skb,
@@ -1749,11 +1748,13 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw,
                                       wiphy_name(local->hw.wiphy));
                        }
                        dev_kfree_skb(skb);
-                       return NULL;
+                       skb = NULL;
+                       goto out;
                }
 
+               control->vif = vif;
                control->tx_rate =
-                       ((sdata->flags & IEEE80211_SDATA_SHORT_PREAMBLE) &&
+                       (sdata->bss_conf.use_short_preamble &&
                        (rsel.rate->flags & IEEE80211_RATE_PREAMBLE2)) ?
                        rsel.rate->val2 : rsel.rate->val;
                control->antenna_sel_tx = local->hw.conf.antenna_sel_tx;
@@ -1764,6 +1765,9 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw,
        }
 
        ap->num_beacons++;
+
+ out:
+       rcu_read_unlock();
        return skb;
 }
 EXPORT_SYMBOL(ieee80211_beacon_get);
@@ -1815,12 +1819,24 @@ ieee80211_get_buffered_bc(struct ieee80211_hw *hw,
        struct net_device *bdev;
        struct ieee80211_sub_if_data *sdata;
        struct ieee80211_if_ap *bss = NULL;
+       struct beacon_data *beacon;
 
        sdata = vif_to_sdata(vif);
        bdev = sdata->dev;
 
-       if (!bss || sdata->type != IEEE80211_IF_TYPE_AP || !bss->beacon_head)
+
+       if (!bss)
+               return NULL;
+
+       rcu_read_lock();
+       beacon = rcu_dereference(bss->beacon);
+
+       if (sdata->vif.type != IEEE80211_IF_TYPE_AP || !beacon ||
+           !beacon->head) {
+               rcu_read_unlock();
                return NULL;
+       }
+       rcu_read_unlock();
 
        if (bss->dtim_count != 0)
                return NULL; /* send buffered bc/mc only after DTIM beacon */