mac80211: assign bss_conf.bssid only once
authorJohannes Berg <johannes.berg@intel.com>
Fri, 14 Dec 2012 13:34:25 +0000 (14:34 +0100)
committerJohannes Berg <johannes.berg@intel.com>
Thu, 3 Jan 2013 12:01:37 +0000 (13:01 +0100)
Instead of checking every time bss_info_changed is called,
assign the pointer once depending on the interface type
and then leave it untouched until the interface type is
changed. This makes the ieee80211_bss_info_change_notify()
now a simple wrapper to call the driver only.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/driver-ops.h
net/mac80211/iface.c
net/mac80211/main.c
net/mac80211/mesh.c
net/mac80211/pm.c

index cccc486ae3d08ae1a7b450a870270010266bc5eb..0c07f94c53780cbf8b00609a24af435128923b17 100644 (file)
@@ -212,6 +212,8 @@ static inline void drv_bss_info_changed(struct ieee80211_local *local,
                     sdata->vif.type != NL80211_IFTYPE_AP &&
                     sdata->vif.type != NL80211_IFTYPE_ADHOC &&
                     sdata->vif.type != NL80211_IFTYPE_MESH_POINT);
+       WARN_ON_ONCE(sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE &&
+                    changed & ~BSS_CHANGED_IDLE);
 
        check_sdata_in_driver(sdata);
 
index 1ab7d8e57d39ce1bd94022db6f968a8e2463937b..06fac2991d4003a72715f10dc49ae4f032cf95d7 100644 (file)
@@ -1227,6 +1227,7 @@ static void ieee80211_setup_sdata(struct ieee80211_sub_if_data *sdata,
        case NL80211_IFTYPE_AP:
                skb_queue_head_init(&sdata->u.ap.ps.bc_buf);
                INIT_LIST_HEAD(&sdata->u.ap.vlans);
+               sdata->vif.bss_conf.bssid = sdata->vif.addr;
                break;
        case NL80211_IFTYPE_P2P_CLIENT:
                type = NL80211_IFTYPE_STATION;
@@ -1234,9 +1235,11 @@ static void ieee80211_setup_sdata(struct ieee80211_sub_if_data *sdata,
                sdata->vif.p2p = true;
                /* fall through */
        case NL80211_IFTYPE_STATION:
+               sdata->vif.bss_conf.bssid = sdata->u.mgd.bssid;
                ieee80211_sta_setup_sdata(sdata);
                break;
        case NL80211_IFTYPE_ADHOC:
+               sdata->vif.bss_conf.bssid = sdata->u.ibss.bssid;
                ieee80211_ibss_setup_sdata(sdata);
                break;
        case NL80211_IFTYPE_MESH_POINT:
@@ -1250,8 +1253,12 @@ static void ieee80211_setup_sdata(struct ieee80211_sub_if_data *sdata,
                                      MONITOR_FLAG_OTHER_BSS;
                break;
        case NL80211_IFTYPE_WDS:
+               sdata->vif.bss_conf.bssid = NULL;
+               break;
        case NL80211_IFTYPE_AP_VLAN:
+               break;
        case NL80211_IFTYPE_P2P_DEVICE:
+               sdata->vif.bss_conf.bssid = sdata->vif.addr;
                break;
        case NL80211_IFTYPE_UNSPECIFIED:
        case NUM_NL80211_IFTYPES:
index b719a16eabdefad1530f26da10eb4e29b6957d7f..e6514f240fce90f7d668fb7397b50f49dc6d529d 100644 (file)
@@ -207,30 +207,10 @@ void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata,
                                      u32 changed)
 {
        struct ieee80211_local *local = sdata->local;
-       static const u8 zero[ETH_ALEN] = { 0 };
 
        if (!changed)
                return;
 
-       if (sdata->vif.type == NL80211_IFTYPE_STATION) {
-               sdata->vif.bss_conf.bssid = sdata->u.mgd.bssid;
-       } else if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
-               sdata->vif.bss_conf.bssid = sdata->u.ibss.bssid;
-       else if (sdata->vif.type == NL80211_IFTYPE_AP)
-               sdata->vif.bss_conf.bssid = sdata->vif.addr;
-       else if (sdata->vif.type == NL80211_IFTYPE_WDS)
-               sdata->vif.bss_conf.bssid = NULL;
-       else if (ieee80211_vif_is_mesh(&sdata->vif)) {
-               sdata->vif.bss_conf.bssid = zero;
-       } else if (sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE) {
-               sdata->vif.bss_conf.bssid = sdata->vif.addr;
-               WARN_ONCE(changed & ~(BSS_CHANGED_IDLE),
-                         "P2P Device BSS changed %#x", changed);
-       } else {
-               WARN_ON(1);
-               return;
-       }
-
        drv_bss_info_changed(local, sdata, &sdata->vif.bss_conf, changed);
 }
 
index fcfa7ef9af98549c73b00d2ec893025853b3086f..245885841c8dd40b9eb493f3276943296c4d6ab0 100644 (file)
@@ -810,6 +810,7 @@ void ieee80211_mesh_notify_scan_completed(struct ieee80211_local *local)
 void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata)
 {
        struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
+       static u8 zero_addr[ETH_ALEN] = {};
 
        setup_timer(&ifmsh->housekeeping_timer,
                    ieee80211_mesh_housekeeping_timer,
@@ -835,4 +836,6 @@ void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata)
        INIT_LIST_HEAD(&ifmsh->preq_queue.list);
        spin_lock_init(&ifmsh->mesh_preq_queue_lock);
        spin_lock_init(&ifmsh->sync_offset_lock);
+
+       sdata->vif.bss_conf.bssid = zero_addr;
 }
index 8a67d7e982f79f1f1c847b609d1e38bebec3bc4b..f81fd30581d9e69cc91cc8be9a15d25e0094c2ac 100644 (file)
@@ -121,6 +121,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
 
        /* remove all interfaces */
        list_for_each_entry(sdata, &local->interfaces, list) {
+               static u8 zero_addr[ETH_ALEN] = {};
                u32 changed = 0;
 
                if (!ieee80211_sdata_running(sdata))
@@ -152,6 +153,8 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
                sdata->suspend_bss_conf = sdata->vif.bss_conf;
                memset(&sdata->vif.bss_conf, 0, sizeof(sdata->vif.bss_conf));
                sdata->vif.bss_conf.idle = true;
+               if (sdata->suspend_bss_conf.bssid)
+                       sdata->vif.bss_conf.bssid = zero_addr;
 
                /* disable beaconing or remove association */
                ieee80211_bss_info_change_notify(sdata, changed);