]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - net/mac80211/main.c
mac80211: simplify key locking
[mirror_ubuntu-artful-kernel.git] / net / mac80211 / main.c
index b887e484ae04427d3ec2118c13e9238c5fc650e9..045ead9507aa797e814cfe2b00853ff6b5f1268e 100644 (file)
@@ -71,7 +71,7 @@ void ieee80211_configure_filter(struct ieee80211_local *local)
        spin_lock_bh(&local->filter_lock);
        changed_flags = local->filter_flags ^ new_flags;
 
-       mc = drv_prepare_multicast(local, local->mc_count, local->mc_list);
+       mc = drv_prepare_multicast(local, &local->mc_list);
        spin_unlock_bh(&local->filter_lock);
 
        /* be a bit nasty */
@@ -111,7 +111,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
                channel_type = local->tmp_channel_type;
        } else {
                chan = local->oper_channel;
-               channel_type = local->oper_channel_type;
+               channel_type = local->_oper_channel_type;
        }
 
        if (chan != local->hw.conf.channel ||
@@ -309,6 +309,8 @@ void ieee80211_restart_hw(struct ieee80211_hw *hw)
 {
        struct ieee80211_local *local = hw_to_local(hw);
 
+       trace_api_restart_hw(local);
+
        /* use this reason, __ieee80211_resume will unblock it */
        ieee80211_stop_queues_by_reason(hw,
                IEEE80211_QUEUE_STOP_REASON_SUSPEND);
@@ -327,6 +329,58 @@ static void ieee80211_recalc_smps_work(struct work_struct *work)
        mutex_unlock(&local->iflist_mtx);
 }
 
+int ieee80211_set_arp_filter(struct ieee80211_sub_if_data *sdata)
+{
+       struct in_device *idev;
+       int ret = 0;
+
+       BUG_ON(!sdata);
+       ASSERT_RTNL();
+
+       idev = sdata->dev->ip_ptr;
+       if (!idev)
+               return 0;
+
+       ret = drv_configure_arp_filter(sdata->local, &sdata->vif,
+                                      idev->ifa_list);
+       return ret;
+}
+
+static int ieee80211_ifa_changed(struct notifier_block *nb,
+                                unsigned long data, void *arg)
+{
+       struct in_ifaddr *ifa = arg;
+       struct ieee80211_local *local =
+               container_of(nb, struct ieee80211_local,
+                            ifa_notifier);
+       struct net_device *ndev = ifa->ifa_dev->dev;
+       struct wireless_dev *wdev = ndev->ieee80211_ptr;
+       struct ieee80211_sub_if_data *sdata;
+       struct ieee80211_if_managed *ifmgd;
+
+       /* Make sure it's our interface that got changed */
+       if (!wdev)
+               return NOTIFY_DONE;
+
+       if (wdev->wiphy != local->hw.wiphy)
+               return NOTIFY_DONE;
+
+       /* We are concerned about IP addresses only when associated */
+       sdata = IEEE80211_DEV_TO_SUB_IF(ndev);
+
+       /* ARP filtering is only supported in managed mode */
+       if (sdata->vif.type != NL80211_IFTYPE_STATION)
+               return NOTIFY_DONE;
+
+       ifmgd = &sdata->u.mgd;
+       mutex_lock(&ifmgd->mtx);
+       if (ifmgd->associated)
+               ieee80211_set_arp_filter(sdata);
+       mutex_unlock(&ifmgd->mtx);
+
+       return NOTIFY_DONE;
+}
+
 struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
                                        const struct ieee80211_ops *ops)
 {
@@ -388,10 +442,13 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
        local->uapsd_max_sp_len = IEEE80211_DEFAULT_MAX_SP_LEN;
 
        INIT_LIST_HEAD(&local->interfaces);
+
+       __hw_addr_init(&local->mc_list);
+
        mutex_init(&local->iflist_mtx);
        mutex_init(&local->scan_mtx);
 
-       spin_lock_init(&local->key_lock);
+       mutex_init(&local->key_mtx);
        spin_lock_init(&local->filter_lock);
        spin_lock_init(&local->queue_stop_reason_lock);
 
@@ -437,7 +494,7 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
        struct ieee80211_local *local = hw_to_local(hw);
        int result;
        enum ieee80211_band band;
-       int channels, i, j, max_bitrates;
+       int channels, max_bitrates;
        bool supp_ht;
        static const u32 cipher_suites[] = {
                WLAN_CIPHER_SUITE_WEP40,
@@ -567,6 +624,8 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
 
        local->hw.conf.listen_interval = local->hw.max_listen_interval;
 
+       local->hw.conf.dynamic_ps_forced_timeout = -1;
+
        result = sta_info_start(local);
        if (result < 0)
                goto fail_sta_info;
@@ -601,33 +660,26 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
 
        ieee80211_led_init(local);
 
-       /* alloc internal scan request */
-       i = 0;
-       local->int_scan_req->ssids = &local->scan_ssid;
-       local->int_scan_req->n_ssids = 1;
-       for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
-               if (!hw->wiphy->bands[band])
-                       continue;
-               for (j = 0; j < hw->wiphy->bands[band]->n_channels; j++) {
-                       local->int_scan_req->channels[i] =
-                               &hw->wiphy->bands[band]->channels[j];
-                       i++;
-               }
-       }
-       local->int_scan_req->n_channels = i;
-
        local->network_latency_notifier.notifier_call =
                ieee80211_max_network_latency;
        result = pm_qos_add_notifier(PM_QOS_NETWORK_LATENCY,
                                     &local->network_latency_notifier);
-
        if (result) {
                rtnl_lock();
                goto fail_pm_qos;
        }
 
+       local->ifa_notifier.notifier_call = ieee80211_ifa_changed;
+       result = register_inetaddr_notifier(&local->ifa_notifier);
+       if (result)
+               goto fail_ifa;
+
        return 0;
 
+ fail_ifa:
+       pm_qos_remove_notifier(PM_QOS_NETWORK_LATENCY,
+                              &local->network_latency_notifier);
+       rtnl_lock();
  fail_pm_qos:
        ieee80211_led_exit(local);
        ieee80211_remove_interfaces(local);
@@ -655,6 +707,7 @@ void ieee80211_unregister_hw(struct ieee80211_hw *hw)
 
        pm_qos_remove_notifier(PM_QOS_NETWORK_LATENCY,
                               &local->network_latency_notifier);
+       unregister_inetaddr_notifier(&local->ifa_notifier);
 
        rtnl_lock();
 
@@ -712,6 +765,10 @@ static int __init ieee80211_init(void)
        if (ret)
                return ret;
 
+       ret = rc80211_minstrel_ht_init();
+       if (ret)
+               goto err_minstrel;
+
        ret = rc80211_pid_init();
        if (ret)
                goto err_pid;
@@ -724,6 +781,8 @@ static int __init ieee80211_init(void)
  err_netdev:
        rc80211_pid_exit();
  err_pid:
+       rc80211_minstrel_ht_exit();
+ err_minstrel:
        rc80211_minstrel_exit();
 
        return ret;
@@ -732,6 +791,7 @@ static int __init ieee80211_init(void)
 static void __exit ieee80211_exit(void)
 {
        rc80211_pid_exit();
+       rc80211_minstrel_ht_exit();
        rc80211_minstrel_exit();
 
        /*