mac80211: clean up mesh code
[firefly-linux-kernel-4.4.55.git] / net / mac80211 / cfg.c
index b1befac1736a01a7dbf1e44e6ff19f45657cf8b5..6ac49231efa9eec5cbde744891e19fb782b603ec 100644 (file)
@@ -15,9 +15,7 @@
 #include "ieee80211_i.h"
 #include "cfg.h"
 #include "ieee80211_rate.h"
-#ifdef CONFIG_MAC80211_MESH
 #include "mesh.h"
-#endif
 
 #define DEFAULT_RATES 0
 
@@ -119,14 +117,10 @@ static int ieee80211_change_iface(struct wiphy *wiphy, int ifindex,
        ieee80211_if_reinit(dev);
        ieee80211_if_set_type(dev, itype);
 
-#ifdef CONFIG_MAC80211_MESH
-       if (sdata->vif.type == IEEE80211_IF_TYPE_MESH_POINT &&
-           params->mesh_id_len) {
-               sdata->u.sta.mesh_id_len = params->mesh_id_len;
-               memcpy(sdata->u.sta.mesh_id, params->mesh_id,
-                      params->mesh_id_len);
-       }
-#endif
+       if (ieee80211_vif_is_mesh(&sdata->vif) && params->mesh_id_len)
+               ieee80211_if_sta_set_mesh_id(&sdata->u.sta,
+                                            params->mesh_id_len,
+                                            params->mesh_id);
 
        if (sdata->vif.type != IEEE80211_IF_TYPE_MNTR || !flags)
                return 0;
@@ -317,9 +311,7 @@ static int ieee80211_config_default_key(struct wiphy *wiphy,
 
 static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo)
 {
-#ifdef CONFIG_MAC80211_MESH
        struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev);
-#endif
 
        sinfo->filled = STATION_INFO_INACTIVE_TIME |
                        STATION_INFO_RX_BYTES |
@@ -329,8 +321,8 @@ static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo)
        sinfo->rx_bytes = sta->rx_bytes;
        sinfo->tx_bytes = sta->tx_bytes;
 
+       if (ieee80211_vif_is_mesh(&sdata->vif)) {
 #ifdef CONFIG_MAC80211_MESH
-       if (sdata->vif.type == IEEE80211_IF_TYPE_MESH_POINT) {
                sinfo->filled |= STATION_INFO_LLID |
                                 STATION_INFO_PLID |
                                 STATION_INFO_PLINK_STATE;
@@ -338,8 +330,8 @@ static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo)
                sinfo->llid = le16_to_cpu(sta->llid);
                sinfo->plid = le16_to_cpu(sta->plid);
                sinfo->plink_state = sta->plink_state;
-       }
 #endif
+       }
 }
 
 
@@ -580,9 +572,7 @@ static void sta_apply_parameters(struct ieee80211_local *local,
        u32 rates;
        int i, j;
        struct ieee80211_supported_band *sband;
-#ifdef CONFIG_MAC80211_MESH
        struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev);
-#endif
 
        if (params->station_flags & STATION_FLAG_CHANGED) {
                sta->flags &= ~WLAN_STA_AUTHORIZED;
@@ -621,9 +611,7 @@ static void sta_apply_parameters(struct ieee80211_local *local,
                sta->supp_rates[local->oper_channel->band] = rates;
        }
 
-#ifdef CONFIG_MAC80211_MESH
-       if (sdata->vif.type == IEEE80211_IF_TYPE_MESH_POINT &&
-           params->plink_action)
+       if (ieee80211_vif_is_mesh(&sdata->vif) && params->plink_action) {
                switch (params->plink_action) {
                case PLINK_ACTION_OPEN:
                        mesh_plink_open(sta);
@@ -632,7 +620,7 @@ static void sta_apply_parameters(struct ieee80211_local *local,
                        mesh_plink_block(sta);
                        break;
                }
-#endif
+       }
 }
 
 static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
@@ -655,11 +643,9 @@ static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
        } else
                sdata = IEEE80211_DEV_TO_SUB_IF(dev);
 
-#ifdef CONFIG_MAC80211_MESH
-       if (sdata->vif.type == IEEE80211_IF_TYPE_MESH_POINT)
+       if (ieee80211_vif_is_mesh(&sdata->vif))
                sta = mesh_plink_add(mac, DEFAULT_RATES, dev);
        else
-#endif
                sta = sta_info_add(local, dev, mac, GFP_KERNEL);
 
        if (IS_ERR(sta))