]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - net/mac80211/ieee80211.c
cfg80211 API for channels/bitrates, mac80211 and driver conversion
[mirror_ubuntu-bionic-kernel.git] / net / mac80211 / ieee80211.c
index 42c27089f006774c9438606c2cd01680eed76c4b..de894b61a23cad3018b6f839c2e3593222866d4f 100644 (file)
@@ -165,6 +165,7 @@ static int ieee80211_open(struct net_device *dev)
        struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
        struct ieee80211_if_init_conf conf;
        int res;
+       bool need_hw_reconfig = 0;
 
        sdata = IEEE80211_DEV_TO_SUB_IF(dev);
 
@@ -177,21 +178,21 @@ static int ieee80211_open(struct net_device *dev)
                        /*
                         * check whether it may have the same address
                         */
-                       if (!identical_mac_addr_allowed(sdata->type,
-                                                       nsdata->type))
+                       if (!identical_mac_addr_allowed(sdata->vif.type,
+                                                       nsdata->vif.type))
                                return -ENOTUNIQ;
 
                        /*
                         * can only add VLANs to enabled APs
                         */
-                       if (sdata->type == IEEE80211_IF_TYPE_VLAN &&
-                           nsdata->type == IEEE80211_IF_TYPE_AP &&
+                       if (sdata->vif.type == IEEE80211_IF_TYPE_VLAN &&
+                           nsdata->vif.type == IEEE80211_IF_TYPE_AP &&
                            netif_running(nsdata->dev))
                                sdata->u.vlan.ap = nsdata;
                }
        }
 
-       switch (sdata->type) {
+       switch (sdata->vif.type) {
        case IEEE80211_IF_TYPE_WDS:
                if (is_zero_ether_addr(sdata->u.wds.remote_addr))
                        return -ENOLINK;
@@ -218,11 +219,11 @@ static int ieee80211_open(struct net_device *dev)
                        res = local->ops->start(local_to_hw(local));
                if (res)
                        return res;
-               ieee80211_hw_config(local);
+               need_hw_reconfig = 1;
                ieee80211_led_radio(local, local->hw.conf.radio_enabled);
        }
 
-       switch (sdata->type) {
+       switch (sdata->vif.type) {
        case IEEE80211_IF_TYPE_VLAN:
                list_add(&sdata->u.vlan.list, &sdata->u.vlan.ap->u.ap.vlans);
                /* no need to tell driver */
@@ -244,7 +245,7 @@ static int ieee80211_open(struct net_device *dev)
                /* fall through */
        default:
                conf.vif = &sdata->vif;
-               conf.type = sdata->type;
+               conf.type = sdata->vif.type;
                conf.mac_addr = dev->dev_addr;
                res = local->ops->add_interface(local_to_hw(local), &conf);
                if (res && !local->open_count && local->ops->stop)
@@ -256,7 +257,7 @@ static int ieee80211_open(struct net_device *dev)
                ieee80211_reset_erp_info(dev);
                ieee80211_enable_keys(sdata);
 
-               if (sdata->type == IEEE80211_IF_TYPE_STA &&
+               if (sdata->vif.type == IEEE80211_IF_TYPE_STA &&
                    !(sdata->flags & IEEE80211_SDATA_USERSPACE_MLME))
                        netif_carrier_off(dev);
                else
@@ -282,6 +283,8 @@ static int ieee80211_open(struct net_device *dev)
                atomic_inc(&local->iff_promiscs);
 
        local->open_count++;
+       if (need_hw_reconfig)
+               ieee80211_hw_config(local);
 
        netif_start_queue(dev);
 
@@ -299,9 +302,11 @@ static int ieee80211_stop(struct net_device *dev)
        sdata = IEEE80211_DEV_TO_SUB_IF(dev);
 
        list_for_each_entry(sta, &local->sta_list, list) {
-               for (i = 0; i <  STA_TID_NUM; i++)
-                       ieee80211_sta_stop_rx_ba_session(sta->dev, sta->addr,
-                                               i, WLAN_BACK_RECIPIENT,
+               if (sta->dev == dev)
+                       for (i = 0; i <  STA_TID_NUM; i++)
+                               ieee80211_sta_stop_rx_ba_session(sta->dev,
+                                               sta->addr, i,
+                                               WLAN_BACK_RECIPIENT,
                                                WLAN_REASON_QSTA_LEAVE_QBSS);
        }
 
@@ -321,10 +326,17 @@ static int ieee80211_stop(struct net_device *dev)
 
        dev_mc_unsync(local->mdev, dev);
 
-       /* down all dependent devices, that is VLANs */
-       if (sdata->type == IEEE80211_IF_TYPE_AP) {
+       /* APs need special treatment */
+       if (sdata->vif.type == IEEE80211_IF_TYPE_AP) {
                struct ieee80211_sub_if_data *vlan, *tmp;
+               struct beacon_data *old_beacon = sdata->u.ap.beacon;
+
+               /* remove beacon */
+               rcu_assign_pointer(sdata->u.ap.beacon, NULL);
+               synchronize_rcu();
+               kfree(old_beacon);
 
+               /* down all dependent devices, that is VLANs */
                list_for_each_entry_safe(vlan, tmp, &sdata->u.ap.vlans,
                                         u.vlan.list)
                        dev_close(vlan->dev);
@@ -333,7 +345,7 @@ static int ieee80211_stop(struct net_device *dev)
 
        local->open_count--;
 
-       switch (sdata->type) {
+       switch (sdata->vif.type) {
        case IEEE80211_IF_TYPE_VLAN:
                list_del(&sdata->u.vlan.list);
                sdata->u.vlan.ap = NULL;
@@ -379,7 +391,7 @@ static int ieee80211_stop(struct net_device *dev)
                /* fall through */
        default:
                conf.vif = &sdata->vif;
-               conf.type = sdata->type;
+               conf.type = sdata->vif.type;
                conf.mac_addr = dev->dev_addr;
                /* disable all keys for as long as this netdev is down */
                ieee80211_disable_keys(sdata);
@@ -402,6 +414,329 @@ static int ieee80211_stop(struct net_device *dev)
        return 0;
 }
 
+int ieee80211_start_tx_ba_session(struct ieee80211_hw *hw, u8 *ra, u16 tid)
+{
+       struct ieee80211_local *local = hw_to_local(hw);
+       struct sta_info *sta;
+       struct ieee80211_sub_if_data *sdata;
+       u16 start_seq_num = 0;
+       u8 *state;
+       int ret;
+       DECLARE_MAC_BUF(mac);
+
+       if (tid >= STA_TID_NUM)
+               return -EINVAL;
+
+#ifdef CONFIG_MAC80211_HT_DEBUG
+       printk(KERN_DEBUG "Open BA session requested for %s tid %u\n",
+                               print_mac(mac, ra), tid);
+#endif /* CONFIG_MAC80211_HT_DEBUG */
+
+       sta = sta_info_get(local, ra);
+       if (!sta) {
+               printk(KERN_DEBUG "Could not find the station\n");
+               return -ENOENT;
+       }
+
+       spin_lock_bh(&sta->ampdu_mlme.ampdu_tx);
+
+       /* we have tried too many times, receiver does not want A-MPDU */
+       if (sta->ampdu_mlme.tid_tx[tid].addba_req_num > HT_AGG_MAX_RETRIES) {
+               ret = -EBUSY;
+               goto start_ba_exit;
+       }
+
+       state = &sta->ampdu_mlme.tid_tx[tid].state;
+       /* check if the TID is not in aggregation flow already */
+       if (*state != HT_AGG_STATE_IDLE) {
+#ifdef CONFIG_MAC80211_HT_DEBUG
+               printk(KERN_DEBUG "BA request denied - session is not "
+                                "idle on tid %u\n", tid);
+#endif /* CONFIG_MAC80211_HT_DEBUG */
+               ret = -EAGAIN;
+               goto start_ba_exit;
+       }
+
+       /* ensure that TX flow won't interrupt us
+        * until the end of the call to requeue function */
+       spin_lock_bh(&local->mdev->queue_lock);
+
+       /* create a new queue for this aggregation */
+       ret = ieee80211_ht_agg_queue_add(local, sta, tid);
+
+       /* case no queue is available to aggregation
+        * don't switch to aggregation */
+       if (ret) {
+#ifdef CONFIG_MAC80211_HT_DEBUG
+               printk(KERN_DEBUG "BA request denied - no queue available for"
+                                       " tid %d\n", tid);
+#endif /* CONFIG_MAC80211_HT_DEBUG */
+               spin_unlock_bh(&local->mdev->queue_lock);
+               goto start_ba_exit;
+       }
+       sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev);
+
+       /* Ok, the Addba frame hasn't been sent yet, but if the driver calls the
+        * call back right away, it must see that the flow has begun */
+       *state |= HT_ADDBA_REQUESTED_MSK;
+
+       if (local->ops->ampdu_action)
+               ret = local->ops->ampdu_action(hw, IEEE80211_AMPDU_TX_START,
+                                               ra, tid, &start_seq_num);
+
+       if (ret) {
+               /* No need to requeue the packets in the agg queue, since we
+                * held the tx lock: no packet could be enqueued to the newly
+                * allocated queue */
+                ieee80211_ht_agg_queue_remove(local, sta, tid, 0);
+#ifdef CONFIG_MAC80211_HT_DEBUG
+               printk(KERN_DEBUG "BA request denied - HW or queue unavailable"
+                               " for tid %d\n", tid);
+#endif /* CONFIG_MAC80211_HT_DEBUG */
+               spin_unlock_bh(&local->mdev->queue_lock);
+               *state = HT_AGG_STATE_IDLE;
+               goto start_ba_exit;
+       }
+
+       /* Will put all the packets in the new SW queue */
+       ieee80211_requeue(local, ieee802_1d_to_ac[tid]);
+       spin_unlock_bh(&local->mdev->queue_lock);
+
+       /* We have most probably almost emptied the legacy queue */
+       /* ieee80211_wake_queue(local_to_hw(local), ieee802_1d_to_ac[tid]); */
+
+       /* send an addBA request */
+       sta->ampdu_mlme.dialog_token_allocator++;
+       sta->ampdu_mlme.tid_tx[tid].dialog_token =
+                       sta->ampdu_mlme.dialog_token_allocator;
+       sta->ampdu_mlme.tid_tx[tid].ssn = start_seq_num;
+
+       ieee80211_send_addba_request(sta->dev, ra, tid,
+                        sta->ampdu_mlme.tid_tx[tid].dialog_token,
+                        sta->ampdu_mlme.tid_tx[tid].ssn,
+                        0x40, 5000);
+
+       /* activate the timer for the recipient's addBA response */
+       sta->ampdu_mlme.tid_tx[tid].addba_resp_timer.expires =
+                               jiffies + ADDBA_RESP_INTERVAL;
+       add_timer(&sta->ampdu_mlme.tid_tx[tid].addba_resp_timer);
+       printk(KERN_DEBUG "activated addBA response timer on tid %d\n", tid);
+
+start_ba_exit:
+       spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx);
+       sta_info_put(sta);
+       return ret;
+}
+EXPORT_SYMBOL(ieee80211_start_tx_ba_session);
+
+int ieee80211_stop_tx_ba_session(struct ieee80211_hw *hw,
+                                u8 *ra, u16 tid,
+                                enum ieee80211_back_parties initiator)
+{
+       struct ieee80211_local *local = hw_to_local(hw);
+       struct sta_info *sta;
+       u8 *state;
+       int ret = 0;
+       DECLARE_MAC_BUF(mac);
+
+       if (tid >= STA_TID_NUM)
+               return -EINVAL;
+
+#ifdef CONFIG_MAC80211_HT_DEBUG
+       printk(KERN_DEBUG "Stop a BA session requested for %s tid %u\n",
+                               print_mac(mac, ra), tid);
+#endif /* CONFIG_MAC80211_HT_DEBUG */
+
+       sta = sta_info_get(local, ra);
+       if (!sta)
+               return -ENOENT;
+
+       /* check if the TID is in aggregation */
+       state = &sta->ampdu_mlme.tid_tx[tid].state;
+       spin_lock_bh(&sta->ampdu_mlme.ampdu_tx);
+
+       if (*state != HT_AGG_STATE_OPERATIONAL) {
+#ifdef CONFIG_MAC80211_HT_DEBUG
+               printk(KERN_DEBUG "Try to stop Tx aggregation on"
+                               " non active TID\n");
+#endif /* CONFIG_MAC80211_HT_DEBUG */
+               ret = -ENOENT;
+               goto stop_BA_exit;
+       }
+
+       ieee80211_stop_queue(hw, sta->tid_to_tx_q[tid]);
+
+       *state = HT_AGG_STATE_REQ_STOP_BA_MSK |
+               (initiator << HT_AGG_STATE_INITIATOR_SHIFT);
+
+       if (local->ops->ampdu_action)
+               ret = local->ops->ampdu_action(hw, IEEE80211_AMPDU_TX_STOP,
+                                               ra, tid, NULL);
+
+       /* case HW denied going back to legacy */
+       if (ret) {
+               WARN_ON(ret != -EBUSY);
+               *state = HT_AGG_STATE_OPERATIONAL;
+               ieee80211_wake_queue(hw, sta->tid_to_tx_q[tid]);
+               goto stop_BA_exit;
+       }
+
+stop_BA_exit:
+       spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx);
+       sta_info_put(sta);
+       return ret;
+}
+EXPORT_SYMBOL(ieee80211_stop_tx_ba_session);
+
+void ieee80211_start_tx_ba_cb(struct ieee80211_hw *hw, u8 *ra, u16 tid)
+{
+       struct ieee80211_local *local = hw_to_local(hw);
+       struct sta_info *sta;
+       u8 *state;
+       DECLARE_MAC_BUF(mac);
+
+       if (tid >= STA_TID_NUM) {
+               printk(KERN_DEBUG "Bad TID value: tid = %d (>= %d)\n",
+                               tid, STA_TID_NUM);
+               return;
+       }
+
+       sta = sta_info_get(local, ra);
+       if (!sta) {
+               printk(KERN_DEBUG "Could not find station: %s\n",
+                               print_mac(mac, ra));
+               return;
+       }
+
+       state = &sta->ampdu_mlme.tid_tx[tid].state;
+       spin_lock_bh(&sta->ampdu_mlme.ampdu_tx);
+
+       if (!(*state & HT_ADDBA_REQUESTED_MSK)) {
+               printk(KERN_DEBUG "addBA was not requested yet, state is %d\n",
+                               *state);
+               spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx);
+               sta_info_put(sta);
+               return;
+       }
+
+       WARN_ON_ONCE(*state & HT_ADDBA_DRV_READY_MSK);
+
+       *state |= HT_ADDBA_DRV_READY_MSK;
+
+       if (*state == HT_AGG_STATE_OPERATIONAL) {
+               printk(KERN_DEBUG "Aggregation is on for tid %d \n", tid);
+               ieee80211_wake_queue(hw, sta->tid_to_tx_q[tid]);
+       }
+       spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx);
+       sta_info_put(sta);
+}
+EXPORT_SYMBOL(ieee80211_start_tx_ba_cb);
+
+void ieee80211_stop_tx_ba_cb(struct ieee80211_hw *hw, u8 *ra, u8 tid)
+{
+       struct ieee80211_local *local = hw_to_local(hw);
+       struct sta_info *sta;
+       u8 *state;
+       int agg_queue;
+       DECLARE_MAC_BUF(mac);
+
+       if (tid >= STA_TID_NUM) {
+               printk(KERN_DEBUG "Bad TID value: tid = %d (>= %d)\n",
+                               tid, STA_TID_NUM);
+               return;
+       }
+
+       printk(KERN_DEBUG "Stop a BA session requested on DA %s tid %d\n",
+                               print_mac(mac, ra), tid);
+
+       sta = sta_info_get(local, ra);
+       if (!sta) {
+               printk(KERN_DEBUG "Could not find station: %s\n",
+                               print_mac(mac, ra));
+               return;
+       }
+       state = &sta->ampdu_mlme.tid_tx[tid].state;
+
+       spin_lock_bh(&sta->ampdu_mlme.ampdu_tx);
+       if ((*state & HT_AGG_STATE_REQ_STOP_BA_MSK) == 0) {
+               printk(KERN_DEBUG "unexpected callback to A-MPDU stop\n");
+               sta_info_put(sta);
+               spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx);
+               return;
+       }
+
+       if (*state & HT_AGG_STATE_INITIATOR_MSK)
+               ieee80211_send_delba(sta->dev, ra, tid,
+                       WLAN_BACK_INITIATOR, WLAN_REASON_QSTA_NOT_USE);
+
+       agg_queue = sta->tid_to_tx_q[tid];
+
+       /* avoid ordering issues: we are the only one that can modify
+        * the content of the qdiscs */
+       spin_lock_bh(&local->mdev->queue_lock);
+       /* remove the queue for this aggregation */
+       ieee80211_ht_agg_queue_remove(local, sta, tid, 1);
+       spin_unlock_bh(&local->mdev->queue_lock);
+
+       /* we just requeued the all the frames that were in the removed
+        * queue, and since we might miss a softirq we do netif_schedule.
+        * ieee80211_wake_queue is not used here as this queue is not
+        * necessarily stopped */
+       netif_schedule(local->mdev);
+       *state = HT_AGG_STATE_IDLE;
+       sta->ampdu_mlme.tid_tx[tid].addba_req_num = 0;
+       spin_unlock_bh(&sta->ampdu_mlme.ampdu_tx);
+
+       sta_info_put(sta);
+}
+EXPORT_SYMBOL(ieee80211_stop_tx_ba_cb);
+
+void ieee80211_start_tx_ba_cb_irqsafe(struct ieee80211_hw *hw,
+                                     const u8 *ra, u16 tid)
+{
+       struct ieee80211_local *local = hw_to_local(hw);
+       struct ieee80211_ra_tid *ra_tid;
+       struct sk_buff *skb = dev_alloc_skb(0);
+
+       if (unlikely(!skb)) {
+               if (net_ratelimit())
+                       printk(KERN_WARNING "%s: Not enough memory, "
+                              "dropping start BA session", skb->dev->name);
+               return;
+       }
+       ra_tid = (struct ieee80211_ra_tid *) &skb->cb;
+       memcpy(&ra_tid->ra, ra, ETH_ALEN);
+       ra_tid->tid = tid;
+
+       skb->pkt_type = IEEE80211_ADDBA_MSG;
+       skb_queue_tail(&local->skb_queue, skb);
+       tasklet_schedule(&local->tasklet);
+}
+EXPORT_SYMBOL(ieee80211_start_tx_ba_cb_irqsafe);
+
+void ieee80211_stop_tx_ba_cb_irqsafe(struct ieee80211_hw *hw,
+                                    const u8 *ra, u16 tid)
+{
+       struct ieee80211_local *local = hw_to_local(hw);
+       struct ieee80211_ra_tid *ra_tid;
+       struct sk_buff *skb = dev_alloc_skb(0);
+
+       if (unlikely(!skb)) {
+               if (net_ratelimit())
+                       printk(KERN_WARNING "%s: Not enough memory, "
+                              "dropping stop BA session", skb->dev->name);
+               return;
+       }
+       ra_tid = (struct ieee80211_ra_tid *) &skb->cb;
+       memcpy(&ra_tid->ra, ra, ETH_ALEN);
+       ra_tid->tid = tid;
+
+       skb->pkt_type = IEEE80211_DELBA_MSG;
+       skb_queue_tail(&local->skb_queue, skb);
+       tasklet_schedule(&local->tasklet);
+}
+EXPORT_SYMBOL(ieee80211_stop_tx_ba_cb_irqsafe);
+
 static void ieee80211_set_multicast_list(struct net_device *dev)
 {
        struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
@@ -502,13 +837,13 @@ static int __ieee80211_if_config(struct net_device *dev,
                return 0;
 
        memset(&conf, 0, sizeof(conf));
-       conf.type = sdata->type;
-       if (sdata->type == IEEE80211_IF_TYPE_STA ||
-           sdata->type == IEEE80211_IF_TYPE_IBSS) {
+       conf.type = sdata->vif.type;
+       if (sdata->vif.type == IEEE80211_IF_TYPE_STA ||
+           sdata->vif.type == IEEE80211_IF_TYPE_IBSS) {
                conf.bssid = sdata->u.sta.bssid;
                conf.ssid = sdata->u.sta.ssid;
                conf.ssid_len = sdata->u.sta.ssid_len;
-       } else if (sdata->type == IEEE80211_IF_TYPE_AP) {
+       } else if (sdata->vif.type == IEEE80211_IF_TYPE_AP) {
                conf.ssid = sdata->u.ap.ssid;
                conf.ssid_len = sdata->u.ap.ssid_len;
                conf.beacon = beacon;
@@ -541,37 +876,28 @@ int ieee80211_if_config_beacon(struct net_device *dev)
 
 int ieee80211_hw_config(struct ieee80211_local *local)
 {
-       struct ieee80211_hw_mode *mode;
        struct ieee80211_channel *chan;
        int ret = 0;
 
-       if (local->sta_sw_scanning) {
+       if (local->sta_sw_scanning)
                chan = local->scan_channel;
-               mode = local->scan_hw_mode;
-       } else {
+       else
                chan = local->oper_channel;
-               mode = local->oper_hw_mode;
-       }
 
-       local->hw.conf.channel = chan->chan;
-       local->hw.conf.channel_val = chan->val;
-       if (!local->hw.conf.power_level) {
-               local->hw.conf.power_level = chan->power_level;
-       } else {
-               local->hw.conf.power_level = min(chan->power_level,
-                                                local->hw.conf.power_level);
-       }
-       local->hw.conf.freq = chan->freq;
-       local->hw.conf.phymode = mode->mode;
-       local->hw.conf.antenna_max = chan->antenna_max;
-       local->hw.conf.chan = chan;
-       local->hw.conf.mode = mode;
+       local->hw.conf.channel = chan;
+
+       if (!local->hw.conf.power_level)
+               local->hw.conf.power_level = chan->max_power;
+       else
+               local->hw.conf.power_level = min(chan->max_power,
+                                              local->hw.conf.power_level);
+
+       local->hw.conf.max_antenna_gain = chan->max_antenna_gain;
 
 #ifdef CONFIG_MAC80211_VERBOSE_DEBUG
-       printk(KERN_DEBUG "HW CONFIG: channel=%d freq=%d "
-              "phymode=%d\n", local->hw.conf.channel, local->hw.conf.freq,
-              local->hw.conf.phymode);
-#endif /* CONFIG_MAC80211_VERBOSE_DEBUG */
+       printk(KERN_DEBUG "%s: HW CONFIG: freq=%d\n",
+              wiphy_name(local->hw.wiphy), chan->center_freq);
+#endif
 
        if (local->open_count)
                ret = local->ops->config(local_to_hw(local), &local->hw.conf);
@@ -589,11 +915,13 @@ int ieee80211_hw_config_ht(struct ieee80211_local *local, int enable_ht,
                           struct ieee80211_ht_bss_info *req_bss_cap)
 {
        struct ieee80211_conf *conf = &local->hw.conf;
-       struct ieee80211_hw_mode *mode = conf->mode;
+       struct ieee80211_supported_band *sband;
        int i;
 
+       sband = local->hw.wiphy->bands[conf->channel->band];
+
        /* HT is not supported */
-       if (!mode->ht_info.ht_supported) {
+       if (!sband->ht_info.ht_supported) {
                conf->flags &= ~IEEE80211_CONF_SUPPORT_HT_MODE;
                return -EOPNOTSUPP;
        }
@@ -603,17 +931,17 @@ int ieee80211_hw_config_ht(struct ieee80211_local *local, int enable_ht,
                conf->flags &= ~IEEE80211_CONF_SUPPORT_HT_MODE;
        } else {
                conf->flags |= IEEE80211_CONF_SUPPORT_HT_MODE;
-               conf->ht_conf.cap = req_ht_cap->cap & mode->ht_info.cap;
+               conf->ht_conf.cap = req_ht_cap->cap & sband->ht_info.cap;
                conf->ht_conf.cap &= ~(IEEE80211_HT_CAP_MIMO_PS);
                conf->ht_conf.cap |=
-                       mode->ht_info.cap & IEEE80211_HT_CAP_MIMO_PS;
+                       sband->ht_info.cap & IEEE80211_HT_CAP_MIMO_PS;
                conf->ht_bss_conf.primary_channel =
                        req_bss_cap->primary_channel;
                conf->ht_bss_conf.bss_cap = req_bss_cap->bss_cap;
                conf->ht_bss_conf.bss_op_mode = req_bss_cap->bss_op_mode;
                for (i = 0; i < SUPP_MCS_SET_LEN; i++)
                        conf->ht_conf.supp_mcs_set[i] =
-                               mode->ht_info.supp_mcs_set[i] &
+                               sband->ht_info.supp_mcs_set[i] &
                                  req_ht_cap->supp_mcs_set[i];
 
                /* In STA mode, this gives us indication
@@ -628,25 +956,30 @@ int ieee80211_hw_config_ht(struct ieee80211_local *local, int enable_ht,
        return 0;
 }
 
-void ieee80211_erp_info_change_notify(struct net_device *dev, u8 changes)
+void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata,
+                                     u32 changed)
 {
-       struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
-       struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
-       if (local->ops->erp_ie_changed)
-               local->ops->erp_ie_changed(local_to_hw(local), changes,
-                       !!(sdata->flags & IEEE80211_SDATA_USE_PROTECTION),
-                       !(sdata->flags & IEEE80211_SDATA_SHORT_PREAMBLE));
+       struct ieee80211_local *local = sdata->local;
+
+       if (!changed)
+               return;
+
+       if (local->ops->bss_info_changed)
+               local->ops->bss_info_changed(local_to_hw(local),
+                                            &sdata->vif,
+                                            &sdata->bss_conf,
+                                            changed);
 }
 
 void ieee80211_reset_erp_info(struct net_device *dev)
 {
        struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
 
-       sdata->flags &= ~(IEEE80211_SDATA_USE_PROTECTION |
-                       IEEE80211_SDATA_SHORT_PREAMBLE);
-       ieee80211_erp_info_change_notify(dev,
-                                        IEEE80211_ERP_CHANGE_PROTECTION |
-                                        IEEE80211_ERP_CHANGE_PREAMBLE);
+       sdata->bss_conf.use_cts_prot = 0;
+       sdata->bss_conf.use_short_preamble = 0;
+       ieee80211_bss_info_change_notify(sdata,
+                                        BSS_CHANGED_ERP_CTS_PROT |
+                                        BSS_CHANGED_ERP_PREAMBLE);
 }
 
 void ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw,
@@ -696,6 +1029,7 @@ static void ieee80211_tasklet_handler(unsigned long data)
        struct sk_buff *skb;
        struct ieee80211_rx_status rx_status;
        struct ieee80211_tx_status *tx_status;
+       struct ieee80211_ra_tid *ra_tid;
 
        while ((skb = skb_dequeue(&local->skb_queue)) ||
               (skb = skb_dequeue(&local->skb_queue_unreliable))) {
@@ -703,7 +1037,7 @@ static void ieee80211_tasklet_handler(unsigned long data)
                case IEEE80211_RX_MSG:
                        /* status is in skb->cb */
                        memcpy(&rx_status, skb->cb, sizeof(rx_status));
-                       /* Clear skb->type in order to not confuse kernel
+                       /* Clear skb->pkt_type in order to not confuse kernel
                         * netstack. */
                        skb->pkt_type = 0;
                        __ieee80211_rx(local_to_hw(local), skb, &rx_status);
@@ -716,6 +1050,18 @@ static void ieee80211_tasklet_handler(unsigned long data)
                                            skb, tx_status);
                        kfree(tx_status);
                        break;
+               case IEEE80211_DELBA_MSG:
+                       ra_tid = (struct ieee80211_ra_tid *) &skb->cb;
+                       ieee80211_stop_tx_ba_cb(local_to_hw(local),
+                                               ra_tid->ra, ra_tid->tid);
+                       dev_kfree_skb(skb);
+                       break;
+               case IEEE80211_ADDBA_MSG:
+                       ra_tid = (struct ieee80211_ra_tid *) &skb->cb;
+                       ieee80211_start_tx_ba_cb(local_to_hw(local),
+                                                ra_tid->ra, ra_tid->tid);
+                       dev_kfree_skb(skb);
+                       break ;
                default: /* should never get here! */
                        printk(KERN_ERR "%s: Unknown message type (%d)\n",
                               wiphy_name(local->hw.wiphy), skb->pkt_type);
@@ -962,7 +1308,7 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb,
                if (!monitors || !skb)
                        goto out;
 
-               if (sdata->type == IEEE80211_IF_TYPE_MNTR) {
+               if (sdata->vif.type == IEEE80211_IF_TYPE_MNTR) {
                        if (!netif_running(sdata->dev))
                                continue;
                        monitors--;
@@ -1054,7 +1400,6 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
        local->hw.queues = 1; /* default */
 
        local->mdev = mdev;
-       local->rx_pre_handlers = ieee80211_rx_pre_handlers;
        local->rx_handlers = ieee80211_rx_handlers;
        local->tx_handlers = ieee80211_tx_handlers;
 
@@ -1066,10 +1411,6 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
        local->long_retry_limit = 4;
        local->hw.conf.radio_enabled = 1;
 
-       local->enabled_modes = ~0;
-
-       INIT_LIST_HEAD(&local->modes_list);
-
        INIT_LIST_HEAD(&local->interfaces);
 
        INIT_DELAYED_WORK(&local->scan_work, ieee80211_sta_scan_work);
@@ -1084,7 +1425,7 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
        mdev->header_ops = &ieee80211_header_ops;
        mdev->set_multicast_list = ieee80211_master_set_multicast_list;
 
-       sdata->type = IEEE80211_IF_TYPE_AP;
+       sdata->vif.type = IEEE80211_IF_TYPE_AP;
        sdata->dev = mdev;
        sdata->local = local;
        sdata->u.ap.force_unicast_rateidx = -1;
@@ -1114,6 +1455,25 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
        struct ieee80211_local *local = hw_to_local(hw);
        const char *name;
        int result;
+       enum ieee80211_band band;
+
+       /*
+        * generic code guarantees at least one band,
+        * set this very early because much code assumes
+        * that hw.conf.channel is assigned
+        */
+       for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
+               struct ieee80211_supported_band *sband;
+
+               sband = local->hw.wiphy->bands[band];
+               if (sband) {
+                       /* init channel we're on */
+                       local->hw.conf.channel =
+                       local->oper_channel =
+                       local->scan_channel = &sband->channels[0];
+                       break;
+               }
+       }
 
        result = wiphy_register(local->hw.wiphy);
        if (result < 0)
@@ -1215,44 +1575,10 @@ fail_workqueue:
 }
 EXPORT_SYMBOL(ieee80211_register_hw);
 
-int ieee80211_register_hwmode(struct ieee80211_hw *hw,
-                             struct ieee80211_hw_mode *mode)
-{
-       struct ieee80211_local *local = hw_to_local(hw);
-       struct ieee80211_rate *rate;
-       int i;
-
-       INIT_LIST_HEAD(&mode->list);
-       list_add_tail(&mode->list, &local->modes_list);
-
-       local->hw_modes |= (1 << mode->mode);
-       for (i = 0; i < mode->num_rates; i++) {
-               rate = &(mode->rates[i]);
-               rate->rate_inv = CHAN_UTIL_RATE_LCM / rate->rate;
-       }
-       ieee80211_prepare_rates(local, mode);
-
-       if (!local->oper_hw_mode) {
-               /* Default to this mode */
-               local->hw.conf.phymode = mode->mode;
-               local->oper_hw_mode = local->scan_hw_mode = mode;
-               local->oper_channel = local->scan_channel = &mode->channels[0];
-               local->hw.conf.mode = local->oper_hw_mode;
-               local->hw.conf.chan = local->oper_channel;
-       }
-
-       if (!(hw->flags & IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED))
-               ieee80211_set_default_regdomain(mode);
-
-       return 0;
-}
-EXPORT_SYMBOL(ieee80211_register_hwmode);
-
 void ieee80211_unregister_hw(struct ieee80211_hw *hw)
 {
        struct ieee80211_local *local = hw_to_local(hw);
        struct ieee80211_sub_if_data *sdata, *tmp;
-       int i;
 
        tasklet_kill(&local->tx_pending_tasklet);
        tasklet_kill(&local->tasklet);
@@ -1293,11 +1619,6 @@ void ieee80211_unregister_hw(struct ieee80211_hw *hw)
        rate_control_deinitialize(local);
        debugfs_hw_del(local);
 
-       for (i = 0; i < NUM_IEEE80211_MODES; i++) {
-               kfree(local->supp_rates[i]);
-               kfree(local->basic_rates[i]);
-       }
-
        if (skb_queue_len(&local->skb_queue)
                        || skb_queue_len(&local->skb_queue_unreliable))
                printk(KERN_WARNING "%s: skb_queue not empty\n",
@@ -1330,29 +1651,28 @@ static int __init ieee80211_init(void)
 
        ret = rc80211_simple_init();
        if (ret)
-               goto fail;
+               goto out;
 
        ret = rc80211_pid_init();
        if (ret)
-               goto fail_simple;
+               goto out_cleanup_simple;
 
        ret = ieee80211_wme_register();
        if (ret) {
                printk(KERN_DEBUG "ieee80211_init: failed to "
                       "initialize WME (err=%d)\n", ret);
-               goto fail_pid;
+               goto out_cleanup_pid;
        }
 
        ieee80211_debugfs_netdev_init();
-       ieee80211_regdomain_init();
 
        return 0;
 
- fail_pid:
-       rc80211_simple_exit();
- fail_simple:
+ out_cleanup_pid:
        rc80211_pid_exit();
- fail:
+ out_cleanup_simple:
+       rc80211_simple_exit();
+ out:
        return ret;
 }