]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/wireless/b43legacy/main.c
mac80211/drivers: rewrite the rate control API
[linux-2.6-omap-h63xx.git] / drivers / net / wireless / b43legacy / main.c
index 1cb77db5c29265d55d059b398f0c3dcb04c3b47a..9edbdf9cb50fd7811dd8289511bd40e7c41d29b9 100644 (file)
@@ -888,13 +888,13 @@ generate_new:
 
 static void handle_irq_tbtt_indication(struct b43legacy_wldev *dev)
 {
-       if (b43legacy_is_mode(dev->wl, IEEE80211_IF_TYPE_AP)) {
+       if (b43legacy_is_mode(dev->wl, NL80211_IFTYPE_AP)) {
                /* TODO: PS TBTT */
        } else {
                if (1/*FIXME: the last PSpoll frame was sent successfully */)
                        b43legacy_power_saving_ctl_bits(dev, -1, -1);
        }
-       if (b43legacy_is_mode(dev->wl, IEEE80211_IF_TYPE_IBSS))
+       if (b43legacy_is_mode(dev->wl, NL80211_IFTYPE_ADHOC))
                dev->dfq_valid = 1;
 }
 
@@ -1201,7 +1201,7 @@ static void handle_irq_beacon(struct b43legacy_wldev *dev)
        struct b43legacy_wl *wl = dev->wl;
        u32 cmd;
 
-       if (!b43legacy_is_mode(wl, IEEE80211_IF_TYPE_AP))
+       if (!b43legacy_is_mode(wl, NL80211_IFTYPE_AP))
                return;
 
        /* This is the bottom half of the asynchronous beacon update. */
@@ -1936,9 +1936,9 @@ static void b43legacy_adjust_opmode(struct b43legacy_wldev *dev)
        ctl &= ~B43legacy_MACCTL_BEACPROMISC;
        ctl |= B43legacy_MACCTL_INFRA;
 
-       if (b43legacy_is_mode(wl, IEEE80211_IF_TYPE_AP))
+       if (b43legacy_is_mode(wl, NL80211_IFTYPE_AP))
                ctl |= B43legacy_MACCTL_AP;
-       else if (b43legacy_is_mode(wl, IEEE80211_IF_TYPE_IBSS))
+       else if (b43legacy_is_mode(wl, NL80211_IFTYPE_ADHOC))
                ctl &= ~B43legacy_MACCTL_INFRA;
 
        if (wl->filter_flags & FIF_CONTROL)
@@ -2556,26 +2556,27 @@ init_failure:
        return err;
 }
 
-static int b43legacy_antenna_from_ieee80211(u8 antenna)
+/* Write the short and long frame retry limit values. */
+static void b43legacy_set_retry_limits(struct b43legacy_wldev *dev,
+                                      unsigned int short_retry,
+                                      unsigned int long_retry)
 {
-       switch (antenna) {
-       case 0: /* default/diversity */
-               return B43legacy_ANTENNA_DEFAULT;
-       case 1: /* Antenna 0 */
-               return B43legacy_ANTENNA0;
-       case 2: /* Antenna 1 */
-               return B43legacy_ANTENNA1;
-       default:
-               return B43legacy_ANTENNA_DEFAULT;
-       }
+       /* The retry limit is a 4-bit counter. Enforce this to avoid overflowing
+        * the chip-internal counter. */
+       short_retry = min(short_retry, (unsigned int)0xF);
+       long_retry = min(long_retry, (unsigned int)0xF);
+
+       b43legacy_shm_write16(dev, B43legacy_SHM_WIRELESS, 0x0006, short_retry);
+       b43legacy_shm_write16(dev, B43legacy_SHM_WIRELESS, 0x0007, long_retry);
 }
 
 static int b43legacy_op_dev_config(struct ieee80211_hw *hw,
-                                  struct ieee80211_conf *conf)
+                                  u32 changed)
 {
        struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw);
        struct b43legacy_wldev *dev;
        struct b43legacy_phy *phy;
+       struct ieee80211_conf *conf = &hw->conf;
        unsigned long flags;
        unsigned int new_phymode = 0xFFFF;
        int antenna_tx;
@@ -2583,13 +2584,21 @@ static int b43legacy_op_dev_config(struct ieee80211_hw *hw,
        int err = 0;
        u32 savedirqs;
 
-       antenna_tx = b43legacy_antenna_from_ieee80211(conf->antenna_sel_tx);
-       antenna_rx = b43legacy_antenna_from_ieee80211(conf->antenna_sel_rx);
+       antenna_tx = B43legacy_ANTENNA_DEFAULT;
+       antenna_rx = B43legacy_ANTENNA_DEFAULT;
 
        mutex_lock(&wl->mutex);
        dev = wl->current_dev;
        phy = &dev->phy;
 
+       if (changed & IEEE80211_CONF_CHANGE_RETRY_LIMITS)
+               b43legacy_set_retry_limits(dev,
+                                          conf->short_frame_max_tx_count,
+                                          conf->long_frame_max_tx_count);
+       changed &= ~IEEE80211_CONF_CHANGE_RETRY_LIMITS;
+       if (!changed)
+               goto out_unlock_mutex;
+
        /* Switch the PHY mode (if necessary). */
        switch (conf->channel->band) {
        case IEEE80211_BAND_2GHZ:
@@ -2646,7 +2655,7 @@ static int b43legacy_op_dev_config(struct ieee80211_hw *hw,
        b43legacy_mgmtframe_txantenna(dev, antenna_tx);
 
        /* Update templates for AP mode. */
-       if (b43legacy_is_mode(wl, IEEE80211_IF_TYPE_AP))
+       if (b43legacy_is_mode(wl, NL80211_IFTYPE_AP))
                b43legacy_set_beacon_int(dev, conf->beacon_int);
 
 
@@ -2733,12 +2742,12 @@ static int b43legacy_op_config_interface(struct ieee80211_hw *hw,
        else
                memset(wl->bssid, 0, ETH_ALEN);
        if (b43legacy_status(dev) >= B43legacy_STAT_INITIALIZED) {
-               if (b43legacy_is_mode(wl, IEEE80211_IF_TYPE_AP)) {
-                       B43legacy_WARN_ON(vif->type != IEEE80211_IF_TYPE_AP);
+               if (b43legacy_is_mode(wl, NL80211_IFTYPE_AP)) {
+                       B43legacy_WARN_ON(vif->type != NL80211_IFTYPE_AP);
                        b43legacy_set_ssid(dev, conf->ssid, conf->ssid_len);
                        if (conf->changed & IEEE80211_IFCC_BEACON)
                                b43legacy_update_templates(wl);
-               } else if (b43legacy_is_mode(wl, IEEE80211_IF_TYPE_IBSS)) {
+               } else if (b43legacy_is_mode(wl, NL80211_IFTYPE_ADHOC)) {
                        if (conf->changed & IEEE80211_IFCC_BEACON)
                                b43legacy_update_templates(wl);
                }
@@ -3002,25 +3011,11 @@ static void b43legacy_imcfglo_timeouts_workaround(struct b43legacy_wldev *dev)
 #endif /* CONFIG_SSB_DRIVER_PCICORE */
 }
 
-/* Write the short and long frame retry limit values. */
-static void b43legacy_set_retry_limits(struct b43legacy_wldev *dev,
-                                      unsigned int short_retry,
-                                      unsigned int long_retry)
-{
-       /* The retry limit is a 4-bit counter. Enforce this to avoid overflowing
-        * the chip-internal counter. */
-       short_retry = min(short_retry, (unsigned int)0xF);
-       long_retry = min(long_retry, (unsigned int)0xF);
-
-       b43legacy_shm_write16(dev, B43legacy_SHM_WIRELESS, 0x0006, short_retry);
-       b43legacy_shm_write16(dev, B43legacy_SHM_WIRELESS, 0x0007, long_retry);
-}
-
 static void b43legacy_set_synth_pu_delay(struct b43legacy_wldev *dev,
                                          bool idle) {
        u16 pu_delay = 1050;
 
-       if (b43legacy_is_mode(dev->wl, IEEE80211_IF_TYPE_IBSS) || idle)
+       if (b43legacy_is_mode(dev->wl, NL80211_IFTYPE_ADHOC) || idle)
                pu_delay = 500;
        if ((dev->phy.radio_ver == 0x2050) && (dev->phy.radio_rev == 8))
                pu_delay = max(pu_delay, (u16)2400);
@@ -3035,7 +3030,7 @@ static void b43legacy_set_pretbtt(struct b43legacy_wldev *dev)
        u16 pretbtt;
 
        /* The time value is in microseconds. */
-       if (b43legacy_is_mode(dev->wl, IEEE80211_IF_TYPE_IBSS))
+       if (b43legacy_is_mode(dev->wl, NL80211_IFTYPE_ADHOC))
                pretbtt = 2;
        else
                pretbtt = 250;
@@ -3259,10 +3254,10 @@ static int b43legacy_op_add_interface(struct ieee80211_hw *hw,
 
        /* TODO: allow WDS/AP devices to coexist */
 
-       if (conf->type != IEEE80211_IF_TYPE_AP &&
-           conf->type != IEEE80211_IF_TYPE_STA &&
-           conf->type != IEEE80211_IF_TYPE_WDS &&
-           conf->type != IEEE80211_IF_TYPE_IBSS)
+       if (conf->type != NL80211_IFTYPE_AP &&
+           conf->type != NL80211_IFTYPE_STATION &&
+           conf->type != NL80211_IFTYPE_WDS &&
+           conf->type != NL80211_IFTYPE_ADHOC)
                return -EOPNOTSUPP;
 
        mutex_lock(&wl->mutex);
@@ -3380,30 +3375,8 @@ static void b43legacy_op_stop(struct ieee80211_hw *hw)
        mutex_unlock(&wl->mutex);
 }
 
-static int b43legacy_op_set_retry_limit(struct ieee80211_hw *hw,
-                                       u32 short_retry_limit,
-                                       u32 long_retry_limit)
-{
-       struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw);
-       struct b43legacy_wldev *dev;
-       int err = 0;
-
-       mutex_lock(&wl->mutex);
-       dev = wl->current_dev;
-       if (unlikely(!dev ||
-                    (b43legacy_status(dev) < B43legacy_STAT_INITIALIZED))) {
-               err = -ENODEV;
-               goto out_unlock;
-       }
-       b43legacy_set_retry_limits(dev, short_retry_limit, long_retry_limit);
-out_unlock:
-       mutex_unlock(&wl->mutex);
-
-       return err;
-}
-
 static int b43legacy_op_beacon_set_tim(struct ieee80211_hw *hw,
-                                      int aid, int set)
+                                      struct ieee80211_sta *sta, bool set)
 {
        struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw);
        unsigned long flags;
@@ -3427,7 +3400,6 @@ static const struct ieee80211_ops b43legacy_hw_ops = {
        .get_tx_stats           = b43legacy_op_get_tx_stats,
        .start                  = b43legacy_op_start,
        .stop                   = b43legacy_op_stop,
-       .set_retry_limit        = b43legacy_op_set_retry_limit,
        .set_tim                = b43legacy_op_beacon_set_tim,
 };
 
@@ -3704,7 +3676,13 @@ static int b43legacy_wireless_init(struct ssb_device *dev)
        hw->flags = IEEE80211_HW_RX_INCLUDES_FCS |
                    IEEE80211_HW_SIGNAL_DBM |
                    IEEE80211_HW_NOISE_DBM;
+       hw->wiphy->interface_modes =
+               BIT(NL80211_IFTYPE_AP) |
+               BIT(NL80211_IFTYPE_STATION) |
+               BIT(NL80211_IFTYPE_WDS) |
+               BIT(NL80211_IFTYPE_ADHOC);
        hw->queues = 1; /* FIXME: hardware has more queues */
+       hw->max_rates = 2;
        SET_IEEE80211_DEV(hw, dev->dev);
        if (is_valid_ether_addr(sprom->et1mac))
                SET_IEEE80211_PERM_ADDR(hw, sprom->et1mac);