Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 902acc78 authored by Johannes Berg's avatar Johannes Berg Committed by John W. Linville
Browse files

mac80211: clean up mesh code



Various cleanups, reducing the #ifdef mess and other things.

Signed-off-by: default avatarJohannes Berg <johannes@sipsolutions.net>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent f7a92144
Loading
Loading
Loading
Loading
+8 −0
Original line number Original line Diff line number Diff line
@@ -465,6 +465,14 @@ struct ieee80211_vif {
	u8 drv_priv[0] __attribute__((__aligned__(sizeof(void *))));
	u8 drv_priv[0] __attribute__((__aligned__(sizeof(void *))));
};
};


static inline bool ieee80211_vif_is_mesh(struct ieee80211_vif *vif)
{
#ifdef CONFIG_MAC80211_MESH
	return vif->type == IEEE80211_IF_TYPE_MESH_POINT;
#endif
	return false;
}

/**
/**
 * struct ieee80211_if_init_conf - initial configuration of an interface
 * struct ieee80211_if_init_conf - initial configuration of an interface
 *
 *
+9 −23
Original line number Original line Diff line number Diff line
@@ -15,9 +15,7 @@
#include "ieee80211_i.h"
#include "ieee80211_i.h"
#include "cfg.h"
#include "cfg.h"
#include "ieee80211_rate.h"
#include "ieee80211_rate.h"
#ifdef CONFIG_MAC80211_MESH
#include "mesh.h"
#include "mesh.h"
#endif


#define DEFAULT_RATES 0
#define DEFAULT_RATES 0


@@ -119,14 +117,10 @@ static int ieee80211_change_iface(struct wiphy *wiphy, int ifindex,
	ieee80211_if_reinit(dev);
	ieee80211_if_reinit(dev);
	ieee80211_if_set_type(dev, itype);
	ieee80211_if_set_type(dev, itype);


#ifdef CONFIG_MAC80211_MESH
	if (ieee80211_vif_is_mesh(&sdata->vif) && params->mesh_id_len)
	if (sdata->vif.type == IEEE80211_IF_TYPE_MESH_POINT &&
		ieee80211_if_sta_set_mesh_id(&sdata->u.sta,
	    params->mesh_id_len) {
					     params->mesh_id_len,
		sdata->u.sta.mesh_id_len = params->mesh_id_len;
					     params->mesh_id);
		memcpy(sdata->u.sta.mesh_id, params->mesh_id,
		       params->mesh_id_len);
	}
#endif


	if (sdata->vif.type != IEEE80211_IF_TYPE_MNTR || !flags)
	if (sdata->vif.type != IEEE80211_IF_TYPE_MNTR || !flags)
		return 0;
		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)
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);
	struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev);
#endif


	sinfo->filled = STATION_INFO_INACTIVE_TIME |
	sinfo->filled = STATION_INFO_INACTIVE_TIME |
			STATION_INFO_RX_BYTES |
			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->rx_bytes = sta->rx_bytes;
	sinfo->tx_bytes = sta->tx_bytes;
	sinfo->tx_bytes = sta->tx_bytes;


	if (ieee80211_vif_is_mesh(&sdata->vif)) {
#ifdef CONFIG_MAC80211_MESH
#ifdef CONFIG_MAC80211_MESH
	if (sdata->vif.type == IEEE80211_IF_TYPE_MESH_POINT) {
		sinfo->filled |= STATION_INFO_LLID |
		sinfo->filled |= STATION_INFO_LLID |
				 STATION_INFO_PLID |
				 STATION_INFO_PLID |
				 STATION_INFO_PLINK_STATE;
				 STATION_INFO_PLINK_STATE;
@@ -338,9 +330,9 @@ static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo)
		sinfo->llid = le16_to_cpu(sta->llid);
		sinfo->llid = le16_to_cpu(sta->llid);
		sinfo->plid = le16_to_cpu(sta->plid);
		sinfo->plid = le16_to_cpu(sta->plid);
		sinfo->plink_state = sta->plink_state;
		sinfo->plink_state = sta->plink_state;
	}
#endif
#endif
	}
	}
}




static int ieee80211_dump_station(struct wiphy *wiphy, struct net_device *dev,
static int ieee80211_dump_station(struct wiphy *wiphy, struct net_device *dev,
@@ -580,9 +572,7 @@ static void sta_apply_parameters(struct ieee80211_local *local,
	u32 rates;
	u32 rates;
	int i, j;
	int i, j;
	struct ieee80211_supported_band *sband;
	struct ieee80211_supported_band *sband;
#ifdef CONFIG_MAC80211_MESH
	struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev);
	struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev);
#endif


	if (params->station_flags & STATION_FLAG_CHANGED) {
	if (params->station_flags & STATION_FLAG_CHANGED) {
		sta->flags &= ~WLAN_STA_AUTHORIZED;
		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;
		sta->supp_rates[local->oper_channel->band] = rates;
	}
	}


#ifdef CONFIG_MAC80211_MESH
	if (ieee80211_vif_is_mesh(&sdata->vif) && params->plink_action) {
	if (sdata->vif.type == IEEE80211_IF_TYPE_MESH_POINT &&
	    params->plink_action)
		switch (params->plink_action) {
		switch (params->plink_action) {
		case PLINK_ACTION_OPEN:
		case PLINK_ACTION_OPEN:
			mesh_plink_open(sta);
			mesh_plink_open(sta);
@@ -632,7 +620,7 @@ static void sta_apply_parameters(struct ieee80211_local *local,
			mesh_plink_block(sta);
			mesh_plink_block(sta);
			break;
			break;
		}
		}
#endif
	}
}
}


static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
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
	} else
		sdata = IEEE80211_DEV_TO_SUB_IF(dev);
		sdata = IEEE80211_DEV_TO_SUB_IF(dev);


#ifdef CONFIG_MAC80211_MESH
	if (ieee80211_vif_is_mesh(&sdata->vif))
	if (sdata->vif.type == IEEE80211_IF_TYPE_MESH_POINT)
		sta = mesh_plink_add(mac, DEFAULT_RATES, dev);
		sta = mesh_plink_add(mac, DEFAULT_RATES, dev);
	else
	else
#endif
		sta = sta_info_add(local, dev, mac, GFP_KERNEL);
		sta = sta_info_add(local, dev, mac, GFP_KERNEL);


	if (IS_ERR(sta))
	if (IS_ERR(sta))
+2 −7
Original line number Original line Diff line number Diff line
@@ -26,9 +26,7 @@


#include "ieee80211_i.h"
#include "ieee80211_i.h"
#include "ieee80211_rate.h"
#include "ieee80211_rate.h"
#ifdef CONFIG_MAC80211_MESH
#include "mesh.h"
#include "mesh.h"
#endif
#include "wep.h"
#include "wep.h"
#include "wme.h"
#include "wme.h"
#include "aes_ccm.h"
#include "aes_ccm.h"
@@ -938,11 +936,9 @@ static int __ieee80211_if_config(struct net_device *dev,
		conf.bssid = sdata->u.sta.bssid;
		conf.bssid = sdata->u.sta.bssid;
		conf.ssid = sdata->u.sta.ssid;
		conf.ssid = sdata->u.sta.ssid;
		conf.ssid_len = sdata->u.sta.ssid_len;
		conf.ssid_len = sdata->u.sta.ssid_len;
#ifdef CONFIG_MAC80211_MESH
	} else if (ieee80211_vif_is_mesh(&sdata->vif)) {
	} else if (sdata->vif.type == IEEE80211_IF_TYPE_MESH_POINT) {
		conf.beacon = beacon;
		conf.beacon = beacon;
		ieee80211_start_mesh(dev);
		ieee80211_start_mesh(dev);
#endif
	} else if (sdata->vif.type == IEEE80211_IF_TYPE_AP) {
	} else if (sdata->vif.type == IEEE80211_IF_TYPE_AP) {
		conf.ssid = sdata->u.ap.ssid;
		conf.ssid = sdata->u.ap.ssid;
		conf.ssid_len = sdata->u.ap.ssid_len;
		conf.ssid_len = sdata->u.ap.ssid_len;
@@ -1824,10 +1820,9 @@ static void __exit ieee80211_exit(void)
	rc80211_simple_exit();
	rc80211_simple_exit();
	rc80211_pid_exit();
	rc80211_pid_exit();


#ifdef CONFIG_MAC80211_MESH
	if (mesh_allocated)
	if (mesh_allocated)
		ieee80211s_stop();
		ieee80211s_stop();
#endif

	ieee80211_wme_unregister();
	ieee80211_wme_unregister();
	ieee80211_debugfs_netdev_exit();
	ieee80211_debugfs_netdev_exit();
}
}
+49 −7
Original line number Original line Diff line number Diff line
@@ -93,9 +93,8 @@ struct ieee80211_sta_bss {
#ifdef CONFIG_MAC80211_MESH
#ifdef CONFIG_MAC80211_MESH
	u8 *mesh_id;
	u8 *mesh_id;
	size_t mesh_id_len;
	size_t mesh_id_len;
#endif
	/* mesh_cfg left out the ifdef to reduce clutter on bss handling */
	u8 *mesh_cfg;
	u8 *mesh_cfg;
#endif
#define IEEE80211_MAX_SUPP_RATES 32
#define IEEE80211_MAX_SUPP_RATES 32
	u8 supp_rates[IEEE80211_MAX_SUPP_RATES];
	u8 supp_rates[IEEE80211_MAX_SUPP_RATES];
	size_t supp_rates_len;
	size_t supp_rates_len;
@@ -113,6 +112,30 @@ struct ieee80211_sta_bss {
	u8 erp_value;
	u8 erp_value;
};
};


static inline u8 *bss_mesh_cfg(struct ieee80211_sta_bss *bss)
{
#ifdef CONFIG_MAC80211_MESH
	return bss->mesh_cfg;
#endif
	return NULL;
}

static inline u8 *bss_mesh_id(struct ieee80211_sta_bss *bss)
{
#ifdef CONFIG_MAC80211_MESH
	return bss->mesh_id;
#endif
	return NULL;
}

static inline u8 bss_mesh_id_len(struct ieee80211_sta_bss *bss)
{
#ifdef CONFIG_MAC80211_MESH
	return bss->mesh_id_len;
#endif
	return 0;
}



typedef unsigned __bitwise__ ieee80211_tx_result;
typedef unsigned __bitwise__ ieee80211_tx_result;
#define TX_CONTINUE	((__force ieee80211_tx_result) 0u)
#define TX_CONTINUE	((__force ieee80211_tx_result) 0u)
@@ -233,7 +256,6 @@ struct ieee80211_if_vlan {
	struct list_head list;
	struct list_head list;
};
};


#ifdef CONFIG_MAC80211_MESH
struct mesh_stats {
struct mesh_stats {
	__u32 fwded_frames;		/* Mesh forwarded frames */
	__u32 fwded_frames;		/* Mesh forwarded frames */
	__u32 dropped_frames_ttl;	/* Not transmitted since mesh_ttl == 0*/
	__u32 dropped_frames_ttl;	/* Not transmitted since mesh_ttl == 0*/
@@ -249,7 +271,6 @@ struct mesh_preq_queue {
	u8 flags;
	u8 flags;
};
};



struct mesh_config {
struct mesh_config {
	/* Timeouts in ms */
	/* Timeouts in ms */
	/* Mesh plink management parameters */
	/* Mesh plink management parameters */
@@ -268,7 +289,7 @@ struct mesh_config {
	u32 path_refresh_time;
	u32 path_refresh_time;
	u16 min_discovery_timeout;
	u16 min_discovery_timeout;
};
};
#endif



/* flags used in struct ieee80211_if_sta.flags */
/* flags used in struct ieee80211_if_sta.flags */
#define IEEE80211_STA_SSID_SET		BIT(0)
#define IEEE80211_STA_SSID_SET		BIT(0)
@@ -361,6 +382,22 @@ struct ieee80211_if_sta {
	int num_beacons; /* number of TXed beacon frames by this STA */
	int num_beacons; /* number of TXed beacon frames by this STA */
};
};


static inline void ieee80211_if_sta_set_mesh_id(struct ieee80211_if_sta *ifsta,
						u8 mesh_id_len, u8 *mesh_id)
{
#ifdef CONFIG_MAC80211_MESH
	ifsta->mesh_id_len = mesh_id_len;
	memcpy(ifsta->mesh_id, mesh_id, mesh_id_len);
#endif
}

#ifdef CONFIG_MAC80211_MESH
#define IEEE80211_IFSTA_MESH_CTR_INC(sta, name)	\
	do { (sta)->mshstats.name++; } while (0)
#else
#define IEEE80211_IFSTA_MESH_CTR_INC(sta, name) \
	do { } while (0)
#endif


/* flags used in struct ieee80211_sub_if_data.flags */
/* flags used in struct ieee80211_sub_if_data.flags */
#define IEEE80211_SDATA_ALLMULTI	BIT(0)
#define IEEE80211_SDATA_ALLMULTI	BIT(0)
@@ -884,12 +921,17 @@ void sta_addba_resp_timer_expired(unsigned long data);
u64 ieee80211_sta_get_rates(struct ieee80211_local *local,
u64 ieee80211_sta_get_rates(struct ieee80211_local *local,
			    struct ieee802_11_elems *elems,
			    struct ieee802_11_elems *elems,
			    enum ieee80211_band band);
			    enum ieee80211_band band);
void ieee80211_start_mesh(struct net_device *dev);
void ieee80211_sta_tx(struct net_device *dev, struct sk_buff *skb,
void ieee80211_sta_tx(struct net_device *dev, struct sk_buff *skb,
		int encrypt);
		int encrypt);
void ieee802_11_parse_elems(u8 *start, size_t len,
void ieee802_11_parse_elems(u8 *start, size_t len,
				   struct ieee802_11_elems *elems);
				   struct ieee802_11_elems *elems);


#ifdef CONFIG_MAC80211_MESH
void ieee80211_start_mesh(struct net_device *dev);
#else
static inline void ieee80211_start_mesh(struct net_device *dev)
{}
#endif


/* ieee80211_iface.c */
/* ieee80211_iface.c */
int ieee80211_if_add(struct net_device *dev, const char *name,
int ieee80211_if_add(struct net_device *dev, const char *name,
+11 −55
Original line number Original line Diff line number Diff line
@@ -15,9 +15,7 @@
#include "ieee80211_i.h"
#include "ieee80211_i.h"
#include "sta_info.h"
#include "sta_info.h"
#include "debugfs_netdev.h"
#include "debugfs_netdev.h"
#ifdef CONFIG_MAC80211_MESH
#include "mesh.h"
#include "mesh.h"
#endif


void ieee80211_if_sdata_init(struct ieee80211_sub_if_data *sdata)
void ieee80211_if_sdata_init(struct ieee80211_sub_if_data *sdata)
{
{
@@ -82,14 +80,11 @@ int ieee80211_if_add(struct net_device *dev, const char *name,
	ieee80211_debugfs_add_netdev(sdata);
	ieee80211_debugfs_add_netdev(sdata);
	ieee80211_if_set_type(ndev, type);
	ieee80211_if_set_type(ndev, type);


#ifdef CONFIG_MAC80211_MESH
	if (ieee80211_vif_is_mesh(&sdata->vif) &&
	if (sdata->vif.type == IEEE80211_IF_TYPE_MESH_POINT &&
	    params && params->mesh_id_len)
	    params && params->mesh_id_len) {
		ieee80211_if_sta_set_mesh_id(&sdata->u.sta,
		sdata->u.sta.mesh_id_len = params->mesh_id_len;
					     params->mesh_id_len,
		memcpy(sdata->u.sta.mesh_id, params->mesh_id,
					     params->mesh_id);
		       params->mesh_id_len);
	}
#endif


	/* we're under RTNL so all this is fine */
	/* we're under RTNL so all this is fine */
	if (unlikely(local->reg_state == IEEE80211_DEV_UNREGISTERED)) {
	if (unlikely(local->reg_state == IEEE80211_DEV_UNREGISTERED)) {
@@ -170,47 +165,8 @@ void ieee80211_if_set_type(struct net_device *dev, int type)
		msdata = IEEE80211_DEV_TO_SUB_IF(sdata->local->mdev);
		msdata = IEEE80211_DEV_TO_SUB_IF(sdata->local->mdev);
		sdata->bss = &msdata->u.ap;
		sdata->bss = &msdata->u.ap;


#ifdef CONFIG_MAC80211_MESH
		if (ieee80211_vif_is_mesh(&sdata->vif))
		if (type == IEEE80211_IF_TYPE_MESH_POINT) {
			ieee80211_mesh_init_sdata(sdata);
			ifsta->mshcfg.dot11MeshRetryTimeout = MESH_RET_T;
			ifsta->mshcfg.dot11MeshConfirmTimeout = MESH_CONF_T;
			ifsta->mshcfg.dot11MeshHoldingTimeout = MESH_HOLD_T;
			ifsta->mshcfg.dot11MeshMaxRetries = MESH_MAX_RETR;
			ifsta->mshcfg.dot11MeshTTL = MESH_TTL;
			ifsta->mshcfg.auto_open_plinks = true;
			ifsta->mshcfg.dot11MeshMaxPeerLinks =
				MESH_MAX_ESTAB_PLINKS;
			ifsta->mshcfg.dot11MeshHWMPactivePathTimeout =
				MESH_PATH_TIMEOUT;
			ifsta->mshcfg.dot11MeshHWMPpreqMinInterval =
				MESH_PREQ_MIN_INT;
			ifsta->mshcfg.dot11MeshHWMPnetDiameterTraversalTime =
				MESH_DIAM_TRAVERSAL_TIME;
			ifsta->mshcfg.dot11MeshHWMPmaxPREQretries =
				MESH_MAX_PREQ_RETRIES;
			ifsta->mshcfg.path_refresh_time =
				MESH_PATH_REFRESH_TIME;
			ifsta->mshcfg.min_discovery_timeout =
				MESH_MIN_DISCOVERY_TIMEOUT;
			ifsta->accepting_plinks = true;
			ifsta->preq_id = 0;
			ifsta->dsn = 0;
			atomic_set(&ifsta->mpaths, 0);
			mesh_rmc_init(dev);
			ifsta->last_preq = jiffies;
			/* Allocate all mesh structures when creating the first
			 * mesh interface.
			 */
			if (!mesh_allocated)
				ieee80211s_init();
			mesh_ids_set_default(ifsta);
			setup_timer(&ifsta->mesh_path_timer,
				    ieee80211_mesh_path_timer,
				    (unsigned long) sdata);
			INIT_LIST_HEAD(&ifsta->preq_queue.list);
			spin_lock_init(&ifsta->mesh_preq_queue_lock);
		}
#endif
		break;
		break;
	}
	}
	case IEEE80211_IF_TYPE_MNTR:
	case IEEE80211_IF_TYPE_MNTR:
@@ -240,6 +196,10 @@ void ieee80211_if_reinit(struct net_device *dev)


	ieee80211_if_sdata_deinit(sdata);
	ieee80211_if_sdata_deinit(sdata);


	/* Need to handle mesh specially to allow eliding the function call */
	if (ieee80211_vif_is_mesh(&sdata->vif))
		mesh_rmc_free(dev);

	switch (sdata->vif.type) {
	switch (sdata->vif.type) {
	case IEEE80211_IF_TYPE_INVALID:
	case IEEE80211_IF_TYPE_INVALID:
		/* cannot happen */
		/* cannot happen */
@@ -292,10 +252,6 @@ void ieee80211_if_reinit(struct net_device *dev)
		}
		}
		break;
		break;
	case IEEE80211_IF_TYPE_MESH_POINT:
	case IEEE80211_IF_TYPE_MESH_POINT:
#ifdef CONFIG_MAC80211_MESH
		mesh_rmc_free(dev);
#endif
		/* fall through */
	case IEEE80211_IF_TYPE_STA:
	case IEEE80211_IF_TYPE_STA:
	case IEEE80211_IF_TYPE_IBSS:
	case IEEE80211_IF_TYPE_IBSS:
		kfree(sdata->u.sta.extra_ie);
		kfree(sdata->u.sta.extra_ie);
Loading