mac80211: dont use interface indices in drivers
[deliverable/linux.git] / drivers / net / wireless / b43 / xmit.c
index 0bd6f8a348a8a195821ff8ec5721c167b0443bca..5014213b77523431da6c3f48a75708363e5a8cca 100644 (file)
@@ -5,7 +5,7 @@
   Transmission (TX/RX) related functions.
 
   Copyright (C) 2005 Martin Langer <martin-langer@gmx.de>
-  Copyright (C) 2005 Stefano Brivio <st3@riseup.net>
+  Copyright (C) 2005 Stefano Brivio <stefano.brivio@polimi.it>
   Copyright (C) 2005, 2006 Michael Buesch <mb@bu3sch.de>
   Copyright (C) 2005 Danny van Dyk <kugelfang@gentoo.org>
   Copyright (C) 2005 Andreas Jaggi <andreas.jaggi@waterwave.ch>
@@ -30,7 +30,7 @@
 #include "xmit.h"
 #include "phy.h"
 #include "dma.h"
-#include "pio.h"
+
 
 /* Extract the bitrate out of a CCK PLCP header. */
 static u8 b43_plcp_get_bitrate_cck(struct b43_plcp_hdr6 *plcp)
@@ -221,7 +221,7 @@ static void generate_txhdr_fw4(struct b43_wldev *dev,
        } else {
                int fbrate_base100kbps = B43_RATE_TO_BASE100KBPS(rate_fb);
                txhdr->dur_fb = ieee80211_generic_frame_duration(dev->wl->hw,
-                                                                dev->wl->if_id,
+                                                                txctl->vif,
                                                                 fragment_len,
                                                                 fbrate_base100kbps);
        }
@@ -270,14 +270,15 @@ static void generate_txhdr_fw4(struct b43_wldev *dev,
                phy_ctl |= B43_TX4_PHY_OFDM;
        if (dev->short_preamble)
                phy_ctl |= B43_TX4_PHY_SHORTPRMBL;
-       switch (txctl->antenna_sel_tx) {
-       case 0:
+
+       switch (b43_ieee80211_antenna_sanitize(dev, txctl->antenna_sel_tx)) {
+       case 0: /* Default */
                phy_ctl |= B43_TX4_PHY_ANTLAST;
                break;
-       case 1:
+       case 1: /* Antenna 0 */
                phy_ctl |= B43_TX4_PHY_ANT0;
                break;
-       case 2:
+       case 2: /* Antenna 1 */
                phy_ctl |= B43_TX4_PHY_ANT1;
                break;
        default:
@@ -294,6 +295,8 @@ static void generate_txhdr_fw4(struct b43_wldev *dev,
                mac_ctl |= B43_TX4_MAC_STMSDU;
        if (phy->type == B43_PHYTYPE_A)
                mac_ctl |= B43_TX4_MAC_5GHZ;
+       if (txctl->flags & IEEE80211_TXCTL_LONG_RETRY_LIMIT)
+               mac_ctl |= B43_TX4_MAC_LONGFRAME;
 
        /* Generate the RTS or CTS-to-self frame */
        if ((txctl->flags & IEEE80211_TXCTL_USE_RTS_CTS) ||
@@ -309,7 +312,7 @@ static void generate_txhdr_fw4(struct b43_wldev *dev,
                rts_rate_fb_ofdm = b43_is_ofdm_rate(rts_rate_fb);
 
                if (txctl->flags & IEEE80211_TXCTL_USE_CTS_PROTECT) {
-                       ieee80211_ctstoself_get(dev->wl->hw, dev->wl->if_id,
+                       ieee80211_ctstoself_get(dev->wl->hw, txctl->vif,
                                                fragment_data, fragment_len,
                                                txctl,
                                                (struct ieee80211_cts *)(txhdr->
@@ -317,7 +320,7 @@ static void generate_txhdr_fw4(struct b43_wldev *dev,
                        mac_ctl |= B43_TX4_MAC_SENDCTS;
                        len = sizeof(struct ieee80211_cts);
                } else {
-                       ieee80211_rts_get(dev->wl->hw, dev->wl->if_id,
+                       ieee80211_rts_get(dev->wl->hw, txctl->vif,
                                          fragment_data, fragment_len, txctl,
                                          (struct ieee80211_rts *)(txhdr->
                                                                   rts_frame));
@@ -342,7 +345,6 @@ static void generate_txhdr_fw4(struct b43_wldev *dev,
                            b43_plcp_get_ratecode_cck(rts_rate);
                if (rts_rate_fb_ofdm)
                        extra_ft |= B43_TX4_EFT_RTSFBOFDM;
-               mac_ctl |= B43_TX4_MAC_LONGFRAME;
        }
 
        /* Magic cookie */
@@ -384,7 +386,7 @@ static s8 b43_rssi_postprocess(struct b43_wldev *dev,
                        else
                                tmp -= 3;
                } else {
-                       if (dev->dev->bus->sprom.r1.
+                       if (dev->dev->bus->sprom.
                            boardflags_lo & B43_BFL_RSSI) {
                                if (in_rssi > 63)
                                        in_rssi = 63;
@@ -488,7 +490,6 @@ void b43_rx(struct b43_wldev *dev, struct sk_buff *skb, const void *_rxhdr)
        }
        wlhdr = (struct ieee80211_hdr *)(skb->data);
        fctl = le16_to_cpu(wlhdr->frame_control);
-       skb_trim(skb, skb->len - FCS_LEN);
 
        if (macstat & B43_RX_MAC_DEC) {
                unsigned int keyidx;
@@ -525,27 +526,55 @@ void b43_rx(struct b43_wldev *dev, struct sk_buff *skb, const void *_rxhdr)
        else
                status.rate = b43_plcp_get_bitrate_cck(plcp);
        status.antenna = !!(phystat0 & B43_RX_PHYST0_ANT);
-       status.mactime = mactime;
+
+       /*
+        * If monitors are present get full 64-bit timestamp. This
+        * code assumes we get to process the packet within 16 bits
+        * of timestamp, i.e. about 65 milliseconds after the PHY
+        * received the first symbol.
+        */
+       if (dev->wl->radiotap_enabled) {
+               u16 low_mactime_now;
+
+               b43_tsf_read(dev, &status.mactime);
+               low_mactime_now = status.mactime;
+               status.mactime = status.mactime & ~0xFFFFULL;
+               status.mactime += mactime;
+               if (low_mactime_now <= mactime)
+                       status.mactime -= 0x10000;
+               status.flag |= RX_FLAG_TSFT;
+       }
 
        chanid = (chanstat & B43_RX_CHAN_ID) >> B43_RX_CHAN_ID_SHIFT;
        switch (chanstat & B43_RX_CHAN_PHYTYPE) {
        case B43_PHYTYPE_A:
                status.phymode = MODE_IEEE80211A;
-               status.freq = chanid;
-               status.channel = b43_freq_to_channel_a(chanid);
-               break;
-       case B43_PHYTYPE_B:
-               status.phymode = MODE_IEEE80211B;
-               status.freq = chanid + 2400;
-               status.channel = b43_freq_to_channel_bg(chanid + 2400);
+               B43_WARN_ON(1);
+               /* FIXME: We don't really know which value the "chanid" contains.
+                *        So the following assignment might be wrong. */
+               status.channel = chanid;
+               status.freq = b43_channel_to_freq_5ghz(status.channel);
                break;
        case B43_PHYTYPE_G:
                status.phymode = MODE_IEEE80211G;
+               /* chanid is the radio channel cookie value as used
+                * to tune the radio. */
                status.freq = chanid + 2400;
-               status.channel = b43_freq_to_channel_bg(chanid + 2400);
+               status.channel = b43_freq_to_channel_2ghz(status.freq);
+               break;
+       case B43_PHYTYPE_N:
+               status.phymode = 0xDEAD /*FIXME MODE_IEEE80211N*/;
+               /* chanid is the SHM channel cookie. Which is the plain
+                * channel number in b43. */
+               status.channel = chanid;
+               if (chanstat & B43_RX_CHAN_5GHZ)
+                       status.freq = b43_freq_to_channel_5ghz(status.freq);
+               else
+                       status.freq = b43_freq_to_channel_2ghz(status.freq);
                break;
        default:
                B43_WARN_ON(1);
+               goto drop;
        }
 
        dev->stats.last_rx = jiffies;
@@ -575,10 +604,7 @@ void b43_handle_txstatus(struct b43_wldev *dev,
                        dev->wl->ieee_stats.dot11RTSSuccessCount++;
        }
 
-       if (b43_using_pio(dev))
-               b43_pio_handle_txstatus(dev, status);
-       else
-               b43_dma_handle_txstatus(dev, status);
+       b43_dma_handle_txstatus(dev, status);
 }
 
 /* Handle TX status report as received through DMA/PIO queues */
@@ -607,19 +633,13 @@ void b43_handle_hwtxstatus(struct b43_wldev *dev,
 /* Stop any TX operation on the device (suspend the hardware queues) */
 void b43_tx_suspend(struct b43_wldev *dev)
 {
-       if (b43_using_pio(dev))
-               b43_pio_freeze_txqueues(dev);
-       else
-               b43_dma_tx_suspend(dev);
+       b43_dma_tx_suspend(dev);
 }
 
 /* Resume any TX operation on the device (resume the hardware queues) */
 void b43_tx_resume(struct b43_wldev *dev)
 {
-       if (b43_using_pio(dev))
-               b43_pio_thaw_txqueues(dev);
-       else
-               b43_dma_tx_resume(dev);
+       b43_dma_tx_resume(dev);
 }
 
 #if 0
This page took 0.0486 seconds and 5 git commands to generate.